View.js 81 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988
  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.loadTemplateStyle( function () {
  105. this.loadActionbar();
  106. this.loadView();
  107. this.loadPaging();
  108. this.selected();
  109. this.setEvent();
  110. //if (this.options.showTab) this.page.showTabIm();
  111. this.setViewWidth();
  112. this.designer.addEvent("resize", this.setViewWidth.bind(this));
  113. }.bind(this))
  114. },
  115. setEvent: function(){
  116. this.areaNode.addEvent("click", this.selected.bind(this));
  117. this.refreshNode.addEvent("click", function(e){
  118. this.loadViewData();
  119. e.stopPropagation();
  120. }.bind(this));
  121. this.addColumnNode.addEvent("click", function(e){
  122. this.addColumn();
  123. e.stopPropagation();
  124. }.bind(this));
  125. },
  126. loadViewData: function(){
  127. if (this.data.id){
  128. this.saveSilence(function(){
  129. this.viewContentBodyNode.empty();
  130. this.viewContentTableNode = new Element("table", {
  131. "styles": this.css.viewContentTableNode,
  132. "border": "0px",
  133. "cellPadding": "0",
  134. "cellSpacing": "0"
  135. }).inject(this.viewContentBodyNode);
  136. this.designer.actions.loadView(this.data.id, null,function(json){
  137. var entries = {};
  138. json.data.selectList.each(function(entry){entries[entry.column] = entry;}.bind(this));
  139. if (this.json.data.group.column){
  140. if (json.data.groupGrid.length){
  141. var groupColumn = null;
  142. for (var c = 0; c<json.data.selectList.length; c++){
  143. if (json.data.selectList[c].column === json.data.group.column){
  144. groupColumn = json.data.selectList[c];
  145. break;
  146. }
  147. }
  148. json.data.groupGrid.each(function(line, idx){
  149. var groupTr = new Element("tr", {"styles": this.css.viewContentTrNode}).inject(this.viewContentTableNode);
  150. var colSpan = this.items.length ;
  151. var td = new Element("td", {"styles": this.css.viewContentGroupTdNode, "colSpan": colSpan}).inject(groupTr);
  152. var groupAreaNode = new Element("div", {"styles": this.css.viewContentTdGroupNode}).inject(td);
  153. var groupIconNode = new Element("div", {"styles": this.css.viewContentTdGroupIconNode}).inject(groupAreaNode);
  154. var groupTextNode = new Element("div", {"styles": this.css.viewContentTdGroupTextNode}).inject(groupAreaNode);
  155. if (groupColumn){
  156. //groupTextNode.set("text", (groupColumn.code) ? MWF.Macro.exec(groupColumn.code, {"value": line.group, "gridData": json.data.groupGrid, "data": json.data, "entry": line}) : line.group);
  157. groupTextNode.set("text", line.group);
  158. }else{
  159. groupTextNode.set("text", line.group);
  160. }
  161. var subtrs = [];
  162. line.list.each(function(entry){
  163. var tr = new Element("tr", {"styles": this.css.viewContentTrNode}).inject(this.viewContentTableNode);
  164. tr.setStyle("display", "none");
  165. //this.createViewCheckboxTd( tr );
  166. var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr);
  167. Object.each(entries, function(c, k){
  168. var d = entry.data[k];
  169. if (d!=undefined){
  170. if (k!=this.json.data.group.column){
  171. var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr);
  172. //td.set("text", (entries[k].code) ? MWF.Macro.exec(entries[k].code, {"value": d, "gridData": json.data.groupGrid, "data": json.data, "entry": entry}) : d);
  173. if (c.isHtml){
  174. td.set("html", d);
  175. }else{
  176. td.set("text", d);
  177. }
  178. }
  179. }
  180. }.bind(this));
  181. // Object.each(entry.data, function(d, k){
  182. // if (k!=this.json.data.group.column){
  183. // var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr);
  184. // td.set("text", (entries[k].code) ? MWF.Macro.exec(entries[k].code, {"value": d, "gridData": json.data.groupGrid, "data": json.data, "entry": entry}) : d);
  185. // }
  186. // }.bind(this));
  187. subtrs.push(tr)
  188. }.bind(this));
  189. groupAreaNode.store("subtrs", subtrs);
  190. var _self = this;
  191. groupAreaNode.addEvent("click", function(){
  192. var subtrs = this.retrieve("subtrs");
  193. var iconNode = groupAreaNode.getFirst("div");
  194. if (subtrs[0]){
  195. if (subtrs[0].getStyle("display")=="none"){
  196. subtrs.each(function(subtr){ subtr.setStyle("display", "table-row"); });
  197. iconNode.setStyle("background", "url("+"/x_component_process_ViewDesigner/$View/default/icon/down.png) center center no-repeat");
  198. }else{
  199. subtrs.each(function(subtr){ subtr.setStyle("display", "none"); });
  200. iconNode.setStyle("background", "url("+"/x_component_process_ViewDesigner/$View/default/icon/right.png) center center no-repeat");
  201. }
  202. }
  203. _self.setContentHeight();
  204. });
  205. }.bind(this));
  206. this.setContentColumnWidth();
  207. this.setContentHeight();
  208. }
  209. }else{
  210. if (json.data.grid.length){
  211. json.data.grid.each(function(line, idx){
  212. var tr = new Element("tr", {"styles": this.css.viewContentTrNode}).inject(this.viewContentTableNode);
  213. //this.createViewCheckboxTd( tr );
  214. Object.each(entries, function(c, k){
  215. var d = line.data[k];
  216. if (d!=undefined){
  217. var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr);
  218. //td.set("text", (entries[k].code) ? MWF.Macro.exec(entries[k].code, {"value": d, "gridData": json.data.grid, "data": json.data, "entry": line}) : d);
  219. if (c.isHtml){
  220. td.set("html", d);
  221. }else{
  222. td.set("text", d);
  223. }
  224. //td.set("text", d);
  225. }
  226. }.bind(this));
  227. // Object.each(line.data, function(d, k){
  228. // var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr);
  229. // td.set("text", (entries[k].code) ? MWF.Macro.exec(entries[k].code, {"value": d, "gridData": json.data.grid, "data": json.data, "entry": line}) : d);
  230. // }.bind(this));
  231. }.bind(this));
  232. this.setContentColumnWidth();
  233. this.setContentHeight();
  234. }
  235. }
  236. }.bind(this));
  237. //this.getLookupAction(function(){
  238. // this.lookupAction.invoke({"name": "lookup","async": true, "parameter": {"id": this.data.id},"success": function(json){
  239. // if (json.data.length){
  240. // json.data.each(function(line, idx){
  241. // var tr = new Element("tr", {"styles": this.css.viewContentTrNode}).inject(this.viewContentTableNode);
  242. // line.each(function(cell, i){
  243. // var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr);
  244. // td.set("text", cell);
  245. // }.bind(this));
  246. // }.bind(this));
  247. // this.setContentColumnWidth();
  248. // this.setContentHeight();
  249. // }
  250. // }.bind(this)});
  251. //}.bind(this));
  252. }.bind(this));
  253. }
  254. },
  255. setContentColumnWidth: function(){
  256. var titleTds = this.viewTitleTrNode.getElements("td");
  257. var widthList = [];
  258. titleTds.each(function(td){widthList.push(td.getSize().x);});
  259. var flag = false;
  260. if (this.viewContentTableNode){
  261. trs = this.viewContentTableNode.getElements("tr");
  262. for (var i=0; i<trs.length; i++){
  263. var tr = trs[i];
  264. var tds = tr.getElements("td");
  265. tds.each(function(contentTd, i){
  266. if (contentTd.get("colSpan")==1){
  267. contentTd.setStyle("width", ""+widthList[i]+"px");
  268. flag = true;
  269. }
  270. });
  271. if (flag) break;
  272. }
  273. //var tr = this.viewContentTableNode.getFirst("tr");
  274. //if (tr){
  275. // var tds = tr.getElements("td");
  276. // tds.each(function(contentTd, i){
  277. // if (!contentTd.get("colSpan")){
  278. // contentTd.setStyle("width", ""+widthList[i]+"px");
  279. // }
  280. // });
  281. //}
  282. }
  283. },
  284. //getLookupAction: function(callback){
  285. // if (!this.lookupAction){
  286. // MWF.require("MWF.xDesktop.Actions.RestActions", function(){
  287. // this.lookupAction = new MWF.xDesktop.Actions.RestActions("", "x_processplatform_assemble_surface_lookup", "");
  288. // this.lookupAction.getActions = function(actionCallback){
  289. //
  290. // this.actions = {"lookup": {"uri": "/jaxrs/view/{id}"}};
  291. // if (actionCallback) actionCallback();
  292. // }
  293. // if (callback) callback();
  294. // }.bind(this));
  295. // }else{
  296. // if (callback) callback();
  297. // }
  298. //},
  299. addColumn: function(){
  300. MWF.require("MWF.widget.UUID", function(){
  301. var id = (new MWF.widget.UUID).id;
  302. var json = {
  303. "id": id,
  304. "column": id,
  305. "displayName": this.designer.lp.unnamed,
  306. "orderType": "original"
  307. };
  308. if (!this.json.data.selectList) this.json.data.selectList = [];
  309. this.json.data.selectList.push(json);
  310. var column = new MWF.xApplication.query.ViewDesigner.View.Column(json, this);
  311. this.items.push(column);
  312. column.selected();
  313. if (this.viewContentTableNode){
  314. var trs = this.viewContentTableNode.getElements("tr");
  315. trs.each(function(tr){
  316. new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr)
  317. }.bind(this));
  318. //this.setContentColumnWidth();
  319. }
  320. this.setViewWidth();
  321. this.addColumnNode.scrollIntoView(true);
  322. }.bind(this));
  323. //new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 0}).toRight();
  324. },
  325. selected: function(){
  326. if (this.currentSelectedModule){
  327. if (this.currentSelectedModule==this){
  328. return true;
  329. }else{
  330. this.currentSelectedModule.unSelected();
  331. }
  332. }
  333. this.currentSelectedModule = this;
  334. this.showProperty();
  335. },
  336. unSelected: function(){
  337. this.currentSelectedModule = null;
  338. this.hideProperty();
  339. },
  340. loadViewNodes: function(){
  341. this.viewAreaNode = new Element("div#viewAreaNode", {"styles": this.css.viewAreaNode}).inject(this.areaNode);
  342. this.viewTitleNode = new Element("div#viewTitleNode", {"styles": this.css.viewTitleNode}).inject(this.viewAreaNode);
  343. this.refreshNode = new Element("div", {"styles": this.css.refreshNode}).inject(this.viewTitleNode);
  344. this.addColumnNode = new Element("div", {"styles": this.css.addColumnNode}).inject(this.viewTitleNode);
  345. this.viewTitleContentNode = new Element("div", {"styles": this.css.viewTitleContentNode}).inject(this.viewTitleNode);
  346. this.viewTitleTableNode = new Element("table", {
  347. "styles": this.css.viewTitleTableNode,
  348. "border": "0px",
  349. "cellPadding": "0",
  350. "cellSpacing": "0"
  351. }).inject(this.viewTitleContentNode);
  352. this.viewTitleTrNode = new Element("tr", {"styles": this.css.viewTitleTrNode}).inject(this.viewTitleTableNode);
  353. this.viewContentScrollNode = new Element("div", {"styles": this.css.viewContentScrollNode}).inject(this.viewAreaNode);
  354. this.viewContentNode = new Element("div", {"styles": this.css.viewContentNode}).inject(this.viewContentScrollNode);
  355. MWF.require("MWF.widget.ScrollBar", function(){
  356. new MWF.widget.ScrollBar(this.viewContentScrollNode, {"style": "view", "distance": 100, "indent": false});
  357. }.bind(this));
  358. this.contentLeftNode = new Element("div", {"styles": this.css.contentLeftNode}).inject(this.viewContentNode);
  359. this.contentRightNode = new Element("div", {"styles": this.css.contentRightNode}).inject(this.viewContentNode);
  360. this.viewContentBodyNode = new Element("div", {"styles": this.css.viewContentBodyNode}).inject(this.viewContentNode);
  361. this.viewContentTableNode = new Element("table", {
  362. "styles": this.css.viewContentTableNode,
  363. "border": "0px",
  364. "cellPadding": "0",
  365. "cellSpacing": "0"
  366. }).inject(this.viewContentBodyNode);
  367. },
  368. setContentHeight: function(){
  369. var size = this.areaNode.getSize();
  370. var titleSize = this.viewTitleNode.getSize();
  371. var actionbarSize = this.actionbarNode ? this.actionbarNode.getSize() : {x:0, y:0};
  372. var pagingSize = this.pagingNode ? this.pagingNode.getSize() : {x:0, y:0};
  373. var height = size.y-titleSize.y-actionbarSize.y-pagingSize.y-2;
  374. this.viewContentScrollNode.setStyle("height", height);
  375. var contentSize = this.viewContentBodyNode.getSize();
  376. if (height<contentSize.y) height = contentSize.y+10;
  377. this.viewContentNode.setStyle("height", height);
  378. this.contentLeftNode.setStyle("height", height);
  379. this.contentRightNode.setStyle("height", height);
  380. //this.viewContentBodyNode.setStyle("min-height", height);
  381. },
  382. loadViewColumns: function(){
  383. // for (var i=0; i<10; i++){
  384. if (this.json.data.selectList) {
  385. this.json.data.selectList.each(function (json) {
  386. this.items.push(new MWF.xApplication.query.ViewDesigner.View.Column(json, this));
  387. }.bind(this));
  388. }
  389. // }
  390. },
  391. loadViewSelectAllNode : function(){
  392. var _self = this;
  393. var td = new Element("td.viewTitleCheckboxTd",{ "styles": this.css.viewTitleColumnAreaNode }).inject( this.viewTitleTrNode );
  394. td.setStyles({
  395. "width":"30px", "text-align" : "center",
  396. "display" : this.json.data.selectAllEnable ? "table-cell" : "none"
  397. });
  398. new Element("input",{
  399. "type" : "checkbox",
  400. "events" : {
  401. "change" : function(){
  402. _self.viewContentTableNode.getElements(".viewContentCheckbox").set("checked", this.checked )
  403. }
  404. }
  405. }).inject(td);
  406. },
  407. createViewCheckboxTd : function( tr ){
  408. var td = new Element("td.viewContentCheckboxTd", {"styles": this.css.viewContentTdNode}).inject(tr, "top");
  409. td.setStyles({
  410. "width":"30px", "text-align" : "center",
  411. "display" : this.json.data.selectAllEnable ? "table-cell" : "none"
  412. });
  413. new Element("input.viewContentCheckbox",{
  414. "type" : "checkbox"
  415. }).inject(td);
  416. },
  417. loadView: function(){
  418. this.loadViewNodes();
  419. //this.loadViewSelectAllNode();
  420. this.loadViewColumns();
  421. // this.addTopItemNode.addEvent("click", this.addTopItem.bind(this));
  422. },
  423. loadActionbar: function(){
  424. this.actionbarNode = new Element("div#actionbarNode", {"styles": this.css.actionbarNode}).inject(this.areaNode);
  425. this.actionbarList = [];
  426. if( !this.json.data.actionbarHidden ){
  427. this.showActionbar( true );
  428. }
  429. },
  430. hideActionbar : function(){
  431. this.actionbarNode.hide();
  432. this.setContentHeight();
  433. },
  434. showActionbar : function( noSetHeight ){
  435. this.actionbarNode.show();
  436. if( !this.json.data.actionbarList )this.json.data.actionbarList = [];
  437. if( !this.actionbarList || this.actionbarList.length == 0 ){
  438. if( this.json.data.actionbarList.length ){
  439. this.json.data.actionbarList.each( function(json){
  440. this.actionbarList.push( new MWF.xApplication.query.ViewDesigner.View.Actionbar( json, this.json.data.actionbarList, this) )
  441. }.bind(this));
  442. }else{
  443. this.actionbarList.push( new MWF.xApplication.query.ViewDesigner.View.Actionbar( null, this.json.data.actionbarList, this) )
  444. }
  445. }
  446. if( !noSetHeight )this.setContentHeight();
  447. },
  448. loadPaging: function( noSetHeight ){
  449. this.pagingNode = new Element("div#pagingNode", {"styles": this.css.pagingNode}).inject(this.areaNode);
  450. this.pagingList = [];
  451. if( !this.json.data.pagingList )this.json.data.pagingList = [];
  452. if( !this.pagingList || this.pagingList.length == 0 ){
  453. if( this.json.data.pagingList.length ){
  454. this.json.data.pagingList.each( function(json){
  455. this.pagingList.push( new MWF.xApplication.query.ViewDesigner.View.Paging( json, this.json.data.pagingList, this) )
  456. }.bind(this));
  457. }else{
  458. this.pagingList.push( new MWF.xApplication.query.ViewDesigner.View.Paging( null, this.json.data.pagingList, this) )
  459. }
  460. }
  461. // if( !noSetHeight )this.setContentHeight();
  462. },
  463. setViewWidth: function(){
  464. if( !this.viewAreaNode )return;
  465. this.viewAreaNode.setStyle("width", "auto");
  466. this.viewTitleNode.setStyle("width", "auto");
  467. var s1 = this.viewTitleTableNode.getSize();
  468. var s2 = this.refreshNode.getSize();
  469. var s3 = this.addColumnNode.getSize();
  470. var width = s1.x+s2.x+s2.x;
  471. var size = this.areaNode.getSize();
  472. if (width>size.x){
  473. this.viewTitleNode.setStyle("width", ""+width+"px");
  474. this.viewAreaNode.setStyle("width", ""+width+"px");
  475. }else{
  476. this.viewTitleNode.setStyle("width", ""+size.x+"px");
  477. this.viewAreaNode.setStyle("width", ""+size.x+"px");
  478. }
  479. this.setContentColumnWidth();
  480. this.setContentHeight();
  481. },
  482. //setPropertyContent: function(){
  483. // this.designer.propertyIdNode.set("text", this.data.id);
  484. // this.designer.propertyNameNode.set("value", this.data.name);
  485. // this.designer.propertyAliasNode.set("value", this.data.alias);
  486. // this.designer.propertyDescriptionNode.set("value", this.data.description);
  487. //
  488. // this.designer.jsonDomNode.empty();
  489. // MWF.require("MWF.widget.JsonParse", function(){
  490. // this.jsonParse = new MWF.widget.JsonParse(this.data.data, this.designer.jsonDomNode, this.designer.jsonTextAreaNode);
  491. // window.setTimeout(function(){
  492. // this.jsonParse.load();
  493. // }.bind(this), 1);
  494. // }.bind(this));
  495. //},
  496. setAreaNodeSize: function(){
  497. //var size = this.node.getSize();
  498. ////var tabSize = this.tab.tabNodeContainer.getSize();
  499. //var tabSize = this.node.getSize();
  500. //var y = size.y - tabSize.y;
  501. //this.areaNode.setStyle("height", ""+y+"px");
  502. //if (this.editor) if (this.editor.editor) this.editor.editor.resize();
  503. },
  504. // createRootItem: function() {
  505. // this.items.push(new MWF.xApplication.process.DictionaryDesigner.Dictionary.item("ROOT", this.data.data, null, 0, this, true));
  506. // },
  507. saveSilence: function(callback){
  508. if (!this.data.name){
  509. this.designer.notice(this.designer.lp.notice.inputName, "error");
  510. return false;
  511. }
  512. this.designer.actions.saveView(this.data, function(json){
  513. this.data.id = json.data.id;
  514. //this.page.textNode.set("text", this.data.name);
  515. if (this.lisNode) {
  516. this.lisNode.getLast().set("text", this.data.name+"("+this.data.alias+")");
  517. }
  518. if (callback) callback();
  519. }.bind(this));
  520. },
  521. save: function(callback){
  522. //if (this.designer.tab.showPage==this.page){
  523. if (!this.data.name){
  524. this.designer.notice(this.designer.lp.notice.inputName, "error");
  525. return false;
  526. }
  527. //}
  528. this.designer.actions.saveView(this.data, function(json){
  529. this.designer.notice(this.designer.lp.notice.save_success, "success", this.node, {"x": "left", "y": "bottom"});
  530. this.data.id = json.data.id;
  531. //this.page.textNode.set("text", this.data.name);
  532. if (this.lisNode) {
  533. this.lisNode.getLast().set("text", this.data.name+"("+this.data.alias+")");
  534. }
  535. if (callback) callback();
  536. }.bind(this));
  537. },
  538. explode: function(){},
  539. implode: function(){},
  540. _setEditStyle: function(name, input, oldValue){
  541. if (name=="type"){
  542. this.items.each(function(item){
  543. if (item.property){
  544. var processDiv = item.property.propertyContent.getElements("#"+item.json.id+"dataPathSelectedProcessArea");
  545. var cmsDiv = item.property.propertyContent.getElements("#"+item.json.id+"dataPathSelectedCMSArea");
  546. if (this.json[name]=="cms"){
  547. cmsDiv.setStyle("display", "block");
  548. processDiv.setStyle("display", "none");
  549. }else{
  550. cmsDiv.setStyle("display", "none");
  551. processDiv.setStyle("display", "block");
  552. }
  553. }
  554. }.bind(this));
  555. }
  556. if( name=="data.actionbarHidden" ){
  557. if( this.json.data.actionbarHidden ){
  558. this.hideActionbar()
  559. }else{
  560. this.showActionbar()
  561. }
  562. }
  563. if( name=="data.selectAllEnable" ){
  564. if( this.json.data.selectAllEnable ){
  565. this.viewTitleTrNode.getElement(".viewTitleCheckboxTd").setStyle("display","table-cell");
  566. this.viewContentTableNode.getElements(".viewContentCheckboxTd").setStyle("display","table-cell");
  567. }else{
  568. this.viewTitleTrNode.getElement(".viewTitleCheckboxTd").setStyle("display","none");
  569. this.viewContentTableNode.getElements(".viewContentCheckboxTd").setStyle("display","none");
  570. }
  571. }
  572. if (name=="data.viewStyleType"){
  573. debugger;
  574. var file = (this.stylesList && this.json.data.viewStyleType) ? this.stylesList[this.json.data.viewStyleType].file : null;
  575. var extendFile = (this.stylesList && this.json.data.viewStyleType) ? this.stylesList[this.json.data.viewStyleType].extendFile : null;
  576. this.loadTemplateStyles( file, extendFile, function( templateStyles ){
  577. this.templateStyles = templateStyles;
  578. var oldFile, oldExtendFile;
  579. if( oldValue && this.stylesList[oldValue] ){
  580. oldFile = this.stylesList[oldValue].file;
  581. oldExtendFile = this.stylesList[oldValue].extendFile;
  582. }
  583. this.loadTemplateStyles( oldFile, oldExtendFile, function( oldTemplateStyles ){
  584. this.json.data.styleConfig = (this.stylesList && this.json.data.viewStyleType) ? this.stylesList[this.json.data.viewStyleType] : null;
  585. if (oldTemplateStyles["table"]) this.clearTemplateStyles(oldTemplateStyles["table"]);
  586. if (this.templateStyles["table"]) this.setTemplateStyles(this.templateStyles["table"]);
  587. this.setAllStyles();
  588. this.actionbarList.each( function (module) {
  589. if (oldTemplateStyles["actionbar"]){
  590. module.clearTemplateStyles(oldTemplateStyles["actionbar"]);
  591. }
  592. module.setStyleTemplate();
  593. module.setAllStyles();
  594. })
  595. this.pagingList.each( function (module) {
  596. if (oldTemplateStyles["paging"]){
  597. module.clearTemplateStyles(oldTemplateStyles["paging"]);
  598. }
  599. module.setStyleTemplate();
  600. module.setAllStyles();
  601. });
  602. // this.moduleList.each(function(module){
  603. // if (oldTemplateStyles[module.moduleName]){
  604. // module.clearTemplateStyles(oldTemplateStyles[module.moduleName]);
  605. // }
  606. // module.setStyleTemplate();
  607. // module.setAllStyles();
  608. // }.bind(this));
  609. }.bind(this))
  610. }.bind(this))
  611. }
  612. },
  613. setAllStyles: function(){
  614. this.setPropertiesOrStyles("styles");
  615. this.setPropertiesOrStyles("properties");
  616. this.reloadMaplist();
  617. },
  618. reloadMaplist: function(){
  619. if (this.property) Object.each(this.property.maplists, function(map, name){ map.reload(this.json[name]);}.bind(this));
  620. },
  621. setPropertiesOrStyles: function(name){
  622. if (name=="styles"){
  623. this.setCustomStyles();
  624. }
  625. if (name=="properties"){
  626. this.node.setProperties(this.json.properties);
  627. }
  628. },
  629. setCustomStyles: function(){
  630. // var border = this.node.getStyle("border");
  631. // this.node.clearStyles();
  632. // this.node.setStyles((this.options.mode==="Mobile") ? this.css.formMobileNode : this.css.formNode);
  633. // var y = this.container.getStyle("height");
  634. // y = (y) ? y.toInt()-2 : this.container.getSize().y-2;
  635. // this.node.setStyle("min-height", ""+y+"px");
  636. //
  637. // if (this.initialStyles) this.node.setStyles(this.initialStyles);
  638. // this.node.setStyle("border", border);
  639. //
  640. // Object.each(this.json.styles, function(value, key){
  641. // var reg = /^border\w*/ig;
  642. // if (!key.test(reg)){
  643. // this.node.setStyle(key, value);
  644. // }
  645. // }.bind(this));
  646. },
  647. saveAs: function(){
  648. var form = new MWF.xApplication.query.ViewDesigner.View.NewNameForm(this, {
  649. name : this.data.name + "_" + MWF.xApplication.query.ViewDesigner.LP.copy,
  650. query : this.data.query || this.data.application,
  651. queryName : this.data.queryName || this.data.applicationName
  652. }, {
  653. onSave : function( data, callback ){
  654. this._saveAs( data, callback );
  655. }.bind(this)
  656. }, {
  657. app: this.designer
  658. });
  659. form.edit()
  660. },
  661. cloneObject : function( obj ){
  662. if (null == obj || "object" != typeof obj) return obj;
  663. if ( typeof obj.length==='number'){ //数组
  664. //print( "array" );
  665. var copy = [];
  666. for (var i = 0, len = obj.length; i < len; ++i) {
  667. copy[i] = this.cloneObject(obj[i]);
  668. }
  669. return copy;
  670. }else{
  671. var copy = {};
  672. for (var attr in obj) {
  673. copy[attr] = this.cloneObject(obj[attr]);
  674. }
  675. return copy;
  676. }
  677. },
  678. _saveAs : function( data , callback){
  679. var _self = this;
  680. var d = this.cloneObject( this.data );
  681. d.isNewView = true;
  682. d.id = this.designer.actions.getUUID();
  683. d.name = data.name;
  684. d.alias = "";
  685. d.query = data.query;
  686. d.queryName = data.queryName;
  687. d.application = data.query;
  688. d.applicationName = data.queryName;
  689. d.pid = d.id + d.id;
  690. delete d[this.data.id+"viewFilterType"];
  691. d[d.id+"viewFilterType"]="custom";
  692. d.data.selectList.each( function( entry ){
  693. entry.id = (new MWF.widget.UUID).id;
  694. }.bind(this));
  695. this.designer.actions.saveView(d, function(json){
  696. this.designer.notice(this.designer.lp.notice.saveAs_success, "success", this.node, {"x": "left", "y": "bottom"});
  697. if (callback) callback();
  698. }.bind(this));
  699. },
  700. loadTemplateStyle : function( callback ){
  701. this.loadStylesList(function(){
  702. var oldStyleValue = "";
  703. if ((!this.json.data.viewStyleType) || !this.stylesList[this.json.data.viewStyleType]) this.json.data.viewStyleType="default";
  704. // if (this.options.mode=="Mobile"){
  705. // if (this.json.viewStyleType != "defaultMobile"){
  706. // var styles = this.stylesList[this.json.viewStyleType];
  707. // if( !styles || typeOf(styles.mode)!=="array" || !styles.mode.contains( "mobile" ) ){
  708. // oldStyleValue = this.json.viewStyleType;
  709. // this.json.viewStyleType = "defaultMobile";
  710. // }
  711. // }
  712. // }
  713. this.loadTemplateStyles( this.stylesList[this.json.data.viewStyleType].file, this.stylesList[this.json.data.viewStyleType].extendFile,
  714. function( templateStyles ){
  715. this.templateStyles = templateStyles;
  716. // this.loadDomModules();
  717. if (this.json.data.viewStyleType && this.templateStyles && this.templateStyles["table"]){
  718. this.setTemplateStyles(this.templateStyles["table"]);
  719. }
  720. this.setCustomStyles();
  721. this.node.setProperties(this.json.data.properties);
  722. if(callback)callback();
  723. // this.setNodeEvents();
  724. // if (this.options.mode=="Mobile"){
  725. // if (oldStyleValue) this._setEditStyle("viewStyleType", null, oldStyleValue);
  726. // }
  727. }.bind(this)
  728. );
  729. }.bind(this));
  730. },
  731. removeStyles: function(from, to){
  732. if (this.json.data[to]){
  733. Object.each(from, function(style, key){
  734. if (this.json.data[to][key] && this.json.data[to][key]==style){
  735. delete this.json.data[to][key];
  736. }
  737. }.bind(this));
  738. }
  739. },
  740. copyStyles: function(from, to){
  741. if (!this.json.data[to]) this.json.data[to] = {};
  742. Object.each(from, function(style, key){
  743. if (!this.json.data[to][key]) this.json.data[to][key] = style;
  744. }.bind(this));
  745. },
  746. clearTemplateStyles: function(styles){
  747. if (styles){
  748. if (styles.styles) this.removeStyles(styles.styles, "styles");
  749. if (styles.properties) this.removeStyles(styles.properties, "properties");
  750. }
  751. },
  752. setTemplateStyles: function(styles){
  753. if (styles.styles) this.copyStyles(styles.styles, "styles");
  754. if (styles.properties) this.copyStyles(styles.properties, "properties");
  755. },
  756. loadTemplateStyles : function( file, extendFile, callback ){
  757. if( !file ){
  758. if (callback) callback({});
  759. return;
  760. }
  761. this.templateStylesList = this.templateStylesList || {};
  762. if( this.templateStylesList[file] ){
  763. if (callback) callback(this.templateStylesList[file]);
  764. return;
  765. }
  766. this.loadTemplateStyleFile( file, function( json_file ){
  767. this.loadTemplateExtendStyleFile( extendFile, function( json_extend ){
  768. this.templateStylesList[file] = Object.merge( json_file, json_extend );
  769. if (callback) callback(this.templateStylesList[file]);
  770. }.bind(this))
  771. }.bind(this))
  772. },
  773. loadTemplateStyleFile : function(file, callback ){
  774. if( !file ){
  775. if (callback) callback({});
  776. return;
  777. }
  778. var stylesUrl = "/x_component_query_ViewDesigner/$View/skin/"+file;
  779. MWF.getJSON(stylesUrl,{
  780. "onSuccess": function(responseJSON){
  781. //this.templateStylesList[file] = responseJSON;
  782. if (callback) callback(responseJSON);
  783. }.bind(this),
  784. "onRequestFailure": function(){
  785. if (callback) callback({});
  786. }.bind(this),
  787. "onError": function(){
  788. if (callback) callback({});
  789. }.bind(this)
  790. }
  791. );
  792. },
  793. loadTemplateExtendStyleFile : function(extendFile, callback ){
  794. if( !extendFile ){
  795. if (callback) callback({});
  796. return;
  797. }
  798. var stylesUrl = "/x_component_query_ViewDesigner/$View/skin/"+extendFile;
  799. MWF.getJSON(stylesUrl,{
  800. "onSuccess": function(responseJSON){
  801. //this.templateStylesList[file] = responseJSON;
  802. if (callback) callback(responseJSON);
  803. }.bind(this),
  804. "onRequestFailure": function(){
  805. if (callback) callback({});
  806. }.bind(this),
  807. "onError": function(){
  808. if (callback) callback({});
  809. }.bind(this)
  810. }
  811. );
  812. },
  813. loadStylesList: function(callback){
  814. var configUrl = "/x_component_query_ViewDesigner/$View/skin/config.json";
  815. MWF.getJSON(configUrl,{
  816. "onSuccess": function(responseJSON){
  817. this.stylesList = responseJSON;
  818. if (callback) callback(this.stylesList);
  819. }.bind(this),
  820. "onRequestFailure": function(){
  821. this.stylesList = {};
  822. if (callback) callback(this.stylesList);
  823. }.bind(this),
  824. "onError": function(){
  825. this.stylesList = {};
  826. if (callback) callback(this.stylesList);
  827. }.bind(this)
  828. }
  829. );
  830. }
  831. });
  832. MWF.xApplication.query.ViewDesigner.View.Column = new Class({
  833. initialize: function(json, view, next){
  834. this.propertyPath = "/x_component_query_ViewDesigner/$View/column.html";
  835. this.view = view;
  836. this.json = json;
  837. this.next = next;
  838. this.css = this.view.css;
  839. this.content = this.view.viewTitleTrNode;
  840. this.domListNode = this.view.domListNode;
  841. this.load();
  842. },
  843. load: function(){
  844. this.areaNode = new Element("td", {"styles": this.css.viewTitleColumnAreaNode});
  845. this.areaNode.store("column", this);
  846. if (this.next){
  847. this.areaNode.inject(this.next.areaNode, "before");
  848. }else{
  849. this.areaNode.inject(this.content);
  850. }
  851. this.node = new Element("div", {
  852. "styles": this.css.viewTitleColumnNode
  853. }).inject(this.areaNode);
  854. this.textNode = new Element("div", {
  855. "styles": this.css.viewTitleColumnTextNode,
  856. "text": this.json.displayName
  857. }).inject(this.node);
  858. this.createDomListItem();
  859. this._createIconAction();
  860. //if (!this.json.export) this.hideMode();
  861. this.setEvent();
  862. },
  863. createDomListItem: function(){
  864. this.listNode = new Element("div", {"styles": this.css.cloumnListNode});
  865. if (this.next){
  866. this.listNode.inject(this.next.listNode, "before");
  867. }else{
  868. this.listNode.inject(this.domListNode);
  869. }
  870. var listIconNode = new Element("div", {"styles": this.css.cloumnListIconNode}).inject(this.listNode);
  871. var listTextNode = new Element("div", {"styles": this.css.cloumnListTextNode}).inject(this.listNode);
  872. this.resetTextNode();
  873. },
  874. setEvent: function(){
  875. this.node.addEvents({
  876. "click": function(e){this.selected(); e.stopPropagation();}.bind(this),
  877. "mouseover": function(){if (!this.isSelected) this.node.setStyles(this.css.viewTitleColumnNode_over)}.bind(this),
  878. "mouseout": function(){if (!this.isSelected) if (this.isError){
  879. this.node.setStyles(this.css.viewTitleColumnNode_error)
  880. }else{
  881. this.node.setStyles(this.css.viewTitleColumnNode)
  882. }}.bind(this)
  883. });
  884. this.listNode.addEvents({
  885. "click": function(e){this.selected(); e.stopPropagation();}.bind(this),
  886. "mouseover": function(){debugger; if (!this.isSelected) this.listNode.setStyles(this.css.cloumnListNode_over)}.bind(this),
  887. "mouseout": function(){if (!this.isSelected) this.listNode.setStyles(this.css.cloumnListNode)}.bind(this)
  888. });
  889. },
  890. _createIconAction: function(){
  891. if (!this.actionArea){
  892. this.actionArea = new Element("div", {"styles": this.css.actionAreaNode}).inject(this.view.areaNode, "after");
  893. this._createAction({
  894. "name": "move",
  895. "icon": "move1.png",
  896. "event": "mousedown",
  897. "action": "move",
  898. "title": MWF.APPDVD.LP.action.move
  899. });
  900. this._createAction({
  901. "name": "add",
  902. "icon": "add.png",
  903. "event": "click",
  904. "action": "addColumn",
  905. "title": MWF.APPDVD.LP.action.add
  906. });
  907. this._createAction({
  908. "name": "delete",
  909. "icon": "delete1.png",
  910. "event": "click",
  911. "action": "delete",
  912. "title": MWF.APPDVD.LP.action["delete"]
  913. });
  914. }
  915. },
  916. _createAction: function(action){
  917. var actionNode = new Element("div", {
  918. "styles": this.css.actionNodeStyles,
  919. "title": action.title
  920. }).inject(this.actionArea);
  921. actionNode.setStyle("background", "url("+this.view.path+this.view.options.style+"/action/"+action.icon+") no-repeat left center");
  922. actionNode.addEvent(action.event, function(e){
  923. this[action.action](e);
  924. }.bind(this));
  925. actionNode.addEvents({
  926. "mouseover": function(e){
  927. e.target.setStyle("border", "1px solid #999");
  928. }.bind(this),
  929. "mouseout": function(e){
  930. e.target.setStyle("border", "1px solid #F1F1F1");
  931. }.bind(this)
  932. });
  933. },
  934. _setActionAreaPosition: function(){
  935. var p = this.node.getPosition(this.view.areaNode.getOffsetParent());
  936. var y = p.y-25;
  937. var x = p.x;
  938. this.actionArea.setPosition({"x": x, "y": y});
  939. },
  940. _showActions: function(){
  941. if (this.actionArea){
  942. this._setActionAreaPosition();
  943. this.actionArea.setStyle("display", "block");
  944. }
  945. },
  946. _hideActions: function(){
  947. if (this.actionArea) this.actionArea.setStyle("display", "none");
  948. },
  949. selected: function(){
  950. if (this.view.currentSelectedModule){
  951. if (this.view.currentSelectedModule==this){
  952. return true;
  953. }else{
  954. this.view.currentSelectedModule.unSelected();
  955. }
  956. }
  957. this.node.setStyles(this.css.viewTitleColumnNode_selected);
  958. this.listNode.setStyles(this.css.cloumnListNode_selected);
  959. new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 100}).toElementEdge(this.node);
  960. new Fx.Scroll(this.view.designer.propertyDomArea, {"wheelStops": false, "duration": 100}).toElement(this.listNode);
  961. this.view.currentSelectedModule = this;
  962. this.isSelected = true;
  963. this._showActions();
  964. this.showProperty();
  965. },
  966. unSelected: function(){
  967. this.view.currentSelectedModule = null;
  968. //this.node.setStyles(this.css.viewTitleColumnNode);
  969. if (this.isError){
  970. this.node.setStyles(this.css.viewTitleColumnNode_error)
  971. }else{
  972. this.node.setStyles(this.css.viewTitleColumnNode)
  973. }
  974. this.listNode.setStyles(this.css.cloumnListNode);
  975. this.isSelected = false;
  976. this._hideActions();
  977. this.hideProperty();
  978. },
  979. showProperty: function(){
  980. if (!this.property){
  981. this.property = new MWF.xApplication.query.ViewDesigner.Property(this, this.view.designer.propertyContentArea, this.view.designer, {
  982. "path": this.propertyPath,
  983. "onPostLoad": function(){
  984. this.property.show();
  985. var processDiv = this.property.propertyContent.getElements("#"+this.json.id+"dataPathSelectedProcessArea");
  986. var cmsDiv = this.property.propertyContent.getElements("#"+this.json.id+"dataPathSelectedCMSArea");
  987. if (this.view.json.type=="cms"){
  988. processDiv.setStyle("display", "none");
  989. cmsDiv.setStyle("display", "block");
  990. }else{
  991. processDiv.setStyle("display", "block");
  992. cmsDiv.setStyle("display", "none");
  993. }
  994. }.bind(this)
  995. });
  996. this.property.load();
  997. }else{
  998. this.property.show();
  999. }
  1000. },
  1001. hideProperty: function(){
  1002. if (this.property) this.property.hide();
  1003. },
  1004. _setEditStyle: function(name, input, oldValue){
  1005. if (name=="displayName") this.resetTextNode();
  1006. if (name=="selectType") this.resetTextNode();
  1007. if (name=="attribute") this.resetTextNode();
  1008. if (name=="path") this.resetTextNode();
  1009. if (name=="column"){
  1010. this.view.json.data.orderList.each(function(order){
  1011. if (order.column==oldValue) order.column = this.json.column
  1012. }.bind(this));
  1013. if (this.view.json.data.group.column == oldValue) this.view.json.data.group.column = this.json.column;
  1014. }
  1015. },
  1016. resetTextNode: function(){
  1017. var listText = (this.json.selectType=="attribute") ? (this.json.attribute || "") : (this.json.path || "");
  1018. if (!listText) listText = "unnamed";
  1019. this.textNode.set("text", this.json.displayName);
  1020. this.listNode.getLast().set("text", this.json.displayName+"("+listText+")");
  1021. },
  1022. "delete": function(e){
  1023. var _self = this;
  1024. if (!e) e = this.node;
  1025. this.view.designer.confirm("warn", e, MWF.APPDVD.LP.notice.deleteColumnTitle, MWF.APPDVD.LP.notice.deleteColumn, 300, 120, function(){
  1026. _self.destroy();
  1027. this.close();
  1028. }, function(){
  1029. this.close();
  1030. }, null);
  1031. },
  1032. destroy: function(){
  1033. if (this.view.currentSelectedModule==this) this.view.currentSelectedModule = null;
  1034. if (this.actionArea) this.actionArea.destroy();
  1035. if (this.listNode) this.listNode.destroy();
  1036. if (this.property) this.property.propertyContent.destroy();
  1037. var idx = this.view.items.indexOf(this);
  1038. if (this.view.viewContentTableNode){
  1039. var trs = this.view.viewContentTableNode.getElements("tr");
  1040. trs.each(function(tr){
  1041. tr.deleteCell(idx);
  1042. }.bind(this));
  1043. }
  1044. if (this.view.json.data.selectList) this.view.json.data.selectList.erase(this.json);
  1045. if (this.view.json.data.calculate) if (this.view.json.data.calculate.calculateList) this.view.json.data.calculate.calculateList.erase(this.json);
  1046. this.view.items.erase(this);
  1047. if (this.view.property) this.view.property.loadStatColumnSelect();
  1048. this.areaNode.destroy();
  1049. this.view.selected();
  1050. this.view.setViewWidth();
  1051. MWF.release(this);
  1052. delete this;
  1053. },
  1054. addColumn: function(e, data){
  1055. MWF.require("MWF.widget.UUID", function(){
  1056. var json;
  1057. if (data){
  1058. json = Object.clone(data);
  1059. json.id = (new MWF.widget.UUID).id;
  1060. json.column = (new MWF.widget.UUID).id;
  1061. }else{
  1062. var id = (new MWF.widget.UUID).id;
  1063. json = {
  1064. "id": id,
  1065. "column": id,
  1066. "displayName": this.view.designer.lp.unnamed,
  1067. "orderType": "original"
  1068. };
  1069. }
  1070. var idx = this.view.json.data.selectList.indexOf(this.json);
  1071. this.view.json.data.selectList.splice(idx, 0, json);
  1072. var column = new MWF.xApplication.query.ViewDesigner.View.Column(json, this.view, this);
  1073. this.view.items.splice(idx, 0, column);
  1074. column.selected();
  1075. if (this.view.viewContentTableNode){
  1076. var trs = this.view.viewContentTableNode.getElements("tr");
  1077. trs.each(function(tr){
  1078. var td = tr.insertCell(idx);
  1079. td.setStyles(this.css.viewContentTdNode);
  1080. }.bind(this));
  1081. }
  1082. this.view.setViewWidth();
  1083. }.bind(this));
  1084. },
  1085. move: function(e){
  1086. var columnNodes = [];
  1087. this.view.items.each(function(item){
  1088. if (item!=this){
  1089. columnNodes.push(item.areaNode);
  1090. }
  1091. }.bind(this));
  1092. this._createMoveNode();
  1093. this._setNodeMove(columnNodes, e);
  1094. },
  1095. _createMoveNode: function(){
  1096. this.moveNode = new Element("div", {"text": this.node.get("text")});
  1097. this.moveNode.inject(this.view.designer.content);
  1098. this.moveNode.setStyles({
  1099. "border": "2px dashed #ffa200",
  1100. "opacity": 0.7,
  1101. "height": "30px",
  1102. "line-height": "30px",
  1103. "padding": "0px 10px",
  1104. "position": "absolute"
  1105. });
  1106. },
  1107. _setMoveNodePosition: function(e){
  1108. var x = e.page.x+2;
  1109. var y = e.page.y+2;
  1110. this.moveNode.positionTo(x, y);
  1111. },
  1112. createMoveFlagNode: function(){
  1113. this.moveFlagNode = new Element("td", {"styles": this.css.moveFlagNode});
  1114. },
  1115. _setNodeMove: function(droppables, e){
  1116. this._setMoveNodePosition(e);
  1117. var movePosition = this.moveNode.getPosition();
  1118. var moveSize = this.moveNode.getSize();
  1119. var contentPosition = this.content.getPosition();
  1120. var contentSize = this.content.getSize();
  1121. var nodeDrag = new Drag.Move(this.moveNode, {
  1122. "droppables": droppables,
  1123. "limit": {
  1124. "x": [contentPosition.x, contentPosition.x+contentSize.x],
  1125. "y": [movePosition.y, movePosition.y+moveSize.y]
  1126. },
  1127. "onEnter": function(dragging, inObj){
  1128. if (!this.moveFlagNode) this.createMoveFlagNode();
  1129. this.moveFlagNode.inject(inObj, "before");
  1130. }.bind(this),
  1131. "onLeave": function(dragging, inObj){
  1132. if (this.moveFlagNode){
  1133. this.moveFlagNode.dispose();
  1134. }
  1135. }.bind(this),
  1136. "onDrop": function(dragging, inObj){
  1137. if (inObj){
  1138. this.areaNode.inject(inObj, "before");
  1139. var column = inObj.retrieve("column");
  1140. this.listNode.inject(column.listNode, "before");
  1141. var idx = this.view.json.data.selectList.indexOf(column.json);
  1142. this.view.json.data.selectList.erase(this.json);
  1143. this.view.items.erase(this);
  1144. this.view.json.data.selectList.splice(idx, 0, this.json);
  1145. this.view.items.splice(idx, 0, this);
  1146. if (this.moveNode) this.moveNode.destroy();
  1147. if (this.moveFlagNode) this.moveFlagNode.destroy();
  1148. this._setActionAreaPosition();
  1149. }else{
  1150. if (this.moveNode) this.moveNode.destroy();
  1151. if (this.moveFlagNode) this.moveFlagNode.destroy();
  1152. }
  1153. }.bind(this),
  1154. "onCancel": function(dragging){
  1155. if (this.moveNode) this.moveNode.destroy();
  1156. if (this.moveFlagNode) this.moveFlagNode.destroy();
  1157. }.bind(this)
  1158. });
  1159. nodeDrag.start(e);
  1160. }
  1161. //hideMode: function(){
  1162. // if (!this.columnHideFlagNode){
  1163. // this.columnHideFlagNode = new Element("div", {"styles": this.view.css.columnHideFlagNode}).inject(this.node);
  1164. // }
  1165. //},
  1166. //showMode: function(){
  1167. // if (this.columnHideFlagNode) this.columnHideFlagNode.destroy();
  1168. // this.columnHideFlagNode = null;
  1169. //}
  1170. });
  1171. MWF.xApplication.query.ViewDesigner.View.$Module = MWF.QV$Module = new Class({
  1172. Extends: MWF.widget.Common,
  1173. Implements: [Options, Events],
  1174. copyStyles: function(from, to){
  1175. if (!this.json[to]) this.json[to] = {};
  1176. Object.each(from, function(style, key){
  1177. //if (!this.json[to][key])
  1178. this.json[to][key] = style;
  1179. }.bind(this));
  1180. },
  1181. removeStyles: function(from, to){
  1182. if (this.json[to]){
  1183. Object.each(from, function(style, key){
  1184. if (this.json[to][key] && this.json[to][key]==style){
  1185. delete this.json[to][key];
  1186. }
  1187. //if (this.json[from][key]){
  1188. // delete this.json[to][key];
  1189. //}
  1190. }.bind(this));
  1191. }
  1192. },
  1193. setTemplateStyles: function(styles){
  1194. if (styles.styles) this.copyStyles(styles.styles, "styles");
  1195. if (styles.properties) this.copyStyles(styles.properties, "properties");
  1196. },
  1197. clearTemplateStyles: function(styles){
  1198. if (styles){
  1199. if (styles.styles) this.removeStyles(styles.styles, "styles");
  1200. if (styles.properties) this.removeStyles(styles.properties, "properties");
  1201. }
  1202. },
  1203. setStyleTemplate: function(){
  1204. if( this.view.templateStyles && this.view.templateStyles[this.moduleName] ){
  1205. this.setTemplateStyles(this.view.templateStyles[this.moduleName]);
  1206. }
  1207. },
  1208. setAllStyles: function(){
  1209. this.setPropertiesOrStyles("styles");
  1210. this.setPropertiesOrStyles("inputStyles");
  1211. this.setPropertiesOrStyles("properties");
  1212. this.reloadMaplist();
  1213. },
  1214. showProperty: function(){
  1215. if (!this.property){
  1216. this.property = new MWF.xApplication.query.ViewDesigner.Property(this, this.view.designer.propertyContentArea, this.view.designer, {
  1217. "path": this.propertyPath,
  1218. "onPostLoad": function(){
  1219. this.property.show();
  1220. }.bind(this)
  1221. });
  1222. this.property.load();
  1223. }else{
  1224. this.property.show();
  1225. }
  1226. },
  1227. hideProperty: function(){
  1228. if (this.property) this.property.hide();
  1229. },
  1230. deletePropertiesOrStyles: function(name, key){
  1231. if (name=="properties"){
  1232. try{
  1233. this.node.removeProperty(key);
  1234. }catch(e){}
  1235. }
  1236. },
  1237. setPropertiesOrStyles: function(name){
  1238. if (name=="styles"){
  1239. try{
  1240. this.setCustomStyles();
  1241. }catch(e){}
  1242. }
  1243. if (name=="properties"){
  1244. try{
  1245. this.node.setProperties(this.json.properties);
  1246. }catch(e){}
  1247. }
  1248. },
  1249. setCustomNodeStyles: function(node, styles){
  1250. var border = node.getStyle("border");
  1251. node.clearStyles();
  1252. //node.setStyles(styles);
  1253. node.setStyle("border", border);
  1254. Object.each(styles, function(value, key){
  1255. var reg = /^border\w*/ig;
  1256. if (!key.test(reg)){
  1257. node.setStyle(key, value);
  1258. }
  1259. }.bind(this));
  1260. },
  1261. setCustomStyles: function(){
  1262. var border = this.node.getStyle("border");
  1263. this.node.clearStyles();
  1264. this.node.setStyles(this.css.moduleNode);
  1265. if (this.initialStyles) this.node.setStyles(this.initialStyles);
  1266. this.node.setStyle("border", border);
  1267. if (this.json.styles) Object.each(this.json.styles, function(value, key){
  1268. if ((value.indexOf("x_processplatform_assemble_surface")!=-1 || value.indexOf("x_portal_assemble_surface")!=-1)){
  1269. var host1 = MWF.Actions.getHost("x_processplatform_assemble_surface");
  1270. var host2 = MWF.Actions.getHost("x_portal_assemble_surface");
  1271. if (value.indexOf("/x_processplatform_assemble_surface")!==-1){
  1272. value = value.replace("/x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  1273. }else if (value.indexOf("x_processplatform_assemble_surface")!==-1){
  1274. value = value.replace("x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  1275. }
  1276. if (value.indexOf("/x_portal_assemble_surface")!==-1){
  1277. value = value.replace("/x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  1278. }else if (value.indexOf("x_portal_assemble_surface")!==-1){
  1279. value = value.replace("x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  1280. }
  1281. }
  1282. var reg = /^border\w*/ig;
  1283. if (!key.test(reg)){
  1284. if (key){
  1285. if (key.toString().toLowerCase()==="display"){
  1286. if (value.toString().toLowerCase()==="none"){
  1287. this.node.setStyle("opacity", 0.3);
  1288. }else{
  1289. this.node.setStyle("opacity", 1);
  1290. this.node.setStyle(key, value);
  1291. }
  1292. }else{
  1293. this.node.setStyle(key, value);
  1294. }
  1295. }
  1296. }
  1297. //this.node.setStyle(key, value);
  1298. }.bind(this));
  1299. },
  1300. _setEditStyle: function(name, obj, oldValue){
  1301. var title = "";
  1302. var text = "";
  1303. if (name==="name"){
  1304. title = this.json.name || this.json.id;
  1305. text = this.json.type.substr(this.json.type.lastIndexOf("$")+1, this.json.type.length);
  1306. this.treeNode.setText("<"+text+"> "+title);
  1307. }
  1308. if (name==="id"){
  1309. title = this.json.name || this.json.id;
  1310. if (!this.json.name){
  1311. text = this.json.type.substr(this.json.type.lastIndexOf("$")+1, this.json.type.length);
  1312. this.treeNode.setText("<"+text+"> "+this.json.id);
  1313. }
  1314. this.treeNode.setTitle(this.json.id);
  1315. this.node.set("id", this.json.id);
  1316. }
  1317. this._setEditStyle_custom(name, obj, oldValue);
  1318. },
  1319. reloadMaplist: function(){
  1320. if (this.property) Object.each(this.property.maplists, function(map, name){ map.reload(this.json[name]);}.bind(this));
  1321. },
  1322. getHtml: function(){
  1323. var copy = this.node.clone(true, true);
  1324. copy.clearStyles(true);
  1325. var html = copy.outerHTML;
  1326. copy.destroy();
  1327. return html;
  1328. },
  1329. getJson: function(){
  1330. var json = Object.clone(this.json);
  1331. var o = {};
  1332. o[json.id] = json;
  1333. return o;
  1334. }
  1335. })
  1336. MWF.require("MWF.widget.Toolbar", null, false);
  1337. MWF.xApplication.query.ViewDesigner.View.Actionbar = new Class({
  1338. Extends: MWF.xApplication.query.ViewDesigner.View.$Module,
  1339. options : {
  1340. "style" : "default",
  1341. "customImageStyle" : "default"
  1342. },
  1343. initialize: function(json, jsonList, view, options){
  1344. this.setOptions( options );
  1345. this.propertyPath = "/x_component_query_ViewDesigner/$View/actionbar.html";
  1346. this.path = "/x_component_query_ViewDesigner/$View/";
  1347. this.imagePath_default = "/x_component_query_ViewDesigner/$View/";
  1348. this.imagePath_custom = "/x_component_process_FormDesigner/Module/Actionbar/";
  1349. this.cssPath = "/x_component_query_ViewDesigner/$View/"+this.options.style+"/actionbar.wcss";
  1350. this.view = view;
  1351. this.json = json;
  1352. this.jsonList = jsonList;
  1353. this.css = this.view.css;
  1354. this.container = this.view.actionbarNode;
  1355. this.moduleName = "actionbar";
  1356. this.load();
  1357. },
  1358. load: function(){
  1359. this.systemTools = [];
  1360. this.customTools = [];
  1361. if( !this.json ){
  1362. this.loadDefaultJson(function(){
  1363. this._load()
  1364. }.bind(this));
  1365. }else{
  1366. this._load()
  1367. }
  1368. },
  1369. _load : function(){
  1370. this.json.moduleName = this.moduleName;
  1371. this._createNode();
  1372. //this._createIconAction();
  1373. //if (!this.json.export) this.hideMode();
  1374. this.setEvent();
  1375. },
  1376. loadDefaultJson: function(callback){
  1377. var url = this.path+"actionbar.json";
  1378. MWF.getJSON(url, {
  1379. "onSuccess": function(obj){
  1380. this.view.designer.actions.getUUID(function(id){
  1381. obj.id=id;
  1382. //obj.isNewView = true;
  1383. //obj.application = this.view.designer.application.id;
  1384. this.json = obj;
  1385. this.jsonList.push( this.json );
  1386. if (callback) callback(obj);
  1387. }.bind(this));
  1388. }.bind(this),
  1389. "onerror": function(text){
  1390. this.view.designer.notice(text, "error");
  1391. }.bind(this),
  1392. "onRequestFailure": function(xhr){
  1393. this.view.designer.notice(xhr.responseText, "error");
  1394. }.bind(this)
  1395. });
  1396. },
  1397. setTemplateStyles: function(styles){
  1398. this.json.style = styles.style;
  1399. this.json.iconOverStyle = styles.iconOverStyle || "";
  1400. this.json.customIconStyle = styles.customIconStyle;
  1401. this.json.customIconOverStyle = styles.customIconOverStyle || "";
  1402. this.json.forceStyles = styles.forceStyles || "";
  1403. },
  1404. clearTemplateStyles: function(styles){
  1405. this.json.style = "form";
  1406. this.json.iconOverStyle = "";
  1407. this.json.customIconStyle = "";
  1408. this.json.customIconOverStyle = "";
  1409. this.json.forceStyles = "";
  1410. },
  1411. setAllStyles: function(){
  1412. this._resetActionbar();
  1413. },
  1414. setEvent: function(){
  1415. this.node.addEvents({
  1416. "click": function(e){this.selected(); e.stopPropagation();}.bind(this),
  1417. "mouseover": function(){if (!this.isSelected) this.node.setStyles(this.css.toolbarWarpNode_over)}.bind(this),
  1418. "mouseout": function(){if (!this.isSelected) this.node.setStyles(this.css.toolbarWarpNode) }.bind(this)
  1419. });
  1420. },
  1421. selected: function(){
  1422. if (this.view.currentSelectedModule){
  1423. if (this.view.currentSelectedModule==this){
  1424. return true;
  1425. }else{
  1426. this.view.currentSelectedModule.unSelected();
  1427. }
  1428. }
  1429. this.node.setStyles(this.css.toolbarWarpNode_selected);
  1430. //this.listNode.setStyles(this.css.cloumnListNode_selected);
  1431. new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 100}).toElementEdge(this.node);
  1432. //new Fx.Scroll(this.view.designer.propertyDomArea, {"wheelStops": false, "duration": 100}).toElement(this.listNode);
  1433. this.view.currentSelectedModule = this;
  1434. this.isSelected = true;
  1435. //this._showActions();
  1436. this.showProperty();
  1437. },
  1438. unSelected: function(){
  1439. this.view.currentSelectedModule = null;
  1440. this.node.setStyles(this.css.toolbarWarpNode)
  1441. //this.listNode.setStyles(this.css.cloumnListNode);
  1442. this.isSelected = false;
  1443. //this._hideActions();
  1444. this.hideProperty();
  1445. },
  1446. resetTextNode: function(){
  1447. var listText = (this.json.selectType=="attribute") ? (this.json.attribute || "") : (this.json.path || "");
  1448. if (!listText) listText = "unnamed";
  1449. this.textNode.set("text", this.json.displayName);
  1450. this.listNode.getLast().set("text", this.json.displayName+"("+listText+")");
  1451. },
  1452. _createNode: function(callback){
  1453. this.node = new Element("div", {
  1454. "id": this.json.id,
  1455. "MWFType": "actionbar",
  1456. "styles": this.css.toolbarWarpNode,
  1457. "events": {
  1458. "selectstart": function(e){
  1459. e.preventDefault();
  1460. }
  1461. }
  1462. }).inject(this.container );
  1463. this.toolbarNode = new Element("div").inject(this.node);
  1464. this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {"style": this.json.style}, this);
  1465. if (!this.json.actionStyles){
  1466. this.json.actionStyles = Object.clone(this.toolbarWidget.css);
  1467. }
  1468. //MWF.getJSON(this.path+"toolbars.json", function(json){
  1469. // this.json.defaultTools = json;
  1470. // this.setToolbars(json, this.toolbarNode);
  1471. // debugger;
  1472. // this.toolbarWidget.load();
  1473. //}.bind(this), false);
  1474. if (this.json.defaultTools){
  1475. var json = Array.clone(this.json.defaultTools);
  1476. //if (this.json.tools) json.append(this.json.tools);
  1477. this.setToolbars(json, this.toolbarNode);
  1478. if (this.json.tools){
  1479. this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  1480. }
  1481. this.toolbarWidget.load();
  1482. this._setEditStyle_custom("hideSystemTools");
  1483. //json = null;
  1484. }else{
  1485. MWF.getJSON(this.path+"toolbars.json", function(json){
  1486. this.json.defaultTools = json;
  1487. var json = Array.clone(this.json.defaultTools);
  1488. //if (this.json.tools) json.append(this.json.tools);
  1489. this.setToolbars(json, this.toolbarNode);
  1490. if (this.json.tools){
  1491. this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  1492. }
  1493. this.toolbarWidget.load();
  1494. this._setEditStyle_custom("hideSystemTools");
  1495. //json = null;
  1496. }.bind(this), false);
  1497. }
  1498. },
  1499. _refreshActionbar: function(){
  1500. //if (this.form.options.mode == "Mobile"){
  1501. // this.node.set("text", MWF.APPFD.LP.notice.notUseModuleInMobile+"("+this.moduleName+")");
  1502. // this.node.setStyles({"height": "24px", "line-height": "24px", "background-color": "#999"});
  1503. //}else{
  1504. this.toolbarNode = this.node.getFirst("div");
  1505. this.toolbarNode.empty();
  1506. this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {"style": this.json.style}, this);
  1507. if (!this.json.actionStyles) this.json.actionStyles = Object.clone(this.toolbarWidget.css);
  1508. this.toolbarWidget.css = this.json.actionStyles;
  1509. if (this.json.defaultTools){
  1510. var json = Array.clone(this.json.defaultTools);
  1511. //if (this.json.tools) json.append(this.json.tools);
  1512. this.setToolbars(json, this.toolbarNode);
  1513. if (this.json.tools){
  1514. this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  1515. }
  1516. this.toolbarWidget.load();
  1517. //json = null;
  1518. }else{
  1519. MWF.getJSON(this.path+"toolbars.json", function(json){
  1520. this.json.defaultTools = json;
  1521. var json = Array.clone(this.json.defaultTools);
  1522. //if (this.json.tools) json.append(this.json.tools);
  1523. this.setToolbars(json, this.toolbarNode);
  1524. if (this.json.tools){
  1525. this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  1526. }
  1527. this.toolbarWidget.load();
  1528. //json = null;
  1529. }.bind(this), false);
  1530. }
  1531. //}
  1532. },
  1533. _resetActionbar: function(){
  1534. //if (this.form.options.mode == "Mobile"){
  1535. // this.node.set("text", MWF.APPFD.LP.notice.notUseModuleInMobile+"("+this.moduleName+")");
  1536. // this.node.setStyles({"height": "24px", "line-height": "24px", "background-color": "#999"});
  1537. //}else{
  1538. this.toolbarNode = this.node.getFirst("div");
  1539. this.toolbarNode.empty();
  1540. this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {"style": this.json.style}, this);
  1541. if (!this.json.actionStyles){
  1542. this.json.actionStyles = Object.merge( Object.clone( this.toolbarWidget.css ), this.json.forceStyles || {} );
  1543. }else{
  1544. this.toolbarWidget.css = Object.merge( Object.clone( this.json.actionStyles ), this.toolbarWidget.css, this.json.forceStyles || {} );
  1545. this.json.actionStyles = Object.clone(this.toolbarWidget.css);
  1546. }
  1547. if (this.json.defaultTools){
  1548. var json = Array.clone(this.json.defaultTools);
  1549. //if (this.json.tools) json.append(this.json.tools);
  1550. this.setToolbars(json, this.toolbarNode);
  1551. if (this.json.tools){
  1552. this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  1553. }
  1554. this.toolbarWidget.load();
  1555. //json = null;
  1556. }else{
  1557. MWF.getJSON(this.path+"toolbars.json", function(json){
  1558. this.json.defaultTools = json;
  1559. var json = Array.clone(this.json.defaultTools);
  1560. //if (this.json.tools) json.append(this.json.tools);
  1561. this.setToolbars(json, this.toolbarNode);
  1562. if (this.json.tools){
  1563. this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  1564. }
  1565. this.toolbarWidget.load();
  1566. //json = null;
  1567. }.bind(this), false);
  1568. }
  1569. //}
  1570. },
  1571. setToolbars: function(tools, node){
  1572. tools.each(function(tool){
  1573. var actionNode = new Element("div", {
  1574. "MWFnodetype": tool.type,
  1575. "MWFButtonImage": this.imagePath_default+""+this.options.style+"/actionbar/"+tool.img,
  1576. "title": tool.title,
  1577. "MWFButtonAction": tool.action,
  1578. "MWFButtonText": tool.text
  1579. }).inject(node);
  1580. if( this.json.iconOverStyle ){
  1581. actionNode.set("MWFButtonImageOver" , this.imagePath_default+""+this.options.style+"/actionbar/"+this.json.iconOverStyle+"/"+tool.img );
  1582. }
  1583. this.systemTools.push(actionNode);
  1584. if (tool.sub){
  1585. var subNode = node.getLast();
  1586. this.setToolbars(tool.sub, subNode);
  1587. }
  1588. }.bind(this));
  1589. },
  1590. setCustomToolbars: function(tools, node){
  1591. //var style = (this.json.style || "default").indexOf("red") > -1 ? "red" : "blue";
  1592. var path = "";
  1593. if( this.json.customIconStyle ){
  1594. path = this.json.customIconStyle+ "/";
  1595. }
  1596. tools.each(function(tool){
  1597. var actionNode = new Element("div", {
  1598. "MWFnodetype": tool.type,
  1599. "MWFButtonImage": this.imagePath_custom+""+this.options.customImageStyle +"/custom/"+path+tool.img,
  1600. "title": tool.title,
  1601. "MWFButtonAction": tool.action,
  1602. "MWFButtonText": tool.text
  1603. }).inject(node);
  1604. if( this.json.customIconOverStyle ){
  1605. actionNode.set("MWFButtonImageOver" , this.imagePath_custom+""+this.options.customImageStyle +"/custom/"+this.json.customIconOverStyle+ "/" +tool.img );
  1606. }
  1607. this.customTools.push(actionNode);
  1608. if (tool.sub){
  1609. var subNode = node.getLast();
  1610. this.setToolbars(tool.sub, subNode);
  1611. }
  1612. }.bind(this));
  1613. },
  1614. _setEditStyle_custom: function(name){
  1615. if (name=="hideSystemTools"){
  1616. if (this.json.hideSystemTools){
  1617. this.systemTools.each(function(tool){
  1618. tool.setStyle("display", "none");
  1619. });
  1620. }else{
  1621. this.systemTools.each(function(tool){
  1622. tool.setStyle("display", "block");
  1623. });
  1624. }
  1625. }
  1626. if (name=="defaultTools" || name=="tools" || name==="actionStyles"){
  1627. this._refreshActionbar();
  1628. }
  1629. }
  1630. });
  1631. MWF.require("MWF.widget.Paging", null, false);
  1632. MWF.xApplication.query.ViewDesigner.View.Paging = new Class({
  1633. Extends: MWF.xApplication.query.ViewDesigner.View.$Module,
  1634. options : {
  1635. "style" : "default"
  1636. },
  1637. initialize: function(json, jsonList, view, options){
  1638. this.setOptions( options );
  1639. this.propertyPath = "/x_component_query_ViewDesigner/$View/paging.html";
  1640. this.view = view;
  1641. this.json = json;
  1642. this.jsonList = jsonList;
  1643. this.css = this.view.css;
  1644. this.container = this.view.pagingNode;
  1645. this.moduleName = "paging";
  1646. this.load();
  1647. },
  1648. load: function(){
  1649. this.systemTools = [];
  1650. this.customTools = [];
  1651. if( !this.json ){
  1652. this.loadDefaultJson(function(){
  1653. this._load();
  1654. }.bind(this));
  1655. }else{
  1656. this._load();
  1657. }
  1658. },
  1659. _load : function(){
  1660. this.json.moduleName = this.moduleName;
  1661. this._createNode();
  1662. this.setEvent();
  1663. },
  1664. loadDefaultJson: function(callback){
  1665. var url = this.view.path+"paging.json";
  1666. MWF.getJSON(url, {
  1667. "onSuccess": function(obj){
  1668. this.view.designer.actions.getUUID(function(id){
  1669. obj.id=id;
  1670. this.json = obj;
  1671. this.jsonList.push( this.json );
  1672. if (callback) callback(obj);
  1673. }.bind(this));
  1674. }.bind(this),
  1675. "onerror": function(text){
  1676. this.view.designer.notice(text, "error");
  1677. }.bind(this),
  1678. "onRequestFailure": function(xhr){
  1679. this.view.designer.notice(xhr.responseText, "error");
  1680. }.bind(this)
  1681. });
  1682. },
  1683. setTemplateStyles: function(styles){
  1684. this.json.style = styles.style;
  1685. this.json.forceStyles = styles.forceStyles || "";
  1686. },
  1687. clearTemplateStyles: function(styles){
  1688. this.json.style = "default";
  1689. this.json.forceStyles = "";
  1690. },
  1691. setAllStyles: function(){
  1692. this._resetPaging();
  1693. },
  1694. setEvent: function(){
  1695. this.node.addEvents({
  1696. "click": function(e){this.selected(); e.stopPropagation();}.bind(this),
  1697. "mouseover": function(){if (!this.isSelected) this.node.setStyles(this.css.pagingWarpNode_over)}.bind(this),
  1698. "mouseout": function(){if (!this.isSelected) this.node.setStyles(this.css.pagingWarpNode) }.bind(this)
  1699. });
  1700. },
  1701. selected: function(){
  1702. if (this.view.currentSelectedModule){
  1703. if (this.view.currentSelectedModule==this){
  1704. return true;
  1705. }else{
  1706. this.view.currentSelectedModule.unSelected();
  1707. }
  1708. }
  1709. this.node.setStyles(this.css.pagingWarpNode_selected);
  1710. new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 100}).toElementEdge(this.node);
  1711. this.view.currentSelectedModule = this;
  1712. this.isSelected = true;
  1713. this.showProperty();
  1714. },
  1715. unSelected: function(){
  1716. this.view.currentSelectedModule = null;
  1717. this.node.setStyles(this.css.pagingWarpNode);
  1718. this.isSelected = false;
  1719. this.hideProperty();
  1720. },
  1721. resetTextNode: function(){
  1722. var listText = (this.json.selectType=="attribute") ? (this.json.attribute || "") : (this.json.path || "");
  1723. if (!listText) listText = "unnamed";
  1724. this.textNode.set("text", this.json.displayName);
  1725. this.listNode.getLast().set("text", this.json.displayName+"("+listText+")");
  1726. },
  1727. _createNode: function(callback){
  1728. this.node = new Element("div", {
  1729. "id": this.json.id,
  1730. "MWFType": "paging",
  1731. "styles": this.css.pagingWarpNode,
  1732. "events": {
  1733. "selectstart": function(e){
  1734. e.preventDefault();
  1735. }
  1736. }
  1737. }).inject(this.container );
  1738. this.pagingNode = new Element("div").inject(this.node);
  1739. this.loadWidget();
  1740. // this.pagingWidget = new MWF.widget.Paging(this.pagingNode, {"style": this.json.style}, this);
  1741. // if (!this.json.pagingStyles){
  1742. // this.json.pagingStyles = Object.clone(this.pagingWidget.css);
  1743. // }
  1744. // this.pagingWidget.load();
  1745. },
  1746. loadWidget : function( isReset ){
  1747. var visiblePages = this.json.visiblePages ? this.json.visiblePages.toInt() : 9;
  1748. this.pagingWidget = new o2.widget.Paging(this.pagingNode, {
  1749. style : this.json.style || "default",
  1750. countPerPage: 20, //this.json.pageSize || this.options.perPageCount,
  1751. visiblePages: visiblePages,
  1752. currentPage: 1,
  1753. itemSize: visiblePages * 20 * 3,
  1754. // pageSize: this.pages,
  1755. hasNextPage: typeOf( this.json.hasPreNextPage ) === "boolean" ? this.json.hasPreNextPage : true,
  1756. hasPrevPage: typeOf( this.json.hasPreNextPage ) === "boolean" ? this.json.hasPreNextPage : true,
  1757. hasTruningBar: typeOf( this.json.hasTruningBar ) === "boolean" ? this.json.hasTruningBar : true,
  1758. hasBatchTuring: typeOf( this.json.hasBatchTuring ) === "boolean" ? this.json.hasBatchTuring : true,
  1759. hasFirstPage: typeOf( this.json.hasFirstLastPage ) === "boolean" ? this.json.hasFirstLastPage : true,
  1760. hasLastPage: typeOf( this.json.hasFirstLastPage ) === "boolean" ? this.json.hasFirstLastPage : true,
  1761. hasJumper: typeOf( this.json.hasPageJumper ) === "boolean" ? this.json.hasPageJumper : true,
  1762. hiddenWithDisable: false,
  1763. // hiddenWithNoItem: true,
  1764. text: {
  1765. prePage: this.json.prePageText,
  1766. nextPage: this.json.nextPageText,
  1767. firstPage: this.json.firstPageText,
  1768. lastPage: this.json.lastPageText
  1769. },
  1770. onJumpingPage : function( pageNum, itemNum ){
  1771. }.bind(this),
  1772. onPostLoad : function () {
  1773. this.view.setContentHeight()
  1774. // if(this.setContentHeightFun)this.setContentHeightFun();
  1775. }.bind(this)
  1776. }, isReset ? {} : (this.json.pagingStyles || {}));
  1777. if( isReset ){
  1778. if (!this.json.pagingStyles){
  1779. this.json.pagingStyles = Object.merge( Object.clone( this.pagingWidget.css ), this.json.forceStyles || {} );
  1780. }else{
  1781. this.pagingWidget.css = Object.merge( Object.clone( this.json.pagingStyles ), this.pagingWidget.css, this.json.forceStyles || {} );
  1782. this.json.pagingStyles = Object.clone(this.pagingWidget.css);
  1783. }
  1784. }else{
  1785. if (!this.json.pagingStyles){
  1786. this.json.pagingStyles = Object.clone(this.pagingWidget.css);
  1787. }
  1788. }
  1789. this.pagingWidget.load();
  1790. },
  1791. _resetPaging : function(){
  1792. this.pagingNode.empty();
  1793. this.loadWidget( true );
  1794. },
  1795. _refreshPaging: function(){
  1796. this.pagingNode.empty();
  1797. this.loadWidget();
  1798. },
  1799. _setEditStyle_custom: function(name, obj, oldValue){
  1800. debugger;
  1801. if ( ["hasTruningBar","visiblePages","hasBatchTuring",
  1802. "hasFirstLastPage","hasPreNextPage","hasPageJumper",
  1803. "firstPageText","lastPageText","prePageText","nextPageText",
  1804. "pagingStyles"].contains(name)){
  1805. this._refreshPaging();
  1806. }
  1807. }
  1808. });