Main.js 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805
  1. MWF.APPDD = MWF.xApplication.process.DictionaryDesigner;
  2. MWF.APPDD.options = {
  3. "multitask": true,
  4. "executable": false
  5. };
  6. //MWF.xDesktop.requireApp("process.ProcessManager", "Actions.RestActions", null, false);
  7. MWF.xDesktop.requireApp("process.DictionaryDesigner", "Dictionary", null, false);
  8. MWF.xApplication.process.DictionaryDesigner.Main = new Class({
  9. Extends: MWF.xApplication.Common.Main,
  10. Implements: [Options, Events],
  11. options: {
  12. "style": "default",
  13. "name": "process.DictionaryDesigner",
  14. "icon": "icon.png",
  15. "title": MWF.APPDD.LP.title,
  16. "appTitle": MWF.APPDD.LP.title,
  17. "id": "",
  18. "width": "1200",
  19. "height": "600",
  20. "actions": null,
  21. "category": null,
  22. "processData": null
  23. },
  24. onQueryLoad: function(){
  25. this.shortcut = true;
  26. if (this.status){
  27. this.options.application = this.status.applicationId;
  28. this.application = this.status.application || this.status.applicationId;
  29. this.options.id = this.status.id;
  30. this.setOptions(this.status.options);
  31. }
  32. if (!this.options.id){
  33. this.options.desktopReload = false;
  34. this.options.title = this.options.title + "-"+MWF.APPDD.LP.newDictionary;
  35. }
  36. if (!this.actions){
  37. // if (this.options.action){
  38. // MWF.xDesktop.requireApp("process."+this.options.action, "Actions.RestActions", function(){
  39. // this.actions = new MWF.xApplication.process[this.options.action].Actions.RestActions();
  40. // }.bind(this), false);
  41. // }else{
  42. this.actions = MWF.Actions.get("x_processplatform_assemble_designer");
  43. //this.actions = new MWF.xApplication.process.ProcessManager.Actions.RestActions();
  44. // }
  45. debugger;
  46. this.actions.application = this.application;
  47. }
  48. this.lp = MWF.xApplication.process.DictionaryDesigner.LP;
  49. this.addEvent("queryClose", function(e){
  50. if (this.explorer){
  51. this.explorer.reload();
  52. }
  53. }.bind(this));
  54. // this.processData = this.options.processData;
  55. },
  56. loadApplication: function(callback){
  57. this.createNode();
  58. if (!this.options.isRefresh){
  59. this.maxSize(function(){
  60. this.openForm();
  61. }.bind(this));
  62. }else{
  63. this.openForm();
  64. }
  65. if (!this.options.readMode) this.addKeyboardEvents();
  66. if (callback) callback();
  67. },
  68. addKeyboardEvents: function(){
  69. this.addEvent("copy", function(){
  70. this.copyModule();
  71. }.bind(this));
  72. this.addEvent("paste", function(){
  73. this.pasteModule();
  74. }.bind(this));
  75. this.addEvent("cut", function(){
  76. this.cutModule();
  77. }.bind(this));
  78. this.addEvent("keySave", function(e){
  79. this.keySave(e);
  80. }.bind(this));
  81. this.addEvent("keyDelete", function(e){
  82. this.keyDelete(e);
  83. }.bind(this));
  84. },
  85. keySave: function(e){
  86. if (this.shortcut) {
  87. if (this.tab.showPage) {
  88. var dictionary = this.tab.showPage.dictionary;
  89. if (dictionary) {
  90. dictionary.save();
  91. e.preventDefault();
  92. }
  93. }
  94. }
  95. },
  96. keyDelete: function(){
  97. if (this.shortcut) {
  98. if (this.tab.showPage) {
  99. var dictionary = this.tab.showPage.dictionary;
  100. if (dictionary) {
  101. if (dictionary.currentSelectedItem) {
  102. var item = dictionary.currentSelectedItem;
  103. item.delItem(item.itemTextNode);
  104. }
  105. }
  106. }
  107. }
  108. },
  109. copyModule: function(){
  110. if (this.shortcut) {
  111. if (this.tab.showPage) {
  112. var dictionary = this.tab.showPage.dictionary;
  113. if (dictionary) {
  114. if (dictionary.currentSelectedItem) {
  115. var item = dictionary.currentSelectedItem;
  116. MWF.clipboard.data = {
  117. "type": "dictionary",
  118. "data": {
  119. "key": item.key,
  120. "value": (typeOf(item.value)=="object") ? Object.clone(item.value) : item.value
  121. }
  122. };
  123. }
  124. }
  125. }
  126. }
  127. },
  128. cutModule: function(){
  129. if (this.shortcut) {
  130. if (this.tab.showPage) {
  131. var dictionary = this.tab.showPage.dictionary;
  132. if (dictionary) {
  133. if (dictionary.currentSelectedItem) {
  134. this.copyModule();
  135. var item = dictionary.currentSelectedItem;
  136. item.destroy();
  137. }
  138. }
  139. }
  140. }
  141. },
  142. pasteModule: function(){
  143. if (this.shortcut) {
  144. if (MWF.clipboard.data) {
  145. if (MWF.clipboard.data.type == "dictionary") {
  146. if (this.tab.showPage) {
  147. var dictionary = this.tab.showPage.dictionary;
  148. if (dictionary) {
  149. if (dictionary.currentSelectedItem) {
  150. var item = dictionary.currentSelectedItem;
  151. var key = MWF.clipboard.data.data.key;
  152. var value = (typeOf(MWF.clipboard.data.data.value)=="object") ? Object.clone(MWF.clipboard.data.data.value) : MWF.clipboard.data.data.value;
  153. var level = item.level;
  154. var parent = item;
  155. var nextSibling = null;
  156. if (!item.parent){//top level
  157. level = 1;
  158. }else{
  159. if (item.type!="array" && item.type!="object"){
  160. parent = item.parent;
  161. nextSibling = item;
  162. }else{
  163. if (item.exp){
  164. level = item.level+1;
  165. }else{
  166. parent = item.parent;
  167. nextSibling = item;
  168. }
  169. }
  170. }
  171. var idx = parent.children.length;
  172. if (item.type=="array"){
  173. if (nextSibling){
  174. key = nextSibling.key;
  175. parent.value.splice(nextSibling.key, 0, value);
  176. for (var i=nextSibling.key; i<parent.children.length; i++){
  177. subItem = parent.children[i];
  178. subItem.key = subItem.key+1;
  179. subItem.setNodeText();
  180. }
  181. }else{
  182. var key = parent.value.length;
  183. parent.value.push(value);
  184. }
  185. idx = key;
  186. }else{
  187. var oldKey = key;
  188. var i = 0;
  189. while (parent.value[key] != undefined) {
  190. i++;
  191. key = oldKey + i;
  192. }
  193. parent.value[key] = value;
  194. if (nextSibling) var idx = parent.children.indexOf(nextSibling);
  195. }
  196. var item = new MWF.xApplication.process.DictionaryDesigner.Dictionary.item(key, value, parent, level, this.dictionary, true, nextSibling);
  197. if (idx) parent.children[idx-1].nextSibling = item;
  198. parent.children.splice(idx, 0, item);
  199. }
  200. }
  201. }
  202. }
  203. }
  204. }
  205. },
  206. createNode: function(){
  207. this.content.setStyle("overflow", "hidden");
  208. this.node = new Element("div", {
  209. "styles": {"width": "100%", "height": "100%", "overflow": "hidden"}
  210. }).inject(this.content);
  211. },
  212. getApplication:function(callback){
  213. if (!this.application){
  214. this.actions.getApplication(this.options.application, function(json){
  215. this.application = {"name": json.data.name, "id": json.data.id};
  216. if (callback) callback();
  217. }.bind(this));
  218. }else{
  219. if (callback) callback();
  220. }
  221. },
  222. openForm: function(){
  223. this.getApplication(function(){
  224. this.initOptions();
  225. this.loadNodes();
  226. this.loadDictionaryListNodes();
  227. // this.loadToolbar();
  228. this.loadContentNode();
  229. this.loadProperty();
  230. // this.loadTools();
  231. this.resizeNode();
  232. this.addEvent("resize", this.resizeNode.bind(this));
  233. this.loadDictionary();
  234. if (this.toolbarContentNode){
  235. this.setScrollBar(this.toolbarContentNode, null, {
  236. "V": {"x": 0, "y": 0},
  237. "H": {"x": 0, "y": 0}
  238. });
  239. this.setScrollBar(this.propertyDomArea, null, {
  240. "V": {"x": 0, "y": 0},
  241. "H": {"x": 0, "y": 0}
  242. });
  243. }
  244. }.bind(this));
  245. },
  246. initOptions: function(){
  247. //this.toolsData = null;
  248. //this.toolbarMode = "all";
  249. //this.tools = [];
  250. //this.toolbarDecrease = 0;
  251. //
  252. //this.designNode = null;
  253. //this.form = null;
  254. },
  255. loadNodes: function(){
  256. this.dictionaryListNode = new Element("div", {
  257. "styles": this.css.dictionaryListNode
  258. }).inject(this.node);
  259. this.propertyNode = new Element("div", {
  260. "styles": this.css.propertyNode
  261. }).inject(this.node);
  262. this.contentNode = new Element("div", {
  263. "styles": this.css.contentNode
  264. }).inject(this.node);
  265. },
  266. //loadDictionaryListNodes-------------------------------
  267. loadDictionaryListNodes: function(){
  268. this.dictionaryListTitleNode = new Element("div", {
  269. "styles": this.css.dictionaryListTitleNode,
  270. "text": MWF.APPDD.LP.dictionary
  271. }).inject(this.dictionaryListNode);
  272. this.dictionaryListResizeNode = new Element("div", {"styles": this.css.dictionaryListResizeNode}).inject(this.dictionaryListNode);
  273. this.dictionaryListAreaSccrollNode = new Element("div", {"styles": this.css.dictionaryListAreaSccrollNode}).inject(this.dictionaryListNode);
  274. this.dictionaryListAreaNode = new Element("div", {"styles": this.css.dictionaryListAreaNode}).inject(this.dictionaryListAreaSccrollNode);
  275. this.loadDictionaryListResize();
  276. this.loadDictionaryList();
  277. },
  278. loadDictionaryListResize: function(){
  279. this.dictionaryListResize = new Drag(this.dictionaryListResizeNode,{
  280. "snap": 1,
  281. "onStart": function(el, e){
  282. var x = (Browser.name=="firefox") ? e.event.clientX : e.event.x;
  283. var y = (Browser.name=="firefox") ? e.event.clientY : e.event.y;
  284. el.store("position", {"x": x, "y": y});
  285. var size = this.dictionaryListAreaSccrollNode.getSize();
  286. el.store("initialWidth", size.x);
  287. }.bind(this),
  288. "onDrag": function(el, e){
  289. var x = (Browser.name=="firefox") ? e.event.clientX : e.event.x;
  290. // var y = e.event.y;
  291. var bodySize = this.content.getSize();
  292. var position = el.retrieve("position");
  293. var initialWidth = el.retrieve("initialWidth").toFloat();
  294. var dx = x.toFloat() - position.x.toFloat();
  295. var width = initialWidth+dx;
  296. if (width> bodySize.x/2) width = bodySize.x/2;
  297. if (width<40) width = 40;
  298. this.contentNode.setStyle("margin-left", width+1);
  299. this.dictionaryListNode.setStyle("width", width);
  300. }.bind(this)
  301. });
  302. },
  303. loadDictionaryList: function(){
  304. this.actions.listDictionary(this.application.id || this.application, function (json) {
  305. json.data.each(function(dictionary){
  306. this.createListDictionaryItem(dictionary);
  307. }.bind(this));
  308. }.bind(this), null, false);
  309. },
  310. createListDictionaryItem: function(dictionary, isNew){
  311. var _self = this;
  312. var listDictionaryItem = new Element("div", {"styles": this.css.listDictionaryItem}).inject(this.dictionaryListAreaNode, (isNew) ? "top": "bottom");
  313. var listDictionaryItemIcon = new Element("div", {"styles": this.css.listDictionaryItemIcon}).inject(listDictionaryItem);
  314. var listDictionaryItemText = new Element("div", {"styles": this.css.listDictionaryItemText, "text": (dictionary.name) ? dictionary.name+" ("+dictionary.alias+")" : this.lp.newDictionary}).inject(listDictionaryItem);
  315. listDictionaryItem.store("dictionary", dictionary);
  316. listDictionaryItem.addEvents({
  317. "dblclick": function(e){_self.loadDictionaryByData(this, e);},
  318. "mouseover": function(){if (_self.currentListDictionaryItem!=this) this.setStyles(_self.css.listDictionaryItem_over);},
  319. "mouseout": function(){if (_self.currentListDictionaryItem!=this) this.setStyles(_self.css.listDictionaryItem);}
  320. });
  321. },
  322. loadDictionaryByData: function(node, e){
  323. var dictionary = node.retrieve("dictionary");
  324. var openNew = true;
  325. for (var i = 0; i<this.tab.pages.length; i++){
  326. if (dictionary.id==this.tab.pages[i].dictionary.data.id){
  327. this.tab.pages[i].showTabIm();
  328. openNew = false;
  329. break;
  330. }
  331. }
  332. if (openNew){
  333. this.loadDictionaryData(dictionary.id, function(data){
  334. var dictionary = new MWF.xApplication.process.DictionaryDesigner.Dictionary(this, data);
  335. dictionary.load();
  336. }.bind(this), true);
  337. }
  338. },
  339. //loadContentNode------------------------------
  340. loadContentNode: function(){
  341. this.contentToolbarNode = new Element("div#contentToolbarNode", {
  342. "styles": this.css.contentToolbarNode
  343. }).inject(this.contentNode);
  344. if (!this.options.readMode) this.loadContentToolbar();
  345. this.editContentNode = new Element("div", {
  346. "styles": this.css.editContentNode
  347. }).inject(this.contentNode);
  348. this.loadEditContent(function(){
  349. // if (this.designDcoument) this.designDcoument.body.setStyles(this.css.designBody);
  350. if (this.designNode) this.designNode.setStyles(this.css.designNode);
  351. }.bind(this));
  352. },
  353. loadContentToolbar: function(callback){
  354. this.getFormToolbarHTML(function(toolbarNode){
  355. var spans = toolbarNode.getElements("span");
  356. spans.each(function(item, idx){
  357. var img = item.get("MWFButtonImage");
  358. if (img){
  359. item.set("MWFButtonImage", this.path+""+this.options.style+"/toolbar/"+img);
  360. }
  361. }.bind(this));
  362. $(toolbarNode).inject(this.contentToolbarNode);
  363. MWF.require("MWF.widget.Toolbar", function(){
  364. this.toolbar = new MWF.widget.Toolbar(toolbarNode, {"style": "ProcessCategory"}, this);
  365. this.toolbar.load();
  366. if (callback) callback();
  367. }.bind(this));
  368. }.bind(this));
  369. },
  370. getFormToolbarHTML: function(callback){
  371. var toolbarUrl = this.path+this.options.style+"/toolbars.html";
  372. var r = new Request.HTML({
  373. url: toolbarUrl,
  374. method: "get",
  375. onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript){
  376. var toolbarNode = responseTree[0];
  377. if (callback) callback(toolbarNode);
  378. }.bind(this),
  379. onFailure: function(xhr){
  380. this.notice("request processToolbars error: "+xhr.responseText, "error");
  381. }.bind(this)
  382. });
  383. r.send();
  384. },
  385. maxOrReturnEditor: function(){
  386. if (!this.isMax){
  387. this.designNode.inject(this.node);
  388. this.designNode.setStyles({
  389. "position": "absolute",
  390. "width": "100%",
  391. "height": "100%",
  392. "top": "0px",
  393. "margin": "0px",
  394. "left": "0px"
  395. });
  396. this.tab.pages.each(function(page){
  397. page.dictionary.setAreaNodeSize();
  398. });
  399. this.isMax = true;
  400. }else{
  401. this.isMax = false;
  402. this.designNode.inject(this.editContentNode);
  403. this.designNode.setStyles(this.css.designNode);
  404. this.designNode.setStyles({
  405. "position": "static"
  406. });
  407. this.resizeNode();
  408. this.tab.pages.each(function(page){
  409. page.dictionary.setAreaNodeSize();
  410. });
  411. }
  412. },
  413. loadEditContent: function(callback){
  414. this.designNode = new Element("div", {
  415. "styles": this.css.designNode
  416. }).inject(this.editContentNode);
  417. MWF.require("MWF.widget.Tab", function(){
  418. this.tab = new MWF.widget.Tab(this.designNode, {"style": "dictionary"});
  419. this.tab.load();
  420. }.bind(this), false);
  421. // MWF.require("MWF.widget.ScrollBar", function(){
  422. // new MWF.widget.ScrollBar(this.designNode, {"distance": 100});
  423. // }.bind(this));
  424. },
  425. //loadProperty------------------------
  426. loadProperty: function(){
  427. this.propertyTitleNode = new Element("div", {
  428. "styles": this.css.propertyTitleNode,
  429. "text": MWF.APPDD.LP.property
  430. }).inject(this.propertyNode);
  431. this.propertyResizeBar = new Element("div", {
  432. "styles": this.css.propertyResizeBar
  433. }).inject(this.propertyNode);
  434. this.loadPropertyResize();
  435. this.propertyContentNode = new Element("div", {
  436. "styles": this.css.propertyContentNode
  437. }).inject(this.propertyNode);
  438. this.propertyDomArea = new Element("div", {
  439. "styles": this.css.propertyDomArea
  440. }).inject(this.propertyContentNode);
  441. this.propertyDomPercent = 0.3;
  442. this.propertyContentResizeNode = new Element("div", {
  443. "styles": this.css.propertyContentResizeNode
  444. }).inject(this.propertyContentNode);
  445. this.propertyContentArea = new Element("div", {
  446. "styles": this.css.propertyContentArea
  447. }).inject(this.propertyContentNode);
  448. this.loadPropertyContentResize();
  449. this.setPropertyContent();
  450. this.propertyNode.addEvent("keydown", function(e){e.stopPropagation();});
  451. },
  452. setPropertyContent: function(){
  453. this.dictionaryPropertyNode = new Element("div", {"styles": this.css.dictionaryPropertyNode});
  454. this.jsonDomNode = new Element("div", {"styles": this.css.jsonDomNode});
  455. this.jsonTextNode = new Element("div", {"styles": this.css.jsonTextNode});
  456. this.jsonTextAreaNode = new Element("textarea", {"styles": this.css.jsonTextAreaNode}).inject(this.jsonTextNode);
  457. MWF.require("MWF.widget.Tab", function(){
  458. var tab = new MWF.widget.Tab(this.propertyContentArea, {"style": "moduleList"});
  459. tab.load();
  460. tab.addTab(this.dictionaryPropertyNode, this.lp.property, false);
  461. tab.addTab(this.jsonDomNode, "JSON", false);
  462. tab.addTab(this.jsonTextNode, "TEXT", false);
  463. tab.pages[0].showTab();
  464. }.bind(this));
  465. var node = new Element("div", {"styles": this.css.propertyTitleNode, "text": this.lp.id+":"}).inject(this.dictionaryPropertyNode);
  466. this.propertyIdNode = new Element("div", {"styles": this.css.propertyTextNode}).inject(this.dictionaryPropertyNode);
  467. node = new Element("div", {"styles": this.css.propertyTitleNode, "text": this.lp.name+":"}).inject(this.dictionaryPropertyNode);
  468. this.propertyNameNode = new Element("input", {"styles": this.css.propertyInputNode}).inject(this.dictionaryPropertyNode);
  469. if (this.options.noModifyName || this.options.readMode){
  470. this.propertyNameNode.set("readonly", true);
  471. this.propertyNameNode.addEvent("keydown", function(){
  472. this.notice(this.lp.notice.noModifyName, "error");
  473. }.bind(this));
  474. }
  475. node = new Element("div", {"styles": this.css.propertyTitleNode, "text": this.lp.alias+":"}).inject(this.dictionaryPropertyNode);
  476. this.propertyAliasNode = new Element("input", {"styles": this.css.propertyInputNode}).inject(this.dictionaryPropertyNode);
  477. if (this.options.noModifyName || this.options.readMode){
  478. this.propertyAliasNode.set("readonly", true);
  479. this.propertyAliasNode.addEvent("keydown", function(){
  480. this.notice(this.lp.notice.noModifyName, "error");
  481. }.bind(this));
  482. }
  483. node = new Element("div", {"styles": this.css.propertyTitleNode, "text": this.lp.description+":"}).inject(this.dictionaryPropertyNode);
  484. this.propertyDescriptionNode = new Element("textarea", {"styles": this.css.propertyInputAreaNode}).inject(this.dictionaryPropertyNode);
  485. if (this.options.noModifyName || this.options.readMode){
  486. this.propertyDescriptionNode.set("readonly", true);
  487. }
  488. },
  489. loadPropertyResize: function(){
  490. // var size = this.propertyNode.getSize();
  491. // var position = this.propertyResizeBar.getPosition();
  492. this.propertyResize = new Drag(this.propertyResizeBar,{
  493. "snap": 1,
  494. "onStart": function(el, e){
  495. var x = (Browser.name=="firefox") ? e.event.clientX : e.event.x;
  496. var y = (Browser.name=="firefox") ? e.event.clientY : e.event.y;
  497. el.store("position", {"x": x, "y": y});
  498. var size = this.propertyNode.getSize();
  499. el.store("initialWidth", size.x);
  500. }.bind(this),
  501. "onDrag": function(el, e){
  502. var x = (Browser.name=="firefox") ? e.event.clientX : e.event.x;
  503. // var y = e.event.y;
  504. var bodySize = this.content.getSize();
  505. var position = el.retrieve("position");
  506. var initialWidth = el.retrieve("initialWidth").toFloat();
  507. var dx = position.x.toFloat()-x.toFloat();
  508. var width = initialWidth+dx;
  509. if (width> bodySize.x/2) width = bodySize.x/2;
  510. if (width<40) width = 40;
  511. this.contentNode.setStyle("margin-right", width+1);
  512. this.propertyNode.setStyle("width", width);
  513. }.bind(this)
  514. });
  515. },
  516. loadPropertyContentResize: function(){
  517. this.propertyContentResize = new Drag(this.propertyContentResizeNode, {
  518. "snap": 1,
  519. "onStart": function(el, e){
  520. var x = (Browser.name=="firefox") ? e.event.clientX : e.event.x;
  521. var y = (Browser.name=="firefox") ? e.event.clientY : e.event.y;
  522. el.store("position", {"x": x, "y": y});
  523. var size = this.propertyDomArea.getSize();
  524. el.store("initialHeight", size.y);
  525. }.bind(this),
  526. "onDrag": function(el, e){
  527. var size = this.propertyContentNode.getSize();
  528. // var x = e.event.x;
  529. var y = (Browser.name=="firefox") ? e.event.clientY : e.event.y;
  530. var position = el.retrieve("position");
  531. var dy = y.toFloat()-position.y.toFloat();
  532. var initialHeight = el.retrieve("initialHeight").toFloat();
  533. var height = initialHeight+dy;
  534. if (height<40) height = 40;
  535. if (height> size.y-40) height = size.y-40;
  536. this.propertyDomPercent = height/size.y;
  537. this.setPropertyContentResize();
  538. }.bind(this)
  539. });
  540. },
  541. setPropertyContentResize: function(){
  542. var size = this.propertyContentNode.getSize();
  543. var resizeNodeSize = this.propertyContentResizeNode.getSize();
  544. var height = size.y-resizeNodeSize.y;
  545. var domHeight = this.propertyDomPercent*height;
  546. var contentHeight = height-domHeight;
  547. this.propertyDomArea.setStyle("height", ""+domHeight+"px");
  548. this.propertyContentArea.setStyle("height", ""+contentHeight+"px");
  549. if (this.form){
  550. if (this.form.currentSelectedModule){
  551. if (this.form.currentSelectedModule.property){
  552. var tab = this.form.currentSelectedModule.property.propertyTab;
  553. if (tab){
  554. var tabTitleSize = tab.tabNodeContainer.getSize();
  555. tab.pages.each(function(page){
  556. var topMargin = page.contentNodeArea.getStyle("margin-top").toFloat();
  557. var bottomMargin = page.contentNodeArea.getStyle("margin-bottom").toFloat();
  558. var tabContentNodeAreaHeight = contentHeight - topMargin - bottomMargin - tabTitleSize.y.toFloat()-15;
  559. page.contentNodeArea.setStyle("height", tabContentNodeAreaHeight);
  560. }.bind(this));
  561. }
  562. }
  563. }
  564. }
  565. },
  566. //resizeNode------------------------------------------------
  567. resizeNode: function(){
  568. var nodeSize = this.node.getSize();
  569. this.contentNode.setStyle("height", ""+nodeSize.y+"px");
  570. this.propertyNode.setStyle("height", ""+nodeSize.y+"px");
  571. var contentToolbarMarginTop = this.contentToolbarNode.getStyle("margin-top").toFloat();
  572. var contentToolbarMarginBottom = this.contentToolbarNode.getStyle("margin-bottom").toFloat();
  573. var allContentToolberSize = this.contentToolbarNode.getComputedSize();
  574. var y = nodeSize.y - allContentToolberSize.totalHeight - contentToolbarMarginTop - contentToolbarMarginBottom;
  575. this.editContentNode.setStyle("height", ""+y+"px");
  576. if (this.designNode){
  577. var designMarginTop = this.designNode.getStyle("margin-top").toFloat();
  578. var designMarginBottom = this.designNode.getStyle("margin-bottom").toFloat();
  579. y = nodeSize.y - allContentToolberSize.totalHeight - contentToolbarMarginTop - contentToolbarMarginBottom - designMarginTop - designMarginBottom;
  580. this.designNode.setStyle("height", ""+y+"px");
  581. }
  582. titleSize = this.propertyTitleNode.getSize();
  583. titleMarginTop = this.propertyTitleNode.getStyle("margin-top").toFloat();
  584. titleMarginBottom = this.propertyTitleNode.getStyle("margin-bottom").toFloat();
  585. titlePaddingTop = this.propertyTitleNode.getStyle("padding-top").toFloat();
  586. titlePaddingBottom = this.propertyTitleNode.getStyle("padding-bottom").toFloat();
  587. y = titleSize.y+titleMarginTop+titleMarginBottom+titlePaddingTop+titlePaddingBottom;
  588. y = nodeSize.y-y;
  589. this.propertyContentNode.setStyle("height", ""+y+"px");
  590. this.propertyResizeBar.setStyle("height", ""+y+"px");
  591. this.setPropertyContentResize();
  592. titleSize = this.dictionaryListTitleNode.getSize();
  593. titleMarginTop = this.dictionaryListTitleNode.getStyle("margin-top").toFloat();
  594. titleMarginBottom = this.dictionaryListTitleNode.getStyle("margin-bottom").toFloat();
  595. titlePaddingTop = this.dictionaryListTitleNode.getStyle("padding-top").toFloat();
  596. titlePaddingBottom = this.dictionaryListTitleNode.getStyle("padding-bottom").toFloat();
  597. nodeMarginTop = this.dictionaryListAreaSccrollNode.getStyle("margin-top").toFloat();
  598. nodeMarginBottom = this.dictionaryListAreaSccrollNode.getStyle("margin-bottom").toFloat();
  599. y = titleSize.y+titleMarginTop+titleMarginBottom+titlePaddingTop+titlePaddingBottom+nodeMarginTop+nodeMarginBottom;
  600. y = nodeSize.y-y;
  601. this.dictionaryListAreaSccrollNode.setStyle("height", ""+y+"px");
  602. this.dictionaryListResizeNode.setStyle("height", ""+y+"px");
  603. },
  604. //loadForm------------------------------------------
  605. loadDictionary: function(){
  606. debugger;
  607. this.getDictionaryData(this.options.id, function(ddata){
  608. this.setTitle(this.options.appTitle + "-"+ddata.name);
  609. this.taskitem.setText(this.options.appTitle + "-"+ddata.name);
  610. this.options.appTitle = this.options.appTitle + "-"+ddata.name;
  611. if (this.options.readMode){
  612. this.dictionary = new MWF.xApplication.process.DictionaryDesigner.DictionaryReader(this, ddata);
  613. }else{
  614. this.dictionary = new MWF.xApplication.process.DictionaryDesigner.Dictionary(this, ddata);
  615. }
  616. this.dictionary.load();
  617. if (this.status){
  618. if (this.status.openDictionarys){
  619. this.status.openDictionarys.each(function(id){
  620. this.loadDictionaryData(id, function(data){
  621. var showTab = true;
  622. if (this.status.currentId){
  623. if (this.status.currentId!=data.id) showTab = false;
  624. }
  625. if (this.options.readMode){
  626. var dictionary = new MWF.xApplication.process.DictionaryDesigner.DictionaryReader(this, data, {"showTab": showTab});
  627. }else{
  628. var dictionary = new MWF.xApplication.process.DictionaryDesigner.Dictionary(this, data, {"showTab": showTab});
  629. }
  630. dictionary.load();
  631. }.bind(this), true);
  632. }.bind(this));
  633. }
  634. }
  635. }.bind(this));
  636. },
  637. getDictionaryData: function(id, callback){
  638. if (!this.options.id){
  639. this.loadNewDictionaryData(callback);
  640. }else{
  641. this.loadDictionaryData(id, callback);
  642. }
  643. },
  644. loadNewDictionaryData: function(callback){
  645. var data = {
  646. "name": "",
  647. "id": "",
  648. "application": this.application.id,
  649. "alias": "",
  650. "description": "",
  651. "data": {}
  652. };
  653. this.createListDictionaryItem(data, true);
  654. if (callback) callback(data);
  655. },
  656. loadDictionaryData: function(id, callback){
  657. debugger;
  658. this.actions.getDictionary(id, function(json){
  659. if (json){
  660. var data = json.data;
  661. if (!this.application){
  662. this.actions.getApplication(data.application, function(json){
  663. this.application = {"name": json.data.name, "id": json.data.id};
  664. if (callback) callback(data);
  665. }.bind(this));
  666. }else{
  667. if (callback) callback(data);
  668. }
  669. }
  670. }.bind(this));
  671. },
  672. saveDictionary: function(){
  673. if (this.tab.showPage){
  674. var dictionary = this.tab.showPage.dictionary;
  675. dictionary.save(function(){
  676. if (dictionary==this.dictionary){
  677. var name = dictionary.data.name;
  678. this.setTitle(MWF.APPDD.LP.title + "-"+name);
  679. this.options.desktopReload = true;
  680. this.options.id = dictionary.data.id;
  681. }
  682. }.bind(this));
  683. }
  684. },
  685. saveDictionaryAs: function(){
  686. this.dictionary.saveAs();
  687. },
  688. dictionaryExplode: function(){
  689. this.dictionary.explode();
  690. },
  691. dictionaryImplode: function(){
  692. this.dictionary.implode();
  693. },
  694. //recordStatus: function(){
  695. // return {"id": this.options.id};
  696. //},
  697. dictionarySearch: function(){
  698. this.dictionary.loadSearch();
  699. },
  700. recordStatus: function(){
  701. if (this.tab){
  702. var openDictionarys = [];
  703. this.tab.pages.each(function(page){
  704. if (page.dictionary.data.id!=this.options.id) openDictionarys.push(page.dictionary.data.id);
  705. }.bind(this));
  706. var currentId = this.tab.showPage.dictionary.data.id;
  707. var status = {
  708. "id": this.options.id,
  709. "application": this.application,
  710. "applicationId": this.application.id || this.application,
  711. "openDictionarys": openDictionarys,
  712. "currentId": currentId,
  713. "options": {
  714. "action": this.options.action,
  715. "noCreate": this.options.noCreate,
  716. "noDelete": this.options.noDelete,
  717. "noModifyName": this.options.noModifyName,
  718. "readMode": this.options.readMode
  719. }
  720. };
  721. return status;
  722. }
  723. return {"id": this.options.id, "application": this.application};
  724. }
  725. });