View.js 96 KB

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