View.js 95 KB

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