View.js 88 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107
  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. debugger;
  619. var file = (this.stylesList && this.json.data.viewStyleType) ? this.stylesList[this.json.data.viewStyleType].file : null;
  620. var extendFile = (this.stylesList && this.json.data.viewStyleType) ? this.stylesList[this.json.data.viewStyleType].extendFile : null;
  621. this.loadTemplateStyles( file, extendFile, function( templateStyles ){
  622. this.templateStyles = templateStyles;
  623. var oldFile, oldExtendFile;
  624. if( oldValue && this.stylesList[oldValue] ){
  625. oldFile = this.stylesList[oldValue].file;
  626. oldExtendFile = this.stylesList[oldValue].extendFile;
  627. }
  628. this.loadTemplateStyles( oldFile, oldExtendFile, function( oldTemplateStyles ){
  629. this.json.data.styleConfig = (this.stylesList && this.json.data.viewStyleType) ? this.stylesList[this.json.data.viewStyleType] : null;
  630. if (oldTemplateStyles["view"]) this.clearTemplateStyles(oldTemplateStyles["view"]);
  631. if (this.templateStyles["view"]) this.setTemplateStyles(this.templateStyles["view"]);
  632. this.setAllStyles();
  633. this.actionbarList.each( function (module) {
  634. if (oldTemplateStyles["actionbar"]){
  635. module.clearTemplateStyles(oldTemplateStyles["actionbar"]);
  636. }
  637. module.setStyleTemplate();
  638. module.setAllStyles();
  639. })
  640. this.pagingList.each( function (module) {
  641. if (oldTemplateStyles["paging"]){
  642. module.clearTemplateStyles(oldTemplateStyles["paging"]);
  643. }
  644. module.setStyleTemplate();
  645. module.setAllStyles();
  646. });
  647. // this.moduleList.each(function(module){
  648. // if (oldTemplateStyles[module.moduleName]){
  649. // module.clearTemplateStyles(oldTemplateStyles[module.moduleName]);
  650. // }
  651. // module.setStyleTemplate();
  652. // module.setAllStyles();
  653. // }.bind(this));
  654. }.bind(this))
  655. }.bind(this))
  656. }
  657. if (name=="data.viewStyles"){
  658. this.setCustomStyles();
  659. }
  660. },
  661. setAllStyles: function(){
  662. // this.setPropertiesOrStyles("styles");
  663. // this.setPropertiesOrStyles("properties");
  664. this.setCustomStyles();
  665. this.reloadMaplist();
  666. },
  667. reloadMaplist: function(){
  668. if (this.property) Object.each(this.property.maplists, function(map, name){ map.reload(this.json[name]);}.bind(this));
  669. },
  670. // setPropertiesOrStyles: function(name){
  671. // if (name=="styles"){
  672. // this.setCustomStyles();
  673. // }
  674. // if (name=="properties"){
  675. // this.node.setProperties(this.json.properties);
  676. // }
  677. // },
  678. setCustomStyles: function(){
  679. this.items.each( function( item ){
  680. item.setCustomStyles()
  681. }.bind(this));
  682. // var border = this.node.getStyle("border");
  683. // this.node.clearStyles();
  684. // this.node.setStyles((this.options.mode==="Mobile") ? this.css.formMobileNode : this.css.formNode);
  685. // var y = this.container.getStyle("height");
  686. // y = (y) ? y.toInt()-2 : this.container.getSize().y-2;
  687. // this.node.setStyle("min-height", ""+y+"px");
  688. //
  689. // if (this.initialStyles) this.node.setStyles(this.initialStyles);
  690. // this.node.setStyle("border", border);
  691. //
  692. // Object.each(this.json.styles, function(value, key){
  693. // var reg = /^border\w*/ig;
  694. // if (!key.test(reg)){
  695. // this.node.setStyle(key, value);
  696. // }
  697. // }.bind(this));
  698. },
  699. loadTemplateStyle : function( callback ){
  700. this.loadStylesList(function(){
  701. var oldStyleValue = "";
  702. if ((!this.json.data.viewStyleType) || !this.stylesList[this.json.data.viewStyleType]) this.json.data.viewStyleType="default";
  703. // if (this.options.mode=="Mobile"){
  704. // if (this.json.viewStyleType != "defaultMobile"){
  705. // var styles = this.stylesList[this.json.viewStyleType];
  706. // if( !styles || typeOf(styles.mode)!=="array" || !styles.mode.contains( "mobile" ) ){
  707. // oldStyleValue = this.json.viewStyleType;
  708. // this.json.viewStyleType = "defaultMobile";
  709. // }
  710. // }
  711. // }
  712. this.loadTemplateStyles( this.stylesList[this.json.data.viewStyleType].file, this.stylesList[this.json.data.viewStyleType].extendFile,
  713. function( templateStyles ){
  714. this.templateStyles = templateStyles;
  715. debugger;
  716. // this.loadDomModules();
  717. if( !this.json.data.viewStyleType )this.json.data.viewStyleType = "default";
  718. if ( this.templateStyles && this.templateStyles["view"]){
  719. if(!this.json.data.viewStyles){
  720. this.json.data.viewStyles = Object.clone(this.templateStyles["view"]);
  721. }else{
  722. this.setTemplateStyles(this.templateStyles["view"]);
  723. }
  724. }
  725. this.setCustomStyles();
  726. // this.node.setProperties(this.json.data.properties);
  727. if(callback)callback();
  728. // this.setNodeEvents();
  729. // if (this.options.mode=="Mobile"){
  730. // if (oldStyleValue) this._setEditStyle("viewStyleType", null, oldStyleValue);
  731. // }
  732. }.bind(this)
  733. );
  734. }.bind(this));
  735. },
  736. removeStyles: function(from, to){
  737. if (this.json.data.viewStyles[to]){
  738. Object.each(from, function(style, key){
  739. if (this.json.data.viewStyles[to][key] && this.json.data.viewStyles[to][key]==style){
  740. delete this.json.data.viewStyles[to][key];
  741. }
  742. }.bind(this));
  743. }
  744. },
  745. copyStyles: function(from, to){
  746. if (!this.json.data.viewStyles[to]) this.json.data.viewStyles[to] = {};
  747. Object.each(from, function(style, key){
  748. if (!this.json.data.viewStyles[to][key]) this.json.data.viewStyles[to][key] = style;
  749. }.bind(this));
  750. },
  751. // clearTemplateStyles: function(styles){
  752. // if (styles){
  753. // if (styles.styles) this.removeStyles(styles.styles, "styles");
  754. // if (styles.properties) this.removeStyles(styles.properties, "properties");
  755. // }
  756. // },
  757. // setTemplateStyles: function(styles){
  758. // if (styles.styles) this.copyStyles(styles.styles, "styles");
  759. // if (styles.properties) this.copyStyles(styles.properties, "properties");
  760. // },
  761. clearTemplateStyles: function(styles){
  762. if (styles){
  763. if (styles.container) this.removeStyles(styles.container, "container");
  764. if (styles.table) this.removeStyles(styles.table, "table");
  765. if (styles.titleTr) this.removeStyles(styles.titleTr, "titleTr");
  766. if (styles.titleTd) this.removeStyles(styles.titleTd, "titleTd");
  767. if (styles.contentTr) this.removeStyles(styles.contentTr, "contentTr");
  768. if (styles.contentSelectedTr) this.removeStyles(styles.contentSelectedTr, "contentSelectedTr");
  769. if (styles.contentTd) this.removeStyles(styles.contentTd, "contentTd");
  770. if (styles.contentGroupTd) this.removeStyles(styles.contentGroupTd, "contentGroupTd");
  771. if (styles.groupCollapseNode) this.removeStyles(styles.groupCollapseNode, "groupCollapseNode");
  772. if (styles.groupExpandNode) this.removeStyles(styles.groupExpandNode, "groupExpandNode");
  773. if (styles.checkboxNode) this.removeStyles(styles.checkboxNode, "checkboxNode");
  774. if (styles.checkedCheckboxNode) this.removeStyles(styles.checkedCheckboxNode, "checkedCheckboxNode");
  775. if (styles.radioNode) this.removeStyles(styles.radioNode, "radioNode");
  776. if (styles.checkedRadioNode) this.removeStyles(styles.checkedRadioNode, "checkedRadioNode");
  777. if (styles.tableProperties) this.removeStyles(styles.tableProperties, "tableProperties");
  778. }
  779. },
  780. setTemplateStyles: function(styles){
  781. if (styles.container) this.copyStyles(styles.container, "container");
  782. if (styles.table) this.copyStyles(styles.table, "table");
  783. if (styles.titleTr) this.copyStyles(styles.titleTr, "titleTr");
  784. if (styles.titleTd) this.copyStyles(styles.titleTd, "titleTd");
  785. if (styles.contentTr) this.copyStyles(styles.contentTr, "contentTr");
  786. if (styles.contentSelectedTr) this.copyStyles(styles.contentSelectedTr, "contentSelectedTr");
  787. if (styles.contentTd) this.copyStyles(styles.contentTd, "contentTd");
  788. if (styles.contentGroupTd) this.copyStyles(styles.contentGroupTd, "contentGroupTd");
  789. if (styles.groupCollapseNode) this.copyStyles(styles.groupCollapseNode, "groupCollapseNode");
  790. if (styles.groupExpandNode) this.copyStyles(styles.groupExpandNode, "groupExpandNode");
  791. if (styles.checkboxNode) this.copyStyles(styles.checkboxNode, "checkboxNode");
  792. if (styles.checkedCheckboxNode) this.copyStyles(styles.checkedCheckboxNode, "checkedCheckboxNode");
  793. if (styles.radioNode) this.copyStyles(styles.radioNode, "radioNode");
  794. if (styles.checkedRadioNode) this.copyStyles(styles.checkedRadioNode, "checkedRadioNode");
  795. if (styles.tableProperties) this.copyStyles(styles.tableProperties, "tableProperties");
  796. },
  797. loadTemplateStyles : function( file, extendFile, callback ){
  798. if( !file ){
  799. if (callback) callback({});
  800. return;
  801. }
  802. this.templateStylesList = this.templateStylesList || {};
  803. if( this.templateStylesList[file] ){
  804. if (callback) callback(this.templateStylesList[file]);
  805. return;
  806. }
  807. this.loadTemplateStyleFile( file, function( json_file ){
  808. this.loadTemplateExtendStyleFile( extendFile, function( json_extend ){
  809. this.templateStylesList[file] = Object.merge( json_file, json_extend );
  810. if (callback) callback(this.templateStylesList[file]);
  811. }.bind(this))
  812. }.bind(this))
  813. },
  814. loadTemplateStyleFile : function(file, callback ){
  815. if( !file ){
  816. if (callback) callback({});
  817. return;
  818. }
  819. var stylesUrl = "/x_component_query_ViewDesigner/$View/skin/"+file;
  820. MWF.getJSON(stylesUrl,{
  821. "onSuccess": function(responseJSON){
  822. //this.templateStylesList[file] = responseJSON;
  823. if (callback) callback(responseJSON);
  824. }.bind(this),
  825. "onRequestFailure": function(){
  826. if (callback) callback({});
  827. }.bind(this),
  828. "onError": function(){
  829. if (callback) callback({});
  830. }.bind(this)
  831. }
  832. );
  833. },
  834. loadTemplateExtendStyleFile : function(extendFile, callback ){
  835. if( !extendFile ){
  836. if (callback) callback({});
  837. return;
  838. }
  839. var stylesUrl = "/x_component_query_ViewDesigner/$View/skin/"+extendFile;
  840. MWF.getJSON(stylesUrl,{
  841. "onSuccess": function(responseJSON){
  842. //this.templateStylesList[file] = responseJSON;
  843. if (callback) callback(responseJSON);
  844. }.bind(this),
  845. "onRequestFailure": function(){
  846. if (callback) callback({});
  847. }.bind(this),
  848. "onError": function(){
  849. if (callback) callback({});
  850. }.bind(this)
  851. }
  852. );
  853. },
  854. loadStylesList: function(callback){
  855. var configUrl = "/x_component_query_ViewDesigner/$View/skin/config.json";
  856. MWF.getJSON(configUrl,{
  857. "onSuccess": function(responseJSON){
  858. this.stylesList = responseJSON;
  859. if (callback) callback(this.stylesList);
  860. }.bind(this),
  861. "onRequestFailure": function(){
  862. this.stylesList = {};
  863. if (callback) callback(this.stylesList);
  864. }.bind(this),
  865. "onError": function(){
  866. this.stylesList = {};
  867. if (callback) callback(this.stylesList);
  868. }.bind(this)
  869. }
  870. );
  871. },
  872. saveAs: function(){
  873. var form = new MWF.xApplication.query.ViewDesigner.View.NewNameForm(this, {
  874. name : this.data.name + "_" + MWF.xApplication.query.ViewDesigner.LP.copy,
  875. query : this.data.query || this.data.application,
  876. queryName : this.data.queryName || this.data.applicationName
  877. }, {
  878. onSave : function( data, callback ){
  879. this._saveAs( data, callback );
  880. }.bind(this)
  881. }, {
  882. app: this.designer
  883. });
  884. form.edit()
  885. },
  886. cloneObject : function( obj ){
  887. if (null == obj || "object" != typeof obj) return obj;
  888. if ( typeof obj.length==='number'){ //数组
  889. //print( "array" );
  890. var copy = [];
  891. for (var i = 0, len = obj.length; i < len; ++i) {
  892. copy[i] = this.cloneObject(obj[i]);
  893. }
  894. return copy;
  895. }else{
  896. var copy = {};
  897. for (var attr in obj) {
  898. copy[attr] = this.cloneObject(obj[attr]);
  899. }
  900. return copy;
  901. }
  902. },
  903. _saveAs : function( data , callback){
  904. var _self = this;
  905. var d = this.cloneObject( this.data );
  906. d.isNewView = true;
  907. d.id = this.designer.actions.getUUID();
  908. d.name = data.name;
  909. d.alias = "";
  910. d.query = data.query;
  911. d.queryName = data.queryName;
  912. d.application = data.query;
  913. d.applicationName = data.queryName;
  914. d.pid = d.id + d.id;
  915. delete d[this.data.id+"viewFilterType"];
  916. d[d.id+"viewFilterType"]="custom";
  917. d.data.selectList.each( function( entry ){
  918. entry.id = (new MWF.widget.UUID).id;
  919. }.bind(this));
  920. this.designer.actions.saveView(d, function(json){
  921. this.designer.notice(this.designer.lp.notice.saveAs_success, "success", this.node, {"x": "left", "y": "bottom"});
  922. if (callback) callback();
  923. }.bind(this));
  924. }
  925. });
  926. MWF.xApplication.query.ViewDesigner.View.Column = new Class({
  927. initialize: function(json, view, next){
  928. this.propertyPath = "/x_component_query_ViewDesigner/$View/column.html";
  929. this.view = view;
  930. this.json = json;
  931. this.next = next;
  932. this.css = this.view.css;
  933. this.content = this.view.viewTitleTrNode;
  934. this.domListNode = this.view.domListNode;
  935. this.load();
  936. },
  937. load: function(){
  938. this.areaNode = new Element("td", {"styles": this.css.viewTitleColumnAreaNode});
  939. this.areaNode.store("column", this);
  940. if (this.next){
  941. this.areaNode.inject(this.next.areaNode, "before");
  942. }else{
  943. this.areaNode.inject(this.content);
  944. }
  945. this.node = new Element("div", {
  946. "styles": this.css.viewTitleColumnNode
  947. }).inject(this.areaNode);
  948. this.textNode = new Element("div", {
  949. "styles": this.css.viewTitleColumnTextNode,
  950. "text": this.json.displayName
  951. }).inject(this.node);
  952. this.createDomListItem();
  953. this._createIconAction();
  954. //if (!this.json.export) this.hideMode();
  955. this.setEvent();
  956. this.setCustomStyles();
  957. },
  958. setCustomStyles : function(){
  959. var viewStyles = this.view.json.data.viewStyles;
  960. var border = this.areaNode.getStyle("border");
  961. this.areaNode.clearStyles();
  962. this.areaNode.setStyles(this.css.viewTitleColumnAreaNode);
  963. // var y = this.container.getStyle("height");
  964. // y = (y) ? y.toInt()-2 : this.container.getSize().y-2;
  965. // this.node.setStyle("min-height", ""+y+"px");
  966. // if (this.initialStyles) this.node.setStyles(this.initialStyles);
  967. this.node.setStyle("border", border);
  968. Object.each(viewStyles.titleTd, function(value, key){
  969. var reg = /^border\w*/ig;
  970. if (!key.test(reg)){
  971. this.node.setStyle(key, value);
  972. }
  973. }.bind(this));
  974. },
  975. createDomListItem: function(){
  976. this.listNode = new Element("div", {"styles": this.css.cloumnListNode});
  977. if (this.next){
  978. this.listNode.inject(this.next.listNode, "before");
  979. }else{
  980. this.listNode.inject(this.domListNode);
  981. }
  982. var listIconNode = new Element("div", {"styles": this.css.cloumnListIconNode}).inject(this.listNode);
  983. var listTextNode = new Element("div", {"styles": this.css.cloumnListTextNode}).inject(this.listNode);
  984. this.resetTextNode();
  985. },
  986. setEvent: function(){
  987. this.node.addEvents({
  988. "click": function(e){this.selected(); e.stopPropagation();}.bind(this),
  989. "mouseover": function(){if (!this.isSelected) this.node.setStyles(this.css.viewTitleColumnNode_over)}.bind(this),
  990. "mouseout": function(){if (!this.isSelected) if (this.isError){
  991. this.node.setStyles(this.css.viewTitleColumnNode_error)
  992. }else{
  993. this.node.setStyles(this.css.viewTitleColumnNode)
  994. }}.bind(this)
  995. });
  996. this.listNode.addEvents({
  997. "click": function(e){this.selected(); e.stopPropagation();}.bind(this),
  998. "mouseover": function(){debugger; if (!this.isSelected) this.listNode.setStyles(this.css.cloumnListNode_over)}.bind(this),
  999. "mouseout": function(){if (!this.isSelected) this.listNode.setStyles(this.css.cloumnListNode)}.bind(this)
  1000. });
  1001. },
  1002. _createIconAction: function(){
  1003. if (!this.actionArea){
  1004. this.actionArea = new Element("div", {"styles": this.css.actionAreaNode}).inject(this.view.areaNode, "after");
  1005. this._createAction({
  1006. "name": "move",
  1007. "icon": "move1.png",
  1008. "event": "mousedown",
  1009. "action": "move",
  1010. "title": MWF.APPDVD.LP.action.move
  1011. });
  1012. this._createAction({
  1013. "name": "add",
  1014. "icon": "add.png",
  1015. "event": "click",
  1016. "action": "addColumn",
  1017. "title": MWF.APPDVD.LP.action.add
  1018. });
  1019. this._createAction({
  1020. "name": "delete",
  1021. "icon": "delete1.png",
  1022. "event": "click",
  1023. "action": "delete",
  1024. "title": MWF.APPDVD.LP.action["delete"]
  1025. });
  1026. }
  1027. },
  1028. _createAction: function(action){
  1029. var actionNode = new Element("div", {
  1030. "styles": this.css.actionNodeStyles,
  1031. "title": action.title
  1032. }).inject(this.actionArea);
  1033. actionNode.setStyle("background", "url("+this.view.path+this.view.options.style+"/action/"+action.icon+") no-repeat left center");
  1034. actionNode.addEvent(action.event, function(e){
  1035. this[action.action](e);
  1036. }.bind(this));
  1037. actionNode.addEvents({
  1038. "mouseover": function(e){
  1039. e.target.setStyle("border", "1px solid #999");
  1040. }.bind(this),
  1041. "mouseout": function(e){
  1042. e.target.setStyle("border", "1px solid #F1F1F1");
  1043. }.bind(this)
  1044. });
  1045. },
  1046. _setActionAreaPosition: function(){
  1047. var p = this.node.getPosition(this.view.areaNode.getOffsetParent());
  1048. var y = p.y-25;
  1049. var x = p.x;
  1050. this.actionArea.setPosition({"x": x, "y": y});
  1051. },
  1052. _showActions: function(){
  1053. if (this.actionArea){
  1054. this._setActionAreaPosition();
  1055. this.actionArea.setStyle("display", "block");
  1056. }
  1057. },
  1058. _hideActions: function(){
  1059. if (this.actionArea) this.actionArea.setStyle("display", "none");
  1060. },
  1061. selected: function(){
  1062. if (this.view.currentSelectedModule){
  1063. if (this.view.currentSelectedModule==this){
  1064. return true;
  1065. }else{
  1066. this.view.currentSelectedModule.unSelected();
  1067. }
  1068. }
  1069. this.node.setStyles(this.css.viewTitleColumnNode_selected);
  1070. this.listNode.setStyles(this.css.cloumnListNode_selected);
  1071. new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 100}).toElementEdge(this.node);
  1072. new Fx.Scroll(this.view.designer.propertyDomArea, {"wheelStops": false, "duration": 100}).toElement(this.listNode);
  1073. this.view.currentSelectedModule = this;
  1074. this.isSelected = true;
  1075. this._showActions();
  1076. this.showProperty();
  1077. },
  1078. unSelected: function(){
  1079. this.view.currentSelectedModule = null;
  1080. //this.node.setStyles(this.css.viewTitleColumnNode);
  1081. if (this.isError){
  1082. this.node.setStyles(this.css.viewTitleColumnNode_error)
  1083. }else{
  1084. this.node.setStyles(this.css.viewTitleColumnNode)
  1085. }
  1086. this.listNode.setStyles(this.css.cloumnListNode);
  1087. this.isSelected = false;
  1088. this._hideActions();
  1089. this.hideProperty();
  1090. },
  1091. showProperty: function(){
  1092. if (!this.property){
  1093. this.property = new MWF.xApplication.query.ViewDesigner.Property(this, this.view.designer.propertyContentArea, this.view.designer, {
  1094. "path": this.propertyPath,
  1095. "onPostLoad": function(){
  1096. this.property.show();
  1097. var processDiv = this.property.propertyContent.getElements("#"+this.json.id+"dataPathSelectedProcessArea");
  1098. var cmsDiv = this.property.propertyContent.getElements("#"+this.json.id+"dataPathSelectedCMSArea");
  1099. if (this.view.json.type=="cms"){
  1100. processDiv.setStyle("display", "none");
  1101. cmsDiv.setStyle("display", "block");
  1102. }else{
  1103. processDiv.setStyle("display", "block");
  1104. cmsDiv.setStyle("display", "none");
  1105. }
  1106. }.bind(this)
  1107. });
  1108. this.property.load();
  1109. }else{
  1110. this.property.show();
  1111. }
  1112. },
  1113. hideProperty: function(){
  1114. if (this.property) this.property.hide();
  1115. },
  1116. _setEditStyle: function(name, input, oldValue){
  1117. if (name=="displayName") this.resetTextNode();
  1118. if (name=="selectType") this.resetTextNode();
  1119. if (name=="attribute") this.resetTextNode();
  1120. if (name=="path") this.resetTextNode();
  1121. if (name=="column"){
  1122. this.view.json.data.orderList.each(function(order){
  1123. if (order.column==oldValue) order.column = this.json.column
  1124. }.bind(this));
  1125. if (this.view.json.data.group.column == oldValue) this.view.json.data.group.column = this.json.column;
  1126. }
  1127. },
  1128. resetTextNode: function(){
  1129. var listText = (this.json.selectType=="attribute") ? (this.json.attribute || "") : (this.json.path || "");
  1130. if (!listText) listText = "unnamed";
  1131. this.textNode.set("text", this.json.displayName);
  1132. this.listNode.getLast().set("text", this.json.displayName+"("+listText+")");
  1133. },
  1134. "delete": function(e){
  1135. var _self = this;
  1136. if (!e) e = this.node;
  1137. this.view.designer.confirm("warn", e, MWF.APPDVD.LP.notice.deleteColumnTitle, MWF.APPDVD.LP.notice.deleteColumn, 300, 120, function(){
  1138. _self.destroy();
  1139. this.close();
  1140. }, function(){
  1141. this.close();
  1142. }, null);
  1143. },
  1144. destroy: function(){
  1145. if (this.view.currentSelectedModule==this) this.view.currentSelectedModule = null;
  1146. if (this.actionArea) this.actionArea.destroy();
  1147. if (this.listNode) this.listNode.destroy();
  1148. if (this.property) this.property.propertyContent.destroy();
  1149. var idx = this.view.items.indexOf(this);
  1150. if (this.view.viewContentTableNode){
  1151. var trs = this.view.viewContentTableNode.getElements("tr");
  1152. trs.each(function(tr){
  1153. tr.deleteCell(idx);
  1154. }.bind(this));
  1155. }
  1156. if (this.view.json.data.selectList) this.view.json.data.selectList.erase(this.json);
  1157. if (this.view.json.data.calculate) if (this.view.json.data.calculate.calculateList) this.view.json.data.calculate.calculateList.erase(this.json);
  1158. this.view.items.erase(this);
  1159. if (this.view.property) this.view.property.loadStatColumnSelect();
  1160. this.areaNode.destroy();
  1161. this.view.selected();
  1162. this.view.setViewWidth();
  1163. MWF.release(this);
  1164. delete this;
  1165. },
  1166. addColumn: function(e, data){
  1167. MWF.require("MWF.widget.UUID", function(){
  1168. var json;
  1169. if (data){
  1170. json = Object.clone(data);
  1171. json.id = (new MWF.widget.UUID).id;
  1172. json.column = (new MWF.widget.UUID).id;
  1173. }else{
  1174. var id = (new MWF.widget.UUID).id;
  1175. json = {
  1176. "id": id,
  1177. "column": id,
  1178. "displayName": this.view.designer.lp.unnamed,
  1179. "orderType": "original"
  1180. };
  1181. }
  1182. var idx = this.view.json.data.selectList.indexOf(this.json);
  1183. this.view.json.data.selectList.splice(idx, 0, json);
  1184. var column = new MWF.xApplication.query.ViewDesigner.View.Column(json, this.view, this);
  1185. this.view.items.splice(idx, 0, column);
  1186. column.selected();
  1187. if (this.view.viewContentTableNode){
  1188. var trs = this.view.viewContentTableNode.getElements("tr");
  1189. trs.each(function(tr){
  1190. var td = tr.insertCell(idx);
  1191. td.setStyles(this.css.viewContentTdNode);
  1192. }.bind(this));
  1193. }
  1194. this.view.setViewWidth();
  1195. }.bind(this));
  1196. },
  1197. move: function(e){
  1198. var columnNodes = [];
  1199. this.view.items.each(function(item){
  1200. if (item!=this){
  1201. columnNodes.push(item.areaNode);
  1202. }
  1203. }.bind(this));
  1204. this._createMoveNode();
  1205. this._setNodeMove(columnNodes, e);
  1206. },
  1207. _createMoveNode: function(){
  1208. this.moveNode = new Element("div", {"text": this.node.get("text")});
  1209. this.moveNode.inject(this.view.designer.content);
  1210. this.moveNode.setStyles({
  1211. "border": "2px dashed #ffa200",
  1212. "opacity": 0.7,
  1213. "height": "30px",
  1214. "line-height": "30px",
  1215. "padding": "0px 10px",
  1216. "position": "absolute"
  1217. });
  1218. },
  1219. _setMoveNodePosition: function(e){
  1220. var x = e.page.x+2;
  1221. var y = e.page.y+2;
  1222. this.moveNode.positionTo(x, y);
  1223. },
  1224. createMoveFlagNode: function(){
  1225. this.moveFlagNode = new Element("td", {"styles": this.css.moveFlagNode});
  1226. },
  1227. _setNodeMove: function(droppables, e){
  1228. this._setMoveNodePosition(e);
  1229. var movePosition = this.moveNode.getPosition();
  1230. var moveSize = this.moveNode.getSize();
  1231. var contentPosition = this.content.getPosition();
  1232. var contentSize = this.content.getSize();
  1233. var nodeDrag = new Drag.Move(this.moveNode, {
  1234. "droppables": droppables,
  1235. "limit": {
  1236. "x": [contentPosition.x, contentPosition.x+contentSize.x],
  1237. "y": [movePosition.y, movePosition.y+moveSize.y]
  1238. },
  1239. "onEnter": function(dragging, inObj){
  1240. if (!this.moveFlagNode) this.createMoveFlagNode();
  1241. this.moveFlagNode.inject(inObj, "before");
  1242. }.bind(this),
  1243. "onLeave": function(dragging, inObj){
  1244. if (this.moveFlagNode){
  1245. this.moveFlagNode.dispose();
  1246. }
  1247. }.bind(this),
  1248. "onDrop": function(dragging, inObj){
  1249. if (inObj){
  1250. this.areaNode.inject(inObj, "before");
  1251. var column = inObj.retrieve("column");
  1252. this.listNode.inject(column.listNode, "before");
  1253. var idx = this.view.json.data.selectList.indexOf(column.json);
  1254. this.view.json.data.selectList.erase(this.json);
  1255. this.view.items.erase(this);
  1256. this.view.json.data.selectList.splice(idx, 0, this.json);
  1257. this.view.items.splice(idx, 0, this);
  1258. if (this.moveNode) this.moveNode.destroy();
  1259. if (this.moveFlagNode) this.moveFlagNode.destroy();
  1260. this._setActionAreaPosition();
  1261. }else{
  1262. if (this.moveNode) this.moveNode.destroy();
  1263. if (this.moveFlagNode) this.moveFlagNode.destroy();
  1264. }
  1265. }.bind(this),
  1266. "onCancel": function(dragging){
  1267. if (this.moveNode) this.moveNode.destroy();
  1268. if (this.moveFlagNode) this.moveFlagNode.destroy();
  1269. }.bind(this)
  1270. });
  1271. nodeDrag.start(e);
  1272. }
  1273. //hideMode: function(){
  1274. // if (!this.columnHideFlagNode){
  1275. // this.columnHideFlagNode = new Element("div", {"styles": this.view.css.columnHideFlagNode}).inject(this.node);
  1276. // }
  1277. //},
  1278. //showMode: function(){
  1279. // if (this.columnHideFlagNode) this.columnHideFlagNode.destroy();
  1280. // this.columnHideFlagNode = null;
  1281. //}
  1282. });
  1283. MWF.xApplication.query.ViewDesigner.View.$Module = MWF.QV$Module = new Class({
  1284. Extends: MWF.widget.Common,
  1285. Implements: [Options, Events],
  1286. copyStyles: function(from, to){
  1287. if (!this.json[to]) this.json[to] = {};
  1288. Object.each(from, function(style, key){
  1289. //if (!this.json[to][key])
  1290. this.json[to][key] = style;
  1291. }.bind(this));
  1292. },
  1293. removeStyles: function(from, to){
  1294. if (this.json[to]){
  1295. Object.each(from, function(style, key){
  1296. if (this.json[to][key] && this.json[to][key]==style){
  1297. delete this.json[to][key];
  1298. }
  1299. //if (this.json[from][key]){
  1300. // delete this.json[to][key];
  1301. //}
  1302. }.bind(this));
  1303. }
  1304. },
  1305. setTemplateStyles: function(styles){
  1306. if (styles.styles) this.copyStyles(styles.styles, "styles");
  1307. if (styles.properties) this.copyStyles(styles.properties, "properties");
  1308. },
  1309. clearTemplateStyles: function(styles){
  1310. if (styles){
  1311. if (styles.styles) this.removeStyles(styles.styles, "styles");
  1312. if (styles.properties) this.removeStyles(styles.properties, "properties");
  1313. }
  1314. },
  1315. setStyleTemplate: function(){
  1316. if( this.view.templateStyles && this.view.templateStyles[this.moduleName] ){
  1317. this.setTemplateStyles(this.view.templateStyles[this.moduleName]);
  1318. }
  1319. },
  1320. setAllStyles: function(){
  1321. this.setPropertiesOrStyles("styles");
  1322. this.setPropertiesOrStyles("inputStyles");
  1323. this.setPropertiesOrStyles("properties");
  1324. this.reloadMaplist();
  1325. },
  1326. showProperty: function(){
  1327. if (!this.property){
  1328. this.property = new MWF.xApplication.query.ViewDesigner.Property(this, this.view.designer.propertyContentArea, this.view.designer, {
  1329. "path": this.propertyPath,
  1330. "onPostLoad": function(){
  1331. this.property.show();
  1332. }.bind(this)
  1333. });
  1334. this.property.load();
  1335. }else{
  1336. this.property.show();
  1337. }
  1338. },
  1339. hideProperty: function(){
  1340. if (this.property) this.property.hide();
  1341. },
  1342. deletePropertiesOrStyles: function(name, key){
  1343. if (name=="properties"){
  1344. try{
  1345. this.node.removeProperty(key);
  1346. }catch(e){}
  1347. }
  1348. },
  1349. setPropertiesOrStyles: function(name){
  1350. if (name=="styles"){
  1351. try{
  1352. this.setCustomStyles();
  1353. }catch(e){}
  1354. }
  1355. if (name=="properties"){
  1356. try{
  1357. this.node.setProperties(this.json.properties);
  1358. }catch(e){}
  1359. }
  1360. },
  1361. setCustomNodeStyles: function(node, styles){
  1362. var border = node.getStyle("border");
  1363. node.clearStyles();
  1364. //node.setStyles(styles);
  1365. node.setStyle("border", border);
  1366. Object.each(styles, function(value, key){
  1367. var reg = /^border\w*/ig;
  1368. if (!key.test(reg)){
  1369. node.setStyle(key, value);
  1370. }
  1371. }.bind(this));
  1372. },
  1373. setCustomStyles: function(){
  1374. var border = this.node.getStyle("border");
  1375. this.node.clearStyles();
  1376. this.node.setStyles(this.css.moduleNode);
  1377. if (this.initialStyles) this.node.setStyles(this.initialStyles);
  1378. this.node.setStyle("border", border);
  1379. if (this.json.styles) Object.each(this.json.styles, function(value, key){
  1380. if ((value.indexOf("x_processplatform_assemble_surface")!=-1 || value.indexOf("x_portal_assemble_surface")!=-1)){
  1381. var host1 = MWF.Actions.getHost("x_processplatform_assemble_surface");
  1382. var host2 = MWF.Actions.getHost("x_portal_assemble_surface");
  1383. if (value.indexOf("/x_processplatform_assemble_surface")!==-1){
  1384. value = value.replace("/x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  1385. }else if (value.indexOf("x_processplatform_assemble_surface")!==-1){
  1386. value = value.replace("x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  1387. }
  1388. if (value.indexOf("/x_portal_assemble_surface")!==-1){
  1389. value = value.replace("/x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  1390. }else if (value.indexOf("x_portal_assemble_surface")!==-1){
  1391. value = value.replace("x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  1392. }
  1393. }
  1394. var reg = /^border\w*/ig;
  1395. if (!key.test(reg)){
  1396. if (key){
  1397. if (key.toString().toLowerCase()==="display"){
  1398. if (value.toString().toLowerCase()==="none"){
  1399. this.node.setStyle("opacity", 0.3);
  1400. }else{
  1401. this.node.setStyle("opacity", 1);
  1402. this.node.setStyle(key, value);
  1403. }
  1404. }else{
  1405. this.node.setStyle(key, value);
  1406. }
  1407. }
  1408. }
  1409. //this.node.setStyle(key, value);
  1410. }.bind(this));
  1411. },
  1412. _setEditStyle: function(name, obj, oldValue){
  1413. var title = "";
  1414. var text = "";
  1415. if (name==="name"){
  1416. title = this.json.name || this.json.id;
  1417. text = this.json.type.substr(this.json.type.lastIndexOf("$")+1, this.json.type.length);
  1418. this.treeNode.setText("<"+text+"> "+title);
  1419. }
  1420. if (name==="id"){
  1421. title = this.json.name || this.json.id;
  1422. if (!this.json.name){
  1423. text = this.json.type.substr(this.json.type.lastIndexOf("$")+1, this.json.type.length);
  1424. this.treeNode.setText("<"+text+"> "+this.json.id);
  1425. }
  1426. this.treeNode.setTitle(this.json.id);
  1427. this.node.set("id", this.json.id);
  1428. }
  1429. this._setEditStyle_custom(name, obj, oldValue);
  1430. },
  1431. reloadMaplist: function(){
  1432. if (this.property) Object.each(this.property.maplists, function(map, name){ map.reload(this.json[name]);}.bind(this));
  1433. },
  1434. getHtml: function(){
  1435. var copy = this.node.clone(true, true);
  1436. copy.clearStyles(true);
  1437. var html = copy.outerHTML;
  1438. copy.destroy();
  1439. return html;
  1440. },
  1441. getJson: function(){
  1442. var json = Object.clone(this.json);
  1443. var o = {};
  1444. o[json.id] = json;
  1445. return o;
  1446. }
  1447. })
  1448. MWF.require("MWF.widget.Toolbar", null, false);
  1449. MWF.xApplication.query.ViewDesigner.View.Actionbar = new Class({
  1450. Extends: MWF.xApplication.query.ViewDesigner.View.$Module,
  1451. options : {
  1452. "style" : "default",
  1453. "customImageStyle" : "default"
  1454. },
  1455. initialize: function(json, jsonList, view, options){
  1456. this.setOptions( options );
  1457. this.propertyPath = "/x_component_query_ViewDesigner/$View/actionbar.html";
  1458. this.path = "/x_component_query_ViewDesigner/$View/";
  1459. this.imagePath_default = "/x_component_query_ViewDesigner/$View/";
  1460. this.imagePath_custom = "/x_component_process_FormDesigner/Module/Actionbar/";
  1461. this.cssPath = "/x_component_query_ViewDesigner/$View/"+this.options.style+"/actionbar.wcss";
  1462. this.view = view;
  1463. this.json = json;
  1464. this.jsonList = jsonList;
  1465. this.css = this.view.css;
  1466. this.container = this.view.actionbarNode;
  1467. this.moduleName = "actionbar";
  1468. this.load();
  1469. },
  1470. load: function(){
  1471. this.systemTools = [];
  1472. this.customTools = [];
  1473. if( !this.json ){
  1474. this.loadDefaultJson(function(){
  1475. this._load()
  1476. }.bind(this));
  1477. }else{
  1478. this._load()
  1479. }
  1480. },
  1481. _load : function(){
  1482. this.json.moduleName = this.moduleName;
  1483. this._createNode();
  1484. //this._createIconAction();
  1485. //if (!this.json.export) this.hideMode();
  1486. this.setEvent();
  1487. },
  1488. loadDefaultJson: function(callback){
  1489. var url = this.path+"actionbar.json";
  1490. MWF.getJSON(url, {
  1491. "onSuccess": function(obj){
  1492. this.view.designer.actions.getUUID(function(id){
  1493. obj.id=id;
  1494. //obj.isNewView = true;
  1495. //obj.application = this.view.designer.application.id;
  1496. this.json = obj;
  1497. this.jsonList.push( this.json );
  1498. if (callback) callback(obj);
  1499. }.bind(this));
  1500. }.bind(this),
  1501. "onerror": function(text){
  1502. this.view.designer.notice(text, "error");
  1503. }.bind(this),
  1504. "onRequestFailure": function(xhr){
  1505. this.view.designer.notice(xhr.responseText, "error");
  1506. }.bind(this)
  1507. });
  1508. },
  1509. setTemplateStyles: function(styles){
  1510. this.json.style = styles.style;
  1511. this.json.iconOverStyle = styles.iconOverStyle || "";
  1512. this.json.customIconStyle = styles.customIconStyle;
  1513. this.json.customIconOverStyle = styles.customIconOverStyle || "";
  1514. this.json.forceStyles = styles.forceStyles || "";
  1515. },
  1516. clearTemplateStyles: function(styles){
  1517. this.json.style = "form";
  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. }
  1580. //MWF.getJSON(this.path+"toolbars.json", function(json){
  1581. // this.json.defaultTools = json;
  1582. // this.setToolbars(json, this.toolbarNode);
  1583. // debugger;
  1584. // this.toolbarWidget.load();
  1585. //}.bind(this), false);
  1586. if (this.json.defaultTools){
  1587. var json = Array.clone(this.json.defaultTools);
  1588. //if (this.json.tools) json.append(this.json.tools);
  1589. this.setToolbars(json, this.toolbarNode);
  1590. if (this.json.tools){
  1591. this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  1592. }
  1593. this.toolbarWidget.load();
  1594. this._setEditStyle_custom("hideSystemTools");
  1595. //json = null;
  1596. }else{
  1597. MWF.getJSON(this.path+"toolbars.json", function(json){
  1598. this.json.defaultTools = json;
  1599. var json = Array.clone(this.json.defaultTools);
  1600. //if (this.json.tools) json.append(this.json.tools);
  1601. this.setToolbars(json, this.toolbarNode);
  1602. if (this.json.tools){
  1603. this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  1604. }
  1605. this.toolbarWidget.load();
  1606. this._setEditStyle_custom("hideSystemTools");
  1607. //json = null;
  1608. }.bind(this), false);
  1609. }
  1610. },
  1611. _refreshActionbar: function(){
  1612. //if (this.form.options.mode == "Mobile"){
  1613. // this.node.set("text", MWF.APPFD.LP.notice.notUseModuleInMobile+"("+this.moduleName+")");
  1614. // this.node.setStyles({"height": "24px", "line-height": "24px", "background-color": "#999"});
  1615. //}else{
  1616. this.toolbarNode = this.node.getFirst("div");
  1617. this.toolbarNode.empty();
  1618. this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {"style": this.json.style}, this);
  1619. if (!this.json.actionStyles) this.json.actionStyles = Object.clone(this.toolbarWidget.css);
  1620. this.toolbarWidget.css = this.json.actionStyles;
  1621. if (this.json.defaultTools){
  1622. var json = Array.clone(this.json.defaultTools);
  1623. //if (this.json.tools) json.append(this.json.tools);
  1624. this.setToolbars(json, this.toolbarNode);
  1625. if (this.json.tools){
  1626. this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  1627. }
  1628. this.toolbarWidget.load();
  1629. //json = null;
  1630. }else{
  1631. MWF.getJSON(this.path+"toolbars.json", function(json){
  1632. this.json.defaultTools = json;
  1633. var json = Array.clone(this.json.defaultTools);
  1634. //if (this.json.tools) json.append(this.json.tools);
  1635. this.setToolbars(json, this.toolbarNode);
  1636. if (this.json.tools){
  1637. this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  1638. }
  1639. this.toolbarWidget.load();
  1640. //json = null;
  1641. }.bind(this), false);
  1642. }
  1643. //}
  1644. },
  1645. _resetActionbar: function(){
  1646. //if (this.form.options.mode == "Mobile"){
  1647. // this.node.set("text", MWF.APPFD.LP.notice.notUseModuleInMobile+"("+this.moduleName+")");
  1648. // this.node.setStyles({"height": "24px", "line-height": "24px", "background-color": "#999"});
  1649. //}else{
  1650. this.toolbarNode = this.node.getFirst("div");
  1651. this.toolbarNode.empty();
  1652. this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {"style": this.json.style}, this);
  1653. if (!this.json.actionStyles){
  1654. this.json.actionStyles = Object.merge( Object.clone( this.toolbarWidget.css ), this.json.forceStyles || {} );
  1655. }else{
  1656. this.toolbarWidget.css = Object.merge( Object.clone( this.json.actionStyles ), this.toolbarWidget.css, this.json.forceStyles || {} );
  1657. this.json.actionStyles = Object.clone(this.toolbarWidget.css);
  1658. }
  1659. if (this.json.defaultTools){
  1660. var json = Array.clone(this.json.defaultTools);
  1661. //if (this.json.tools) json.append(this.json.tools);
  1662. this.setToolbars(json, this.toolbarNode);
  1663. if (this.json.tools){
  1664. this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  1665. }
  1666. this.toolbarWidget.load();
  1667. //json = null;
  1668. }else{
  1669. MWF.getJSON(this.path+"toolbars.json", function(json){
  1670. this.json.defaultTools = json;
  1671. var json = Array.clone(this.json.defaultTools);
  1672. //if (this.json.tools) json.append(this.json.tools);
  1673. this.setToolbars(json, this.toolbarNode);
  1674. if (this.json.tools){
  1675. this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  1676. }
  1677. this.toolbarWidget.load();
  1678. //json = null;
  1679. }.bind(this), false);
  1680. }
  1681. //}
  1682. },
  1683. setToolbars: function(tools, node){
  1684. tools.each(function(tool){
  1685. var actionNode = new Element("div", {
  1686. "MWFnodetype": tool.type,
  1687. "MWFButtonImage": this.imagePath_default+""+this.options.style+"/actionbar/"+tool.img,
  1688. "title": tool.title,
  1689. "MWFButtonAction": tool.action,
  1690. "MWFButtonText": tool.text
  1691. }).inject(node);
  1692. if( this.json.iconOverStyle ){
  1693. actionNode.set("MWFButtonImageOver" , this.imagePath_default+""+this.options.style+"/actionbar/"+this.json.iconOverStyle+"/"+tool.img );
  1694. }
  1695. this.systemTools.push(actionNode);
  1696. if (tool.sub){
  1697. var subNode = node.getLast();
  1698. this.setToolbars(tool.sub, subNode);
  1699. }
  1700. }.bind(this));
  1701. },
  1702. setCustomToolbars: function(tools, node){
  1703. //var style = (this.json.style || "default").indexOf("red") > -1 ? "red" : "blue";
  1704. var path = "";
  1705. if( this.json.customIconStyle ){
  1706. path = this.json.customIconStyle+ "/";
  1707. }
  1708. tools.each(function(tool){
  1709. var actionNode = new Element("div", {
  1710. "MWFnodetype": tool.type,
  1711. "MWFButtonImage": this.imagePath_custom+""+this.options.customImageStyle +"/custom/"+path+tool.img,
  1712. "title": tool.title,
  1713. "MWFButtonAction": tool.action,
  1714. "MWFButtonText": tool.text
  1715. }).inject(node);
  1716. if( this.json.customIconOverStyle ){
  1717. actionNode.set("MWFButtonImageOver" , this.imagePath_custom+""+this.options.customImageStyle +"/custom/"+this.json.customIconOverStyle+ "/" +tool.img );
  1718. }
  1719. this.customTools.push(actionNode);
  1720. if (tool.sub){
  1721. var subNode = node.getLast();
  1722. this.setToolbars(tool.sub, subNode);
  1723. }
  1724. }.bind(this));
  1725. },
  1726. _setEditStyle_custom: function(name){
  1727. if (name=="hideSystemTools"){
  1728. if (this.json.hideSystemTools){
  1729. this.systemTools.each(function(tool){
  1730. tool.setStyle("display", "none");
  1731. });
  1732. }else{
  1733. this.systemTools.each(function(tool){
  1734. tool.setStyle("display", "block");
  1735. });
  1736. }
  1737. }
  1738. if (name=="defaultTools" || name=="tools" || name==="actionStyles"){
  1739. this._refreshActionbar();
  1740. }
  1741. }
  1742. });
  1743. MWF.require("MWF.widget.Paging", null, false);
  1744. MWF.xApplication.query.ViewDesigner.View.Paging = new Class({
  1745. Extends: MWF.xApplication.query.ViewDesigner.View.$Module,
  1746. options : {
  1747. "style" : "default"
  1748. },
  1749. initialize: function(json, jsonList, view, options){
  1750. this.setOptions( options );
  1751. this.propertyPath = "/x_component_query_ViewDesigner/$View/paging.html";
  1752. this.view = view;
  1753. this.json = json;
  1754. this.jsonList = jsonList;
  1755. this.css = this.view.css;
  1756. this.container = this.view.pagingNode;
  1757. this.moduleName = "paging";
  1758. this.load();
  1759. },
  1760. load: function(){
  1761. this.systemTools = [];
  1762. this.customTools = [];
  1763. if( !this.json ){
  1764. this.loadDefaultJson(function(){
  1765. this._load();
  1766. }.bind(this));
  1767. }else{
  1768. this._load();
  1769. }
  1770. },
  1771. _load : function(){
  1772. this.json.moduleName = this.moduleName;
  1773. this._createNode();
  1774. this.setEvent();
  1775. },
  1776. loadDefaultJson: function(callback){
  1777. var url = this.view.path+"paging.json";
  1778. MWF.getJSON(url, {
  1779. "onSuccess": function(obj){
  1780. this.view.designer.actions.getUUID(function(id){
  1781. obj.id=id;
  1782. this.json = obj;
  1783. this.jsonList.push( this.json );
  1784. if (callback) callback(obj);
  1785. }.bind(this));
  1786. }.bind(this),
  1787. "onerror": function(text){
  1788. this.view.designer.notice(text, "error");
  1789. }.bind(this),
  1790. "onRequestFailure": function(xhr){
  1791. this.view.designer.notice(xhr.responseText, "error");
  1792. }.bind(this)
  1793. });
  1794. },
  1795. setTemplateStyles: function(styles){
  1796. this.json.style = styles.style;
  1797. this.json.forceStyles = styles.forceStyles || "";
  1798. },
  1799. clearTemplateStyles: function(styles){
  1800. this.json.style = "default";
  1801. this.json.forceStyles = "";
  1802. },
  1803. setAllStyles: function(){
  1804. this._resetPaging();
  1805. },
  1806. setEvent: function(){
  1807. this.node.addEvents({
  1808. "click": function(e){this.selected(); e.stopPropagation();}.bind(this),
  1809. "mouseover": function(){if (!this.isSelected) this.node.setStyles(this.css.pagingWarpNode_over)}.bind(this),
  1810. "mouseout": function(){if (!this.isSelected) this.node.setStyles(this.css.pagingWarpNode) }.bind(this)
  1811. });
  1812. },
  1813. selected: function(){
  1814. if (this.view.currentSelectedModule){
  1815. if (this.view.currentSelectedModule==this){
  1816. return true;
  1817. }else{
  1818. this.view.currentSelectedModule.unSelected();
  1819. }
  1820. }
  1821. this.node.setStyles(this.css.pagingWarpNode_selected);
  1822. new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 100}).toElementEdge(this.node);
  1823. this.view.currentSelectedModule = this;
  1824. this.isSelected = true;
  1825. this.showProperty();
  1826. },
  1827. unSelected: function(){
  1828. this.view.currentSelectedModule = null;
  1829. this.node.setStyles(this.css.pagingWarpNode);
  1830. this.isSelected = false;
  1831. this.hideProperty();
  1832. },
  1833. resetTextNode: function(){
  1834. var listText = (this.json.selectType=="attribute") ? (this.json.attribute || "") : (this.json.path || "");
  1835. if (!listText) listText = "unnamed";
  1836. this.textNode.set("text", this.json.displayName);
  1837. this.listNode.getLast().set("text", this.json.displayName+"("+listText+")");
  1838. },
  1839. _createNode: function(callback){
  1840. this.node = new Element("div", {
  1841. "id": this.json.id,
  1842. "MWFType": "paging",
  1843. "styles": this.css.pagingWarpNode,
  1844. "events": {
  1845. "selectstart": function(e){
  1846. e.preventDefault();
  1847. }
  1848. }
  1849. }).inject(this.container );
  1850. this.pagingNode = new Element("div").inject(this.node);
  1851. this.loadWidget();
  1852. // this.pagingWidget = new MWF.widget.Paging(this.pagingNode, {"style": this.json.style}, this);
  1853. // if (!this.json.pagingStyles){
  1854. // this.json.pagingStyles = Object.clone(this.pagingWidget.css);
  1855. // }
  1856. // this.pagingWidget.load();
  1857. },
  1858. loadWidget : function( isReset ){
  1859. var visiblePages = this.json.visiblePages ? this.json.visiblePages.toInt() : 9;
  1860. this.pagingWidget = new o2.widget.Paging(this.pagingNode, {
  1861. style : this.json.style || "default",
  1862. countPerPage: 20, //this.json.pageSize || this.options.perPageCount,
  1863. visiblePages: visiblePages,
  1864. currentPage: 1,
  1865. itemSize: visiblePages * 20 * 3,
  1866. // pageSize: this.pages,
  1867. hasNextPage: typeOf( this.json.hasPreNextPage ) === "boolean" ? this.json.hasPreNextPage : true,
  1868. hasPrevPage: typeOf( this.json.hasPreNextPage ) === "boolean" ? this.json.hasPreNextPage : true,
  1869. hasTruningBar: typeOf( this.json.hasTruningBar ) === "boolean" ? this.json.hasTruningBar : true,
  1870. hasBatchTuring: typeOf( this.json.hasBatchTuring ) === "boolean" ? this.json.hasBatchTuring : true,
  1871. hasFirstPage: typeOf( this.json.hasFirstLastPage ) === "boolean" ? this.json.hasFirstLastPage : true,
  1872. hasLastPage: typeOf( this.json.hasFirstLastPage ) === "boolean" ? this.json.hasFirstLastPage : true,
  1873. hasJumper: typeOf( this.json.hasPageJumper ) === "boolean" ? this.json.hasPageJumper : true,
  1874. hiddenWithDisable: false,
  1875. // hiddenWithNoItem: true,
  1876. text: {
  1877. prePage: this.json.prePageText,
  1878. nextPage: this.json.nextPageText,
  1879. firstPage: this.json.firstPageText,
  1880. lastPage: this.json.lastPageText
  1881. },
  1882. onJumpingPage : function( pageNum, itemNum ){
  1883. }.bind(this),
  1884. onPostLoad : function () {
  1885. this.view.setContentHeight()
  1886. // if(this.setContentHeightFun)this.setContentHeightFun();
  1887. }.bind(this)
  1888. }, isReset ? {} : (this.json.pagingStyles || {}));
  1889. if( isReset ){
  1890. if (!this.json.pagingStyles){
  1891. this.json.pagingStyles = Object.merge( Object.clone( this.pagingWidget.css ), this.json.forceStyles || {} );
  1892. }else{
  1893. this.pagingWidget.css = Object.merge( Object.clone( this.json.pagingStyles ), this.pagingWidget.css, this.json.forceStyles || {} );
  1894. this.json.pagingStyles = Object.clone(this.pagingWidget.css);
  1895. }
  1896. }else{
  1897. if (!this.json.pagingStyles){
  1898. this.json.pagingStyles = Object.clone(this.pagingWidget.css);
  1899. }
  1900. }
  1901. this.pagingWidget.load();
  1902. },
  1903. _resetPaging : function(){
  1904. this.pagingNode.empty();
  1905. this.loadWidget( true );
  1906. },
  1907. _refreshPaging: function(){
  1908. this.pagingNode.empty();
  1909. this.loadWidget();
  1910. },
  1911. _setEditStyle_custom: function(name, obj, oldValue){
  1912. debugger;
  1913. if ( ["hasTruningBar","visiblePages","hasBatchTuring",
  1914. "hasFirstLastPage","hasPreNextPage","hasPageJumper",
  1915. "firstPageText","lastPageText","prePageText","nextPageText",
  1916. "pagingStyles"].contains(name)){
  1917. this._refreshPaging();
  1918. }
  1919. }
  1920. });