Main.js 33 KB

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