View.js 68 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671
  1. MWF.xApplication = MWF.xApplication || {};
  2. MWF.xApplication.query = MWF.xApplication.query || {};
  3. MWF.xApplication.query.ViewDesigner = MWF.xApplication.query.ViewDesigner || {};
  4. MWF.APPDVD = MWF.xApplication.query.ViewDesigner;
  5. MWF.require("MWF.widget.Common", null, false);
  6. MWF.require("MWF.xScript.Macro", null, false);
  7. MWF.xDesktop.requireApp("query.ViewDesigner", "lp."+MWF.language, null, false);
  8. MWF.xDesktop.requireApp("query.ViewDesigner", "Property", null, false);
  9. MWF.xApplication.query.ViewDesigner.View = new Class({
  10. Extends: MWF.widget.Common,
  11. Implements: [Options, Events],
  12. options: {
  13. "style": "default",
  14. "isView": false,
  15. "showTab": true,
  16. "propertyPath": "/x_component_query_ViewDesigner/$View/view.html"
  17. },
  18. initialize: function(designer, data, options){
  19. this.setOptions(options);
  20. this.path = "/x_component_query_ViewDesigner/$View/";
  21. this.cssPath = "/x_component_query_ViewDesigner/$View/"+this.options.style+"/css.wcss";
  22. this._loadCss();
  23. this.designer = designer;
  24. this.data = data;
  25. if (!this.data.data) this.data.data = {};
  26. this.parseData();
  27. this.node = this.designer.designNode;
  28. //this.tab = this.designer.tab;
  29. this.areaNode = new Element("div", {"styles": {"height": "100%", "overflow": "auto"}});
  30. //MWF.require("MWF.widget.ScrollBar", function(){
  31. // new MWF.widget.ScrollBar(this.areaNode, {"distance": 100});
  32. //}.bind(this));
  33. this.propertyListNode = this.designer.propertyDomArea;
  34. //this.propertyNode = this.designer.propertyContentArea;
  35. if(this.designer.application) this.data.applicationName = this.designer.application.name;
  36. if(this.designer.application) this.data.application = this.designer.application.id;
  37. this.isNewView = (this.data.id) ? false : true;
  38. this.items = [];
  39. this.view = this;
  40. this.autoSave();
  41. this.designer.addEvent("queryClose", function(){
  42. if (this.autoSaveTimerID) window.clearInterval(this.autoSaveTimerID);
  43. }.bind(this));
  44. },
  45. autoSave: function(){
  46. this.autoSaveTimerID = window.setInterval(function(){
  47. if (!this.autoSaveCheckNode) this.autoSaveCheckNode = this.designer.contentToolbarNode.getElement("#MWFDictionaryAutoSaveCheck");
  48. if (this.autoSaveCheckNode){
  49. if (this.autoSaveCheckNode.get("checked")){
  50. this.save();
  51. }
  52. }
  53. }.bind(this), 60000);
  54. },
  55. parseData: function(){
  56. this.json = this.data;
  57. if( !this.json.data.events ){
  58. var url = "/x_component_query_ViewDesigner/$View/view.json";
  59. MWF.getJSON(url, {
  60. "onSuccess": function(obj){
  61. this.json.data.events = obj.data.events;
  62. }.bind(this),
  63. "onerror": function(text){
  64. this.notice(text, "error");
  65. }.bind(this),
  66. "onRequestFailure": function(xhr){
  67. this.notice(xhr.responseText, "error");
  68. }.bind(this)
  69. },false);
  70. }
  71. },
  72. showProperty: function(){
  73. if (!this.property){
  74. this.property = new MWF.xApplication.query.ViewDesigner.Property(this, this.designer.propertyContentArea, this.designer, {
  75. "path": this.options.propertyPath,
  76. "onPostLoad": function(){
  77. this.property.show();
  78. }.bind(this)
  79. });
  80. this.property.load();
  81. }else{
  82. this.property.show();
  83. }
  84. },
  85. hideProperty: function(){
  86. if (this.property) this.property.hide();
  87. },
  88. load : function(){
  89. this.setAreaNodeSize();
  90. this.designer.addEvent("resize", this.setAreaNodeSize.bind(this));
  91. this.areaNode.inject(this.node);
  92. this.designer.viewListAreaNode.getChildren().each(function(node){
  93. var view = node.retrieve("view");
  94. if (view.id==this.data.id){
  95. if (this.designer.currentListViewItem){
  96. this.designer.currentListViewItem.setStyles(this.designer.css.listViewItem);
  97. }
  98. node.setStyles(this.designer.css.listViewItem_current);
  99. this.designer.currentListViewItem = node;
  100. this.lisNode = node;
  101. }
  102. }.bind(this));
  103. this.domListNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.designer.propertyDomArea);
  104. this.loadActionbar();
  105. this.loadView();
  106. this.selected();
  107. this.setEvent();
  108. //if (this.options.showTab) this.page.showTabIm();
  109. this.setViewWidth();
  110. this.designer.addEvent("resize", this.setViewWidth.bind(this));
  111. },
  112. setEvent: function(){
  113. this.areaNode.addEvent("click", this.selected.bind(this));
  114. this.refreshNode.addEvent("click", function(e){
  115. this.loadViewData();
  116. e.stopPropagation();
  117. }.bind(this));
  118. this.addColumnNode.addEvent("click", function(e){
  119. this.addColumn();
  120. e.stopPropagation();
  121. }.bind(this));
  122. },
  123. loadViewData: function(){
  124. if (this.data.id){
  125. this.saveSilence(function(){
  126. this.viewContentBodyNode.empty();
  127. this.viewContentTableNode = new Element("table", {
  128. "styles": this.css.viewContentTableNode,
  129. "border": "0px",
  130. "cellPadding": "0",
  131. "cellSpacing": "0"
  132. }).inject(this.viewContentBodyNode);
  133. this.designer.actions.loadView(this.data.id, null,function(json){
  134. var entries = {};
  135. json.data.selectList.each(function(entry){entries[entry.column] = entry;}.bind(this));
  136. if (this.json.data.group.column){
  137. if (json.data.groupGrid.length){
  138. var groupColumn = null;
  139. for (var c = 0; c<json.data.selectList.length; c++){
  140. if (json.data.selectList[c].column === json.data.group.column){
  141. groupColumn = json.data.selectList[c];
  142. break;
  143. }
  144. }
  145. json.data.groupGrid.each(function(line, idx){
  146. var groupTr = new Element("tr", {"styles": this.css.viewContentTrNode}).inject(this.viewContentTableNode);
  147. var colSpan = this.items.length ;
  148. var td = new Element("td", {"styles": this.css.viewContentGroupTdNode, "colSpan": colSpan}).inject(groupTr);
  149. var groupAreaNode = new Element("div", {"styles": this.css.viewContentTdGroupNode}).inject(td);
  150. var groupIconNode = new Element("div", {"styles": this.css.viewContentTdGroupIconNode}).inject(groupAreaNode);
  151. var groupTextNode = new Element("div", {"styles": this.css.viewContentTdGroupTextNode}).inject(groupAreaNode);
  152. if (groupColumn){
  153. //groupTextNode.set("text", (groupColumn.code) ? MWF.Macro.exec(groupColumn.code, {"value": line.group, "gridData": json.data.groupGrid, "data": json.data, "entry": line}) : line.group);
  154. groupTextNode.set("text", line.group);
  155. }else{
  156. groupTextNode.set("text", line.group);
  157. }
  158. var subtrs = [];
  159. line.list.each(function(entry){
  160. var tr = new Element("tr", {"styles": this.css.viewContentTrNode}).inject(this.viewContentTableNode);
  161. tr.setStyle("display", "none");
  162. //this.createViewCheckboxTd( tr );
  163. var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr);
  164. Object.each(entries, function(c, k){
  165. var d = entry.data[k];
  166. if (d!=undefined){
  167. if (k!=this.json.data.group.column){
  168. var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr);
  169. //td.set("text", (entries[k].code) ? MWF.Macro.exec(entries[k].code, {"value": d, "gridData": json.data.groupGrid, "data": json.data, "entry": entry}) : d);
  170. if (c.isHtml){
  171. td.set("html", d);
  172. }else{
  173. td.set("text", d);
  174. }
  175. }
  176. }
  177. }.bind(this));
  178. // Object.each(entry.data, function(d, k){
  179. // if (k!=this.json.data.group.column){
  180. // var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr);
  181. // td.set("text", (entries[k].code) ? MWF.Macro.exec(entries[k].code, {"value": d, "gridData": json.data.groupGrid, "data": json.data, "entry": entry}) : d);
  182. // }
  183. // }.bind(this));
  184. subtrs.push(tr)
  185. }.bind(this));
  186. groupAreaNode.store("subtrs", subtrs);
  187. var _self = this;
  188. groupAreaNode.addEvent("click", function(){
  189. var subtrs = this.retrieve("subtrs");
  190. var iconNode = groupAreaNode.getFirst("div");
  191. if (subtrs[0]){
  192. if (subtrs[0].getStyle("display")=="none"){
  193. subtrs.each(function(subtr){ subtr.setStyle("display", "table-row"); });
  194. iconNode.setStyle("background", "url("+"/x_component_process_ViewDesigner/$View/default/icon/down.png) center center no-repeat");
  195. }else{
  196. subtrs.each(function(subtr){ subtr.setStyle("display", "none"); });
  197. iconNode.setStyle("background", "url("+"/x_component_process_ViewDesigner/$View/default/icon/right.png) center center no-repeat");
  198. }
  199. }
  200. _self.setContentHeight();
  201. });
  202. }.bind(this));
  203. this.setContentColumnWidth();
  204. this.setContentHeight();
  205. }
  206. }else{
  207. if (json.data.grid.length){
  208. json.data.grid.each(function(line, idx){
  209. var tr = new Element("tr", {"styles": this.css.viewContentTrNode}).inject(this.viewContentTableNode);
  210. //this.createViewCheckboxTd( tr );
  211. Object.each(entries, function(c, k){
  212. var d = line.data[k];
  213. if (d!=undefined){
  214. var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr);
  215. //td.set("text", (entries[k].code) ? MWF.Macro.exec(entries[k].code, {"value": d, "gridData": json.data.grid, "data": json.data, "entry": line}) : d);
  216. if (c.isHtml){
  217. td.set("html", d);
  218. }else{
  219. td.set("text", d);
  220. }
  221. //td.set("text", d);
  222. }
  223. }.bind(this));
  224. // Object.each(line.data, function(d, k){
  225. // var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr);
  226. // td.set("text", (entries[k].code) ? MWF.Macro.exec(entries[k].code, {"value": d, "gridData": json.data.grid, "data": json.data, "entry": line}) : d);
  227. // }.bind(this));
  228. }.bind(this));
  229. this.setContentColumnWidth();
  230. this.setContentHeight();
  231. }
  232. }
  233. }.bind(this));
  234. //this.getLookupAction(function(){
  235. // this.lookupAction.invoke({"name": "lookup","async": true, "parameter": {"id": this.data.id},"success": function(json){
  236. // if (json.data.length){
  237. // json.data.each(function(line, idx){
  238. // var tr = new Element("tr", {"styles": this.css.viewContentTrNode}).inject(this.viewContentTableNode);
  239. // line.each(function(cell, i){
  240. // var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr);
  241. // td.set("text", cell);
  242. // }.bind(this));
  243. // }.bind(this));
  244. // this.setContentColumnWidth();
  245. // this.setContentHeight();
  246. // }
  247. // }.bind(this)});
  248. //}.bind(this));
  249. }.bind(this));
  250. }
  251. },
  252. setContentColumnWidth: function(){
  253. var titleTds = this.viewTitleTrNode.getElements("td");
  254. var widthList = [];
  255. titleTds.each(function(td){widthList.push(td.getSize().x);});
  256. var flag = false;
  257. if (this.viewContentTableNode){
  258. trs = this.viewContentTableNode.getElements("tr");
  259. for (var i=0; i<trs.length; i++){
  260. var tr = trs[i];
  261. var tds = tr.getElements("td");
  262. tds.each(function(contentTd, i){
  263. if (contentTd.get("colSpan")==1){
  264. contentTd.setStyle("width", ""+widthList[i]+"px");
  265. flag = true;
  266. }
  267. });
  268. if (flag) break;
  269. }
  270. //var tr = this.viewContentTableNode.getFirst("tr");
  271. //if (tr){
  272. // var tds = tr.getElements("td");
  273. // tds.each(function(contentTd, i){
  274. // if (!contentTd.get("colSpan")){
  275. // contentTd.setStyle("width", ""+widthList[i]+"px");
  276. // }
  277. // });
  278. //}
  279. }
  280. },
  281. //getLookupAction: function(callback){
  282. // if (!this.lookupAction){
  283. // MWF.require("MWF.xDesktop.Actions.RestActions", function(){
  284. // this.lookupAction = new MWF.xDesktop.Actions.RestActions("", "x_processplatform_assemble_surface_lookup", "");
  285. // this.lookupAction.getActions = function(actionCallback){
  286. //
  287. // this.actions = {"lookup": {"uri": "/jaxrs/view/{id}"}};
  288. // if (actionCallback) actionCallback();
  289. // }
  290. // if (callback) callback();
  291. // }.bind(this));
  292. // }else{
  293. // if (callback) callback();
  294. // }
  295. //},
  296. addColumn: function(){
  297. MWF.require("MWF.widget.UUID", function(){
  298. var id = (new MWF.widget.UUID).id;
  299. var json = {
  300. "id": id,
  301. "column": id,
  302. "displayName": this.designer.lp.unnamed,
  303. "orderType": "original"
  304. };
  305. if (!this.json.data.selectList) this.json.data.selectList = [];
  306. this.json.data.selectList.push(json);
  307. var column = new MWF.xApplication.query.ViewDesigner.View.Column(json, this);
  308. this.items.push(column);
  309. column.selected();
  310. if (this.viewContentTableNode){
  311. var trs = this.viewContentTableNode.getElements("tr");
  312. trs.each(function(tr){
  313. new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr)
  314. }.bind(this));
  315. //this.setContentColumnWidth();
  316. }
  317. this.setViewWidth();
  318. this.addColumnNode.scrollIntoView(true);
  319. }.bind(this));
  320. //new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 0}).toRight();
  321. },
  322. selected: function(){
  323. if (this.currentSelectedModule){
  324. if (this.currentSelectedModule==this){
  325. return true;
  326. }else{
  327. this.currentSelectedModule.unSelected();
  328. }
  329. }
  330. this.currentSelectedModule = this;
  331. this.showProperty();
  332. },
  333. unSelected: function(){
  334. this.currentSelectedModule = null;
  335. this.hideProperty();
  336. },
  337. loadViewNodes: function(){
  338. this.viewAreaNode = new Element("div#viewAreaNode", {"styles": this.css.viewAreaNode}).inject(this.areaNode);
  339. this.viewTitleNode = new Element("div#viewTitleNode", {"styles": this.css.viewTitleNode}).inject(this.viewAreaNode);
  340. this.refreshNode = new Element("div", {"styles": this.css.refreshNode}).inject(this.viewTitleNode);
  341. this.addColumnNode = new Element("div", {"styles": this.css.addColumnNode}).inject(this.viewTitleNode);
  342. this.viewTitleContentNode = new Element("div", {"styles": this.css.viewTitleContentNode}).inject(this.viewTitleNode);
  343. this.viewTitleTableNode = new Element("table", {
  344. "styles": this.css.viewTitleTableNode,
  345. "border": "0px",
  346. "cellPadding": "0",
  347. "cellSpacing": "0"
  348. }).inject(this.viewTitleContentNode);
  349. this.viewTitleTrNode = new Element("tr", {"styles": this.css.viewTitleTrNode}).inject(this.viewTitleTableNode);
  350. this.viewContentScrollNode = new Element("div", {"styles": this.css.viewContentScrollNode}).inject(this.viewAreaNode);
  351. this.viewContentNode = new Element("div", {"styles": this.css.viewContentNode}).inject(this.viewContentScrollNode);
  352. MWF.require("MWF.widget.ScrollBar", function(){
  353. new MWF.widget.ScrollBar(this.viewContentScrollNode, {"style": "view", "distance": 100, "indent": false});
  354. }.bind(this));
  355. this.contentLeftNode = new Element("div", {"styles": this.css.contentLeftNode}).inject(this.viewContentNode);
  356. this.contentRightNode = new Element("div", {"styles": this.css.contentRightNode}).inject(this.viewContentNode);
  357. this.viewContentBodyNode = new Element("div", {"styles": this.css.viewContentBodyNode}).inject(this.viewContentNode);
  358. this.viewContentTableNode = new Element("table", {
  359. "styles": this.css.viewContentTableNode,
  360. "border": "0px",
  361. "cellPadding": "0",
  362. "cellSpacing": "0"
  363. }).inject(this.viewContentBodyNode);
  364. },
  365. setContentHeight: function(){
  366. var size = this.areaNode.getSize();
  367. var titleSize = this.viewTitleNode.getSize();
  368. var actionbarSize = this.actionbarNode ? this.actionbarNode.getSize() : {x:0, y:0};
  369. var height = size.y-titleSize.y-actionbarSize.y-2;
  370. this.viewContentScrollNode.setStyle("height", height);
  371. var contentSize = this.viewContentBodyNode.getSize();
  372. if (height<contentSize.y) height = contentSize.y+10;
  373. this.viewContentNode.setStyle("height", height);
  374. this.contentLeftNode.setStyle("height", height);
  375. this.contentRightNode.setStyle("height", height);
  376. //this.viewContentBodyNode.setStyle("min-height", height);
  377. },
  378. loadViewColumns: function(){
  379. // for (var i=0; i<10; i++){
  380. if (this.json.data.selectList) {
  381. this.json.data.selectList.each(function (json) {
  382. this.items.push(new MWF.xApplication.query.ViewDesigner.View.Column(json, this));
  383. }.bind(this));
  384. }
  385. // }
  386. },
  387. loadViewSelectAllNode : function(){
  388. var _self = this;
  389. var td = new Element("td.viewTitleCheckboxTd",{ "styles": this.css.viewTitleColumnAreaNode }).inject( this.viewTitleTrNode );
  390. td.setStyles({
  391. "width":"30px", "text-align" : "center",
  392. "display" : this.json.data.selectAllEnable ? "table-cell" : "none"
  393. });
  394. new Element("input",{
  395. "type" : "checkbox",
  396. "events" : {
  397. "change" : function(){
  398. _self.viewContentTableNode.getElements(".viewContentCheckbox").set("checked", this.checked )
  399. }
  400. }
  401. }).inject(td);
  402. },
  403. createViewCheckboxTd : function( tr ){
  404. var td = new Element("td.viewContentCheckboxTd", {"styles": this.css.viewContentTdNode}).inject(tr, "top");
  405. td.setStyles({
  406. "width":"30px", "text-align" : "center",
  407. "display" : this.json.data.selectAllEnable ? "table-cell" : "none"
  408. });
  409. new Element("input.viewContentCheckbox",{
  410. "type" : "checkbox"
  411. }).inject(td);
  412. },
  413. loadView: function(){
  414. this.loadViewNodes();
  415. //this.loadViewSelectAllNode();
  416. this.loadViewColumns();
  417. // this.addTopItemNode.addEvent("click", this.addTopItem.bind(this));
  418. },
  419. loadActionbar: function(){
  420. this.actionbarNode = new Element("div#actionbarNode", {"styles": this.css.actionbarNode}).inject(this.areaNode);
  421. this.actionbarList = [];
  422. if( !this.json.data.actionbarHidden ){
  423. this.showActionbar( true );
  424. }
  425. },
  426. hideActionbar : function(){
  427. this.actionbarNode.hide();
  428. this.setContentHeight();
  429. },
  430. showActionbar : function( noSetHeight ){
  431. this.actionbarNode.show();
  432. if( !this.json.data.actionbarList )this.json.data.actionbarList = [];
  433. if( !this.actionbarList || this.actionbarList.length == 0 ){
  434. if( this.json.data.actionbarList.length ){
  435. this.json.data.actionbarList.each( function(json){
  436. this.actionbarList.push( new MWF.xApplication.query.ViewDesigner.View.Actionbar( json, this.json.data.actionbarList, this) )
  437. }.bind(this));
  438. }else{
  439. this.actionbarList.push( new MWF.xApplication.query.ViewDesigner.View.Actionbar( null, this.json.data.actionbarList, this) )
  440. }
  441. }
  442. if( !noSetHeight )this.setContentHeight();
  443. },
  444. setViewWidth: function(){
  445. this.viewAreaNode.setStyle("width", "auto");
  446. this.viewTitleNode.setStyle("width", "auto");
  447. var s1 = this.viewTitleTableNode.getSize();
  448. var s2 = this.refreshNode.getSize();
  449. var s3 = this.addColumnNode.getSize();
  450. var width = s1.x+s2.x+s2.x;
  451. var size = this.areaNode.getSize();
  452. if (width>size.x){
  453. this.viewTitleNode.setStyle("width", ""+width+"px");
  454. this.viewAreaNode.setStyle("width", ""+width+"px");
  455. }else{
  456. this.viewTitleNode.setStyle("width", ""+size.x+"px");
  457. this.viewAreaNode.setStyle("width", ""+size.x+"px");
  458. }
  459. this.setContentColumnWidth();
  460. this.setContentHeight();
  461. },
  462. //setPropertyContent: function(){
  463. // this.designer.propertyIdNode.set("text", this.data.id);
  464. // this.designer.propertyNameNode.set("value", this.data.name);
  465. // this.designer.propertyAliasNode.set("value", this.data.alias);
  466. // this.designer.propertyDescriptionNode.set("value", this.data.description);
  467. //
  468. // this.designer.jsonDomNode.empty();
  469. // MWF.require("MWF.widget.JsonParse", function(){
  470. // this.jsonParse = new MWF.widget.JsonParse(this.data.data, this.designer.jsonDomNode, this.designer.jsonTextAreaNode);
  471. // window.setTimeout(function(){
  472. // this.jsonParse.load();
  473. // }.bind(this), 1);
  474. // }.bind(this));
  475. //},
  476. setAreaNodeSize: function(){
  477. //var size = this.node.getSize();
  478. ////var tabSize = this.tab.tabNodeContainer.getSize();
  479. //var tabSize = this.node.getSize();
  480. //var y = size.y - tabSize.y;
  481. //this.areaNode.setStyle("height", ""+y+"px");
  482. //if (this.editor) if (this.editor.editor) this.editor.editor.resize();
  483. },
  484. // createRootItem: function() {
  485. // this.items.push(new MWF.xApplication.process.DictionaryDesigner.Dictionary.item("ROOT", this.data.data, null, 0, this, true));
  486. // },
  487. saveSilence: function(callback){
  488. if (!this.data.name){
  489. this.designer.notice(this.designer.lp.notice.inputName, "error");
  490. return false;
  491. }
  492. this.designer.actions.saveView(this.data, function(json){
  493. this.data.id = json.data.id;
  494. //this.page.textNode.set("text", this.data.name);
  495. if (this.lisNode) {
  496. this.lisNode.getLast().set("text", this.data.name+"("+this.data.alias+")");
  497. }
  498. if (callback) callback();
  499. }.bind(this));
  500. },
  501. save: function(callback){
  502. //if (this.designer.tab.showPage==this.page){
  503. if (!this.data.name){
  504. this.designer.notice(this.designer.lp.notice.inputName, "error");
  505. return false;
  506. }
  507. //}
  508. this.designer.actions.saveView(this.data, function(json){
  509. this.designer.notice(this.designer.lp.notice.save_success, "success", this.node, {"x": "left", "y": "bottom"});
  510. this.data.id = json.data.id;
  511. //this.page.textNode.set("text", this.data.name);
  512. if (this.lisNode) {
  513. this.lisNode.getLast().set("text", this.data.name+"("+this.data.alias+")");
  514. }
  515. if (callback) callback();
  516. }.bind(this));
  517. },
  518. explode: function(){},
  519. implode: function(){},
  520. _setEditStyle: function(name, input, oldValue){
  521. if (name=="type"){
  522. this.items.each(function(item){
  523. if (item.property){
  524. var processDiv = item.property.propertyContent.getElements("#"+item.json.id+"dataPathSelectedProcessArea");
  525. var cmsDiv = item.property.propertyContent.getElements("#"+item.json.id+"dataPathSelectedCMSArea");
  526. if (this.json[name]=="cms"){
  527. cmsDiv.setStyle("display", "block");
  528. processDiv.setStyle("display", "none");
  529. }else{
  530. cmsDiv.setStyle("display", "none");
  531. processDiv.setStyle("display", "block");
  532. }
  533. }
  534. }.bind(this));
  535. }
  536. if( name=="data.actionbarHidden" ){
  537. if( this.json.data.actionbarHidden ){
  538. this.hideActionbar()
  539. }else{
  540. this.showActionbar()
  541. }
  542. }
  543. if( name=="data.selectAllEnable" ){
  544. if( this.json.data.selectAllEnable ){
  545. this.viewTitleTrNode.getElement(".viewTitleCheckboxTd").setStyle("display","table-cell");
  546. this.viewContentTableNode.getElements(".viewContentCheckboxTd").setStyle("display","table-cell");
  547. }else{
  548. this.viewTitleTrNode.getElement(".viewTitleCheckboxTd").setStyle("display","none");
  549. this.viewContentTableNode.getElements(".viewContentCheckboxTd").setStyle("display","none");
  550. }
  551. }
  552. },
  553. saveAs: function(){
  554. var form = new MWF.xApplication.query.ViewDesigner.View.NewNameForm(this, {
  555. name : this.data.name + "_" + MWF.xApplication.query.ViewDesigner.LP.copy,
  556. query : this.data.query || this.data.application,
  557. queryName : this.data.queryName || this.data.applicationName
  558. }, {
  559. onSave : function( data, callback ){
  560. this._saveAs( data, callback );
  561. }.bind(this)
  562. }, {
  563. app: this.designer
  564. });
  565. form.edit()
  566. },
  567. cloneObject : function( obj ){
  568. if (null == obj || "object" != typeof obj) return obj;
  569. if ( typeof obj.length==='number'){ //数组
  570. //print( "array" );
  571. var copy = [];
  572. for (var i = 0, len = obj.length; i < len; ++i) {
  573. copy[i] = this.cloneObject(obj[i]);
  574. }
  575. return copy;
  576. }else{
  577. var copy = {};
  578. for (var attr in obj) {
  579. copy[attr] = this.cloneObject(obj[attr]);
  580. }
  581. return copy;
  582. }
  583. },
  584. _saveAs : function( data , callback){
  585. var _self = this;
  586. var d = this.cloneObject( this.data );
  587. d.isNewView = true;
  588. d.id = this.designer.actions.getUUID();
  589. d.name = data.name;
  590. d.alias = "";
  591. d.query = data.query;
  592. d.queryName = data.queryName;
  593. d.application = data.query;
  594. d.applicationName = data.queryName;
  595. d.pid = d.id + d.id;
  596. delete d[this.data.id+"viewFilterType"];
  597. d[d.id+"viewFilterType"]="custom";
  598. d.data.selectList.each( function( entry ){
  599. entry.id = (new MWF.widget.UUID).id;
  600. }.bind(this));
  601. this.designer.actions.saveView(d, function(json){
  602. this.designer.notice(this.designer.lp.notice.saveAs_success, "success", this.node, {"x": "left", "y": "bottom"});
  603. if (callback) callback();
  604. }.bind(this));
  605. }
  606. });
  607. MWF.xApplication.query.ViewDesigner.View.Column = new Class({
  608. initialize: function(json, view, next){
  609. this.propertyPath = "/x_component_query_ViewDesigner/$View/column.html";
  610. this.view = view;
  611. this.json = json;
  612. this.next = next;
  613. this.css = this.view.css;
  614. this.content = this.view.viewTitleTrNode;
  615. this.domListNode = this.view.domListNode;
  616. this.load();
  617. },
  618. load: function(){
  619. this.areaNode = new Element("td", {"styles": this.css.viewTitleColumnAreaNode});
  620. this.areaNode.store("column", this);
  621. if (this.next){
  622. this.areaNode.inject(this.next.areaNode, "before");
  623. }else{
  624. this.areaNode.inject(this.content);
  625. }
  626. this.node = new Element("div", {
  627. "styles": this.css.viewTitleColumnNode
  628. }).inject(this.areaNode);
  629. this.textNode = new Element("div", {
  630. "styles": this.css.viewTitleColumnTextNode,
  631. "text": this.json.displayName
  632. }).inject(this.node);
  633. this.createDomListItem();
  634. this._createIconAction();
  635. //if (!this.json.export) this.hideMode();
  636. this.setEvent();
  637. },
  638. createDomListItem: function(){
  639. this.listNode = new Element("div", {"styles": this.css.cloumnListNode});
  640. if (this.next){
  641. this.listNode.inject(this.next.listNode, "before");
  642. }else{
  643. this.listNode.inject(this.domListNode);
  644. }
  645. var listIconNode = new Element("div", {"styles": this.css.cloumnListIconNode}).inject(this.listNode);
  646. var listTextNode = new Element("div", {"styles": this.css.cloumnListTextNode}).inject(this.listNode);
  647. this.resetTextNode();
  648. },
  649. setEvent: function(){
  650. this.node.addEvents({
  651. "click": function(e){this.selected(); e.stopPropagation();}.bind(this),
  652. "mouseover": function(){if (!this.isSelected) this.node.setStyles(this.css.viewTitleColumnNode_over)}.bind(this),
  653. "mouseout": function(){if (!this.isSelected) if (this.isError){
  654. this.node.setStyles(this.css.viewTitleColumnNode_error)
  655. }else{
  656. this.node.setStyles(this.css.viewTitleColumnNode)
  657. }}.bind(this)
  658. });
  659. this.listNode.addEvents({
  660. "click": function(e){this.selected(); e.stopPropagation();}.bind(this),
  661. "mouseover": function(){debugger; if (!this.isSelected) this.listNode.setStyles(this.css.cloumnListNode_over)}.bind(this),
  662. "mouseout": function(){if (!this.isSelected) this.listNode.setStyles(this.css.cloumnListNode)}.bind(this)
  663. });
  664. },
  665. _createIconAction: function(){
  666. if (!this.actionArea){
  667. this.actionArea = new Element("div", {"styles": this.css.actionAreaNode}).inject(this.view.areaNode, "after");
  668. this._createAction({
  669. "name": "move",
  670. "icon": "move1.png",
  671. "event": "mousedown",
  672. "action": "move",
  673. "title": MWF.APPDVD.LP.action.move
  674. });
  675. this._createAction({
  676. "name": "add",
  677. "icon": "add.png",
  678. "event": "click",
  679. "action": "addColumn",
  680. "title": MWF.APPDVD.LP.action.add
  681. });
  682. this._createAction({
  683. "name": "delete",
  684. "icon": "delete1.png",
  685. "event": "click",
  686. "action": "delete",
  687. "title": MWF.APPDVD.LP.action["delete"]
  688. });
  689. }
  690. },
  691. _createAction: function(action){
  692. var actionNode = new Element("div", {
  693. "styles": this.css.actionNodeStyles,
  694. "title": action.title
  695. }).inject(this.actionArea);
  696. actionNode.setStyle("background", "url("+this.view.path+this.view.options.style+"/action/"+action.icon+") no-repeat left center");
  697. actionNode.addEvent(action.event, function(e){
  698. this[action.action](e);
  699. }.bind(this));
  700. actionNode.addEvents({
  701. "mouseover": function(e){
  702. e.target.setStyle("border", "1px solid #999");
  703. }.bind(this),
  704. "mouseout": function(e){
  705. e.target.setStyle("border", "1px solid #F1F1F1");
  706. }.bind(this)
  707. });
  708. },
  709. _setActionAreaPosition: function(){
  710. var p = this.node.getPosition(this.view.areaNode.getOffsetParent());
  711. var y = p.y-25;
  712. var x = p.x;
  713. this.actionArea.setPosition({"x": x, "y": y});
  714. },
  715. _showActions: function(){
  716. if (this.actionArea){
  717. this._setActionAreaPosition();
  718. this.actionArea.setStyle("display", "block");
  719. }
  720. },
  721. _hideActions: function(){
  722. if (this.actionArea) this.actionArea.setStyle("display", "none");
  723. },
  724. selected: function(){
  725. if (this.view.currentSelectedModule){
  726. if (this.view.currentSelectedModule==this){
  727. return true;
  728. }else{
  729. this.view.currentSelectedModule.unSelected();
  730. }
  731. }
  732. this.node.setStyles(this.css.viewTitleColumnNode_selected);
  733. this.listNode.setStyles(this.css.cloumnListNode_selected);
  734. new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 100}).toElementEdge(this.node);
  735. new Fx.Scroll(this.view.designer.propertyDomArea, {"wheelStops": false, "duration": 100}).toElement(this.listNode);
  736. this.view.currentSelectedModule = this;
  737. this.isSelected = true;
  738. this._showActions();
  739. this.showProperty();
  740. },
  741. unSelected: function(){
  742. this.view.currentSelectedModule = null;
  743. //this.node.setStyles(this.css.viewTitleColumnNode);
  744. if (this.isError){
  745. this.node.setStyles(this.css.viewTitleColumnNode_error)
  746. }else{
  747. this.node.setStyles(this.css.viewTitleColumnNode)
  748. }
  749. this.listNode.setStyles(this.css.cloumnListNode);
  750. this.isSelected = false;
  751. this._hideActions();
  752. this.hideProperty();
  753. },
  754. showProperty: function(){
  755. if (!this.property){
  756. this.property = new MWF.xApplication.query.ViewDesigner.Property(this, this.view.designer.propertyContentArea, this.view.designer, {
  757. "path": this.propertyPath,
  758. "onPostLoad": function(){
  759. this.property.show();
  760. var processDiv = this.property.propertyContent.getElements("#"+this.json.id+"dataPathSelectedProcessArea");
  761. var cmsDiv = this.property.propertyContent.getElements("#"+this.json.id+"dataPathSelectedCMSArea");
  762. if (this.view.json.type=="cms"){
  763. processDiv.setStyle("display", "none");
  764. cmsDiv.setStyle("display", "block");
  765. }else{
  766. processDiv.setStyle("display", "block");
  767. cmsDiv.setStyle("display", "none");
  768. }
  769. }.bind(this)
  770. });
  771. this.property.load();
  772. }else{
  773. this.property.show();
  774. }
  775. },
  776. hideProperty: function(){
  777. if (this.property) this.property.hide();
  778. },
  779. _setEditStyle: function(name, input, oldValue){
  780. if (name=="displayName") this.resetTextNode();
  781. if (name=="selectType") this.resetTextNode();
  782. if (name=="attribute") this.resetTextNode();
  783. if (name=="path") this.resetTextNode();
  784. if (name=="column"){
  785. this.view.json.data.orderList.each(function(order){
  786. if (order.column==oldValue) order.column = this.json.column
  787. }.bind(this));
  788. if (this.view.json.data.group.column == oldValue) this.view.json.data.group.column = this.json.column;
  789. }
  790. },
  791. resetTextNode: function(){
  792. var listText = (this.json.selectType=="attribute") ? (this.json.attribute || "") : (this.json.path || "");
  793. if (!listText) listText = "unnamed";
  794. this.textNode.set("text", this.json.displayName);
  795. this.listNode.getLast().set("text", this.json.displayName+"("+listText+")");
  796. },
  797. "delete": function(e){
  798. var _self = this;
  799. if (!e) e = this.node;
  800. this.view.designer.confirm("warn", e, MWF.APPDVD.LP.notice.deleteColumnTitle, MWF.APPDVD.LP.notice.deleteColumn, 300, 120, function(){
  801. _self.destroy();
  802. this.close();
  803. }, function(){
  804. this.close();
  805. }, null);
  806. },
  807. destroy: function(){
  808. if (this.view.currentSelectedModule==this) this.view.currentSelectedModule = null;
  809. if (this.actionArea) this.actionArea.destroy();
  810. if (this.listNode) this.listNode.destroy();
  811. if (this.property) this.property.propertyContent.destroy();
  812. var idx = this.view.items.indexOf(this);
  813. if (this.view.viewContentTableNode){
  814. var trs = this.view.viewContentTableNode.getElements("tr");
  815. trs.each(function(tr){
  816. tr.deleteCell(idx);
  817. }.bind(this));
  818. }
  819. if (this.view.json.data.selectList) this.view.json.data.selectList.erase(this.json);
  820. if (this.view.json.data.calculate) if (this.view.json.data.calculate.calculateList) this.view.json.data.calculate.calculateList.erase(this.json);
  821. this.view.items.erase(this);
  822. if (this.view.property) this.view.property.loadStatColumnSelect();
  823. this.areaNode.destroy();
  824. this.view.selected();
  825. this.view.setViewWidth();
  826. MWF.release(this);
  827. delete this;
  828. },
  829. addColumn: function(e, data){
  830. MWF.require("MWF.widget.UUID", function(){
  831. var json;
  832. if (data){
  833. json = Object.clone(data);
  834. json.id = (new MWF.widget.UUID).id;
  835. json.column = (new MWF.widget.UUID).id;
  836. }else{
  837. var id = (new MWF.widget.UUID).id;
  838. json = {
  839. "id": id,
  840. "column": id,
  841. "displayName": this.view.designer.lp.unnamed,
  842. "orderType": "original"
  843. };
  844. }
  845. var idx = this.view.json.data.selectList.indexOf(this.json);
  846. this.view.json.data.selectList.splice(idx, 0, json);
  847. var column = new MWF.xApplication.query.ViewDesigner.View.Column(json, this.view, this);
  848. this.view.items.splice(idx, 0, column);
  849. column.selected();
  850. if (this.view.viewContentTableNode){
  851. var trs = this.view.viewContentTableNode.getElements("tr");
  852. trs.each(function(tr){
  853. var td = tr.insertCell(idx);
  854. td.setStyles(this.css.viewContentTdNode);
  855. }.bind(this));
  856. }
  857. this.view.setViewWidth();
  858. }.bind(this));
  859. },
  860. move: function(e){
  861. var columnNodes = [];
  862. this.view.items.each(function(item){
  863. if (item!=this){
  864. columnNodes.push(item.areaNode);
  865. }
  866. }.bind(this));
  867. this._createMoveNode();
  868. this._setNodeMove(columnNodes, e);
  869. },
  870. _createMoveNode: function(){
  871. this.moveNode = new Element("div", {"text": this.node.get("text")});
  872. this.moveNode.inject(this.view.designer.content);
  873. this.moveNode.setStyles({
  874. "border": "2px dashed #ffa200",
  875. "opacity": 0.7,
  876. "height": "30px",
  877. "line-height": "30px",
  878. "padding": "0px 10px",
  879. "position": "absolute"
  880. });
  881. },
  882. _setMoveNodePosition: function(e){
  883. var x = e.page.x+2;
  884. var y = e.page.y+2;
  885. this.moveNode.positionTo(x, y);
  886. },
  887. createMoveFlagNode: function(){
  888. this.moveFlagNode = new Element("td", {"styles": this.css.moveFlagNode});
  889. },
  890. _setNodeMove: function(droppables, e){
  891. this._setMoveNodePosition(e);
  892. var movePosition = this.moveNode.getPosition();
  893. var moveSize = this.moveNode.getSize();
  894. var contentPosition = this.content.getPosition();
  895. var contentSize = this.content.getSize();
  896. var nodeDrag = new Drag.Move(this.moveNode, {
  897. "droppables": droppables,
  898. "limit": {
  899. "x": [contentPosition.x, contentPosition.x+contentSize.x],
  900. "y": [movePosition.y, movePosition.y+moveSize.y]
  901. },
  902. "onEnter": function(dragging, inObj){
  903. if (!this.moveFlagNode) this.createMoveFlagNode();
  904. this.moveFlagNode.inject(inObj, "before");
  905. }.bind(this),
  906. "onLeave": function(dragging, inObj){
  907. if (this.moveFlagNode){
  908. this.moveFlagNode.dispose();
  909. }
  910. }.bind(this),
  911. "onDrop": function(dragging, inObj){
  912. if (inObj){
  913. this.areaNode.inject(inObj, "before");
  914. var column = inObj.retrieve("column");
  915. this.listNode.inject(column.listNode, "before");
  916. var idx = this.view.json.data.selectList.indexOf(column.json);
  917. this.view.json.data.selectList.erase(this.json);
  918. this.view.items.erase(this);
  919. this.view.json.data.selectList.splice(idx, 0, this.json);
  920. this.view.items.splice(idx, 0, this);
  921. if (this.moveNode) this.moveNode.destroy();
  922. if (this.moveFlagNode) this.moveFlagNode.destroy();
  923. this._setActionAreaPosition();
  924. }else{
  925. if (this.moveNode) this.moveNode.destroy();
  926. if (this.moveFlagNode) this.moveFlagNode.destroy();
  927. }
  928. }.bind(this),
  929. "onCancel": function(dragging){
  930. if (this.moveNode) this.moveNode.destroy();
  931. if (this.moveFlagNode) this.moveFlagNode.destroy();
  932. }.bind(this)
  933. });
  934. nodeDrag.start(e);
  935. }
  936. //hideMode: function(){
  937. // if (!this.columnHideFlagNode){
  938. // this.columnHideFlagNode = new Element("div", {"styles": this.view.css.columnHideFlagNode}).inject(this.node);
  939. // }
  940. //},
  941. //showMode: function(){
  942. // if (this.columnHideFlagNode) this.columnHideFlagNode.destroy();
  943. // this.columnHideFlagNode = null;
  944. //}
  945. });
  946. MWF.require("MWF.widget.Toolbar", null, false);
  947. MWF.xApplication.query.ViewDesigner.View.Actionbar = new Class({
  948. Implements: [Options, Events],
  949. options : {
  950. "style" : "default",
  951. "customImageStyle" : "default"
  952. },
  953. initialize: function(json, jsonList, view, options){
  954. this.setOptions( options );
  955. this.propertyPath = "/x_component_query_ViewDesigner/$View/actionbar.html";
  956. this.path = "/x_component_query_ViewDesigner/$View/";
  957. this.imagePath_default = "/x_component_query_ViewDesigner/$View/";
  958. this.imagePath_custom = "/x_component_process_FormDesigner/Module/Actionbar/";
  959. this.cssPath = "/x_component_query_ViewDesigner/$View/"+this.options.style+"/actionbar.wcss";
  960. this.view = view;
  961. this.json = json;
  962. this.jsonList = jsonList;
  963. this.css = this.view.css;
  964. this.container = this.view.actionbarNode;
  965. this.load();
  966. },
  967. load: function(){
  968. this.systemTools = [];
  969. this.customTools = [];
  970. if( !this.json ){
  971. this.loadDefaultJson(function(){
  972. this._load()
  973. }.bind(this));
  974. }else{
  975. this._load()
  976. }
  977. },
  978. _load : function(){
  979. this._createNode();
  980. //this._createIconAction();
  981. //if (!this.json.export) this.hideMode();
  982. this.setEvent();
  983. },
  984. loadDefaultJson: function(callback){
  985. var url = this.path+"actionbar.json";
  986. MWF.getJSON(url, {
  987. "onSuccess": function(obj){
  988. this.view.designer.actions.getUUID(function(id){
  989. obj.id=id;
  990. //obj.isNewView = true;
  991. //obj.application = this.view.designer.application.id;
  992. this.json = obj;
  993. this.jsonList.push( this.json );
  994. if (callback) callback(obj);
  995. }.bind(this));
  996. }.bind(this),
  997. "onerror": function(text){
  998. this.view.designer.notice(text, "error");
  999. }.bind(this),
  1000. "onRequestFailure": function(xhr){
  1001. this.view.designer.notice(xhr.responseText, "error");
  1002. }.bind(this)
  1003. });
  1004. },
  1005. setEvent: function(){
  1006. this.node.addEvents({
  1007. "click": function(e){this.selected(); e.stopPropagation();}.bind(this),
  1008. "mouseover": function(){if (!this.isSelected) this.node.setStyles(this.css.toolbarWarpNode_over)}.bind(this),
  1009. "mouseout": function(){if (!this.isSelected) this.node.setStyles(this.css.toolbarWarpNode) }.bind(this)
  1010. });
  1011. },
  1012. //_createIconAction: function(){
  1013. // if (!this.actionArea){
  1014. // this.actionArea = new Element("div", {"styles": this.css.actionAreaNode}).inject(this.container, "after");
  1015. //
  1016. // //this._createAction({
  1017. // // "name": "move",
  1018. // // "icon": "move1.png",
  1019. // // "event": "mousedown",
  1020. // // "action": "move",
  1021. // // "title": MWF.APPDVD.LP.action.move
  1022. // //});
  1023. // //this._createAction({
  1024. // // "name": "add",
  1025. // // "icon": "add.png",
  1026. // // "event": "click",
  1027. // // "action": "addColumn",
  1028. // // "title": MWF.APPDVD.LP.action.add
  1029. // //});
  1030. // this._createAction({
  1031. // "name": "delete",
  1032. // "icon": "delete1.png",
  1033. // "event": "click",
  1034. // "action": "delete",
  1035. // "title": MWF.APPDVD.LP.action["delete"]
  1036. // });
  1037. // }
  1038. //},
  1039. //_createAction: function(action){
  1040. // var actionNode = new Element("div", {
  1041. // "styles": this.css.actionNodeStyles,
  1042. // "title": action.title
  1043. // }).inject(this.actionArea);
  1044. // actionNode.setStyle("background", "url("+this.view.path+this.view.options.style+"/action/"+action.icon+") no-repeat left center");
  1045. // actionNode.addEvent(action.event, function(e){
  1046. // this[action.action](e);
  1047. // }.bind(this));
  1048. // actionNode.addEvents({
  1049. // "mouseover": function(e){
  1050. // e.target.setStyle("border", "1px solid #999");
  1051. // }.bind(this),
  1052. // "mouseout": function(e){
  1053. // e.target.setStyle("border", "1px solid #F1F1F1");
  1054. // }.bind(this)
  1055. // });
  1056. //},
  1057. //_setActionAreaPosition: function(){
  1058. // var p = this.node.getPosition(this.view.areaNode.getOffsetParent());
  1059. // var y = p.y-25;
  1060. // var x = p.x;
  1061. // this.actionArea.setPosition({"x": x, "y": y});
  1062. //},
  1063. //_showActions: function(){
  1064. // if (this.actionArea){
  1065. // this._setActionAreaPosition();
  1066. // this.actionArea.setStyle("display", "block");
  1067. // }
  1068. //},
  1069. //_hideActions: function(){
  1070. // if (this.actionArea) this.actionArea.setStyle("display", "none");
  1071. //},
  1072. selected: function(){
  1073. if (this.view.currentSelectedModule){
  1074. if (this.view.currentSelectedModule==this){
  1075. return true;
  1076. }else{
  1077. this.view.currentSelectedModule.unSelected();
  1078. }
  1079. }
  1080. this.node.setStyles(this.css.toolbarWarpNode_selected);
  1081. //this.listNode.setStyles(this.css.cloumnListNode_selected);
  1082. new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 100}).toElementEdge(this.node);
  1083. //new Fx.Scroll(this.view.designer.propertyDomArea, {"wheelStops": false, "duration": 100}).toElement(this.listNode);
  1084. this.view.currentSelectedModule = this;
  1085. this.isSelected = true;
  1086. //this._showActions();
  1087. this.showProperty();
  1088. },
  1089. unSelected: function(){
  1090. this.view.currentSelectedModule = null;
  1091. this.node.setStyles(this.css.toolbarWarpNode)
  1092. //this.listNode.setStyles(this.css.cloumnListNode);
  1093. this.isSelected = false;
  1094. //this._hideActions();
  1095. this.hideProperty();
  1096. },
  1097. showProperty: function(){
  1098. if (!this.property){
  1099. this.property = new MWF.xApplication.query.ViewDesigner.Property(this, this.view.designer.propertyContentArea, this.view.designer, {
  1100. "path": this.propertyPath,
  1101. "onPostLoad": function(){
  1102. this.property.show();
  1103. //var processDiv = this.property.propertyContent.getElements("#"+this.json.id+"dataPathSelectedProcessArea");
  1104. //var cmsDiv = this.property.propertyContent.getElements("#"+this.json.id+"dataPathSelectedCMSArea");
  1105. //
  1106. //if (this.view.json.type=="cms"){
  1107. // processDiv.setStyle("display", "none");
  1108. // cmsDiv.setStyle("display", "block");
  1109. //}else{
  1110. // processDiv.setStyle("display", "block");
  1111. // cmsDiv.setStyle("display", "none");
  1112. //}
  1113. }.bind(this)
  1114. });
  1115. this.property.load();
  1116. }else{
  1117. this.property.show();
  1118. }
  1119. },
  1120. hideProperty: function(){
  1121. if (this.property) this.property.hide();
  1122. },
  1123. resetTextNode: function(){
  1124. var listText = (this.json.selectType=="attribute") ? (this.json.attribute || "") : (this.json.path || "");
  1125. if (!listText) listText = "unnamed";
  1126. this.textNode.set("text", this.json.displayName);
  1127. this.listNode.getLast().set("text", this.json.displayName+"("+listText+")");
  1128. },
  1129. //"delete": function(e){
  1130. // var _self = this;
  1131. // if (!e) e = this.node;
  1132. // this.view.designer.confirm("warn", e, MWF.APPDVD.LP.notice.deleteColumnTitle, MWF.APPDVD.LP.notice.deleteColumn, 300, 120, function(){
  1133. // _self.destroy();
  1134. //
  1135. // this.close();
  1136. // }, function(){
  1137. // this.close();
  1138. // }, null);
  1139. //},
  1140. //destroy: function(){
  1141. // if (this.view.currentSelectedModule==this) this.view.currentSelectedModule = null;
  1142. // if (this.actionArea) this.actionArea.destroy();
  1143. // if (this.listNode) this.listNode.destroy();
  1144. // if (this.property) this.property.propertyContent.destroy();
  1145. //
  1146. // var idx = this.view.items.indexOf(this);
  1147. //
  1148. // if (this.view.viewContentTableNode){
  1149. // var trs = this.view.viewContentTableNode.getElements("tr");
  1150. // trs.each(function(tr){
  1151. // tr.deleteCell(idx);
  1152. // }.bind(this));
  1153. // }
  1154. //
  1155. // if (this.view.json.data.selectList) this.view.json.data.selectList.erase(this.json);
  1156. // if (this.view.json.data.calculate) if (this.view.json.data.calculate.calculateList) this.view.json.data.calculate.calculateList.erase(this.json);
  1157. // this.view.items.erase(this);
  1158. // if (this.view.property) this.view.property.loadStatColumnSelect();
  1159. //
  1160. // this.areaNode.destroy();
  1161. // this.view.selected();
  1162. //
  1163. // this.view.setViewWidth();
  1164. //
  1165. // MWF.release(this);
  1166. // delete this;
  1167. //},
  1168. //move: function(e){
  1169. // this._createMoveNode();
  1170. //
  1171. // //this._setNodeMove(columnNodes, e);
  1172. //},
  1173. //_createMoveNode: function(){
  1174. // this.moveNode = new Element("div", {"text": this.node.get("text")});
  1175. // this.moveNode.inject(this.view.designer.content);
  1176. // this.moveNode.setStyles({
  1177. // "border": "2px dashed #ffa200",
  1178. // "opacity": 0.7,
  1179. // "height": "30px",
  1180. // "line-height": "30px",
  1181. // "padding": "0px 10px",
  1182. // "position": "absolute"
  1183. // });
  1184. //},
  1185. //_setMoveNodePosition: function(e){
  1186. // var x = e.page.x+2;
  1187. // var y = e.page.y+2;
  1188. // this.moveNode.positionTo(x, y);
  1189. //},
  1190. //createMoveFlagNode: function(){
  1191. // this.moveFlagNode = new Element("td", {"styles": this.css.moveFlagNode});
  1192. //},
  1193. //_setNodeMove: function(droppables, e){
  1194. // this._setMoveNodePosition(e);
  1195. // var movePosition = this.moveNode.getPosition();
  1196. // var moveSize = this.moveNode.getSize();
  1197. // var contentPosition = this.content.getPosition();
  1198. // var contentSize = this.content.getSize();
  1199. //
  1200. // var nodeDrag = new Drag.Move(this.moveNode, {
  1201. // "droppables": droppables,
  1202. // "limit": {
  1203. // "x": [contentPosition.x, contentPosition.x+contentSize.x],
  1204. // "y": [movePosition.y, movePosition.y+moveSize.y]
  1205. // },
  1206. // "onEnter": function(dragging, inObj){
  1207. // if (!this.moveFlagNode) this.createMoveFlagNode();
  1208. // this.moveFlagNode.inject(inObj, "before");
  1209. // }.bind(this),
  1210. // "onLeave": function(dragging, inObj){
  1211. // if (this.moveFlagNode){
  1212. // this.moveFlagNode.dispose();
  1213. // }
  1214. // }.bind(this),
  1215. // "onDrop": function(dragging, inObj){
  1216. // if (inObj){
  1217. // this.areaNode.inject(inObj, "before");
  1218. // var column = inObj.retrieve("column");
  1219. // this.listNode.inject(column.listNode, "before");
  1220. // var idx = this.view.json.data.selectList.indexOf(column.json);
  1221. //
  1222. // this.view.json.data.selectList.erase(this.json);
  1223. // this.view.items.erase(this);
  1224. //
  1225. // this.view.json.data.selectList.splice(idx, 0, this.json);
  1226. // this.view.items.splice(idx, 0, this);
  1227. //
  1228. // if (this.moveNode) this.moveNode.destroy();
  1229. // if (this.moveFlagNode) this.moveFlagNode.destroy();
  1230. // this._setActionAreaPosition();
  1231. // }else{
  1232. // if (this.moveNode) this.moveNode.destroy();
  1233. // if (this.moveFlagNode) this.moveFlagNode.destroy();
  1234. // }
  1235. // }.bind(this),
  1236. // "onCancel": function(dragging){
  1237. // if (this.moveNode) this.moveNode.destroy();
  1238. // if (this.moveFlagNode) this.moveFlagNode.destroy();
  1239. // }.bind(this)
  1240. // });
  1241. // nodeDrag.start(e);
  1242. //},
  1243. deletePropertiesOrStyles: function(name, key){
  1244. if (name=="properties"){
  1245. try{
  1246. this.node.removeProperty(key);
  1247. }catch(e){}
  1248. }
  1249. },
  1250. setPropertiesOrStyles: function(name){
  1251. if (name=="styles"){
  1252. try{
  1253. this.setCustomStyles();
  1254. }catch(e){}
  1255. }
  1256. if (name=="properties"){
  1257. try{
  1258. this.node.setProperties(this.json.properties);
  1259. }catch(e){}
  1260. }
  1261. },
  1262. setCustomNodeStyles: function(node, styles){
  1263. var border = node.getStyle("border");
  1264. node.clearStyles();
  1265. //node.setStyles(styles);
  1266. node.setStyle("border", border);
  1267. Object.each(styles, function(value, key){
  1268. var reg = /^border\w*/ig;
  1269. if (!key.test(reg)){
  1270. node.setStyle(key, value);
  1271. }
  1272. }.bind(this));
  1273. },
  1274. setCustomStyles: function(){
  1275. var border = this.node.getStyle("border");
  1276. this.node.clearStyles();
  1277. this.node.setStyles(this.css.moduleNode);
  1278. if (this.initialStyles) this.node.setStyles(this.initialStyles);
  1279. this.node.setStyle("border", border);
  1280. if (this.json.styles) Object.each(this.json.styles, function(value, key){
  1281. if ((value.indexOf("x_processplatform_assemble_surface")!=-1 || value.indexOf("x_portal_assemble_surface")!=-1)){
  1282. var host1 = MWF.Actions.getHost("x_processplatform_assemble_surface");
  1283. var host2 = MWF.Actions.getHost("x_portal_assemble_surface");
  1284. if (value.indexOf("/x_processplatform_assemble_surface")!==-1){
  1285. value = value.replace("/x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  1286. }else if (value.indexOf("x_processplatform_assemble_surface")!==-1){
  1287. value = value.replace("x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  1288. }
  1289. if (value.indexOf("/x_portal_assemble_surface")!==-1){
  1290. value = value.replace("/x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  1291. }else if (value.indexOf("x_portal_assemble_surface")!==-1){
  1292. value = value.replace("x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  1293. }
  1294. }
  1295. var reg = /^border\w*/ig;
  1296. if (!key.test(reg)){
  1297. if (key){
  1298. if (key.toString().toLowerCase()==="display"){
  1299. if (value.toString().toLowerCase()==="none"){
  1300. this.node.setStyle("opacity", 0.3);
  1301. }else{
  1302. this.node.setStyle("opacity", 1);
  1303. this.node.setStyle(key, value);
  1304. }
  1305. }else{
  1306. this.node.setStyle(key, value);
  1307. }
  1308. }
  1309. }
  1310. //this.node.setStyle(key, value);
  1311. }.bind(this));
  1312. },
  1313. _setEditStyle: function(name, obj, oldValue){
  1314. var title = "";
  1315. var text = "";
  1316. if (name==="name"){
  1317. title = this.json.name || this.json.id;
  1318. text = this.json.type.substr(this.json.type.lastIndexOf("$")+1, this.json.type.length);
  1319. this.treeNode.setText("<"+text+"> "+title);
  1320. }
  1321. if (name==="id"){
  1322. title = this.json.name || this.json.id;
  1323. if (!this.json.name){
  1324. text = this.json.type.substr(this.json.type.lastIndexOf("$")+1, this.json.type.length);
  1325. this.treeNode.setText("<"+text+"> "+this.json.id);
  1326. }
  1327. this.treeNode.setTitle(this.json.id);
  1328. this.node.set("id", this.json.id);
  1329. }
  1330. this._setEditStyle_custom(name, obj, oldValue);
  1331. },
  1332. reloadMaplist: function(){
  1333. if (this.property) Object.each(this.property.maplists, function(map, name){ map.reload(this.json[name]);}.bind(this));
  1334. },
  1335. getHtml: function(){
  1336. var copy = this.node.clone(true, true);
  1337. copy.clearStyles(true);
  1338. var html = copy.outerHTML;
  1339. copy.destroy();
  1340. return html;
  1341. },
  1342. getJson: function(){
  1343. var json = Object.clone(this.json);
  1344. var o = {};
  1345. o[json.id] = json;
  1346. return o;
  1347. },
  1348. _createNode: function(callback){
  1349. this.node = new Element("div", {
  1350. "id": this.json.id,
  1351. "MWFType": "actionbar",
  1352. "styles": this.css.toolbarWarpNode,
  1353. "events": {
  1354. "selectstart": function(e){
  1355. e.preventDefault();
  1356. }
  1357. }
  1358. }).inject(this.container );
  1359. this.toolbarNode = new Element("div").inject(this.node);
  1360. this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {"style": this.json.style}, this);
  1361. if (!this.json.actionStyles){
  1362. this.json.actionStyles = Object.clone(this.toolbarWidget.css);
  1363. }
  1364. //MWF.getJSON(this.path+"toolbars.json", function(json){
  1365. // this.json.defaultTools = json;
  1366. // this.setToolbars(json, this.toolbarNode);
  1367. // debugger;
  1368. // this.toolbarWidget.load();
  1369. //}.bind(this), false);
  1370. if (this.json.defaultTools){
  1371. var json = Array.clone(this.json.defaultTools);
  1372. //if (this.json.tools) json.append(this.json.tools);
  1373. this.setToolbars(json, this.toolbarNode);
  1374. if (this.json.tools){
  1375. this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  1376. }
  1377. this.toolbarWidget.load();
  1378. this._setEditStyle_custom("hideSystemTools");
  1379. //json = null;
  1380. }else{
  1381. MWF.getJSON(this.path+"toolbars.json", function(json){
  1382. this.json.defaultTools = json;
  1383. var json = Array.clone(this.json.defaultTools);
  1384. //if (this.json.tools) json.append(this.json.tools);
  1385. this.setToolbars(json, this.toolbarNode);
  1386. if (this.json.tools){
  1387. this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  1388. }
  1389. this.toolbarWidget.load();
  1390. this._setEditStyle_custom("hideSystemTools");
  1391. //json = null;
  1392. }.bind(this), false);
  1393. }
  1394. },
  1395. _refreshActionbar: function(){
  1396. //if (this.form.options.mode == "Mobile"){
  1397. // this.node.set("text", MWF.APPFD.LP.notice.notUseModuleInMobile+"("+this.moduleName+")");
  1398. // this.node.setStyles({"height": "24px", "line-height": "24px", "background-color": "#999"});
  1399. //}else{
  1400. this.toolbarNode = this.node.getFirst("div");
  1401. this.toolbarNode.empty();
  1402. this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {"style": this.json.style}, this);
  1403. if (!this.json.actionStyles) this.json.actionStyles = Object.clone(this.toolbarWidget.css);
  1404. this.toolbarWidget.css = this.json.actionStyles;
  1405. if (this.json.defaultTools){
  1406. var json = Array.clone(this.json.defaultTools);
  1407. //if (this.json.tools) json.append(this.json.tools);
  1408. this.setToolbars(json, this.toolbarNode);
  1409. if (this.json.tools){
  1410. this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  1411. }
  1412. this.toolbarWidget.load();
  1413. //json = null;
  1414. }else{
  1415. MWF.getJSON(this.path+"toolbars.json", function(json){
  1416. this.json.defaultTools = json;
  1417. var json = Array.clone(this.json.defaultTools);
  1418. //if (this.json.tools) json.append(this.json.tools);
  1419. this.setToolbars(json, this.toolbarNode);
  1420. if (this.json.tools){
  1421. this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  1422. }
  1423. this.toolbarWidget.load();
  1424. //json = null;
  1425. }.bind(this), false);
  1426. }
  1427. //}
  1428. },
  1429. _resetActionbar: function(){
  1430. //if (this.form.options.mode == "Mobile"){
  1431. // this.node.set("text", MWF.APPFD.LP.notice.notUseModuleInMobile+"("+this.moduleName+")");
  1432. // this.node.setStyles({"height": "24px", "line-height": "24px", "background-color": "#999"});
  1433. //}else{
  1434. this.toolbarNode = this.node.getFirst("div");
  1435. this.toolbarNode.empty();
  1436. this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {"style": this.json.style}, this);
  1437. if (!this.json.actionStyles){
  1438. this.json.actionStyles = Object.clone(this.toolbarWidget.css);
  1439. }else{
  1440. this.toolbarWidget.css = Object.merge( Object.clone(this.json.actionStyles), this.toolbarWidget.css );
  1441. this.json.actionStyles = Object.clone(this.toolbarWidget.css);
  1442. }
  1443. if (this.json.defaultTools){
  1444. var json = Array.clone(this.json.defaultTools);
  1445. //if (this.json.tools) json.append(this.json.tools);
  1446. this.setToolbars(json, this.toolbarNode);
  1447. if (this.json.tools){
  1448. this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  1449. }
  1450. this.toolbarWidget.load();
  1451. //json = null;
  1452. }else{
  1453. MWF.getJSON(this.path+"toolbars.json", function(json){
  1454. this.json.defaultTools = json;
  1455. var json = Array.clone(this.json.defaultTools);
  1456. //if (this.json.tools) json.append(this.json.tools);
  1457. this.setToolbars(json, this.toolbarNode);
  1458. if (this.json.tools){
  1459. this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  1460. }
  1461. this.toolbarWidget.load();
  1462. //json = null;
  1463. }.bind(this), false);
  1464. }
  1465. //}
  1466. },
  1467. setToolbars: function(tools, node){
  1468. tools.each(function(tool){
  1469. var actionNode = new Element("div", {
  1470. "MWFnodetype": tool.type,
  1471. "MWFButtonImage": this.imagePath_default+""+this.options.style+"/actionbar/"+tool.img,
  1472. "title": tool.title,
  1473. "MWFButtonAction": tool.action,
  1474. "MWFButtonText": tool.text
  1475. }).inject(node);
  1476. if( this.json.iconOverStyle ){
  1477. actionNode.set("MWFButtonImageOver" , this.imagePath_default+""+this.options.style+"/actionbar/"+this.json.iconOverStyle+"/"+tool.img );
  1478. }
  1479. this.systemTools.push(actionNode);
  1480. if (tool.sub){
  1481. var subNode = node.getLast();
  1482. this.setToolbars(tool.sub, subNode);
  1483. }
  1484. }.bind(this));
  1485. },
  1486. setCustomToolbars: function(tools, node){
  1487. //var style = (this.json.style || "default").indexOf("red") > -1 ? "red" : "blue";
  1488. var path = "";
  1489. if( this.json.customIconStyle ){
  1490. path = this.json.customIconStyle+ "/";
  1491. }
  1492. tools.each(function(tool){
  1493. var actionNode = new Element("div", {
  1494. "MWFnodetype": tool.type,
  1495. "MWFButtonImage": this.imagePath_custom+""+this.options.customImageStyle +"/custom/"+path+tool.img,
  1496. "title": tool.title,
  1497. "MWFButtonAction": tool.action,
  1498. "MWFButtonText": tool.text
  1499. }).inject(node);
  1500. if( this.json.customIconOverStyle ){
  1501. actionNode.set("MWFButtonImageOver" , this.imagePath_custom+""+this.options.customImageStyle +"/custom/"+this.json.customIconOverStyle+ "/" +tool.img );
  1502. }
  1503. this.customTools.push(actionNode);
  1504. if (tool.sub){
  1505. var subNode = node.getLast();
  1506. this.setToolbars(tool.sub, subNode);
  1507. }
  1508. }.bind(this));
  1509. },
  1510. _setEditStyle_custom: function(name){
  1511. if (name=="hideSystemTools"){
  1512. if (this.json.hideSystemTools){
  1513. this.systemTools.each(function(tool){
  1514. tool.setStyle("display", "none");
  1515. });
  1516. }else{
  1517. this.systemTools.each(function(tool){
  1518. tool.setStyle("display", "block");
  1519. });
  1520. }
  1521. }
  1522. if (name=="defaultTools" || name=="tools" || name==="actionStyles"){
  1523. this._refreshActionbar();
  1524. }
  1525. }
  1526. });