View.js 88 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119
  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.iconStyle = styles.iconStyle || "";
  1510. this.json.iconOverStyle = styles.iconOverStyle || "";
  1511. this.json.customIconStyle = styles.customIconStyle;
  1512. this.json.customIconOverStyle = styles.customIconOverStyle || "";
  1513. this.json.forceStyles = styles.forceStyles || "";
  1514. },
  1515. clearTemplateStyles: function(styles){
  1516. this.json.style = "form";
  1517. this.json.iconStyle = "";
  1518. this.json.iconOverStyle = "";
  1519. this.json.customIconStyle = "";
  1520. this.json.customIconOverStyle = "";
  1521. this.json.forceStyles = "";
  1522. },
  1523. setAllStyles: function(){
  1524. this._resetActionbar();
  1525. },
  1526. setEvent: function(){
  1527. this.node.addEvents({
  1528. "click": function(e){this.selected(); e.stopPropagation();}.bind(this),
  1529. "mouseover": function(){if (!this.isSelected) this.node.setStyles(this.css.toolbarWarpNode_over)}.bind(this),
  1530. "mouseout": function(){if (!this.isSelected) this.node.setStyles(this.css.toolbarWarpNode) }.bind(this)
  1531. });
  1532. },
  1533. selected: function(){
  1534. if (this.view.currentSelectedModule){
  1535. if (this.view.currentSelectedModule==this){
  1536. return true;
  1537. }else{
  1538. this.view.currentSelectedModule.unSelected();
  1539. }
  1540. }
  1541. this.node.setStyles(this.css.toolbarWarpNode_selected);
  1542. //this.listNode.setStyles(this.css.cloumnListNode_selected);
  1543. new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 100}).toElementEdge(this.node);
  1544. //new Fx.Scroll(this.view.designer.propertyDomArea, {"wheelStops": false, "duration": 100}).toElement(this.listNode);
  1545. this.view.currentSelectedModule = this;
  1546. this.isSelected = true;
  1547. //this._showActions();
  1548. this.showProperty();
  1549. },
  1550. unSelected: function(){
  1551. this.view.currentSelectedModule = null;
  1552. this.node.setStyles(this.css.toolbarWarpNode)
  1553. //this.listNode.setStyles(this.css.cloumnListNode);
  1554. this.isSelected = false;
  1555. //this._hideActions();
  1556. this.hideProperty();
  1557. },
  1558. resetTextNode: function(){
  1559. var listText = (this.json.selectType=="attribute") ? (this.json.attribute || "") : (this.json.path || "");
  1560. if (!listText) listText = "unnamed";
  1561. this.textNode.set("text", this.json.displayName);
  1562. this.listNode.getLast().set("text", this.json.displayName+"("+listText+")");
  1563. },
  1564. _createNode: function(callback){
  1565. this.node = new Element("div", {
  1566. "id": this.json.id,
  1567. "MWFType": "actionbar",
  1568. "styles": this.css.toolbarWarpNode,
  1569. "events": {
  1570. "selectstart": function(e){
  1571. e.preventDefault();
  1572. }
  1573. }
  1574. }).inject(this.container );
  1575. this.toolbarNode = new Element("div").inject(this.node);
  1576. this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {"style": this.json.style}, this);
  1577. if (!this.json.actionStyles){
  1578. this.json.actionStyles = Object.clone(this.toolbarWidget.css);
  1579. }else{
  1580. this.toolbarWidget.css = Object.clone(this.json.actionStyles);
  1581. }
  1582. //MWF.getJSON(this.path+"toolbars.json", function(json){
  1583. // this.json.defaultTools = json;
  1584. // this.setToolbars(json, this.toolbarNode);
  1585. // debugger;
  1586. // this.toolbarWidget.load();
  1587. //}.bind(this), false);
  1588. if (this.json.defaultTools){
  1589. var json = Array.clone(this.json.defaultTools);
  1590. //if (this.json.tools) json.append(this.json.tools);
  1591. this.setToolbars(json, this.toolbarNode);
  1592. if (this.json.tools){
  1593. this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  1594. }
  1595. this.toolbarWidget.load();
  1596. this._setEditStyle_custom("hideSystemTools");
  1597. //json = null;
  1598. }else{
  1599. MWF.getJSON(this.path+"toolbars.json", function(json){
  1600. this.json.defaultTools = json;
  1601. var json = Array.clone(this.json.defaultTools);
  1602. //if (this.json.tools) json.append(this.json.tools);
  1603. this.setToolbars(json, this.toolbarNode);
  1604. if (this.json.tools){
  1605. this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  1606. }
  1607. this.toolbarWidget.load();
  1608. this._setEditStyle_custom("hideSystemTools");
  1609. //json = null;
  1610. }.bind(this), false);
  1611. }
  1612. },
  1613. _refreshActionbar: function(){
  1614. //if (this.form.options.mode == "Mobile"){
  1615. // this.node.set("text", MWF.APPFD.LP.notice.notUseModuleInMobile+"("+this.moduleName+")");
  1616. // this.node.setStyles({"height": "24px", "line-height": "24px", "background-color": "#999"});
  1617. //}else{
  1618. this.toolbarNode = this.node.getFirst("div");
  1619. this.toolbarNode.empty();
  1620. this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {"style": this.json.style}, this);
  1621. if (!this.json.actionStyles) this.json.actionStyles = Object.clone(this.toolbarWidget.css);
  1622. this.toolbarWidget.css = this.json.actionStyles;
  1623. if (this.json.defaultTools){
  1624. var json = Array.clone(this.json.defaultTools);
  1625. //if (this.json.tools) json.append(this.json.tools);
  1626. this.setToolbars(json, this.toolbarNode);
  1627. if (this.json.tools){
  1628. this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  1629. }
  1630. this.toolbarWidget.load();
  1631. //json = null;
  1632. }else{
  1633. MWF.getJSON(this.path+"toolbars.json", function(json){
  1634. this.json.defaultTools = json;
  1635. var json = Array.clone(this.json.defaultTools);
  1636. //if (this.json.tools) json.append(this.json.tools);
  1637. this.setToolbars(json, this.toolbarNode);
  1638. if (this.json.tools){
  1639. this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  1640. }
  1641. this.toolbarWidget.load();
  1642. //json = null;
  1643. }.bind(this), false);
  1644. }
  1645. //}
  1646. },
  1647. _resetActionbar: function(){
  1648. //if (this.form.options.mode == "Mobile"){
  1649. // this.node.set("text", MWF.APPFD.LP.notice.notUseModuleInMobile+"("+this.moduleName+")");
  1650. // this.node.setStyles({"height": "24px", "line-height": "24px", "background-color": "#999"});
  1651. //}else{
  1652. this.toolbarNode = this.node.getFirst("div");
  1653. this.toolbarNode.empty();
  1654. this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {"style": this.json.style}, this);
  1655. if (!this.json.actionStyles){
  1656. this.json.actionStyles = Object.merge( Object.clone( this.toolbarWidget.css ), this.json.forceStyles || {} );
  1657. }else{
  1658. this.toolbarWidget.css = Object.merge( Object.clone( this.json.actionStyles ), this.toolbarWidget.css, this.json.forceStyles || {} );
  1659. this.json.actionStyles = Object.clone(this.toolbarWidget.css);
  1660. }
  1661. if (this.json.defaultTools){
  1662. var json = Array.clone(this.json.defaultTools);
  1663. //if (this.json.tools) json.append(this.json.tools);
  1664. this.setToolbars(json, this.toolbarNode);
  1665. if (this.json.tools){
  1666. this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  1667. }
  1668. this.toolbarWidget.load();
  1669. //json = null;
  1670. }else{
  1671. MWF.getJSON(this.path+"toolbars.json", function(json){
  1672. this.json.defaultTools = json;
  1673. var json = Array.clone(this.json.defaultTools);
  1674. //if (this.json.tools) json.append(this.json.tools);
  1675. this.setToolbars(json, this.toolbarNode);
  1676. if (this.json.tools){
  1677. this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  1678. }
  1679. this.toolbarWidget.load();
  1680. //json = null;
  1681. }.bind(this), false);
  1682. }
  1683. //}
  1684. },
  1685. setToolbars: function(tools, node){
  1686. tools.each(function(tool){
  1687. var actionNode = new Element("div", {
  1688. "MWFnodetype": tool.type,
  1689. "MWFButtonImage": this.imagePath_default+""+this.options.style+"/actionbar/"+( this.json.iconStyle || "default" )+"/"+tool.img,
  1690. "title": tool.title,
  1691. "MWFButtonAction": tool.action,
  1692. "MWFButtonText": tool.text
  1693. }).inject(node);
  1694. if( this.json.iconOverStyle ){
  1695. actionNode.set("MWFButtonImageOver" , this.imagePath_default+""+this.options.style+"/actionbar/"+this.json.iconOverStyle+"/"+tool.img );
  1696. }
  1697. this.systemTools.push(actionNode);
  1698. if (tool.sub){
  1699. var subNode = node.getLast();
  1700. this.setToolbars(tool.sub, subNode);
  1701. }
  1702. }.bind(this));
  1703. },
  1704. setCustomToolbars: function(tools, node){
  1705. //var style = (this.json.style || "default").indexOf("red") > -1 ? "red" : "blue";
  1706. var path = "";
  1707. if( this.json.customIconStyle ){
  1708. path = this.json.customIconStyle+ "/";
  1709. }
  1710. tools.each(function(tool){
  1711. var actionNode = new Element("div", {
  1712. "MWFnodetype": tool.type,
  1713. "MWFButtonImage": this.imagePath_custom+""+this.options.customImageStyle +"/custom/"+path+tool.img,
  1714. "title": tool.title,
  1715. "MWFButtonAction": tool.action,
  1716. "MWFButtonText": tool.text
  1717. }).inject(node);
  1718. if( this.json.customIconOverStyle ){
  1719. actionNode.set("MWFButtonImageOver" , this.imagePath_custom+""+this.options.customImageStyle +"/custom/"+this.json.customIconOverStyle+ "/" +tool.img );
  1720. }
  1721. this.customTools.push(actionNode);
  1722. if (tool.sub){
  1723. var subNode = node.getLast();
  1724. this.setToolbars(tool.sub, subNode);
  1725. }
  1726. }.bind(this));
  1727. },
  1728. _setEditStyle_custom: function(name){
  1729. if (name=="hideSystemTools"){
  1730. if (this.json.hideSystemTools){
  1731. this.systemTools.each(function(tool){
  1732. tool.setStyle("display", "none");
  1733. });
  1734. }else{
  1735. this.systemTools.each(function(tool){
  1736. tool.setStyle("display", "block");
  1737. });
  1738. }
  1739. }
  1740. if (name=="defaultTools" || name=="tools" || name==="actionStyles"){
  1741. this._refreshActionbar();
  1742. }
  1743. }
  1744. });
  1745. MWF.require("MWF.widget.Paging", null, false);
  1746. MWF.xApplication.query.ViewDesigner.View.Paging = new Class({
  1747. Extends: MWF.xApplication.query.ViewDesigner.View.$Module,
  1748. options : {
  1749. "style" : "default"
  1750. },
  1751. initialize: function(json, jsonList, view, options){
  1752. this.setOptions( options );
  1753. this.propertyPath = "/x_component_query_ViewDesigner/$View/paging.html";
  1754. this.view = view;
  1755. this.json = json;
  1756. this.jsonList = jsonList;
  1757. this.css = this.view.css;
  1758. this.container = this.view.pagingNode;
  1759. this.moduleName = "paging";
  1760. this.load();
  1761. },
  1762. load: function(){
  1763. this.systemTools = [];
  1764. this.customTools = [];
  1765. if( !this.json ){
  1766. this.loadDefaultJson(function(){
  1767. this._load();
  1768. }.bind(this));
  1769. }else{
  1770. this._load();
  1771. }
  1772. },
  1773. _load : function(){
  1774. this.json.moduleName = this.moduleName;
  1775. this._createNode();
  1776. this.setEvent();
  1777. },
  1778. loadDefaultJson: function(callback){
  1779. var url = this.view.path+"paging.json";
  1780. MWF.getJSON(url, {
  1781. "onSuccess": function(obj){
  1782. this.view.designer.actions.getUUID(function(id){
  1783. obj.id=id;
  1784. this.json = obj;
  1785. this.jsonList.push( this.json );
  1786. if (callback) callback(obj);
  1787. }.bind(this));
  1788. }.bind(this),
  1789. "onerror": function(text){
  1790. this.view.designer.notice(text, "error");
  1791. }.bind(this),
  1792. "onRequestFailure": function(xhr){
  1793. this.view.designer.notice(xhr.responseText, "error");
  1794. }.bind(this)
  1795. });
  1796. },
  1797. setTemplateStyles: function(styles){
  1798. if( this.json.buttonStyle === "rect" ){
  1799. this.json.style = styles.style_rect;
  1800. }else if( this.json.buttonStyle === "round" ){
  1801. this.json.style = styles.style_round;
  1802. }else{
  1803. this.json.style = styles.style;
  1804. }
  1805. this.json.forceStyles = styles.forceStyles || "";
  1806. },
  1807. clearTemplateStyles: function(styles){
  1808. this.json.style = "blue_round";
  1809. this.json.forceStyles = "";
  1810. },
  1811. setAllStyles: function(){
  1812. this._resetPaging();
  1813. },
  1814. setEvent: function(){
  1815. this.node.addEvents({
  1816. "click": function(e){this.selected(); e.stopPropagation();}.bind(this),
  1817. "mouseover": function(){if (!this.isSelected) this.node.setStyles(this.css.pagingWarpNode_over)}.bind(this),
  1818. "mouseout": function(){if (!this.isSelected) this.node.setStyles(this.css.pagingWarpNode) }.bind(this)
  1819. });
  1820. },
  1821. selected: function(){
  1822. if (this.view.currentSelectedModule){
  1823. if (this.view.currentSelectedModule==this){
  1824. return true;
  1825. }else{
  1826. this.view.currentSelectedModule.unSelected();
  1827. }
  1828. }
  1829. this.node.setStyles(this.css.pagingWarpNode_selected);
  1830. new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 100}).toElementEdge(this.node);
  1831. this.view.currentSelectedModule = this;
  1832. this.isSelected = true;
  1833. this.showProperty();
  1834. },
  1835. unSelected: function(){
  1836. this.view.currentSelectedModule = null;
  1837. this.node.setStyles(this.css.pagingWarpNode);
  1838. this.isSelected = false;
  1839. this.hideProperty();
  1840. },
  1841. resetTextNode: function(){
  1842. var listText = (this.json.selectType=="attribute") ? (this.json.attribute || "") : (this.json.path || "");
  1843. if (!listText) listText = "unnamed";
  1844. this.textNode.set("text", this.json.displayName);
  1845. this.listNode.getLast().set("text", this.json.displayName+"("+listText+")");
  1846. },
  1847. _createNode: function(callback){
  1848. this.node = new Element("div", {
  1849. "id": this.json.id,
  1850. "MWFType": "paging",
  1851. "styles": this.css.pagingWarpNode,
  1852. "events": {
  1853. "selectstart": function(e){
  1854. e.preventDefault();
  1855. }
  1856. }
  1857. }).inject(this.container );
  1858. this.pagingNode = new Element("div").inject(this.node);
  1859. this.loadWidget();
  1860. // this.pagingWidget = new MWF.widget.Paging(this.pagingNode, {"style": this.json.style}, this);
  1861. // if (!this.json.pagingStyles){
  1862. // this.json.pagingStyles = Object.clone(this.pagingWidget.css);
  1863. // }
  1864. // this.pagingWidget.load();
  1865. },
  1866. loadWidget : function( isReset ){
  1867. var visiblePages = this.json.visiblePages ? this.json.visiblePages.toInt() : 9;
  1868. this.pagingWidget = new o2.widget.Paging(this.pagingNode, {
  1869. style : this.json.style || "default",
  1870. countPerPage: 20, //this.json.pageSize || this.options.perPageCount,
  1871. visiblePages: visiblePages,
  1872. currentPage: 1,
  1873. itemSize: visiblePages * 20 * 3,
  1874. // pageSize: this.pages,
  1875. hasNextPage: typeOf( this.json.hasPreNextPage ) === "boolean" ? this.json.hasPreNextPage : true,
  1876. hasPrevPage: typeOf( this.json.hasPreNextPage ) === "boolean" ? this.json.hasPreNextPage : true,
  1877. hasTruningBar: typeOf( this.json.hasTruningBar ) === "boolean" ? this.json.hasTruningBar : true,
  1878. hasBatchTuring: typeOf( this.json.hasBatchTuring ) === "boolean" ? this.json.hasBatchTuring : true,
  1879. hasFirstPage: typeOf( this.json.hasFirstLastPage ) === "boolean" ? this.json.hasFirstLastPage : true,
  1880. hasLastPage: typeOf( this.json.hasFirstLastPage ) === "boolean" ? this.json.hasFirstLastPage : true,
  1881. hasJumper: typeOf( this.json.hasPageJumper ) === "boolean" ? this.json.hasPageJumper : true,
  1882. hiddenWithDisable: false,
  1883. // hiddenWithNoItem: true,
  1884. text: {
  1885. prePage: this.json.prePageText,
  1886. nextPage: this.json.nextPageText,
  1887. firstPage: this.json.firstPageText,
  1888. lastPage: this.json.lastPageText
  1889. },
  1890. onJumpingPage : function( pageNum, itemNum ){
  1891. }.bind(this),
  1892. onPostLoad : function () {
  1893. this.view.setContentHeight()
  1894. // if(this.setContentHeightFun)this.setContentHeightFun();
  1895. }.bind(this)
  1896. }, isReset ? {} : (this.json.pagingStyles || {}));
  1897. if( isReset ){
  1898. if (!this.json.pagingStyles){
  1899. this.json.pagingStyles = Object.merge( Object.clone( this.pagingWidget.css ), this.json.forceStyles || {} );
  1900. }else{
  1901. this.pagingWidget.css = Object.merge( Object.clone( this.json.pagingStyles ), this.pagingWidget.css, this.json.forceStyles || {} );
  1902. this.json.pagingStyles = Object.clone(this.pagingWidget.css);
  1903. }
  1904. }else{
  1905. if (!this.json.pagingStyles){
  1906. this.json.pagingStyles = Object.clone(this.pagingWidget.css);
  1907. }
  1908. }
  1909. this.pagingWidget.load();
  1910. },
  1911. _resetPaging : function(){
  1912. this.pagingNode.empty();
  1913. this.loadWidget( true );
  1914. },
  1915. _refreshPaging: function(){
  1916. this.pagingNode.empty();
  1917. this.loadWidget();
  1918. },
  1919. _setEditStyle_custom: function(name, obj, oldValue){
  1920. if ( ["hasTruningBar","visiblePages","hasBatchTuring",
  1921. "hasFirstLastPage","hasPreNextPage","hasPageJumper",
  1922. "firstPageText","lastPageText","prePageText","nextPageText",
  1923. "pagingStyles"].contains(name)){
  1924. this._refreshPaging();
  1925. }else if( name === "buttonStyle" ){
  1926. if( this.json.buttonStyle === "rect" ){
  1927. this.json.style = this.view.templateStyles.paging.style_rect;
  1928. }else{
  1929. this.json.style = this.view.templateStyles.paging.style_round;
  1930. }
  1931. this._resetPaging();
  1932. }
  1933. }
  1934. });