View.js 93 KB

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