View.js 105 KB

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