View.js 96 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283
  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. value = o2.filterUrl(value);
  1106. }
  1107. var reg = /^border\w*/ig;
  1108. if (!key.test(reg)){
  1109. if (key){
  1110. if (key.toString().toLowerCase()==="display"){
  1111. if (value.toString().toLowerCase()==="none"){
  1112. this.node.setStyle("opacity", 0.3);
  1113. }else{
  1114. this.node.setStyle("opacity", 1);
  1115. this.node.setStyle(key, value);
  1116. }
  1117. }else{
  1118. this.node.setStyle(key, value);
  1119. }
  1120. }
  1121. }
  1122. //this.node.setStyle(key, value);
  1123. }.bind(this));
  1124. },
  1125. _setEditStyle: function(name, obj, oldValue){
  1126. var title = "";
  1127. var text = "";
  1128. if (name==="name"){
  1129. title = this.json.name || this.json.id;
  1130. text = this.json.type.substr(this.json.type.lastIndexOf("$")+1, this.json.type.length);
  1131. this.treeNode.setText("<"+text+"> "+title);
  1132. }
  1133. if (name==="id"){
  1134. title = this.json.name || this.json.id;
  1135. if (!this.json.name){
  1136. text = this.json.type.substr(this.json.type.lastIndexOf("$")+1, this.json.type.length);
  1137. this.treeNode.setText("<"+text+"> "+this.json.id);
  1138. }
  1139. this.treeNode.setTitle(this.json.id);
  1140. this.node.set("id", this.json.id);
  1141. }
  1142. this._setEditStyle_custom(name, obj, oldValue);
  1143. },
  1144. reloadMaplist: function(){
  1145. if (this.property) Object.each(this.property.maplists, function(map, name){ map.reload(this.json[name]);}.bind(this));
  1146. },
  1147. getHtml: function(){
  1148. var copy = this.node.clone(true, true);
  1149. copy.clearStyles(true);
  1150. var html = copy.outerHTML;
  1151. copy.destroy();
  1152. return html;
  1153. },
  1154. getJson: function(){
  1155. var json = Object.clone(this.json);
  1156. var o = {};
  1157. o[json.id] = json;
  1158. return o;
  1159. }
  1160. });
  1161. MWF.xApplication.query.ViewDesigner.View.Column = new Class({
  1162. Extends: MWF.QV$Module,
  1163. initialize: function(json, view, next){
  1164. this.propertyPath = "../x_component_query_ViewDesigner/$View/column.html";
  1165. this.view = view;
  1166. this.json = json;
  1167. this.next = next;
  1168. this.css = this.view.css;
  1169. this.content = this.view.viewTitleTrNode;
  1170. this.domListNode = this.view.domListNode;
  1171. this.load();
  1172. },
  1173. load: function(){
  1174. if( !this.json.events ){
  1175. this.loadDefaultJson(function () {
  1176. this._load()
  1177. }.bind(this))
  1178. }else{
  1179. this._load();
  1180. }
  1181. },
  1182. _load: function(){
  1183. this.areaNode = new Element("td", {"styles": this.css.viewTitleColumnAreaNode});
  1184. this.areaNode.store("column", this);
  1185. if (this.next){
  1186. this.areaNode.inject(this.next.areaNode, "before");
  1187. }else{
  1188. this.areaNode.inject(this.content);
  1189. }
  1190. this.node = new Element("div", {
  1191. "styles": this.css.viewTitleColumnNode
  1192. }).inject(this.areaNode);
  1193. this.textNode = new Element("div", {
  1194. "styles": this.css.viewTitleColumnTextNode,
  1195. "text": this.json.displayName
  1196. }).inject(this.node);
  1197. this.createDomListItem();
  1198. this._createIconAction();
  1199. //if (!this.json.export) this.hideMode();
  1200. this.setEvent();
  1201. this.setCustomStyles();
  1202. },
  1203. loadDefaultJson: function(callback){
  1204. if( this.view.defaultColumnJson ){
  1205. this.json = Object.merge( this.json, Object.clone(this.view.defaultColumnJson) );
  1206. if (callback) callback(this.json);
  1207. return;
  1208. }
  1209. var url = this.view.path+"column.json";
  1210. MWF.getJSON(url, {
  1211. "onSuccess": function(obj){
  1212. this.view.defaultColumnJson = Object.clone(obj);
  1213. this.json = Object.merge( this.json, Object.clone(obj) );
  1214. if (callback) callback(this.json);
  1215. }.bind(this),
  1216. "onerror": function(text){
  1217. this.view.designer.notice(text, "error");
  1218. }.bind(this),
  1219. "onRequestFailure": function(xhr){
  1220. this.view.designer.notice(xhr.responseText, "error");
  1221. }.bind(this)
  1222. }, false);
  1223. },
  1224. setCustomStyles : function(){
  1225. var viewStyles = this.view.json.data.viewStyles;
  1226. var border = this.areaNode.getStyle("border");
  1227. this.areaNode.clearStyles();
  1228. this.areaNode.setStyles(this.css.viewTitleColumnAreaNode);
  1229. // var y = this.container.getStyle("height");
  1230. // y = (y) ? y.toInt()-2 : this.container.getSize().y-2;
  1231. // this.node.setStyle("min-height", ""+y+"px");
  1232. // if (this.initialStyles) this.node.setStyles(this.initialStyles);
  1233. this.node.setStyle("border", border);
  1234. Object.each(viewStyles.titleTd, function(value, key){
  1235. var reg = /^border\w*/ig;
  1236. if (!key.test(reg)){
  1237. this.node.setStyle(key, value);
  1238. }
  1239. }.bind(this));
  1240. },
  1241. createDomListItem: function(){
  1242. this.listNode = new Element("div", {"styles": this.css.cloumnListNode});
  1243. if (this.next){
  1244. this.listNode.inject(this.next.listNode, "before");
  1245. }else{
  1246. this.listNode.inject(this.domListNode);
  1247. }
  1248. var listIconNode = new Element("div", {"styles": this.css.cloumnListIconNode}).inject(this.listNode);
  1249. var listTextNode = new Element("div", {"styles": this.css.cloumnListTextNode}).inject(this.listNode);
  1250. this.resetTextNode();
  1251. },
  1252. setEvent: function(){
  1253. this.node.addEvents({
  1254. "click": function(e){this.selected(); e.stopPropagation();}.bind(this),
  1255. "mouseover": function(){if (!this.isSelected) this.node.setStyles(this.css.viewTitleColumnNode_over)}.bind(this),
  1256. "mouseout": function(){if (!this.isSelected) if (this.isError){
  1257. this.node.setStyles(this.css.viewTitleColumnNode_error)
  1258. }else{
  1259. this.node.setStyles(this.css.viewTitleColumnNode)
  1260. }}.bind(this)
  1261. });
  1262. this.listNode.addEvents({
  1263. "click": function(e){this.selected(); e.stopPropagation();}.bind(this),
  1264. "mouseover": function(){debugger; if (!this.isSelected) this.listNode.setStyles(this.css.cloumnListNode_over)}.bind(this),
  1265. "mouseout": function(){if (!this.isSelected) this.listNode.setStyles(this.css.cloumnListNode)}.bind(this)
  1266. });
  1267. },
  1268. _createIconAction: function(){
  1269. if (!this.actionArea){
  1270. this.actionArea = new Element("div", {"styles": this.css.actionAreaNode}).inject(this.view.areaNode, "after");
  1271. this._createAction({
  1272. "name": "move",
  1273. "icon": "move1.png",
  1274. "event": "mousedown",
  1275. "action": "move",
  1276. "title": MWF.APPDVD.LP.action.move
  1277. });
  1278. this._createAction({
  1279. "name": "add",
  1280. "icon": "add.png",
  1281. "event": "click",
  1282. "action": "addColumn",
  1283. "title": MWF.APPDVD.LP.action.add
  1284. });
  1285. this._createAction({
  1286. "name": "delete",
  1287. "icon": "delete1.png",
  1288. "event": "click",
  1289. "action": "delete",
  1290. "title": MWF.APPDVD.LP.action["delete"]
  1291. });
  1292. }
  1293. },
  1294. _createAction: function(action){
  1295. var actionNode = new Element("div", {
  1296. "styles": this.css.actionNodeStyles,
  1297. "title": action.title
  1298. }).inject(this.actionArea);
  1299. actionNode.setStyle("background", "url("+this.view.path+this.view.options.style+"/action/"+action.icon+") no-repeat left center");
  1300. actionNode.addEvent(action.event, function(e){
  1301. this[action.action](e);
  1302. }.bind(this));
  1303. actionNode.addEvents({
  1304. "mouseover": function(e){
  1305. e.target.setStyle("border", "1px solid #999");
  1306. }.bind(this),
  1307. "mouseout": function(e){
  1308. e.target.setStyle("border", "1px solid #F1F1F1");
  1309. }.bind(this)
  1310. });
  1311. },
  1312. _setActionAreaPosition: function(){
  1313. var p = this.node.getPosition(this.view.areaNode.getOffsetParent());
  1314. var y = p.y-25;
  1315. var x = p.x;
  1316. this.actionArea.setPosition({"x": x, "y": y});
  1317. },
  1318. _showActions: function(){
  1319. if (this.actionArea){
  1320. this._setActionAreaPosition();
  1321. this.actionArea.setStyle("display", "block");
  1322. }
  1323. },
  1324. _hideActions: function(){
  1325. if (this.actionArea) this.actionArea.setStyle("display", "none");
  1326. },
  1327. selected: function(){
  1328. if (this.view.currentSelectedModule){
  1329. if (this.view.currentSelectedModule==this){
  1330. return true;
  1331. }else{
  1332. this.view.currentSelectedModule.unSelected();
  1333. }
  1334. }
  1335. this.node.setStyles(this.css.viewTitleColumnNode_selected);
  1336. this.listNode.setStyles(this.css.cloumnListNode_selected);
  1337. new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 100}).toElementEdge(this.node);
  1338. new Fx.Scroll(this.view.designer.propertyDomArea, {"wheelStops": false, "duration": 100}).toElement(this.listNode);
  1339. this.view.currentSelectedModule = this;
  1340. this.isSelected = true;
  1341. this._showActions();
  1342. this.showProperty();
  1343. },
  1344. unSelected: function(){
  1345. this.view.currentSelectedModule = null;
  1346. //this.node.setStyles(this.css.viewTitleColumnNode);
  1347. if (this.isError){
  1348. this.node.setStyles(this.css.viewTitleColumnNode_error)
  1349. }else{
  1350. this.node.setStyles(this.css.viewTitleColumnNode)
  1351. }
  1352. this.listNode.setStyles(this.css.cloumnListNode);
  1353. this.isSelected = false;
  1354. this._hideActions();
  1355. this.hideProperty();
  1356. },
  1357. showProperty: function(){
  1358. if (!this.property){
  1359. this.property = new MWF.xApplication.query.ViewDesigner.Property(this, this.view.designer.propertyContentArea, this.view.designer, {
  1360. "path": this.propertyPath,
  1361. "onPostLoad": function(){
  1362. this.property.show();
  1363. var processDiv = this.property.propertyContent.getElements("#"+this.json.id+"dataPathSelectedProcessArea");
  1364. var cmsDiv = this.property.propertyContent.getElements("#"+this.json.id+"dataPathSelectedCMSArea");
  1365. if (this.view.json.type=="cms"){
  1366. processDiv.setStyle("display", "none");
  1367. cmsDiv.setStyle("display", "block");
  1368. }else{
  1369. processDiv.setStyle("display", "block");
  1370. cmsDiv.setStyle("display", "none");
  1371. }
  1372. }.bind(this)
  1373. });
  1374. this.property.load();
  1375. }else{
  1376. this.property.show();
  1377. }
  1378. },
  1379. hideProperty: function(){
  1380. if (this.property) this.property.hide();
  1381. },
  1382. _setEditStyle: function(name, input, oldValue){
  1383. if (name=="displayName") this.resetTextNode();
  1384. if (name=="selectType") this.resetTextNode();
  1385. if (name=="attribute") this.resetTextNode();
  1386. if (name=="path") this.resetTextNode();
  1387. if (name=="column"){
  1388. this.view.json.data.orderList.each(function(order){
  1389. if (order.column==oldValue) order.column = this.json.column
  1390. }.bind(this));
  1391. if (this.view.json.data.group.column == oldValue) this.view.json.data.group.column = this.json.column;
  1392. }
  1393. },
  1394. resetTextNode: function(){
  1395. var listText = (this.json.selectType=="attribute") ? (this.json.attribute || "") : (this.json.path || "");
  1396. if (!listText) listText = "unnamed";
  1397. this.textNode.set("text", this.json.displayName);
  1398. this.listNode.getLast().set("text", this.json.displayName+"("+listText+")");
  1399. },
  1400. "delete": function(e){
  1401. var _self = this;
  1402. if (!e) e = this.node;
  1403. this.view.designer.confirm("warn", e, MWF.APPDVD.LP.notice.deleteColumnTitle, MWF.APPDVD.LP.notice.deleteColumn, 300, 120, function(){
  1404. _self.destroy();
  1405. this.close();
  1406. }, function(){
  1407. this.close();
  1408. }, null);
  1409. },
  1410. isOrderColumn : function(){
  1411. var sortList = this.view.json.data.orderList || [];
  1412. var flag = false;
  1413. sortList.each(function(order){
  1414. if (order.column==this.json.column)flag = true;
  1415. }.bind(this));
  1416. return flag;
  1417. },
  1418. isGroupColumn : function() {
  1419. if (!this.view.json || !this.view.json.data || !this.view.json.data.group) return false;
  1420. return this.view.json.data.group.column === this.json.column;
  1421. },
  1422. destroy: function(){
  1423. if (this.view.currentSelectedModule==this) this.view.currentSelectedModule = null;
  1424. if (this.actionArea) this.actionArea.destroy();
  1425. if (this.listNode) this.listNode.destroy();
  1426. if (this.property) this.property.propertyContent.destroy();
  1427. var idx = this.view.items.indexOf(this);
  1428. if (this.view.viewContentTableNode){
  1429. var trs = this.view.viewContentTableNode.getElements("tr");
  1430. var isGroup = this.isGroupColumn();
  1431. trs.each(function(tr){
  1432. if( isGroup ){
  1433. if( tr.get("data-is-group") === "yes" ){
  1434. tr.destroy()
  1435. }
  1436. }else{
  1437. if( tr.get("data-is-group") !== "yes" ){
  1438. tr.deleteCell(idx);
  1439. }
  1440. }
  1441. }.bind(this));
  1442. }
  1443. if (this.view.json.data.group.column === this.json.column){
  1444. this.view.json.data.group.column = null;
  1445. }
  1446. var sortList = this.view.json.data.orderList || [];
  1447. var deleteItem = null;
  1448. sortList.each(function(order){
  1449. if (order.column==this.json.column){
  1450. deleteItem = order;
  1451. }
  1452. }.bind(this));
  1453. if (deleteItem) sortList.erase(deleteItem);
  1454. if (this.view.json.data.selectList) this.view.json.data.selectList.erase(this.json);
  1455. if (this.view.json.data.calculate) if (this.view.json.data.calculate.calculateList) this.view.json.data.calculate.calculateList.erase(this.json);
  1456. this.view.items.erase(this);
  1457. if (this.view.property) this.view.property.loadStatColumnSelect();
  1458. this.areaNode.destroy();
  1459. this.view.selected();
  1460. this.view.setViewWidth();
  1461. MWF.release(this);
  1462. delete this;
  1463. },
  1464. addColumn: function(e, data){
  1465. MWF.require("MWF.widget.UUID", function(){
  1466. var json;
  1467. if (data){
  1468. json = Object.clone(data);
  1469. json.id = (new MWF.widget.UUID).id;
  1470. json.column = (new MWF.widget.UUID).id;
  1471. }else{
  1472. var id = (new MWF.widget.UUID).id;
  1473. json = {
  1474. "id": id,
  1475. "column": id,
  1476. "displayName": this.view.designer.lp.unnamed,
  1477. "orderType": "original"
  1478. };
  1479. }
  1480. var idx = this.view.json.data.selectList.indexOf(this.json);
  1481. this.view.json.data.selectList.splice(idx, 0, json);
  1482. var column = new MWF.xApplication.query.ViewDesigner.View.Column(json, this.view, this);
  1483. this.view.items.splice(idx, 0, column);
  1484. column.selected();
  1485. if (this.view.viewContentTableNode){
  1486. var trs = this.view.viewContentTableNode.getElements("tr");
  1487. trs.each(function(tr){
  1488. var td = tr.insertCell(idx);
  1489. td.setStyles(this.css.viewContentTdNode);
  1490. }.bind(this));
  1491. }
  1492. this.view.setViewWidth();
  1493. }.bind(this));
  1494. },
  1495. move: function(e){
  1496. var columnNodes = [];
  1497. this.view.items.each(function(item){
  1498. if (item!=this){
  1499. columnNodes.push(item.areaNode);
  1500. }
  1501. }.bind(this));
  1502. this._createMoveNode();
  1503. this._setNodeMove(columnNodes, e);
  1504. },
  1505. _createMoveNode: function(){
  1506. this.moveNode = new Element("div", {"text": this.node.get("text")});
  1507. this.moveNode.inject(this.view.designer.content);
  1508. this.moveNode.setStyles({
  1509. "border": "2px dashed #ffa200",
  1510. "opacity": 0.7,
  1511. "height": "30px",
  1512. "line-height": "30px",
  1513. "padding": "0px 10px",
  1514. "position": "absolute"
  1515. });
  1516. },
  1517. _setMoveNodePosition: function(e){
  1518. var x = e.page.x+2;
  1519. var y = e.page.y+2;
  1520. this.moveNode.positionTo(x, y);
  1521. },
  1522. createMoveFlagNode: function(){
  1523. this.moveFlagNode = new Element("td", {"styles": this.css.moveFlagNode});
  1524. },
  1525. _setNodeMove: function(droppables, e){
  1526. this._setMoveNodePosition(e);
  1527. var movePosition = this.moveNode.getPosition();
  1528. var moveSize = this.moveNode.getSize();
  1529. var contentPosition = this.content.getPosition();
  1530. var contentSize = this.content.getSize();
  1531. var nodeDrag = new Drag.Move(this.moveNode, {
  1532. "droppables": droppables,
  1533. "limit": {
  1534. "x": [contentPosition.x, contentPosition.x+contentSize.x],
  1535. "y": [movePosition.y, movePosition.y+moveSize.y]
  1536. },
  1537. "onEnter": function(dragging, inObj){
  1538. if (!this.moveFlagNode) this.createMoveFlagNode();
  1539. this.moveFlagNode.inject(inObj, "before");
  1540. }.bind(this),
  1541. "onLeave": function(dragging, inObj){
  1542. if (this.moveFlagNode){
  1543. this.moveFlagNode.dispose();
  1544. }
  1545. }.bind(this),
  1546. "onDrop": function(dragging, inObj){
  1547. if (inObj){
  1548. this.areaNode.inject(inObj, "before");
  1549. var column = inObj.retrieve("column");
  1550. this.listNode.inject(column.listNode, "before");
  1551. var idx = this.view.json.data.selectList.indexOf(column.json);
  1552. this.view.json.data.selectList.erase(this.json);
  1553. this.view.items.erase(this);
  1554. this.view.json.data.selectList.splice(idx, 0, this.json);
  1555. this.view.items.splice(idx, 0, this);
  1556. if (this.moveNode) this.moveNode.destroy();
  1557. if (this.moveFlagNode) this.moveFlagNode.destroy();
  1558. this._setActionAreaPosition();
  1559. }else{
  1560. if (this.moveNode) this.moveNode.destroy();
  1561. if (this.moveFlagNode) this.moveFlagNode.destroy();
  1562. }
  1563. }.bind(this),
  1564. "onCancel": function(dragging){
  1565. if (this.moveNode) this.moveNode.destroy();
  1566. if (this.moveFlagNode) this.moveFlagNode.destroy();
  1567. }.bind(this)
  1568. });
  1569. nodeDrag.start(e);
  1570. }
  1571. //hideMode: function(){
  1572. // if (!this.columnHideFlagNode){
  1573. // this.columnHideFlagNode = new Element("div", {"styles": this.view.css.columnHideFlagNode}).inject(this.node);
  1574. // }
  1575. //},
  1576. //showMode: function(){
  1577. // if (this.columnHideFlagNode) this.columnHideFlagNode.destroy();
  1578. // this.columnHideFlagNode = null;
  1579. //}
  1580. });
  1581. MWF.require("MWF.widget.Toolbar", null, false);
  1582. MWF.xApplication.query.ViewDesigner.View.Actionbar = new Class({
  1583. Extends: MWF.xApplication.query.ViewDesigner.View.$Module,
  1584. options : {
  1585. "style" : "default",
  1586. "customImageStyle" : "default"
  1587. },
  1588. initialize: function(json, jsonList, view, options){
  1589. this.setOptions( options );
  1590. this.propertyPath = "../x_component_query_ViewDesigner/$View/actionbar.html";
  1591. this.path = "../x_component_query_ViewDesigner/$View/";
  1592. this.imagePath_default = "../x_component_query_ViewDesigner/$View/";
  1593. this.imagePath_custom = "../x_component_process_FormDesigner/Module/Actionbar/";
  1594. this.cssPath = "../x_component_query_ViewDesigner/$View/"+this.options.style+"/actionbar.wcss";
  1595. this.view = view;
  1596. this.json = json;
  1597. this.jsonList = jsonList;
  1598. this.css = this.view.css;
  1599. this.container = this.view.actionbarNode;
  1600. this.moduleName = "actionbar";
  1601. this.load();
  1602. },
  1603. load: function(){
  1604. this.systemTools = [];
  1605. this.customTools = [];
  1606. if( !this.json ){
  1607. this.loadDefaultJson(function(){
  1608. this._load()
  1609. }.bind(this));
  1610. }else{
  1611. this._load()
  1612. }
  1613. },
  1614. _load : function(){
  1615. this.json.moduleName = this.moduleName;
  1616. this._createNode();
  1617. //this._createIconAction();
  1618. //if (!this.json.export) this.hideMode();
  1619. this.setEvent();
  1620. },
  1621. loadDefaultJson: function(callback){
  1622. var url = this.path+"actionbar.json";
  1623. MWF.getJSON(url, {
  1624. "onSuccess": function(obj){
  1625. this.view.designer.actions.getUUID(function(id){
  1626. obj.id=id;
  1627. //obj.isNewView = true;
  1628. //obj.application = this.view.designer.application.id;
  1629. this.json = obj;
  1630. this.jsonList.push( this.json );
  1631. if (callback) callback(obj);
  1632. }.bind(this));
  1633. }.bind(this),
  1634. "onerror": function(text){
  1635. this.view.designer.notice(text, "error");
  1636. }.bind(this),
  1637. "onRequestFailure": function(xhr){
  1638. this.view.designer.notice(xhr.responseText, "error");
  1639. }.bind(this)
  1640. });
  1641. },
  1642. setTemplateStyles: function(styles){
  1643. this.json.style = styles.style;
  1644. this.json.iconStyle = styles.iconStyle || "";
  1645. this.json.iconOverStyle = styles.iconOverStyle || "";
  1646. this.json.customIconStyle = styles.customIconStyle;
  1647. this.json.customIconOverStyle = styles.customIconOverStyle || "";
  1648. this.json.forceStyles = styles.forceStyles || "";
  1649. },
  1650. clearTemplateStyles: function(styles){
  1651. this.json.style = "form";
  1652. this.json.iconStyle = "";
  1653. this.json.iconOverStyle = "";
  1654. this.json.customIconStyle = "";
  1655. this.json.customIconOverStyle = "";
  1656. this.json.forceStyles = "";
  1657. },
  1658. setAllStyles: function(){
  1659. this._resetActionbar();
  1660. },
  1661. setEvent: function(){
  1662. this.node.addEvents({
  1663. "click": function(e){this.selected(); e.stopPropagation();}.bind(this),
  1664. "mouseover": function(){if (!this.isSelected) this.node.setStyles(this.css.toolbarWarpNode_over)}.bind(this),
  1665. "mouseout": function(){if (!this.isSelected) this.node.setStyles(this.css.toolbarWarpNode) }.bind(this)
  1666. });
  1667. },
  1668. selected: function(){
  1669. if (this.view.currentSelectedModule){
  1670. if (this.view.currentSelectedModule==this){
  1671. return true;
  1672. }else{
  1673. this.view.currentSelectedModule.unSelected();
  1674. }
  1675. }
  1676. this.node.setStyles(this.css.toolbarWarpNode_selected);
  1677. //this.listNode.setStyles(this.css.cloumnListNode_selected);
  1678. new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 100}).toElementEdge(this.node);
  1679. //new Fx.Scroll(this.view.designer.propertyDomArea, {"wheelStops": false, "duration": 100}).toElement(this.listNode);
  1680. this.view.currentSelectedModule = this;
  1681. this.isSelected = true;
  1682. //this._showActions();
  1683. this.showProperty();
  1684. },
  1685. unSelected: function(){
  1686. this.view.currentSelectedModule = null;
  1687. this.node.setStyles(this.css.toolbarWarpNode)
  1688. //this.listNode.setStyles(this.css.cloumnListNode);
  1689. this.isSelected = false;
  1690. //this._hideActions();
  1691. this.hideProperty();
  1692. },
  1693. resetTextNode: function(){
  1694. var listText = (this.json.selectType=="attribute") ? (this.json.attribute || "") : (this.json.path || "");
  1695. if (!listText) listText = "unnamed";
  1696. this.textNode.set("text", this.json.displayName);
  1697. this.listNode.getLast().set("text", this.json.displayName+"("+listText+")");
  1698. },
  1699. getJsonPath : function(){
  1700. return this.path+"toolbars.json";
  1701. },
  1702. _createNode: function(callback){
  1703. this.node = new Element("div", {
  1704. "id": this.json.id,
  1705. "MWFType": "actionbar",
  1706. "styles": this.css.toolbarWarpNode,
  1707. "events": {
  1708. "selectstart": function(e){
  1709. e.preventDefault();
  1710. }
  1711. }
  1712. }).inject(this.container );
  1713. this.toolbarNode = new Element("div").inject(this.node);
  1714. this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {"style": this.json.style}, this);
  1715. if (!this.json.actionStyles){
  1716. this.json.actionStyles = Object.clone(this.toolbarWidget.css);
  1717. }else{
  1718. this.toolbarWidget.css = Object.clone(this.json.actionStyles);
  1719. }
  1720. this.loadMultiToolbar();
  1721. // if (this.json.defaultTools){
  1722. // var json = Array.clone(this.json.defaultTools);
  1723. // this.setToolbars(json, this.toolbarNode);
  1724. // if (this.json.tools){
  1725. // this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  1726. // }
  1727. // this.toolbarWidget.load();
  1728. // this._setEditStyle_custom("hideSystemTools");
  1729. // }else{
  1730. // MWF.getJSON( this.getJsonPath(), function(json){
  1731. // this.json.defaultTools = json;
  1732. // var json = Array.clone(this.json.defaultTools);
  1733. // this.setToolbars(json, this.toolbarNode);
  1734. // if (this.json.tools){
  1735. // this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  1736. // }
  1737. // this.toolbarWidget.load();
  1738. // this._setEditStyle_custom("hideSystemTools");
  1739. // }.bind(this), false);
  1740. // }
  1741. },
  1742. _refreshActionbar: function(){
  1743. //if (this.form.options.mode == "Mobile"){
  1744. // this.node.set("text", MWF.APPFD.LP.notice.notUseModuleInMobile+"("+this.moduleName+")");
  1745. // this.node.setStyles({"height": "24px", "line-height": "24px", "background-color": "#999"});
  1746. //}else{
  1747. this.toolbarNode = this.node.getFirst("div");
  1748. this.toolbarNode.empty();
  1749. this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {"style": this.json.style}, this);
  1750. if (!this.json.actionStyles) this.json.actionStyles = Object.clone(this.toolbarWidget.css);
  1751. this.toolbarWidget.css = this.json.actionStyles;
  1752. this.loadMultiToolbar();
  1753. // if (this.json.defaultTools){
  1754. // var json = Array.clone(this.json.defaultTools);
  1755. // this.setToolbars(json, this.toolbarNode);
  1756. // if (this.json.tools){
  1757. // this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  1758. // }
  1759. // this.toolbarWidget.load();
  1760. // }else{
  1761. // MWF.getJSON( this.getJsonPath(), function(json){
  1762. // this.json.defaultTools = json;
  1763. // var json = Array.clone(this.json.defaultTools);
  1764. // this.setToolbars(json, this.toolbarNode);
  1765. // if (this.json.tools){
  1766. // this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  1767. // }
  1768. // this.toolbarWidget.load();
  1769. // }.bind(this), false);
  1770. // }
  1771. //}
  1772. },
  1773. _resetActionbar: function(){
  1774. //if (this.form.options.mode == "Mobile"){
  1775. // this.node.set("text", MWF.APPFD.LP.notice.notUseModuleInMobile+"("+this.moduleName+")");
  1776. // this.node.setStyles({"height": "24px", "line-height": "24px", "background-color": "#999"});
  1777. //}else{
  1778. this.toolbarNode = this.node.getFirst("div");
  1779. this.toolbarNode.empty();
  1780. this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {"style": this.json.style}, this);
  1781. if (!this.json.actionStyles){
  1782. this.json.actionStyles = Object.merge( Object.clone( this.toolbarWidget.css ), this.json.forceStyles || {} );
  1783. }else{
  1784. this.toolbarWidget.css = Object.merge( Object.clone( this.json.actionStyles ), this.toolbarWidget.css, this.json.forceStyles || {} );
  1785. this.json.actionStyles = Object.clone(this.toolbarWidget.css);
  1786. }
  1787. this.loadMultiToolbar();
  1788. // if (this.json.defaultTools){
  1789. // var json = Array.clone(this.json.defaultTools);
  1790. // this.setToolbars(json, this.toolbarNode);
  1791. // if (this.json.tools){
  1792. // this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  1793. // }
  1794. // this.toolbarWidget.load();
  1795. // }else{
  1796. // MWF.getJSON(this.path+"toolbars.json", function(json){
  1797. // this.json.defaultTools = json;
  1798. // var json = Array.clone(this.json.defaultTools);
  1799. // this.setToolbars(json, this.toolbarNode);
  1800. // if (this.json.tools){
  1801. // this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  1802. // }
  1803. // this.toolbarWidget.load();
  1804. // }.bind(this), false);
  1805. // }
  1806. //}
  1807. },
  1808. loadMultiToolbar : function(){
  1809. if( this.json.multiTools ){
  1810. var json = Array.clone(this.json.multiTools);
  1811. this.setMultiToolbars(json, this.toolbarNode);
  1812. this.toolbarWidget.load();
  1813. this._setEditStyle_custom("hideSystemTools");
  1814. }else if( this.json.defaultTools ){
  1815. this.json.multiTools = this.json.defaultTools.map( function (d) { d.system = true; return d; });
  1816. if (this.json.tools){
  1817. this.json.multiTools = this.json.multiTools.concat( this.json.tools )
  1818. }
  1819. this.setMultiToolbars( Array.clone(this.json.multiTools), this.toolbarNode);
  1820. this.toolbarWidget.load();
  1821. this._setEditStyle_custom("hideSystemTools");
  1822. }else{
  1823. MWF.getJSON(this.path+"toolbars.json", function(json){
  1824. this.json.multiTools = json.map( function (d) { d.system = true; return d; });
  1825. if (this.json.tools){
  1826. this.json.multiTools = this.json.multiTools.concat( this.json.tools )
  1827. }
  1828. this.setMultiToolbars(Array.clone(this.json.multiTools), this.toolbarNode);
  1829. this.toolbarWidget.load();
  1830. this._setEditStyle_custom("hideSystemTools");
  1831. }.bind(this), false);
  1832. }
  1833. },
  1834. setMultiToolbars: function(tools, node){
  1835. tools.each(function(tool){
  1836. if( tool.system ){
  1837. this.setToolbars( [tool], node );
  1838. }else{
  1839. this.setCustomToolbars( [tool], node );
  1840. }
  1841. }.bind(this));
  1842. },
  1843. setToolbars: function(tools, node){
  1844. tools.each(function(tool){
  1845. var actionNode = new Element("div", {
  1846. "MWFnodetype": tool.type,
  1847. "MWFButtonImage": this.imagePath_default+""+this.options.style+"/actionbar/"+( this.json.iconStyle || "default" )+"/"+tool.img,
  1848. "title": tool.title,
  1849. "MWFButtonAction": tool.action,
  1850. "MWFButtonText": tool.text
  1851. }).inject(node);
  1852. if( this.json.iconOverStyle ){
  1853. actionNode.set("MWFButtonImageOver" , this.imagePath_default+""+this.options.style+"/actionbar/"+this.json.iconOverStyle+"/"+tool.img );
  1854. }
  1855. this.systemTools.push(actionNode);
  1856. if (tool.sub){
  1857. var subNode = node.getLast();
  1858. this.setToolbars(tool.sub, subNode);
  1859. }
  1860. }.bind(this));
  1861. },
  1862. setCustomToolbars: function(tools, node){
  1863. //var style = (this.json.style || "default").indexOf("red") > -1 ? "red" : "blue";
  1864. var path = "";
  1865. if( this.json.customIconStyle ){
  1866. path = this.json.customIconStyle+ "/";
  1867. }
  1868. tools.each(function(tool){
  1869. var actionNode = new Element("div", {
  1870. "MWFnodetype": tool.type,
  1871. "MWFButtonImage": this.imagePath_custom+""+this.options.customImageStyle +"/custom/"+path+tool.img,
  1872. "title": tool.title,
  1873. "MWFButtonAction": tool.action,
  1874. "MWFButtonText": tool.text
  1875. }).inject(node);
  1876. if( this.json.customIconOverStyle ){
  1877. actionNode.set("MWFButtonImageOver" , this.imagePath_custom+""+this.options.customImageStyle +"/custom/"+this.json.customIconOverStyle+ "/" +tool.img );
  1878. }
  1879. this.customTools.push(actionNode);
  1880. if (tool.sub){
  1881. var subNode = node.getLast();
  1882. this.setToolbars(tool.sub, subNode);
  1883. }
  1884. }.bind(this));
  1885. },
  1886. _setEditStyle_custom: function(name){
  1887. if (name=="hideSystemTools"){
  1888. if (this.json.hideSystemTools){
  1889. this.systemTools.each(function(tool){
  1890. tool.setStyle("display", "none");
  1891. });
  1892. }else{
  1893. this.systemTools.each(function(tool){
  1894. tool.setStyle("display", "block");
  1895. });
  1896. }
  1897. }
  1898. if (name=="defaultTools" || name=="tools" || name=="multiTools" || name==="actionStyles"){
  1899. this._refreshActionbar();
  1900. }
  1901. }
  1902. });
  1903. MWF.require("MWF.widget.Paging", null, false);
  1904. MWF.xApplication.query.ViewDesigner.View.Paging = new Class({
  1905. Extends: MWF.xApplication.query.ViewDesigner.View.$Module,
  1906. options : {
  1907. "style" : "default"
  1908. },
  1909. initialize: function(json, jsonList, view, options){
  1910. this.setOptions( options );
  1911. this.propertyPath = "../x_component_query_ViewDesigner/$View/paging.html";
  1912. this.view = view;
  1913. this.json = json;
  1914. this.jsonList = jsonList;
  1915. this.css = this.view.css;
  1916. this.container = this.view.pagingNode;
  1917. this.moduleName = "paging";
  1918. this.load();
  1919. },
  1920. load: function(){
  1921. this.systemTools = [];
  1922. this.customTools = [];
  1923. if( !this.json ){
  1924. this.loadDefaultJson(function(){
  1925. this._load();
  1926. }.bind(this));
  1927. }else{
  1928. this._load();
  1929. }
  1930. },
  1931. _load : function(){
  1932. this.json.moduleName = this.moduleName;
  1933. this._createNode();
  1934. this.setEvent();
  1935. },
  1936. loadDefaultJson: function(callback){
  1937. var url = this.view.path+"paging.json";
  1938. MWF.getJSON(url, {
  1939. "onSuccess": function(obj){
  1940. this.view.designer.actions.getUUID(function(id){
  1941. obj.id=id;
  1942. this.json = obj;
  1943. this.jsonList.push( this.json );
  1944. if (callback) callback(obj);
  1945. }.bind(this));
  1946. }.bind(this),
  1947. "onerror": function(text){
  1948. this.view.designer.notice(text, "error");
  1949. }.bind(this),
  1950. "onRequestFailure": function(xhr){
  1951. this.view.designer.notice(xhr.responseText, "error");
  1952. }.bind(this)
  1953. });
  1954. },
  1955. setTemplateStyles: function(styles){
  1956. if( this.json.buttonStyle === "rect" ){
  1957. this.json.style = styles.style_rect;
  1958. }else if( this.json.buttonStyle === "round" ){
  1959. this.json.style = styles.style_round;
  1960. }else{
  1961. this.json.style = styles.style;
  1962. }
  1963. this.json.forceStyles = styles.forceStyles || "";
  1964. },
  1965. clearTemplateStyles: function(styles){
  1966. this.json.style = "blue_round";
  1967. this.json.forceStyles = "";
  1968. },
  1969. setAllStyles: function(){
  1970. this._resetPaging();
  1971. },
  1972. setEvent: function(){
  1973. this.node.addEvents({
  1974. "click": function(e){this.selected(); e.stopPropagation();}.bind(this),
  1975. "mouseover": function(){if (!this.isSelected) this.node.setStyles(this.css.pagingWarpNode_over)}.bind(this),
  1976. "mouseout": function(){if (!this.isSelected) this.node.setStyles(this.css.pagingWarpNode) }.bind(this)
  1977. });
  1978. },
  1979. selected: function(){
  1980. if (this.view.currentSelectedModule){
  1981. if (this.view.currentSelectedModule==this){
  1982. return true;
  1983. }else{
  1984. this.view.currentSelectedModule.unSelected();
  1985. }
  1986. }
  1987. this.node.setStyles(this.css.pagingWarpNode_selected);
  1988. new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 100}).toElementEdge(this.node);
  1989. this.view.currentSelectedModule = this;
  1990. this.isSelected = true;
  1991. this.showProperty();
  1992. },
  1993. unSelected: function(){
  1994. this.view.currentSelectedModule = null;
  1995. this.node.setStyles(this.css.pagingWarpNode);
  1996. this.isSelected = false;
  1997. this.hideProperty();
  1998. },
  1999. resetTextNode: function(){
  2000. var listText = (this.json.selectType=="attribute") ? (this.json.attribute || "") : (this.json.path || "");
  2001. if (!listText) listText = "unnamed";
  2002. this.textNode.set("text", this.json.displayName);
  2003. this.listNode.getLast().set("text", this.json.displayName+"("+listText+")");
  2004. },
  2005. _createNode: function(callback){
  2006. this.node = new Element("div", {
  2007. "id": this.json.id,
  2008. "MWFType": "paging",
  2009. "styles": this.css.pagingWarpNode,
  2010. "events": {
  2011. "selectstart": function(e){
  2012. e.preventDefault();
  2013. }
  2014. }
  2015. }).inject(this.container );
  2016. this.pagingNode = new Element("div").inject(this.node);
  2017. this.loadWidget();
  2018. // this.pagingWidget = new MWF.widget.Paging(this.pagingNode, {"style": this.json.style}, this);
  2019. // if (!this.json.pagingStyles){
  2020. // this.json.pagingStyles = Object.clone(this.pagingWidget.css);
  2021. // }
  2022. // this.pagingWidget.load();
  2023. },
  2024. loadWidget : function( isReset ){
  2025. var visiblePages = this.json.visiblePages ? this.json.visiblePages.toInt() : 9;
  2026. this.pagingWidget = new o2.widget.Paging(this.pagingNode, {
  2027. style : this.json.style || "default",
  2028. countPerPage: 20, //this.json.pageSize || this.options.perPageCount,
  2029. visiblePages: visiblePages,
  2030. currentPage: 1,
  2031. itemSize: visiblePages * 20 * 3,
  2032. // pageSize: this.pages,
  2033. hasNextPage: typeOf( this.json.hasPreNextPage ) === "boolean" ? this.json.hasPreNextPage : true,
  2034. hasPrevPage: typeOf( this.json.hasPreNextPage ) === "boolean" ? this.json.hasPreNextPage : true,
  2035. hasTruningBar: typeOf( this.json.hasTruningBar ) === "boolean" ? this.json.hasTruningBar : true,
  2036. hasBatchTuring: typeOf( this.json.hasBatchTuring ) === "boolean" ? this.json.hasBatchTuring : true,
  2037. hasFirstPage: typeOf( this.json.hasFirstLastPage ) === "boolean" ? this.json.hasFirstLastPage : true,
  2038. hasLastPage: typeOf( this.json.hasFirstLastPage ) === "boolean" ? this.json.hasFirstLastPage : true,
  2039. hasJumper: typeOf( this.json.hasPageJumper ) === "boolean" ? this.json.hasPageJumper : true,
  2040. hiddenWithDisable: false,
  2041. // hiddenWithNoItem: true,
  2042. text: {
  2043. prePage: this.json.prePageText,
  2044. nextPage: this.json.nextPageText,
  2045. firstPage: this.json.firstPageText,
  2046. lastPage: this.json.lastPageText
  2047. },
  2048. onJumpingPage : function( pageNum, itemNum ){
  2049. }.bind(this),
  2050. onPostLoad : function () {
  2051. this.view.setContentHeight()
  2052. // if(this.setContentHeightFun)this.setContentHeightFun();
  2053. }.bind(this)
  2054. }, isReset ? {} : (this.json.pagingStyles || {}));
  2055. if( isReset ){
  2056. if (!this.json.pagingStyles){
  2057. this.json.pagingStyles = Object.merge( Object.clone( this.pagingWidget.css ), this.json.forceStyles || {} );
  2058. }else{
  2059. this.pagingWidget.css = Object.merge( Object.clone( this.json.pagingStyles ), this.pagingWidget.css, this.json.forceStyles || {} );
  2060. this.json.pagingStyles = Object.clone(this.pagingWidget.css);
  2061. }
  2062. }else{
  2063. if (!this.json.pagingStyles){
  2064. this.json.pagingStyles = Object.clone(this.pagingWidget.css);
  2065. }
  2066. }
  2067. this.pagingWidget.load();
  2068. },
  2069. _resetPaging : function(){
  2070. this.pagingNode.empty();
  2071. this.loadWidget( true );
  2072. },
  2073. _refreshPaging: function(){
  2074. this.pagingNode.empty();
  2075. this.loadWidget();
  2076. },
  2077. _setEditStyle_custom: function(name, obj, oldValue){
  2078. if ( ["hasTruningBar","visiblePages","hasBatchTuring",
  2079. "hasFirstLastPage","hasPreNextPage","hasPageJumper",
  2080. "firstPageText","lastPageText","prePageText","nextPageText",
  2081. "pagingStyles"].contains(name)){
  2082. this._refreshPaging();
  2083. }else if( name === "buttonStyle" ){
  2084. if( this.json.buttonStyle === "rect" ){
  2085. this.json.style = this.view.templateStyles.paging.style_rect;
  2086. }else{
  2087. this.json.style = this.view.templateStyles.paging.style_round;
  2088. }
  2089. this._resetPaging();
  2090. }
  2091. }
  2092. });