Dictionary.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. MWF.xApplication = MWF.xApplication || {};
  2. MWF.xApplication.portal = MWF.xApplication.portal || {};
  3. MWF.xApplication.portal.DictionaryDesigner = MWF.xApplication.portal.DictionaryDesigner || {};
  4. MWF.xDesktop.requireApp("process.DictionaryDesigner", "Dictionary", null, false);
  5. MWF.xApplication.portal.DictionaryDesigner.Dictionary = new Class({
  6. Extends: MWF.xApplication.process.DictionaryDesigner.Dictionary,
  7. createRootItem: function() {
  8. this.items.push(new MWF.xApplication.portal.DictionaryDesigner.Dictionary.item("ROOT", this.data.data, null, 0, this, true));
  9. },
  10. saveSilence: function(){
  11. if (!this.isSave){
  12. if( this.scriptPage.isShow ){
  13. if( this.scriptEditor ){
  14. var data = this.getEditorValidData( true );
  15. if( data !== false ){
  16. this.data.data = data;
  17. }else{
  18. return false;
  19. }
  20. }
  21. }
  22. var name = this.designer.propertyNameNode.get("value");
  23. var alias = this.designer.propertyAliasNode.get("value");
  24. var description = this.designer.propertyDescriptionNode.get("value");
  25. if (!name){
  26. this.designer.notice(this.designer.lp.notice.inputName, "error");
  27. return false;
  28. }
  29. this.data.name = name;
  30. this.data.alias = alias;
  31. this.data.description = description;
  32. this.isSave = true;
  33. this.designer.actions.saveDictionary(this.data, function(json){
  34. this.isSave = false;
  35. this.data.id = json.data.id;
  36. if (callback) callback();
  37. }.bind(this), function(xhr, text, error){
  38. this.isSave = false;
  39. //
  40. //var errorText = error+":"+text;
  41. //if (xhr) errorText = xhr.responseText;
  42. //MWF.xDesktop.notice("error", {x: "right", y:"top"}, "request json error: "+errorText);
  43. }.bind(this));
  44. }
  45. },
  46. save: function(callback){
  47. if (!this.isSave){
  48. if (this.designer.tab.showPage==this.page){
  49. if( this.scriptPage.isShow ){
  50. if( this.scriptEditor ){
  51. var data = this.getEditorValidData();
  52. if( data !== false ){
  53. this.data.data = data;
  54. }else{
  55. return false;
  56. }
  57. }
  58. }
  59. var name = this.designer.propertyNameNode.get("value");
  60. var alias = this.designer.propertyAliasNode.get("value");
  61. var description = this.designer.propertyDescriptionNode.get("value");
  62. if (!name || !alias){
  63. this.designer.notice(this.designer.lp.notice.inputName, "error");
  64. return false;
  65. }
  66. this.data.name = name;
  67. this.data.alias = alias;
  68. this.data.description = description;
  69. }
  70. this.isSave = true;
  71. this.designer.actions.saveDictionary(this.data, function(json){
  72. this.isSave = false;
  73. this.designer.notice(this.designer.lp.notice.save_success, "success", this.node, {"x": "left", "y": "bottom"});
  74. this.data.isNewDictionary = false;
  75. this.isNewDictionary = false;
  76. this.data.id = json.data.id;
  77. this.page.textNode.set("text", this.data.name);
  78. if (this.lisNode) {
  79. this.lisNode.getLast().set("text", this.data.name+"("+this.data.alias+")");
  80. }
  81. if (callback) callback();
  82. }.bind(this), function(xhr, text, error){
  83. this.isSave = false;
  84. var errorText = error+":"+text;
  85. if (xhr) errorText = xhr.responseText;
  86. MWF.xDesktop.notice("error", {x: "right", y:"top"}, "request json error: "+errorText);
  87. }.bind(this));
  88. }else{
  89. MWF.xDesktop.notice("info", {x: "right", y:"top"}, this.designer.lp.isSave);
  90. }
  91. },
  92. });
  93. MWF.xApplication.portal.DictionaryDesigner.Dictionary.item = new Class({
  94. Extends: MWF.xApplication.process.DictionaryDesigner.Dictionary.item,
  95. createNewItem: function(key, value, parent, level, dictionary, exp, nextSibling){
  96. return new MWF.xApplication.portal.DictionaryDesigner.Dictionary.item(key, value, parent, level, dictionary, exp, nextSibling);
  97. }
  98. });
  99. MWF.xApplication.portal.DictionaryDesigner.DictionaryReader = new Class({
  100. Extends: MWF.xApplication.process.DictionaryDesigner.DictionaryReader,
  101. autoSave: function(){},
  102. createRootItem: function() {
  103. this.items.push(new MWF.xApplication.portal.DictionaryDesigner.Dictionary.ItemReader("ROOT", this.data.data, null, 0, this, true));
  104. },
  105. });
  106. MWF.xApplication.portal.DictionaryDesigner.Dictionary.ItemReader= new Class({
  107. Extends: MWF.xApplication.process.DictionaryDesigner.Dictionary.ItemReader,
  108. createNewItem: function(key, value, parent, level, dictionary, exp, nextSibling){
  109. return new MWF.xApplication.portal.DictionaryDesigner.Dictionary.ItemReader(key, value, parent, level, dictionary, exp, nextSibling);
  110. }
  111. });