View.js 95 KB

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