Stat.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. MWF.xApplication = MWF.xApplication || {};
  2. MWF.xApplication.query = MWF.xApplication.query || {};
  3. MWF.xApplication.query.StatDesigner = MWF.xApplication.query.StatDesigner || {};
  4. MWF.APPDSTD = MWF.xApplication.query.StatDesigner;
  5. MWF.xDesktop.requireApp("query.StatDesigner", "lp."+MWF.language, null, false);
  6. MWF.xDesktop.requireApp("query.ViewDesigner", "ViewBase", null, false);
  7. MWF.xDesktop.requireApp("query.StatDesigner", "Property", null, false);
  8. MWF.xApplication.query.StatDesigner.Stat = new Class({
  9. Extends: MWF.xApplication.query.ViewDesigner.ViewBase,
  10. Implements: [Options, Events],
  11. options: {
  12. "style": "default",
  13. "isView": false,
  14. "showTab": true,
  15. "propertyPath": "../x_component_query_StatDesigner/$Stat/stat.html"
  16. },
  17. initialize: function(designer, data, options){
  18. this.setOptions(options);
  19. this.path = "../x_component_query_StatDesigner/$Stat/";
  20. this.cssPath = "../x_component_query_StatDesigner/$Stat/"+this.options.style+"/css.wcss";
  21. this._loadCss();
  22. this.designer = designer;
  23. this.data = data;
  24. if (!this.data.data) this.data.data = {};
  25. this.parseData();
  26. this.node = this.designer.designNode;
  27. this.areaNode = new Element("div", {"styles": {"height": "100%", "overflow": "auto"}});
  28. this.propertyListNode = this.designer.propertyDomArea;
  29. if(this.designer.application) this.data.applicationName = this.designer.application.name;
  30. if(this.designer.application) this.data.application = this.designer.application.id;
  31. this.isNewView = (this.data.id) ? false : true;
  32. this.items = [];
  33. this.view = this;
  34. this.queryView = null;
  35. this.autoSave();
  36. this.designer.addEvent("queryClose", function(){
  37. if (this.autoSaveTimerID) window.clearInterval(this.autoSaveTimerID);
  38. }.bind(this));
  39. },
  40. changeViewSelected: function(){
  41. if (this.json.view){
  42. if (!this.queryView){
  43. this.designer.actions.getView(this.json.view, function(view){
  44. this.queryView = JSON.decode(view.data.data);
  45. this.items.each(function(item){
  46. item.changeViewSelected(this.queryView);
  47. }.bind(this));
  48. this.checkIsGroupRadioDisplay();
  49. }.bind(this));
  50. }else{
  51. this.items.each(function(item){
  52. item.changeViewSelected(this.queryView);
  53. }.bind(this));
  54. this.checkIsGroupRadioDisplay();
  55. }
  56. }else{
  57. //item.changeViewSelected();
  58. }
  59. },
  60. checkIsGroupRadioDisplay: function(){
  61. if (this.property){
  62. var groupNode = this.property.propertyContent.getElement(".MWFIsGroupArea");
  63. if (groupNode){
  64. if (this.queryView.group.column){
  65. groupNode.setStyle("display", "block");
  66. }else{
  67. this.json.data.calculate.isGroup = false;
  68. var radios = groupNode.getElements("input");
  69. for (var i=0; i<radios.length; i++){
  70. if (radios[i].value=="false"){
  71. radios[i].set("checked", true);
  72. break;
  73. }
  74. }
  75. this.hideGroupTitle();
  76. groupNode.setStyle("display", "none");
  77. }
  78. }
  79. }
  80. },
  81. checkIsGroupRadio: function(){
  82. if (!this.queryView){
  83. this.designer.actions.getView(this.json.view, function(view){
  84. this.queryView = JSON.decode(view.data.data);
  85. this.checkIsGroupRadioDisplay();
  86. }.bind(this));
  87. }else{
  88. this.checkIsGroupRadioDisplay();
  89. }
  90. },
  91. showProperty: function(){
  92. if (!this.property){
  93. this.property = new MWF.xApplication.query.StatDesigner.Property(this, this.designer.propertyContentArea, this.designer, {
  94. "path": this.options.propertyPath,
  95. "onPostLoad": function(){
  96. this.property.show();
  97. }.bind(this)
  98. });
  99. this.property.load();
  100. }else{
  101. this.property.show();
  102. }
  103. },
  104. //getDataTr: function(ri){
  105. // var tr = null;
  106. // var trs = this.viewContentTableNode.getElements("tr");
  107. // if (trs.length) if (trs[ri]) tr = trs[ri];
  108. // return tr;
  109. //},
  110. //getDataTd: function(tr, ci){
  111. // var td = null;
  112. // var tds = tr.getElements("td");
  113. // if (tds.length) if (tds[ci]) td = tds[ci];
  114. // return td;
  115. //},
  116. //getDataLastColumnCell: function(ri, ci){
  117. // var trs = this.viewContentTableNode.getElements("tr");
  118. // if (trs.length) if (trs[ri]) tr = trs[ri];
  119. // var td = null;
  120. // var tds = tr.getElements("td");
  121. // if (tds.length) if (tds[ci]) td = tds[ci];
  122. // return td;
  123. //},
  124. loadViewData: function(){
  125. if (this.data.id){
  126. this.saveSilence(function(){
  127. this.viewContentBodyNode.empty();
  128. this.viewContentTableNode = new Element("table", {
  129. "styles": this.css.viewContentTableNode,
  130. "border": "0px",
  131. "cellPadding": "0",
  132. "cellSpacing": "0"
  133. }).inject(this.viewContentBodyNode);
  134. this.designer.actions.loadStat(this.data.id, null, function(json){
  135. var entries = {};
  136. json.data.calculate.calculateList.each(function(entry){entries[entry.id] = entry;}.bind(this));
  137. if (this.json.data.calculate.isGroup){
  138. if (json.data.calculateGrid.length){
  139. json.data.calculateGrid.each(function(d){
  140. // var groupColumn = null;
  141. // for (var c = 0; c<json.data.calculate.calculateList.length; c++){
  142. // if (json.data.calculate.calculateList[c].column === json.data.group.column){
  143. // groupColumn = json.data.calculate.calculateList[c];
  144. // break;
  145. // }
  146. // }
  147. var tr = new Element("tr", {"styles": this.css.viewContentTrNode}).inject(this.viewContentTableNode);
  148. var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr);
  149. // if (groupColumn){
  150. // td.set("text", (groupColumn.code) ? MWF.Macro.exec(groupColumn.code, {"value": d.group, "data": json.data}) : d.group);
  151. // }else{
  152. td.set("text", d.group);
  153. // }
  154. //td.set("text", d.group);
  155. td.setStyle("font-weight", "bold");
  156. d.list.each(function(c){
  157. var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr);
  158. td.set("text", (entries[c.column].code) ? MWF.Macro.exec(entries[c.column].code, {"value": c.value, "data": json.data}) : c.value);
  159. }.bind(this));
  160. }.bind(this));
  161. }
  162. if (json.data.calculateAmountGrid){
  163. var tr = new Element("tr", {"styles": this.css.viewContentTrNode}).inject(this.viewContentTableNode);
  164. var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr);
  165. td.set("text", this.designer.lp.amount);
  166. td.setStyles({"font-weight": "bold", "color": "#0000FF"});
  167. json.data.calculateAmountGrid.each(function(c){
  168. var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr);
  169. td.set("text", c.value);
  170. td.setStyles({"font-weight": "bold", "color": "#0000FF"});
  171. }.bind(this));
  172. }
  173. }else{
  174. if (json.data.calculateGrid.length){
  175. var tr = new Element("tr", {"styles": this.css.viewContentTrNode}).inject(this.viewContentTableNode);
  176. json.data.calculateGrid.each(function(d){
  177. var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr);
  178. td.set("text", d.value);
  179. }.bind(this));
  180. }
  181. }
  182. this.setContentColumnWidth();
  183. this.setContentHeight();
  184. }.bind(this));
  185. }.bind(this));
  186. }
  187. },
  188. preview: function(){
  189. if( this.isNewView ){
  190. this.designer.notice( this.designer.lp.saveViewNotice, "error" );
  191. return;
  192. }
  193. this.saveSilence( function () {
  194. var url = "../x_desktop/app.html?app=query.Query&status=";
  195. url += JSON.stringify({
  196. id : this.data.application,
  197. statId : this.data.id
  198. });
  199. window.open(o2.filterUrl(url),"_blank");
  200. }.bind(this));
  201. },
  202. addColumn: function(){
  203. MWF.require("MWF.widget.UUID", function(){
  204. var id = (new MWF.widget.UUID).id;
  205. var json = {
  206. "id": id,
  207. "column": "",
  208. "displayName": this.designer.lp.unnamed,
  209. "calculateType": "sum",
  210. "orderType": "original",
  211. "orderEffectType": "key",
  212. "formatType": "number"
  213. };
  214. if (!this.json.data.calculate.calculateList) this.json.data.calculate.calculateList = [];
  215. this.json.data.calculate.calculateList.push(json);
  216. var column = new MWF.xApplication.query.StatDesigner.Stat.Column(json, this);
  217. this.items.push(column);
  218. column.selected();
  219. if (this.property) this.property.loadStatColumnSelect();
  220. if (this.viewContentTableNode){
  221. var trs = this.viewContentTableNode.getElements("tr");
  222. trs.each(function(tr){
  223. new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr)
  224. }.bind(this));
  225. //this.setContentColumnWidth();
  226. }
  227. this.setViewWidth();
  228. this.addColumnNode.scrollIntoView(false);
  229. }.bind(this));
  230. //new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 0}).toRight();
  231. },
  232. loadViewColumns: function(){
  233. // for (var i=0; i<10; i++){
  234. if (this.json.data && this.json.data.calculate && this.json.data.calculate.calculateList) {
  235. this.json.data.calculate.calculateList.each(function (json) {
  236. this.items.push(new MWF.xApplication.query.StatDesigner.Stat.Column(json, this));
  237. }.bind(this));
  238. }
  239. // }
  240. },
  241. saveSilence: function(callback){
  242. if (!this.data.name){
  243. this.designer.notice(this.designer.lp.notice.inputName, "error");
  244. return false;
  245. }
  246. // if (!this.data.view){
  247. // this.designer.notice(this.designer.lp.notice.inputView, "error");
  248. // return false;
  249. // }
  250. if (!this.checkViewAndColumn()){
  251. this.designer.notice(this.designer.lp.notice.errorViewColumn, "error");
  252. return false;
  253. }
  254. this.designer.actions.saveStat(this.data, function(json){
  255. this.data.id = json.data.id;
  256. if (this.lisNode) {
  257. this.lisNode.getLast().set("text", this.data.name+"("+this.data.alias+")");
  258. }
  259. if (callback) callback();
  260. }.bind(this));
  261. },
  262. save: function(callback){
  263. //if (this.designer.tab.showPage==this.page){
  264. if (!this.data.name){
  265. this.designer.notice(this.designer.lp.notice.inputName, "error");
  266. return false;
  267. }
  268. // if (!this.data.view){
  269. // this.designer.notice(this.designer.lp.notice.inputView, "error");
  270. // return false;
  271. // }
  272. if (!this.checkViewAndColumn()){
  273. this.designer.notice(this.designer.lp.notice.errorViewColumn, "error");
  274. return false;
  275. }
  276. //}
  277. this.designer.actions.saveStat(this.data, function(json){
  278. this.designer.notice(this.designer.lp.notice.save_success, "success", this.node, {"x": "left", "y": "bottom"});
  279. this.data.id = json.data.id;
  280. if (this.lisNode) {
  281. this.lisNode.getLast().set("text", this.data.name+"("+this.data.alias+")");
  282. }
  283. if (callback) callback();
  284. }.bind(this));
  285. },
  286. checkViewAndColumn: function(){
  287. // if (this.json.view){
  288. var flag = true;
  289. for (var i = 0; i<this.items.length; i++){
  290. if (!this.items[i].checkColumn()) flag = false;
  291. }
  292. return flag;
  293. // }else{
  294. // return false;
  295. // }
  296. },
  297. _setEditStyle: function(name, input, oldValue){
  298. // if (name=="view"){
  299. // if (this.data.view!=oldValue){
  300. // this.viewContentBodyNode.empty();
  301. // this.designer.actions.getView(this.json.view, function(view){
  302. // this.queryView = JSON.decode(view.data.data);
  303. // }.bind(this), null, false);
  304. //
  305. // this.changeViewSelected();
  306. // this.checkViewAndColumn();
  307. // }
  308. // }
  309. if (name=="data.calculate.isGroup"){
  310. this.viewContentBodyNode.empty();
  311. if (this.data.data.calculate.isGroup){
  312. this.showGroupTitle();
  313. }else{
  314. this.hideGroupTitle();
  315. }
  316. }
  317. if (name=="data.calculate.title"){
  318. if (!this.data.data.calculate.title){
  319. this.data.data.calculate.title = this.designer.lp.category;
  320. }
  321. if (this.data.data.calculate.title!= oldValue){
  322. if (this.groupTitleNode){
  323. this.groupTitleNode.getFirst().getFirst().set("text", this.data.data.calculate.title);
  324. }
  325. }
  326. }
  327. },
  328. showGroupTitle: function(){
  329. if (!this.groupTitleNode) this.createGroupTitltNode();
  330. },
  331. hideGroupTitle: function(){
  332. if (this.groupTitleNode){
  333. this.groupTitleNode.destroy();
  334. this.groupTitleNode = null;
  335. }
  336. },
  337. createGroupTitltNode: function(){
  338. this.data.data.calculate.title = this.data.data.calculate.title || this.designer.lp.category;
  339. this.groupTitleNode = new Element("td", {"styles": this.css.viewGroupTitleNode});
  340. var node = new Element("div", {
  341. "styles": this.css.viewGroupTitleColumnNode
  342. }).inject(this.groupTitleNode);
  343. var textNode = new Element("div", {
  344. "styles": this.css.viewGroupTitleColumnTextNode,
  345. "text": this.data.data.calculate.title
  346. }).inject(node);
  347. if (this.items.length){
  348. this.groupTitleNode.inject(this.items[0].areaNode, "before");
  349. }else{
  350. this.groupTitleNode.inject(this.viewTitleTrNode);
  351. }
  352. },
  353. saveAs: function(){
  354. var form = new MWF.xApplication.query.StatDesigner.Stat.NewNameForm(this, {
  355. name : this.data.name + "_" + MWF.xApplication.query.StatDesigner.LP.copy,
  356. view : this.data.view,
  357. query : this.data.query || this.data.application,
  358. queryName : this.data.queryName || this.data.applicationName
  359. }, {
  360. onSave : function( data, callback ){
  361. this._saveAs( data, callback );
  362. }.bind(this)
  363. }, {
  364. app: this.designer
  365. });
  366. form.edit()
  367. },
  368. explode: function(){},
  369. implode: function(){},
  370. _saveAs : function( data , callback){
  371. var _self = this;
  372. var d = Object.clone( this.data );
  373. d.isNewView = true;
  374. d.id = this.designer.actions.getUUID();
  375. d.name = data.name;
  376. d.alias = "";
  377. d.query = data.query;
  378. d.queryName = data.queryName;
  379. d.application = data.query;
  380. d.applicationName = data.queryName;
  381. d.view = data.view;
  382. //d.pid = d.id + d.id;
  383. //delete d[this.data.id+"viewFilterType"];
  384. //d[d.id+"viewFilterType"]="custom";
  385. if( d.data.calculate && d.data.calculate.calculateList ){
  386. d.data.calculate.calculateList.each( function( entry ){
  387. entry.id = (new MWF.widget.UUID).id;
  388. }.bind(this));
  389. }
  390. this.designer.actions.saveStat(d, function(json){
  391. this.designer.notice(this.designer.lp.notice.saveAs_success, "success", this.node, {"x": "left", "y": "bottom"});
  392. if (callback) callback();
  393. }.bind(this));
  394. }
  395. //_setEditStyle: function(){}
  396. });
  397. MWF.xApplication.query.StatDesigner.Stat.Column = new Class({
  398. Extends:MWF.xApplication.query.ViewDesigner.ViewBase.Column,
  399. initialize: function(json, view, next){
  400. this.propertyPath = "../x_component_query_StatDesigner/$Stat/column.html";
  401. this.view = view;
  402. this.json = json;
  403. this.next = next;
  404. this.css = this.view.css;
  405. this.content = this.view.viewTitleTrNode;
  406. this.domListNode = this.view.domListNode;
  407. this.load();
  408. },
  409. showProperty: function(){
  410. if (!this.property){
  411. this.property = new MWF.xApplication.query.StatDesigner.Property(this, this.view.designer.propertyContentArea, this.view.designer, {
  412. "path": this.propertyPath,
  413. "onPostLoad": function(){
  414. this.property.show();
  415. this.changeViewSelected();
  416. }.bind(this)
  417. });
  418. this.property.load();
  419. }else{
  420. this.property.show();
  421. }
  422. },
  423. _setEditStyle: function(name, input, oldValue){
  424. //if (name=="displayName") this.resetTextNode();
  425. //if (name=="selectType") this.resetTextNode();
  426. //if (name=="attribute") this.resetTextNode();
  427. //if (name=="path") this.resetTextNode();
  428. if (name=="displayName") this.resetTextNode();
  429. if (name=="column") this.checkColumn();
  430. if (name=="view"){
  431. if (this.json.view!=oldValue){
  432. this.view.viewContentBodyNode.empty();
  433. this.view.designer.actions.getView(this.json.view, function(view){
  434. this.queryView = JSON.decode(view.data.data);
  435. }.bind(this), null, false);
  436. this.changeViewSelected();
  437. //this.checkViewAndColumn();
  438. }
  439. }
  440. },
  441. resetTextNode: function(){
  442. var listText = this.json.displayName+"("+this.json.calculateType+")";
  443. this.textNode.set("text", this.json.displayName);
  444. this.listNode.getLast().set("text", listText);
  445. if (this.view.property) this.view.property.loadStatColumnSelect();
  446. },
  447. "delete": function(e){
  448. var _self = this;
  449. if (!e) e = this.node;
  450. this.view.designer.confirm("warn", e, MWF.APPDSTD.LP.notice.deleteColumnTitle, MWF.APPDSTD.LP.notice.deleteColumn, 300, 120, function(){
  451. _self.destroy();
  452. this.close();
  453. }, function(){
  454. this.close();
  455. }, null);
  456. },
  457. addColumn: function(e, data){
  458. MWF.require("MWF.widget.UUID", function(){
  459. var json;
  460. if (data){
  461. json = Object.clone(data);
  462. json.id = (new MWF.widget.UUID).id;
  463. json.column = (new MWF.widget.UUID).id;
  464. }else{
  465. var id = (new MWF.widget.UUID).id;
  466. json = {
  467. "id": id,
  468. "column": "",
  469. "displayName": this.view.designer.lp.unnamed,
  470. "calculateType": "sum",
  471. "orderType": "original",
  472. "orderEffectType": "key",
  473. "formatType": "number"
  474. };
  475. }
  476. var idx = this.view.json.data.calculate.calculateList.indexOf(this.json);
  477. this.view.json.data.calculate.calculateList.splice(idx, 0, json);
  478. var column = new MWF.xApplication.query.StatDesigner.Stat.Column(json, this.view, this);
  479. this.view.items.splice(idx, 0, column);
  480. column.selected();
  481. if (this.view.property) this.view.property.loadStatColumnSelect();
  482. if (this.view.viewContentTableNode){
  483. var trs = this.view.viewContentTableNode.getElements("tr");
  484. trs.each(function(tr){
  485. var td = tr.insertCell(idx);
  486. td.setStyles(this.css.viewContentTdNode);
  487. }.bind(this));
  488. }
  489. this.view.setViewWidth();
  490. }.bind(this));
  491. },
  492. _setNodeMove: function(droppables, e){
  493. this._setMoveNodePosition(e);
  494. var movePosition = this.moveNode.getPosition();
  495. var moveSize = this.moveNode.getSize();
  496. var contentPosition = this.content.getPosition();
  497. var contentSize = this.content.getSize();
  498. var nodeDrag = new Drag.Move(this.moveNode, {
  499. "droppables": droppables,
  500. "limit": {
  501. "x": [contentPosition.x, contentPosition.x+contentSize.x],
  502. "y": [movePosition.y, movePosition.y+moveSize.y]
  503. },
  504. "onEnter": function(dragging, inObj){
  505. if (!this.moveFlagNode) this.createMoveFlagNode();
  506. this.moveFlagNode.inject(inObj, "before");
  507. }.bind(this),
  508. "onLeave": function(dragging, inObj){
  509. if (this.moveFlagNode){
  510. this.moveFlagNode.dispose();
  511. }
  512. }.bind(this),
  513. "onDrop": function(dragging, inObj){
  514. if (inObj){
  515. this.areaNode.inject(inObj, "before");
  516. var column = inObj.retrieve("column");
  517. this.listNode.inject(column.listNode, "before");
  518. // var idx = this.view.json.data.calculate.calculateList.indexOf(column.json);
  519. this.view.json.data.calculate.calculateList.erase(this.json);
  520. this.view.items.erase(this);
  521. var idx = this.view.json.data.calculate.calculateList.indexOf(column.json);
  522. this.view.json.data.calculate.calculateList.splice(idx, 0, this.json);
  523. this.view.items.splice(idx, 0, this);
  524. if (this.moveNode) this.moveNode.destroy();
  525. if (this.moveFlagNode) this.moveFlagNode.destroy();
  526. this._setActionAreaPosition();
  527. }else{
  528. if (this.moveNode) this.moveNode.destroy();
  529. if (this.moveFlagNode) this.moveFlagNode.destroy();
  530. }
  531. }.bind(this),
  532. "onCancel": function(dragging){
  533. if (this.moveNode) this.moveNode.destroy();
  534. if (this.moveFlagNode) this.moveFlagNode.destroy();
  535. }.bind(this)
  536. });
  537. nodeDrag.start(e);
  538. },
  539. changeViewSelected: function(json){
  540. if (json){
  541. this.changeViewColumnOptions(json);
  542. }else{
  543. if (this.json.view){
  544. if (!this.queryView){
  545. this.view.designer.actions.getView(this.json.view, function(view){
  546. this.queryView = JSON.decode(view.data.data);
  547. this.changeViewColumnOptions(this.queryView);
  548. }.bind(this));
  549. }else{
  550. this.changeViewColumnOptions(this.queryView);
  551. }
  552. }else{
  553. this.changeViewColumnOptions(json);
  554. }
  555. }
  556. },
  557. changeViewColumnOptions: function(json){
  558. if (this.property){
  559. var nodes = this.property.propertyContent.getElements(".MWFViewColumnSelect");
  560. nodes.each(function(node){
  561. node.empty();
  562. if (json){
  563. new Element("option", {
  564. "value": "",
  565. "text": "(none)",
  566. "selected": (!this.json.column)
  567. }).inject(node);
  568. json.selectList.each(function(col){
  569. var o = new Element("option", {
  570. "value": col.column,
  571. "text": col.displayName,
  572. "selected": (col.column==this.json.column)
  573. }).inject(node);
  574. }.bind(this));
  575. }else{
  576. this.json.column = "";
  577. }
  578. }.bind(this));
  579. }
  580. },
  581. checkColumn: function(){
  582. var flag = true;
  583. if (!this.queryView){
  584. if (this.json.view){
  585. this.view.designer.actions.getView(this.json.view, function(view){
  586. this.queryView = JSON.decode(view.data.data);
  587. }.bind(this), null, false);
  588. }else{
  589. this.errorMark();
  590. return false;
  591. }
  592. }
  593. var col = this.queryView.selectList.filter(function(c){
  594. return (c.column==this.json.column);
  595. }.bind(this));
  596. if (!col.length){
  597. this.errorMark();
  598. flag = false;
  599. }else{
  600. this.errorMark(true);
  601. }
  602. return flag;
  603. },
  604. errorMark: function(flag){
  605. if (flag){
  606. this.isError = false;
  607. if (!this.isSelected) this.node.setStyles(this.css.viewTitleColumnNode);
  608. }else{
  609. this.isError = true;
  610. if (!this.isSelected) this.node.setStyles(this.css.viewTitleColumnNode_error);
  611. }
  612. }
  613. });