Main.js 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874
  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. this.formContentNode = this.contentNode;
  226. },
  227. //loadViewListNodes-------------------------------
  228. loadViewListNodes: function(){
  229. this.viewListTitleNode = new Element("div", {
  230. "styles": this.css.viewListTitleNode,
  231. "text": MWF.APPDVD.LP.view
  232. }).inject(this.viewListNode);
  233. this.viewListResizeNode = new Element("div", {"styles": this.css.viewListResizeNode}).inject(this.viewListNode);
  234. this.viewListAreaSccrollNode = new Element("div", {"styles": this.css.viewListAreaSccrollNode}).inject(this.viewListNode);
  235. this.viewListAreaNode = new Element("div", {"styles": this.css.viewListAreaNode}).inject(this.viewListAreaSccrollNode);
  236. this.loadViewListResize();
  237. this.loadViewList();
  238. },
  239. loadViewListResize: function(){
  240. this.viewListResize = new Drag(this.viewListResizeNode,{
  241. "snap": 1,
  242. "onStart": function(el, e){
  243. var x = (Browser.name=="firefox") ? e.event.clientX : e.event.x;
  244. var y = (Browser.name=="firefox") ? e.event.clientY : e.event.y;
  245. el.store("position", {"x": x, "y": y});
  246. var size = this.viewListAreaSccrollNode.getSize();
  247. el.store("initialWidth", size.x);
  248. }.bind(this),
  249. "onDrag": function(el, e){
  250. var x = (Browser.name=="firefox") ? e.event.clientX : e.event.x;
  251. // var y = e.event.y;
  252. var bodySize = this.content.getSize();
  253. var position = el.retrieve("position");
  254. var initialWidth = el.retrieve("initialWidth").toFloat();
  255. var dx = x.toFloat() - position.x.toFloat();
  256. var width = initialWidth+dx;
  257. if (width> bodySize.x/2) width = bodySize.x/2;
  258. if (width<40) width = 40;
  259. this.contentNode.setStyle("margin-left", width+1);
  260. this.viewListNode.setStyle("width", width);
  261. //this.tab.pages.each(function(page){
  262. (this.view || this.table).setViewWidth();
  263. //});
  264. }.bind(this)
  265. });
  266. this.viewListResizeNode.addEvents({
  267. "touchstart": function(e){
  268. el = e.target;
  269. var x = (Browser.name=="firefox") ? e.page.clientX : e.page.x;
  270. var y = (Browser.name=="firefox") ? e.page.clientY : e.page.y;
  271. el.store("position", {"x": x, "y": y});
  272. var size = this.viewListAreaSccrollNode.getSize();
  273. el.store("initialWidth", size.x);
  274. }.bind(this),
  275. "touchmove": function(e){
  276. //Object.each(e, function(v, k){
  277. // alert(k+": "+ v);
  278. //});
  279. el = e.target;
  280. var x = (Browser.name=="firefox") ? e.page.clientX : e.page.x;
  281. // var y = e.event.y;
  282. var bodySize = this.content.getSize();
  283. var position = el.retrieve("position");
  284. var initialWidth = el.retrieve("initialWidth").toFloat();
  285. var dx = x.toFloat() - position.x.toFloat();
  286. var width = initialWidth+dx;
  287. if (width> bodySize.x/2) width = bodySize.x/2;
  288. if (width<40) width = 40;
  289. this.contentNode.setStyle("margin-left", width+1);
  290. this.viewListNode.setStyle("width", width);
  291. //this.tab.pages.each(function(page){
  292. (this.view || this.table).setViewWidth();
  293. //});
  294. }.bind(this)
  295. });
  296. },
  297. loadViewList: function(){
  298. this.actions.listView(this.application.id, function (json) {
  299. json.data.each(function(view){
  300. this.createListViewItem(view);
  301. }.bind(this));
  302. }.bind(this), null, false);
  303. },
  304. //列示所有视图列表
  305. createListViewItem: function(view, isNew){
  306. var _self = this;
  307. var listViewItem = new Element("div", {"styles": this.css.listViewItem}).inject(this.viewListAreaNode, (isNew) ? "top": "bottom");
  308. var listViewItemIcon = new Element("div", {"styles": this.css.listViewItemIcon}).inject(listViewItem);
  309. var listViewItemText = new Element("div", {"styles": this.css.listViewItemText, "text": (view.name) ? view.name+" ("+view.alias+")" : this.lp.newView}).inject(listViewItem);
  310. listViewItem.store("view", view);
  311. listViewItem.addEvents({
  312. "dblclick": function(e){_self.loadViewByData(this, e);},
  313. "mouseover": function(){if (_self.currentListViewItem!=this) this.setStyles(_self.css.listViewItem_over);},
  314. "mouseout": function(){if (_self.currentListViewItem!=this) this.setStyles(_self.css.listViewItem);}
  315. });
  316. },
  317. //打开视图
  318. loadViewByData: function(node, e){
  319. var view = node.retrieve("view");
  320. if (!view.isNewView){
  321. var openNew = true;
  322. //for (var i = 0; i<this.tab.pages.length; i++){
  323. // if (view.id==this.tab.pages[i].view.data.id){
  324. // this.tab.pages[i].showTabIm();
  325. // openNew = false;
  326. // break;
  327. // }
  328. //}
  329. if (openNew){
  330. //this.loadViewData(view.id, function(vdata){
  331. // var view = new MWF.xApplication.process.ViewDesigner.View(this, vdata);
  332. // view.load();
  333. //}.bind(this));
  334. var _self = this;
  335. var options = {
  336. "appId": "query.ViewDesigner"+view.id,
  337. "onQueryLoad": function(){
  338. this.actions = _self.actions;
  339. this.category = _self;
  340. this.options.id = view.id;
  341. this.application = _self.application;
  342. this.explorer = _self.explorer;
  343. }
  344. };
  345. this.desktop.openApplication(e, "query.ViewDesigner", options);
  346. }
  347. }
  348. },
  349. //loadContentNode------------------------------
  350. loadContentNode: function(){
  351. this.contentToolbarNode = new Element("div", {
  352. "styles": this.css.contentToolbarNode
  353. }).inject(this.contentNode);
  354. if (!this.options.readMode) this.loadContentToolbar();
  355. this.editContentNode = new Element("div", {
  356. "styles": this.css.editContentNode
  357. }).inject(this.contentNode);
  358. this.loadEditContent(function(){
  359. // if (this.designDcoument) this.designDcoument.body.setStyles(this.css.designBody);
  360. if (this.designNode) this.designNode.setStyles(this.css.designNode);
  361. }.bind(this));
  362. },
  363. loadContentToolbar: function(callback){
  364. this.getFormToolbarHTML(function(toolbarNode){
  365. var spans = toolbarNode.getElements("span");
  366. spans.each(function(item, idx){
  367. var img = item.get("MWFButtonImage");
  368. if (img){
  369. item.set("MWFButtonImage", this.path+""+this.options.style+"/toolbar/"+img);
  370. }
  371. }.bind(this));
  372. $(toolbarNode).inject(this.contentToolbarNode);
  373. MWF.require("MWF.widget.Toolbar", function(){
  374. this.toolbar = new MWF.widget.Toolbar(toolbarNode, {"style": "ProcessCategory"}, this);
  375. this.toolbar.load();
  376. if (this.table) if (this.table.checkToolbars) this.table.checkToolbars();
  377. if (callback) callback();
  378. }.bind(this));
  379. }.bind(this));
  380. },
  381. getFormToolbarHTML: function(callback){
  382. var toolbarUrl = this.path+this.options.style+"/toolbars.html";
  383. var r = new Request.HTML({
  384. url: toolbarUrl,
  385. method: "get",
  386. onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript){
  387. var toolbarNode = responseTree[0];
  388. if (callback) callback(toolbarNode);
  389. }.bind(this),
  390. onFailure: function(xhr){
  391. this.notice("request processToolbars error: "+xhr.responseText, "error");
  392. }.bind(this)
  393. });
  394. r.send();
  395. },
  396. maxOrReturnEditor: function(){
  397. if (!this.isMax){
  398. this.designNode.inject(this.node);
  399. this.designNode.setStyles({
  400. "position": "absolute",
  401. "width": "100%",
  402. "height": "100%",
  403. "top": "0px",
  404. "margin": "0px",
  405. "left": "0px"
  406. });
  407. //this.tab.pages.each(function(page){
  408. this.view.setAreaNodeSize();
  409. //});
  410. this.isMax = true;
  411. }else{
  412. this.isMax = false;
  413. this.designNode.inject(this.editContentNode);
  414. this.designNode.setStyles(this.css.designNode);
  415. this.designNode.setStyles({
  416. "position": "static"
  417. });
  418. this.resizeNode();
  419. //this.tab.pages.each(function(page){
  420. this.view.setAreaNodeSize();
  421. //});
  422. }
  423. },
  424. loadEditContent: function(callback){
  425. this.designNode = new Element("div", {
  426. "styles": this.css.designNode
  427. }).inject(this.editContentNode);
  428. //MWF.require("MWF.widget.Tab", function(){
  429. // this.tab = new MWF.widget.Tab(this.designNode, {"style": "dictionary"});
  430. // this.tab.load();
  431. //}.bind(this), false);
  432. // MWF.require("MWF.widget.ScrollBar", function(){
  433. // new MWF.widget.ScrollBar(this.designNode, {"distance": 100});
  434. // }.bind(this));
  435. },
  436. //loadProperty------------------------
  437. loadProperty: function(){
  438. this.propertyTitleNode = new Element("div", {
  439. "styles": this.css.propertyTitleNode,
  440. "text": MWF.APPDVD.LP.property
  441. }).inject(this.propertyNode);
  442. this.propertyResizeBar = new Element("div", {
  443. "styles": this.css.propertyResizeBar
  444. }).inject(this.propertyNode);
  445. this.loadPropertyResize();
  446. this.propertyContentNode = new Element("div", {
  447. "styles": this.css.propertyContentNode
  448. }).inject(this.propertyNode);
  449. this.propertyDomArea = new Element("div", {
  450. "styles": this.css.propertyDomArea
  451. }).inject(this.propertyContentNode);
  452. this.propertyDomPercent = 0.3;
  453. this.propertyContentResizeNode = new Element("div", {
  454. "styles": this.css.propertyContentResizeNode
  455. }).inject(this.propertyContentNode);
  456. this.propertyContentArea = new Element("div", {
  457. "styles": this.css.propertyContentArea
  458. }).inject(this.propertyContentNode);
  459. this.loadPropertyContentResize();
  460. //this.setPropertyContent();
  461. this.propertyNode.addEvent("keydown", function(e){e.stopPropagation();});
  462. },
  463. //setPropertyContent: function(){
  464. // this.dictionaryPropertyNode = new Element("div", {"styles": this.css.dictionaryPropertyNode});
  465. // this.jsonDomNode = new Element("div", {"styles": this.css.jsonDomNode});
  466. // this.jsonTextNode = new Element("div", {"styles": this.css.jsonTextNode});
  467. // this.jsonTextAreaNode = new Element("textarea", {"styles": this.css.jsonTextAreaNode}).inject(this.jsonTextNode);
  468. //
  469. // MWF.require("MWF.widget.Tab", function(){
  470. // var tab = new MWF.widget.Tab(this.propertyContentArea, {"style": "moduleList"});
  471. // tab.load();
  472. // tab.addTab(this.dictionaryPropertyNode, this.lp.property, false);
  473. // tab.addTab(this.jsonDomNode, "JSON", false);
  474. // tab.addTab(this.jsonTextNode, "TEXT", false);
  475. // tab.pages[0].showTab();
  476. // }.bind(this));
  477. //
  478. // var node = new Element("div", {"styles": this.css.propertyTitleNode, "text": this.lp.id+":"}).inject(this.dictionaryPropertyNode);
  479. // this.propertyIdNode = new Element("div", {"styles": this.css.propertyTextNode}).inject(this.dictionaryPropertyNode);
  480. //
  481. // node = new Element("div", {"styles": this.css.propertyTitleNode, "text": this.lp.name+":"}).inject(this.dictionaryPropertyNode);
  482. // this.propertyNameNode = new Element("input", {"styles": this.css.propertyInputNode}).inject(this.dictionaryPropertyNode);
  483. // if (this.options.noModifyName || this.options.readMode){
  484. // this.propertyNameNode.set("readonly", true);
  485. // this.propertyNameNode.addEvent("keydown", function(){
  486. // this.notice(this.lp.notice.noModifyName, "error");
  487. // }.bind(this));
  488. // }
  489. //
  490. // node = new Element("div", {"styles": this.css.propertyTitleNode, "text": this.lp.alias+":"}).inject(this.dictionaryPropertyNode);
  491. // this.propertyAliasNode = new Element("input", {"styles": this.css.propertyInputNode}).inject(this.dictionaryPropertyNode);
  492. // if (this.options.noModifyName || this.options.readMode){
  493. // this.propertyAliasNode.set("readonly", true);
  494. // this.propertyAliasNode.addEvent("keydown", function(){
  495. // this.notice(this.lp.notice.noModifyName, "error");
  496. // }.bind(this));
  497. // }
  498. //
  499. // node = new Element("div", {"styles": this.css.propertyTitleNode, "text": this.lp.description+":"}).inject(this.dictionaryPropertyNode);
  500. // this.propertyDescriptionNode = new Element("textarea", {"styles": this.css.propertyInputAreaNode}).inject(this.dictionaryPropertyNode);
  501. // if (this.options.noModifyName || this.options.readMode){
  502. // this.propertyDescriptionNode.set("readonly", true);
  503. // }
  504. //},
  505. loadPropertyResize: function(){
  506. // var size = this.propertyNode.getSize();
  507. // var position = this.propertyResizeBar.getPosition();
  508. this.propertyResize = new Drag(this.propertyResizeBar,{
  509. "snap": 1,
  510. "onStart": function(el, e){
  511. var x = (Browser.name=="firefox") ? e.event.clientX : e.event.x;
  512. var y = (Browser.name=="firefox") ? e.event.clientY : e.event.y;
  513. el.store("position", {"x": x, "y": y});
  514. var size = this.propertyNode.getSize();
  515. el.store("initialWidth", size.x);
  516. }.bind(this),
  517. "onDrag": function(el, e){
  518. var x = (Browser.name=="firefox") ? e.event.clientX : e.event.x;
  519. // var y = e.event.y;
  520. var bodySize = this.content.getSize();
  521. var position = el.retrieve("position");
  522. var initialWidth = el.retrieve("initialWidth").toFloat();
  523. var dx = position.x.toFloat()-x.toFloat();
  524. var width = initialWidth+dx;
  525. if (width> bodySize.x/2) width = bodySize.x/2;
  526. if (width<40) width = 40;
  527. this.contentNode.setStyle("margin-right", width+1);
  528. this.propertyNode.setStyle("width", width);
  529. //this.tab.pages.each(function(page){
  530. (this.view || this.table).setViewWidth();
  531. //});
  532. }.bind(this)
  533. });
  534. },
  535. loadPropertyContentResize: function(){
  536. this.propertyContentResize = new Drag(this.propertyContentResizeNode, {
  537. "snap": 1,
  538. "onStart": function(el, e){
  539. var x = (Browser.name=="firefox") ? e.event.clientX : e.event.x;
  540. var y = (Browser.name=="firefox") ? e.event.clientY : e.event.y;
  541. el.store("position", {"x": x, "y": y});
  542. var size = this.propertyDomArea.getSize();
  543. el.store("initialHeight", size.y);
  544. }.bind(this),
  545. "onDrag": function(el, e){
  546. var size = this.propertyContentNode.getSize();
  547. // var x = e.event.x;
  548. var y = (Browser.name=="firefox") ? e.event.clientY : e.event.y;
  549. var position = el.retrieve("position");
  550. var dy = y.toFloat()-position.y.toFloat();
  551. var initialHeight = el.retrieve("initialHeight").toFloat();
  552. var height = initialHeight+dy;
  553. if (height<40) height = 40;
  554. if (height> size.y-40) height = size.y-40;
  555. this.propertyDomPercent = height/size.y;
  556. this.setPropertyContentResize();
  557. }.bind(this)
  558. });
  559. },
  560. setPropertyContentResize: function(){
  561. var size = this.propertyContentNode.getSize();
  562. var resizeNodeSize = this.propertyContentResizeNode.getSize();
  563. var height = size.y-resizeNodeSize.y;
  564. var domHeight = this.propertyDomPercent*height;
  565. var contentHeight = height-domHeight;
  566. this.propertyDomArea.setStyle("height", ""+domHeight+"px");
  567. this.propertyContentArea.setStyle("height", ""+contentHeight+"px");
  568. if (this.table) this.view = this.table;
  569. if (this.view){
  570. if (this.view.currentSelectedModule){
  571. if (this.view.currentSelectedModule.property){
  572. var tab = this.view.currentSelectedModule.property.propertyTab;
  573. if (tab){
  574. var tabTitleSize = tab.tabNodeContainer.getSize();
  575. tab.pages.each(function(page){
  576. var topMargin = page.contentNodeArea.getStyle("margin-top").toFloat();
  577. var bottomMargin = page.contentNodeArea.getStyle("margin-bottom").toFloat();
  578. var tabContentNodeAreaHeight = contentHeight - topMargin - bottomMargin - tabTitleSize.y.toFloat()-15;
  579. page.contentNodeArea.setStyle("height", tabContentNodeAreaHeight);
  580. }.bind(this));
  581. }
  582. }
  583. }
  584. }
  585. },
  586. //resizeNode------------------------------------------------
  587. resizeNode: function(){
  588. var nodeSize = this.node.getSize();
  589. this.contentNode.setStyle("height", ""+nodeSize.y+"px");
  590. this.propertyNode.setStyle("height", ""+nodeSize.y+"px");
  591. var contentToolbarMarginTop = this.contentToolbarNode.getStyle("margin-top").toFloat();
  592. var contentToolbarMarginBottom = this.contentToolbarNode.getStyle("margin-bottom").toFloat();
  593. var allContentToolberSize = this.contentToolbarNode.getComputedSize();
  594. var y = nodeSize.y - allContentToolberSize.totalHeight - contentToolbarMarginTop - contentToolbarMarginBottom;
  595. this.editContentNode.setStyle("height", ""+y+"px");
  596. if (this.designNode){
  597. var designMarginTop = this.designNode.getStyle("margin-top").toFloat();
  598. var designMarginBottom = this.designNode.getStyle("margin-bottom").toFloat();
  599. y = nodeSize.y - allContentToolberSize.totalHeight - contentToolbarMarginTop - contentToolbarMarginBottom - designMarginTop - designMarginBottom;
  600. this.designNode.setStyle("height", ""+y+"px");
  601. }
  602. titleSize = this.propertyTitleNode.getSize();
  603. titleMarginTop = this.propertyTitleNode.getStyle("margin-top").toFloat();
  604. titleMarginBottom = this.propertyTitleNode.getStyle("margin-bottom").toFloat();
  605. titlePaddingTop = this.propertyTitleNode.getStyle("padding-top").toFloat();
  606. titlePaddingBottom = this.propertyTitleNode.getStyle("padding-bottom").toFloat();
  607. y = titleSize.y+titleMarginTop+titleMarginBottom+titlePaddingTop+titlePaddingBottom;
  608. y = nodeSize.y-y;
  609. this.propertyContentNode.setStyle("height", ""+y+"px");
  610. this.propertyResizeBar.setStyle("height", ""+y+"px");
  611. this.setPropertyContentResize();
  612. titleSize = this.viewListTitleNode.getSize();
  613. titleMarginTop = this.viewListTitleNode.getStyle("margin-top").toFloat();
  614. titleMarginBottom = this.viewListTitleNode.getStyle("margin-bottom").toFloat();
  615. titlePaddingTop = this.viewListTitleNode.getStyle("padding-top").toFloat();
  616. titlePaddingBottom = this.viewListTitleNode.getStyle("padding-bottom").toFloat();
  617. nodeMarginTop = this.viewListAreaSccrollNode.getStyle("margin-top").toFloat();
  618. nodeMarginBottom = this.viewListAreaSccrollNode.getStyle("margin-bottom").toFloat();
  619. y = titleSize.y+titleMarginTop+titleMarginBottom+titlePaddingTop+titlePaddingBottom+nodeMarginTop+nodeMarginBottom;
  620. y = nodeSize.y-y;
  621. this.viewListAreaSccrollNode.setStyle("height", ""+y+"px");
  622. this.viewListResizeNode.setStyle("height", ""+y+"px");
  623. },
  624. //loadView------------------------------------------
  625. loadView: function(callback){
  626. this.getViewData(this.options.id, function(vdata){
  627. this.setTitle(this.options.appTitle + "-"+vdata.name);
  628. this.taskitem.setText(this.options.appTitle + "-"+vdata.name);
  629. this.options.appTitle = this.options.appTitle + "-"+vdata.name;
  630. //if (this.options.readMode){
  631. // this.view = new MWF.xApplication.process.DictionaryDesigner.DictionaryReader(this, ddata);
  632. //}else{
  633. this.view = new MWF.xApplication.query.ViewDesigner.View(this, vdata);
  634. //}
  635. this.view.load();
  636. if (callback) callback();
  637. //if (this.status){
  638. // if (this.status.openViews){
  639. // this.status.openViews.each(function(id){
  640. // this.loadViewData(id, function(data){
  641. // var showTab = true;
  642. // if (this.status.currentId){
  643. // if (this.status.currentId!=data.id) showTab = false;
  644. // }
  645. // //if (this.options.readMode){
  646. // // var view = new MWF.xApplication.process.DictionaryDesigner.DictionaryReader(this, data, {"showTab": showTab});
  647. // //}else{
  648. // var view = new MWF.xApplication.process.DictionaryDesigner.View(this, data, {"showTab": showTab});
  649. // //}
  650. //
  651. // view.load();
  652. // }.bind(this), true);
  653. // }.bind(this));
  654. // }
  655. //}
  656. }.bind(this));
  657. },
  658. getViewData: function(id, callback){
  659. if (!this.options.id){
  660. this.loadNewViewData(callback);
  661. }else{
  662. this.loadViewData(id, callback);
  663. }
  664. },
  665. loadNewViewData: function(callback){
  666. var url = "../x_component_query_ViewDesigner/$View/view.json";
  667. MWF.getJSON(url, {
  668. "onSuccess": function(obj){
  669. this.actions.getUUID(function(id){
  670. obj.id=id;
  671. obj.isNewView = true;
  672. obj.application = this.application.id;
  673. this.createListViewItem(obj, true);
  674. if (callback) callback(obj);
  675. }.bind(this));
  676. }.bind(this),
  677. "onerror": function(text){
  678. this.notice(text, "error");
  679. }.bind(this),
  680. "onRequestFailure": function(xhr){
  681. this.notice(xhr.responseText, "error");
  682. }.bind(this)
  683. });
  684. },
  685. loadViewData: function(id, callback){
  686. this.actions.getView(id, function(json){
  687. if (json){
  688. var data = json.data;
  689. var dataJson = JSON.decode(data.data);
  690. data.data = dataJson;
  691. if (!this.application){
  692. this.actions.getApplication(data.application, function(json){
  693. this.application = {"name": json.data.name, "id": json.data.id};
  694. if (callback) callback(data);
  695. }.bind(this));
  696. }else{
  697. if (callback) callback(data);
  698. }
  699. }
  700. }.bind(this));
  701. },
  702. saveView: function(){
  703. this.view.save(function(){
  704. var name = this.view.data.name;
  705. this.setTitle(MWF.APPDVD.LP.title + "-"+name);
  706. this.options.desktopReload = true;
  707. this.options.id = this.view.data.id;
  708. }.bind(this));
  709. },
  710. preview : function(){
  711. this.view.preview();
  712. },
  713. saveViewAs: function(){
  714. this.view.saveAs();
  715. },
  716. dictionaryExplode: function(){
  717. this.view.explode();
  718. },
  719. dictionaryImplode: function(){
  720. this.view.implode();
  721. },
  722. //recordStatus: function(){
  723. // return {"id": this.options.id};
  724. //},
  725. recordStatus: function(){
  726. //if (this.tab){
  727. var openViews = [];
  728. openViews.push(this.view.data.id);
  729. var currentId = this.view.data.id;
  730. return {
  731. "id": this.options.id,
  732. "application": this.application,
  733. "openViews": openViews,
  734. "currentId": currentId
  735. };
  736. //}
  737. //return {"id": this.options.id, "application": this.application};
  738. }
  739. });
  740. MWF.xDesktop.requireApp("Template", "MPopupForm", null, false);
  741. MWF.xApplication.query.ViewDesigner.View.NewNameForm = new Class({
  742. Extends: MPopupForm,
  743. Implements: [Options, Events],
  744. options: {
  745. "style": "design",
  746. "width": 700,
  747. //"height": 300,
  748. "height": "260",
  749. "hasTop": true,
  750. "hasIcon": false,
  751. "draggable": true,
  752. "title" : MWF.xApplication.query.ViewDesigner.LP.newView
  753. },
  754. _createTableContent: function () {
  755. var html = "<table width='80%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' style='margin: 20px auto 0px auto; '>" +
  756. "<tr><td styles='formTableTitle' lable='selectQuery' width='25%'></td>" +
  757. " <td styles='formTableValue' item='selectQuery' colspan='3' width='75%'></td></tr>" +
  758. "<tr><td styles='formTableTitle' lable='name'></td>" +
  759. " <td styles='formTableValue' item='name' colspan='3'></td></tr>" +
  760. "</table>";
  761. this.formTableArea.set("html", html);
  762. MWF.xDesktop.requireApp("Template", "MForm", function () {
  763. this.form = new MForm(this.formTableArea, this.data || {}, {
  764. isEdited: true,
  765. style: "cms",
  766. hasColon: true,
  767. itemTemplate: {
  768. selectQuery : { text: MWF.xApplication.query.ViewDesigner.LP.application , type : "org", orgType : "Query", defaultValue : this.data.queryName, orgWidgetOptions : {
  769. "canRemove" : false
  770. }},
  771. name: {text: MWF.xApplication.query.ViewDesigner.LP.name, notEmpty: true}
  772. }
  773. }, this.app);
  774. this.form.load();
  775. }.bind(this),null, true)
  776. },
  777. ok: function(){
  778. var data = this.form.getResult(true,null,true,false,true);
  779. if( data ){
  780. var selectQuery = this.form.getItem("selectQuery").orgObject;
  781. if( selectQuery && selectQuery.length > 0 ){
  782. var queryData = selectQuery[0].data;
  783. data.query = queryData.id;
  784. data.queryName = queryData.name;
  785. }else{
  786. //data.query 和 data.queryName 还是传进来的值
  787. }
  788. this.fireEvent("save", [data , function(){
  789. this.close();
  790. }.bind(this)])
  791. }
  792. }
  793. });