View.js 88 KB

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