Viewer.js 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101
  1. MWF.xApplication.query = MWF.xApplication.query || {};
  2. MWF.xApplication.query.Query = MWF.xApplication.query.Query || {};
  3. MWF.require("MWF.widget.Common", null, false);
  4. MWF.require("MWF.xScript.Macro", null, false);
  5. MWF.xDesktop.requireApp("query.Query", "lp.zh-cn", null, false);
  6. MWF.xApplication.query.Query.Viewer = MWF.QViewer = new Class({
  7. Implements: [Options, Events],
  8. Extends: MWF.widget.Common,
  9. options: {
  10. "style": "default",
  11. "resizeNode": true,
  12. "paging" : "scroll",
  13. "perPageCount" : 50,
  14. "isload": "true"
  15. // "actions": {
  16. // "lookup": {"uri": "/jaxrs/view/flag/{view}/query/{application}/execute", "method":"PUT"},
  17. // "getView": {"uri": "/jaxrs/view/flag/{view}/query/{application}"}
  18. //
  19. // },
  20. // "actionRoot": "x_query_assemble_surface"
  21. },
  22. initialize: function(container, json, options){
  23. this.setOptions(options);
  24. this.path = "/x_component_query_Query/$Viewer/";
  25. this.cssPath = "/x_component_query_Query/$Viewer/"+this.options.style+"/css.wcss";
  26. this._loadCss();
  27. this.lp = MWF.xApplication.query.Query.LP;
  28. this.container = $(container);
  29. this.json = json;
  30. this.viewJson = null;
  31. this.filterItems = [];
  32. this.searchStatus = "none"; //none, custom, default
  33. this.items = [];
  34. this.selectedItems = [];
  35. this.hideColumns = [];
  36. this.openColumns = [];
  37. this.gridJson = null;
  38. if (this.options.isload){
  39. this.init(function(){
  40. this.load();
  41. }.bind(this));
  42. }
  43. },
  44. loadView: function(){
  45. if (this.viewJson){
  46. this.reload();
  47. }else{
  48. this.init(function(){
  49. this.load();
  50. }.bind(this));
  51. }
  52. },
  53. init: function(callback){
  54. debugger;
  55. if (this.json.data){
  56. this.viewJson = JSON.decode(this.json.data);
  57. if (callback) callback();
  58. }else{
  59. this.getView(callback);
  60. }
  61. },
  62. load: function(){
  63. this.loadLayout();
  64. this.createSearchNode();
  65. this.createViewNode({"filterList": this.json.filter ? this.json.filter.clone() : null});
  66. if (this.options.resizeNode){
  67. this.setContentHeightFun = this.setContentHeight.bind(this);
  68. this.container.addEvent("resize", this.setContentHeightFun);
  69. this.setContentHeightFun();
  70. }
  71. },
  72. loadLayout: function(){
  73. this.node = new Element("div", {"styles": this.css.node}).inject(this.container);
  74. this.searchAreaNode = new Element("div", {"styles": this.css.searchAreaNode}).inject(this.node);
  75. this.viewAreaNode = new Element("div", {"styles": this.css.viewAreaNode}).inject(this.node);
  76. },
  77. createSearchNode: function(){
  78. if (this.viewJson.customFilterList && this.viewJson.customFilterList.length){
  79. this.searchStatus = "default";
  80. this.loadFilterSearch();
  81. }else{
  82. this.loadSimpleSearch();
  83. }
  84. },
  85. loadSimpleSearch: function(){
  86. this.searchSimpleNode = new Element("div", {"styles": this.css.searchSimpleNode}).inject(this.searchAreaNode);
  87. this.searchSimpleButtonNode = new Element("div", {"styles": this.css.searchSimpleButtonNode}).inject(this.searchSimpleNode);
  88. this.searchSimpleInputNode = new Element("input", {"type":"text", "styles": this.css.searchSimpleInputNode, "value": this.lp.searchKeywork}).inject(this.searchSimpleNode);
  89. this.searchSimpleButtonNode.addEvent("click", function(){
  90. this.search();
  91. }.bind(this));
  92. this.searchSimpleInputNode.addEvents({
  93. "focus": function(){
  94. if (this.searchSimpleInputNode.get("value")===this.lp.searchKeywork) this.searchSimpleInputNode.set("value", "");
  95. }.bind(this),
  96. "blur": function(){if (!this.searchSimpleInputNode.get("value")) this.searchSimpleInputNode.set("value", this.lp.searchKeywork);}.bind(this),
  97. "keydown": function(e){
  98. if (e.code===13) this.search();
  99. }.bind(this)
  100. });
  101. },
  102. search: function(){
  103. if (this.gridJson){
  104. var key = this.searchSimpleInputNode.get("value");
  105. var rows = this.viewTable.rows;
  106. var first = (this.json.isTitle!=="no") ? 1 : 0;
  107. for (var i = first; i<rows.length; i++){
  108. var tr = rows[i];
  109. if (!key || key==this.lp.searchKeywork){
  110. if (tr.getStyle("display")==="none") tr.setStyle("display", "table-row");
  111. }else{
  112. if (tr.get("text").indexOf(key)!==-1){
  113. if (tr.getStyle("display")==="none") tr.setStyle("display", "table-row");
  114. }else{
  115. if (tr.getStyle("display")!=="none") tr.setStyle("display", "none");
  116. }
  117. }
  118. }
  119. }
  120. },
  121. loadFilterSearch: function(){
  122. this.viewSearchCustomActionNode = new Element("div", {"styles": this.css.viewFilterSearchCustomActionNode, "text": this.lp.customSearch}).inject(this.searchAreaNode);
  123. this.viewSearchInputAreaNode = new Element("div", {"styles": this.css.viewFilterSearchInputAreaNode}).inject(this.searchAreaNode);
  124. this.viewSearchIconNode = new Element("div", {"styles": this.css.viewFilterSearchIconNode}).inject(this.viewSearchInputAreaNode);
  125. this.viewSearchInputBoxNode = new Element("div", {"styles": this.css.viewFilterSearchInputBoxNode}).inject(this.viewSearchInputAreaNode);
  126. this.viewSearchInputNode = new Element("input", {"styles": this.css.viewFilterSearchInputNode, "value": this.lp.searchKeywork}).inject(this.viewSearchInputBoxNode);
  127. this.viewSearchInputNode.addEvents({
  128. "focus": function(){
  129. if (this.viewSearchInputNode.get("value")===this.lp.searchKeywork) this.viewSearchInputNode.set("value", "");
  130. }.bind(this),
  131. "blur": function(){if (!this.viewSearchInputNode.get("value")) this.viewSearchInputNode.set("value", this.lp.searchKeywork);}.bind(this),
  132. "keydown": function(e){
  133. if (e.code===13) this.searchView();
  134. }.bind(this)
  135. });
  136. this.viewSearchIconNode.addEvents({
  137. "click": function(){this.searchView();}.bind(this)
  138. });
  139. this.viewSearchCustomActionNode.addEvents({
  140. "click": function(){this.loadCustomSearch();}.bind(this)
  141. });
  142. },
  143. searchView: function(){
  144. if (this.viewJson.customFilterList){
  145. var key = this.viewSearchInputNode.get("value");
  146. if (key && key!==this.lp.searchKeywork){
  147. var filterData = this.json.filter ? this.json.filter : [];
  148. this.viewJson.customFilterList.each(function(entry){
  149. if (entry.formatType==="textValue"){
  150. var d = {
  151. "path": entry.path,
  152. "value": key,
  153. "formatType": entry.formatType,
  154. "logic": "or",
  155. "comparison": "like"
  156. };
  157. filterData.push(d);
  158. }
  159. if (entry.formatType==="numberValue"){
  160. var v = key.toFloat();
  161. if (!isNaN(v)){
  162. var d = {
  163. "path": entry.path,
  164. "value": v,
  165. "formatType": entry.formatType,
  166. "logic": "or",
  167. "comparison": "like"
  168. };
  169. filterData.push(d);
  170. }
  171. }
  172. }.bind(this));
  173. this.createViewNode({"filterList": filterData});
  174. }
  175. }
  176. },
  177. searchCustomView: function(){
  178. if (this.filterItems.length){
  179. var filterData = this.json.filter ? this.json.filter.clone() : [];
  180. this.filterItems.each(function(filter){
  181. filterData.push(filter.data);
  182. }.bind(this));
  183. this.createViewNode({"filterList": filterData});
  184. }else{
  185. this.createViewNode({"filterList": this.json.filter ? this.json.filter.clone() : null});
  186. }
  187. },
  188. loadCustomSearch: function(){
  189. this.viewSearchIconNode.setStyle("display", "none");
  190. this.viewSearchInputBoxNode.setStyle("display", "none");
  191. this.viewSearchCustomActionNode.setStyle("display", "none");
  192. if (!this.searchMorph) this.searchMorph = new Fx.Morph(this.viewSearchInputAreaNode);
  193. var x = this.viewSearchInputAreaNode.getParent().getSize().x-2-20;
  194. this.css.viewFilterSearchInputAreaNode_custom.width = ""+x+"px";
  195. var x1 = this.viewSearchInputAreaNode.getSize().x-2;
  196. this.viewSearchInputAreaNode.setStyle("width", ""+x1+"px");
  197. this.searchMorph.start(this.css.viewFilterSearchInputAreaNode_custom).chain(function(){
  198. this.searchStatus = "custom";
  199. this.css.viewFilterSearchInputAreaNode_custom.width = "auto";
  200. this.viewSearchInputAreaNode.setStyle("width", "auto");
  201. if (this.viewSearchCustomContentNode){
  202. this.viewSearchCustomCloseActionNode.setStyle("display", "block");
  203. this.viewSearchCustomContentNode.setStyle("display", "block");
  204. }else{
  205. this.loadCustomSearchContent();
  206. }
  207. this.setContentHeightFun();
  208. }.bind(this));
  209. this.searchCustomView();
  210. },
  211. loadCustomSearchContent: function(){
  212. this.viewSearchCustomCloseActionNode = new Element("div", {"styles": this.css.viewFilterSearchCustomCloseActionNode}).inject(this.viewSearchInputAreaNode);
  213. this.viewSearchCustomContentNode = new Element("div", {"styles": this.css.viewFilterSearchCustomContentNode}).inject(this.viewSearchInputAreaNode);
  214. this.viewSearchCustomPathContentNode = new Element("div", {"styles": this.css.viewFilterSearchCustomPathContentNode}).inject(this.viewSearchCustomContentNode);
  215. this.viewSearchCustomComparisonContentNode = new Element("div", {"styles": this.css.viewFilterSearchCustomComparisonContentNode}).inject(this.viewSearchCustomContentNode);
  216. this.viewSearchCustomValueContentNode = new Element("div", {"styles": this.css.viewFilterSearchCustomValueContentNode}).inject(this.viewSearchCustomContentNode);
  217. this.viewSearchCustomAddContentNode = new Element("div", {"styles": this.css.viewFilterSearchCustomAddContentNode}).inject(this.viewSearchCustomContentNode);
  218. this.viewSearchCustomAddIconNode = new Element("div", {"styles": this.css.viewFilterSearchCustomAddIconNode}).inject(this.viewSearchCustomAddContentNode);
  219. this.viewSearchCustomFilterContentNode = new Element("div", {"styles": this.css.viewFilterSearchCustomFilterContentNode}).inject(this.viewSearchCustomContentNode);
  220. this.loadViewSearchCustomList();
  221. this.viewSearchCustomCloseActionNode.addEvents({
  222. "click": function(){this.closeCustomSearch();}.bind(this)
  223. });
  224. this.viewSearchCustomAddIconNode.addEvents({
  225. "click": function(){this.viewSearchCustomAddToFilter();}.bind(this)
  226. });
  227. },
  228. loadViewSearchCustomList: function(){
  229. this.viewSearchCustomPathListNode = new Element("select", {
  230. "styles": this.css.viewFilterSearchCustomPathListNode,
  231. "multiple": true
  232. }).inject(this.viewSearchCustomPathContentNode);
  233. this.viewSearchCustomComparisonListNode = new Element("select", {
  234. "styles": this.css.viewFilterSearchCustomComparisonListNode,
  235. "multiple": true
  236. }).inject(this.viewSearchCustomComparisonContentNode);
  237. this.viewJson.customFilterList.each(function(entry){
  238. var option = new Element("option", {
  239. "style": this.css.viewFilterSearchOptionNode,
  240. "value": entry.path,
  241. "text": entry.title
  242. }).inject(this.viewSearchCustomPathListNode);
  243. option.store("entry", entry);
  244. }.bind(this));
  245. this.viewSearchCustomPathListNode.addEvent("change", function(){
  246. this.loadViewSearchCustomComparisonList();
  247. }.bind(this));
  248. },
  249. loadViewSearchCustomComparisonList: function(){
  250. var idx = this.viewSearchCustomPathListNode.selectedIndex;
  251. var option = this.viewSearchCustomPathListNode.options[idx];
  252. var entry = option.retrieve("entry");
  253. if (entry){
  254. switch (entry.formatType){
  255. case "numberValue":
  256. this.loadComparisonSelect(this.lp.numberFilter);
  257. this.loadViewSearchCustomValueNumberInput();
  258. break;
  259. case "dateTimeValue":
  260. this.loadComparisonSelect(this.lp.dateFilter);
  261. this.loadViewSearchCustomValueDateInput();
  262. break;
  263. case "booleanValue":
  264. this.loadComparisonSelect(this.lp.booleanFilter);
  265. this.loadViewSearchCustomValueBooleanInput();
  266. break;
  267. default:
  268. this.loadComparisonSelect(this.lp.textFilter);
  269. this.loadViewSearchCustomValueTextInput();
  270. }
  271. }
  272. },
  273. loadViewSearchCustomValueNumberInput: function(){
  274. this.viewSearchCustomValueContentNode.empty();
  275. this.viewSearchCustomValueNode = new Element("input", {
  276. "styles": this.css.viewFilterSearchCustomValueNode,
  277. "type": "number"
  278. }).inject(this.viewSearchCustomValueContentNode);
  279. },
  280. loadViewSearchCustomValueDateInput: function(){
  281. this.viewSearchCustomValueContentNode.empty();
  282. this.viewSearchCustomValueNode = new Element("input", {
  283. "styles": this.css.viewFilterSearchCustomValueNode,
  284. "type": "text",
  285. "readonly": true
  286. }).inject(this.viewSearchCustomValueContentNode);
  287. MWF.require("MWF.widget.Calendar", function(){
  288. this.calendar = new MWF.widget.Calendar(this.viewSearchCustomValueNode, {
  289. "style": "xform",
  290. "isTime": true,
  291. "target": this.container,
  292. "format": "db"
  293. });
  294. }.bind(this));
  295. },
  296. loadViewSearchCustomValueBooleanInput: function(){
  297. this.viewSearchCustomValueContentNode.empty();
  298. this.viewSearchCustomValueNode = new Element("select", {
  299. "styles": this.css.viewFilterSearchCustomValueSelectNode,
  300. "multiple": true
  301. }).inject(this.viewSearchCustomValueContentNode);
  302. new Element("option", {"value": "true","text": this.lp.yes}).inject(this.viewSearchCustomValueNode);
  303. new Element("option", {"value": "false","text": this.lp.no}).inject(this.viewSearchCustomValueNode);
  304. },
  305. loadViewSearchCustomValueTextInput: function(){
  306. this.viewSearchCustomValueContentNode.empty();
  307. this.viewSearchCustomValueNode = new Element("textarea", {
  308. "styles": this.css.viewFilterSearchCustomValueNode
  309. }).inject(this.viewSearchCustomValueContentNode);
  310. },
  311. loadComparisonSelect:function(obj){
  312. this.viewSearchCustomComparisonListNode.empty();
  313. Object.each(obj, function(v, k){
  314. var option = new Element("option", {"value": k,"text": v}).inject(this.viewSearchCustomComparisonListNode);
  315. }.bind(this));
  316. },
  317. closeCustomSearch: function(){
  318. if (this.viewSearchCustomContentNode && this.viewSearchCustomContentNode.getStyle("display")==="block"){
  319. this.viewSearchCustomCloseActionNode.setStyle("display", "none");
  320. this.viewSearchCustomContentNode.setStyle("display", "none");
  321. var x = this.viewSearchInputAreaNode.getParent().getSize().x;
  322. x1 = x-2-10-90;
  323. this.css.viewFilterSearchInputAreaNode.width = ""+x1+"px";
  324. var x1 = this.viewSearchInputAreaNode.getSize().x-2;
  325. this.viewSearchInputAreaNode.setStyle("width", ""+x1+"px");
  326. if (!this.searchMorph) this.searchMorph = new Fx.Morph(this.viewSearchInputAreaNode);
  327. this.searchMorph.start(this.css.viewFilterSearchInputAreaNode).chain(function(){
  328. this.searchStatus = "default";
  329. this.css.viewFilterSearchInputAreaNode.width = "auto";
  330. this.viewSearchInputAreaNode.setStyle("margin-right", "90px");
  331. this.viewSearchIconNode.setStyle("display", "block");
  332. this.viewSearchInputBoxNode.setStyle("display", "block");
  333. this.viewSearchCustomActionNode.setStyle("display", "block");
  334. this.setContentHeightFun();
  335. }.bind(this));
  336. this.createViewNode({"filterList": this.json.filter ? this.json.filter.clone() : null});
  337. }
  338. },
  339. viewSearchCustomAddToFilter: function(){
  340. var pathIdx = this.viewSearchCustomPathListNode.selectedIndex;
  341. var comparisonIdx = this.viewSearchCustomComparisonListNode.selectedIndex;
  342. if (pathIdx===-1){
  343. MWF.xDesktop.notice("error", {"x": "left", "y": "top"}, this.lp.filterErrorTitle, this.viewSearchCustomPathListNode, {"x": 0, "y": 85});
  344. return false;
  345. }
  346. if (comparisonIdx===-1){
  347. MWF.xDesktop.notice("error", {"x": "left", "y": "top"}, this.lp.filterErrorComparison, this.viewSearchCustomComparisonListNode, {"x": 0, "y": 85});
  348. return false;
  349. }
  350. var pathOption = this.viewSearchCustomPathListNode.options[pathIdx];
  351. var entry = pathOption.retrieve("entry");
  352. if (entry){
  353. var pathTitle = entry.title;
  354. var path = entry.path;
  355. var comparison = this.viewSearchCustomComparisonListNode.options[comparisonIdx].get("value");
  356. var comparisonTitle = this.viewSearchCustomComparisonListNode.options[comparisonIdx].get("text");
  357. var value = "";
  358. switch (entry.formatType){
  359. case "numberValue":
  360. value = this.viewSearchCustomValueNode.get("value");
  361. break;
  362. case "dateTimeValue":
  363. value = this.viewSearchCustomValueNode.get("value");
  364. break;
  365. case "booleanValue":
  366. var idx = this.viewSearchCustomValueNode.selectedIndex;
  367. if (idx!==-1){
  368. var v = this.viewSearchCustomValueNode.options[idx].get("value");
  369. value = (v==="true");
  370. }
  371. break;
  372. default:
  373. value = this.viewSearchCustomValueNode.get("value");
  374. }
  375. if (value===""){
  376. MWF.xDesktop.notice("error", {"x": "left", "y": "top"}, this.lp.filterErrorValue, this.viewSearchCustomValueContentNode, {"x": 0, "y": 85});
  377. return false;
  378. }
  379. this.filterItems.push(new MWF.xApplication.query.Query.Viewer.Filter(this, {
  380. "logic": "and",
  381. "path": path,
  382. "title": pathTitle,
  383. "comparison": comparison,
  384. "comparisonTitle": comparisonTitle,
  385. "value": value,
  386. "formatType": entry.formatType
  387. }, this.viewSearchCustomFilterContentNode));
  388. this.searchCustomView();
  389. }
  390. },
  391. searchViewRemoveFilter: function(filter){
  392. debugger;
  393. this.filterItems.erase(filter);
  394. filter.destroy();
  395. this.searchCustomView()
  396. },
  397. setContentHeight: function(){
  398. var size = this.node.getSize();
  399. var searchSize = this.searchAreaNode.getSize();
  400. var h = size.y-searchSize.y;
  401. this.viewAreaNode.setStyle("height", ""+h+"px");
  402. },
  403. createLoadding: function(){
  404. this.loadingAreaNode = new Element("div", {"styles": this.css.viewLoadingAreaNode}).inject(this.contentAreaNode);
  405. new Element("div", {"styles": {"height": "5px"}}).inject(this.loadingAreaNode);
  406. var loadingNode = new Element("div", {"styles": this.css.viewLoadingNode}).inject(this.loadingAreaNode);
  407. new Element("div", {"styles": this.css.viewLoadingIconNode}).inject(loadingNode);
  408. var loadingTextNode = new Element("div", {"styles": this.css.viewLoadingTextNode}).inject(loadingNode);
  409. loadingTextNode.set("text", "loading...");
  410. },
  411. createViewNode: function(data){
  412. this.viewAreaNode.empty();
  413. this.contentAreaNode = new Element("div", {"styles": this.css.contentAreaNode}).inject(this.viewAreaNode);
  414. this.viewTable = new Element("table", {
  415. "styles": this.css.viewTitleTableNode,
  416. "border": "0px",
  417. "cellPadding": "0",
  418. "cellSpacing": "0"
  419. }).inject(this.contentAreaNode);
  420. this.createLoadding();
  421. if (this.json.isTitle!=="no"){
  422. this.viewTitleLine = new Element("tr", {"styles": this.css.viewTitleLineNode}).inject(this.viewTable);
  423. //if (this.json.select==="single" || this.json.select==="multi") {
  424. this.selectTitleCell = new Element("td", {
  425. "styles": this.css.viewTitleCellNode
  426. }).inject(this.viewTitleLine);
  427. this.selectTitleCell.setStyle("width", "10px");
  428. if (this.json.titleStyles) this.selectTitleCell.setStyles(this.json.titleStyles);
  429. //}
  430. this.entries = {};
  431. this.viewJson.selectList.each(function(column){
  432. this.entries[column.column] = column;
  433. if (!column.hideColumn){
  434. var viewCell = new Element("td", {
  435. "styles": this.css.viewTitleCellNode,
  436. "text": column.displayName
  437. }).inject(this.viewTitleLine);
  438. var size = MWF.getTextSize(column.displayName, this.css.viewTitleCellNode);
  439. viewCell.setStyle("min-width", ""+size.x+"px");
  440. if (this.json.titleStyles) viewCell.setStyles(this.json.titleStyles);
  441. }else{
  442. this.hideColumns.push(column.column);
  443. }
  444. if (column.allowOpen) this.openColumns.push(column.column);
  445. }.bind(this));
  446. this.lookup(data);
  447. }else{
  448. this.viewJson.selectList.each(function(column){
  449. if (column.hideColumn) this.hideColumns.push(column.column);
  450. if (!column.allowOpen) this.openColumns.push(column.column);
  451. }.bind(this));
  452. this.lookup(data);
  453. }
  454. },
  455. lookup: function(data){
  456. this.getLookupAction(function(){
  457. if (this.json.application){
  458. this.lookupAction.loadView(this.json.name, this.json.application, (data || null), function(json){
  459. this.viewData = json.data;
  460. if (this.viewJson.group.column){
  461. this.gridJson = json.data.groupGrid;
  462. this.loadGroupData();
  463. }else{
  464. this.gridJson = json.data.grid;
  465. this.loadData();
  466. }
  467. if (this.loadingAreaNode){
  468. this.loadingAreaNode.destroy();
  469. this.loadingAreaNode = null;
  470. }
  471. }.bind(this));
  472. // this.lookupAction.invoke({"name": "lookup","async": true, "data": (data || null), "parameter": {"view": this.json.name, "application": this.json.application},"success": function(json){
  473. // this.viewData = json.data;
  474. // if (this.viewJson.group.column){
  475. // this.gridJson = json.data.groupGrid;
  476. // this.loadGroupData();
  477. // }else{
  478. // this.gridJson = json.data.grid;
  479. // this.loadData();
  480. // }
  481. // if (this.loadingAreaNode){
  482. // this.loadingAreaNode.destroy();
  483. // this.loadingAreaNode = null;
  484. // }
  485. // }.bind(this)});
  486. }
  487. }.bind(this));
  488. },
  489. loadData: function(){
  490. if (this.gridJson.length){
  491. if( !this.options.paging ){
  492. this.gridJson.each(function(line, i){
  493. this.items.push(new MWF.xApplication.query.Query.Viewer.Item(this, line, null, i));
  494. }.bind(this));
  495. }else{
  496. this.loadPaging();
  497. }
  498. }
  499. },
  500. loadPaging : function(){
  501. this.isItemsLoading = false;
  502. this.pageNumber = 0;
  503. this.isItemsLoaded = false;
  504. this.isSetedScroll = false;
  505. this.setScroll();
  506. this.loadDataByPaging()
  507. },
  508. setScroll : function(){
  509. if( this.options.paging && !this.isSetedScroll ){
  510. this.contentAreaNode.setStyle("overflow","auto");
  511. this.scrollContainerFun = function(){
  512. var scrollSize = this.contentAreaNode.getScrollSize();
  513. var clientSize = this.contentAreaNode.getSize();
  514. var scrollHeight = scrollSize.y - clientSize.y;
  515. //alert( "clientSize.y=" + clientSize.y + " scrollSize.y="+scrollSize.y + " this.contentAreaNode.scrollTop="+this.contentAreaNode.scrollTop);
  516. if (this.contentAreaNode.scrollTop + 150 > scrollHeight ) {
  517. if (!this.isItemsLoaded) this.loadDataByPaging();
  518. }
  519. }.bind(this);
  520. this.isSetedScroll = true;
  521. this.contentAreaNode.addEvent("scroll", this.scrollContainerFun )
  522. }
  523. },
  524. loadDataByPaging : function(){
  525. if( this.isItemsLoading )return;
  526. if( !this.isItemsLoaded ){
  527. var from = Math.min( this.pageNumber * this.options.perPageCount , this.gridJson.length);
  528. var to = Math.min( ( this.pageNumber + 1 ) * this.options.perPageCount + 1 , this.gridJson.length);
  529. this.isItemsLoading = true;
  530. for( var i = from; i<to; i++ ){
  531. this.items.push(new MWF.xApplication.query.Query.Viewer.Item(this, this.gridJson[i], null, i));
  532. }
  533. this.isItemsLoading = false;
  534. this.pageNumber ++;
  535. if( to == this.gridJson.length )this.isItemsLoaded = true;
  536. }
  537. },
  538. loadGroupData: function(){
  539. if (this.selectTitleCell){
  540. this.selectTitleCell.set("html", "<span style='font-family: Webdings'>"+"<img src='/x_component_query_Query/$Viewer/"+this.options.style+"/icon/expand.png'/>"+"</span>");
  541. this.selectTitleCell.setStyle("cursor", "pointer");
  542. this.selectTitleCell.addEvent("click", this.expandOrCollapseAll.bind(this));
  543. }
  544. if (this.gridJson.length){
  545. this.gridJson.each(function(data){
  546. this.items.push(new MWF.xApplication.query.Query.Viewer.ItemCategory(this, data));
  547. }.bind(this));
  548. if (this.json.isExpand=="yes") this.expandOrCollapseAll();
  549. }
  550. },
  551. expandOrCollapseAll: function(){
  552. var icon = this.selectTitleCell.getElement("span");
  553. if (icon.get("html").indexOf("expand.png")===-1){
  554. this.items.each(function(item){
  555. item.collapse();
  556. icon.set("html", "<img src='/x_component_query_Query/$Viewer/"+this.options.style+"/icon/expand.png'/>");
  557. }.bind(this));
  558. }else{
  559. this.items.each(function(item, i){
  560. window.setTimeout(function(){
  561. item.expand();
  562. }.bind(this), 10*i+5);
  563. icon.set("html", "<img src='/x_component_query_Query/$Viewer/"+this.options.style+"/icon/down.png'/>");
  564. }.bind(this));
  565. }
  566. },
  567. getView: function(callback){
  568. this.getLookupAction(function(){
  569. if (this.json.application){
  570. this.lookupAction.getView(this.json.viewName, this.json.application, function(json){
  571. this.viewJson = JSON.decode(json.data.data);
  572. this.json = Object.merge(this.json, json.data);
  573. if (callback) callback();
  574. }.bind(this));
  575. // this.lookupAction.invoke({"name": "getView","async": true, "parameter": {"view": this.json.viewName, "application": this.json.application},"success": function(json){
  576. // this.viewJson = JSON.decode(json.data.data);
  577. // this.json = Object.merge(this.json, json.data);
  578. // //var viewData = JSON.decode(json.data.data);
  579. // if (callback) callback();
  580. // }.bind(this)});
  581. }
  582. }.bind(this));
  583. },
  584. getLookupAction: function(callback){
  585. if (!this.lookupAction){
  586. this.lookupAction = MWF.Actions.get("x_query_assemble_surface");
  587. if (callback) callback();
  588. // var _self = this;
  589. // MWF.require("MWF.xDesktop.Actions.RestActions", function(){
  590. // this.lookupAction = new MWF.xDesktop.Actions.RestActions("", this.options.actionRoot, "");
  591. // this.lookupAction.getActions = function(actionCallback){
  592. // this.actions = _self.options.actions;
  593. // if (actionCallback) actionCallback();
  594. // };
  595. // if (callback) callback();
  596. // }.bind(this));
  597. }else{
  598. if (callback) callback();
  599. }
  600. },
  601. hide: function(){
  602. this.node.setStyle("display", "none");
  603. },
  604. reload: function(){
  605. this.node.setStyle("display", "block");
  606. if (this.loadingAreaNode) this.loadingAreaNode.setStyle("display", "block");
  607. this.filterItems.each(function(filter){
  608. filter.destroy();
  609. }.bind(this));
  610. this.filterItems = [];
  611. if (this.viewSearchInputNode) this.viewSearchInputNode.set("text", this.lp.searchKeywork);
  612. this.closeCustomSearch();
  613. this.viewAreaNode.empty();
  614. this.createViewNode({"filterList": this.json.filter ? this.json.filter.clone() : null});
  615. },
  616. getFilter: function(){
  617. debugger;
  618. var filterData = [];
  619. if (this.searchStatus==="custom"){
  620. if (this.filterItems.length){
  621. this.filterItems.each(function(filter){
  622. filterData.push(filter.data);
  623. }.bind(this));
  624. }
  625. }
  626. if (this.searchStatus==="default"){
  627. var key = this.viewSearchInputNode.get("value");
  628. if (key && key!==this.lp.searchKeywork){
  629. this.viewJson.customFilterList.each(function(entry){
  630. if (entry.formatType==="textValue"){
  631. var d = {
  632. "path": entry.path,
  633. "value": key,
  634. "formatType": entry.formatType,
  635. "logic": "or",
  636. "comparison": "like"
  637. };
  638. filterData.push(d);
  639. }
  640. if (entry.formatType==="numberValue"){
  641. var v = key.toFloat();
  642. if (!isNaN(v)){
  643. var d = {
  644. "path": entry.path,
  645. "value": v,
  646. "formatType": entry.formatType,
  647. "logic": "or",
  648. "comparison": "like"
  649. };
  650. filterData.push(d);
  651. }
  652. }
  653. }.bind(this));
  654. }
  655. }
  656. return (filterData.length) ? filterData : null;
  657. },
  658. getData: function(){
  659. if (this.selectedItems.length){
  660. var arr = [];
  661. this.selectedItems.each(function(item){
  662. arr.push(item.data);
  663. });
  664. return arr;
  665. }else{
  666. return [];
  667. }
  668. }
  669. });
  670. MWF.xApplication.query.Query.Viewer.Item = new Class({
  671. initialize: function(view, data, prev, i){
  672. this.view = view;
  673. this.data = data;
  674. this.css = this.view.css;
  675. this.isSelected = false;
  676. this.prev = prev;
  677. this.load();
  678. },
  679. load: function(){
  680. this.node = new Element("tr", {"styles": this.css.viewContentTrNode});
  681. if (this.prev){
  682. this.node.inject(this.prev.node, "after");
  683. }else{
  684. this.node.inject(this.view.viewTable);
  685. }
  686. //if (this.view.json.select==="single" || this.view.json.select==="multi"){
  687. this.selectTd = new Element("td", {"styles": this.css.viewContentTdNode}).inject(this.node);
  688. this.selectTd.setStyles({"cursor": "pointer"});
  689. if (this.view.json.itemStyles) this.selectTd.setStyles(this.view.json.itemStyles);
  690. //}
  691. Object.each(this.view.entries, function(c, k){
  692. var cell = this.data.data[k] || "";
  693. //if (cell){
  694. if (this.view.hideColumns.indexOf(k)===-1){
  695. var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(this.node);
  696. if (k!== this.view.viewJson.group.column){
  697. var v = (this.view.entries[k].code) ? MWF.Macro.exec(this.view.entries[k].code, {"value": cell, "gridData": this.view.gridJson, "data": this.view.viewData, "entry": this.data}) : cell;
  698. td.set("text", v);
  699. }
  700. if (this.view.openColumns.indexOf(k)!==-1){
  701. this.setOpenWork(td)
  702. }
  703. if (this.view.json.itemStyles) td.setStyles(this.view.json.itemStyles);
  704. }
  705. //}
  706. }.bind(this));
  707. // Object.each(this.data.data, function(cell, k){
  708. // if (this.view.hideColumns.indexOf(k)===-1){
  709. // var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(this.node);
  710. // if (k!== this.view.viewJson.group.column){
  711. // var v = (this.view.entries[k].code) ? MWF.Macro.exec(this.view.entries[k].code, {"value": cell, "gridData": this.view.gridJson, "data": this.view.viewData, "entry": this.data}) : cell;
  712. // td.set("text", v);
  713. // }
  714. // if (this.view.openColumns.indexOf(k)!==-1){
  715. // this.setOpenWork(td)
  716. // }
  717. // if (this.view.json.itemStyles) td.setStyles(this.view.json.itemStyles);
  718. // }
  719. // }.bind(this));
  720. this.setEvent();
  721. },
  722. setOpenWork: function(td){
  723. td.setStyle("cursor", "pointer");
  724. td.addEvent("click", this.openWorkAndCompleted.bind(this));
  725. },
  726. openWorkAndCompleted: function(e){
  727. debugger;
  728. MWF.Actions.get("x_processplatform_assemble_surface").listWorkByJob(this.data.bundle, function(json){
  729. var workCompletedCount = json.data.workCompletedList.length;
  730. var workCount = json.data.workList.length;
  731. var count = workCount+workCompletedCount;
  732. if (count===1){
  733. if (workCompletedCount) {
  734. this.openWorkCompleted(json.data.workCompletedList[0].id, e);
  735. }else{
  736. this.openWork(json.data.workList[0].id, e);
  737. }
  738. }else if (count>1){
  739. var worksAreaNode = this.createWorksArea();
  740. json.data.workCompletedList.each(function(work){
  741. this.createWorkCompletedNode(work, worksAreaNode);
  742. }.bind(this));
  743. json.data.workList.each(function(work){
  744. this.createWorkNode(work, worksAreaNode);
  745. }.bind(this));
  746. this.showWorksArea(worksAreaNode, e);
  747. }else{
  748. }
  749. }.bind(this));
  750. },
  751. createWorkNode: function(work, worksAreaNode){
  752. var worksAreaContentNode = worksAreaNode.getLast();
  753. var node = new Element("div", {"styles": this.css.workAreaNode}).inject(worksAreaContentNode);
  754. var actionNode = new Element("div", {"styles": this.css.workAreaActionNode, "text": this.view.lp.open}).inject(node);
  755. actionNode.store("workId", work.id);
  756. actionNode.addEvent("click", function(e){
  757. this.openWork(e.target.retrieve("workId"), e);
  758. this.mask.hide();
  759. worksAreaNode.destroy();
  760. }.bind(this));
  761. var areaNode = new Element("div", {"styles": this.css.workAreaLeftNode}).inject(node);
  762. var titleNode = new Element("div", {"styles": this.css.workAreaTitleNode, "text": work.title}).inject(areaNode);
  763. var contentNode = new Element("div", {"styles": this.css.workAreaContentNode}).inject(areaNode);
  764. new Element("div", {"styles": this.css.workAreaContentTitleNode, "text": this.view.lp.activity+": "}).inject(contentNode);
  765. new Element("div", {"styles": this.css.workAreaContentTextNode, "text": work.activityName}).inject(contentNode);
  766. var taskUsers = [];
  767. MWF.Actions.get("x_processplatform_assemble_surface").listTaskByWork(work.id, function(json){
  768. json.data.taskList.each(function(task){
  769. taskUsers.push(MWF.name.cn(task.person));
  770. }.bind(this));
  771. new Element("div", {"styles": this.css.workAreaContentTitleNode, "text": this.view.lp.taskPeople+": "}).inject(contentNode);
  772. new Element("div", {"styles": this.css.workAreaContentTextNode, "text": taskUsers.join(", ")}).inject(contentNode);
  773. }.bind(this));
  774. },
  775. createWorkCompletedNode: function(work, worksAreaNode){
  776. var worksAreaContentNode = worksAreaNode.getLast();
  777. var node = new Element("div", {"styles": this.css.workAreaNode}).inject(worksAreaContentNode);
  778. var actionNode = new Element("div", {"styles": this.css.workAreaActionNode, "text": this.view.lp.open}).inject(node);
  779. actionNode.store("workId", work.id);
  780. actionNode.addEvent("click", function(e){
  781. this.mask.hide();
  782. worksAreaNode.destroy();
  783. this.openWorkCompleted(e.target.retrieve("workId"), e)
  784. }.bind(this));
  785. var areaNode = new Element("div", {"styles": this.css.workAreaLeftNode}).inject(node);
  786. var titleNode = new Element("div", {"styles": this.css.workAreaTitleNode, "text": work.title}).inject(areaNode);
  787. var contentNode = new Element("div", {"styles": this.css.workAreaContentNode}).inject(areaNode);
  788. new Element("div", {"styles": this.css.workAreaContentTitleNode, "text": this.view.lp.activity+": "}).inject(contentNode);
  789. new Element("div", {"styles": this.css.workAreaContentTextNode, "text": this.view.lp.processCompleted}).inject(contentNode);
  790. },
  791. createWorksArea: function(){
  792. var worksAreaNode = new Element("div", {"styles": this.css.worksAreaNode});
  793. var worksAreaTitleNode = new Element("div", {"styles": this.css.worksAreaTitleNode}).inject(worksAreaNode);
  794. var worksAreaTitleCloseNode = new Element("div", {"styles": this.css.worksAreaTitleCloseNode}).inject(worksAreaTitleNode);
  795. worksAreaTitleCloseNode.addEvent("click", function(e){
  796. this.mask.hide();
  797. e.target.getParent().getParent().destroy();
  798. }.bind(this));
  799. var worksAreaContentNode = new Element("div", {"styles": this.css.worksAreaContentNode}).inject(worksAreaNode);
  800. return worksAreaNode;
  801. },
  802. showWorksArea: function(node, e){
  803. this.mask = new MWF.widget.Mask({"style": "desktop", "loading": false});
  804. this.mask.loadNode(this.view.container);
  805. node.inject(this.view.node);
  806. this.setWorksAreaPosition(node, e.target);
  807. },
  808. setWorksAreaPosition: function(node, td){
  809. var p = td.getPosition(this.view.container);
  810. var containerS = this.view.container.getSize();
  811. var containerP = this.view.container.getPosition(this.view.container.getOffsetParent());
  812. var s = node.getSize();
  813. var offX = p.x+s.x-containerS.x;
  814. offX = (offX>0) ? offX+20 : 0;
  815. var offY = p.y+s.y-containerS.y;
  816. offY = (offY>0) ? offY+5 : 0;
  817. node.position({
  818. "relativeTo": td,
  819. "position": "lefttop",
  820. "edge": "lefttop",
  821. "offset": {
  822. "x": 0-offX,
  823. "y": 0-offY
  824. }
  825. });
  826. },
  827. openWork: function(id, e){
  828. var options = {"workId": id};
  829. this.view.fireEvent("openDocument", [options, this]);
  830. layout.desktop.openApplication(e, "process.Work", options);
  831. },
  832. openWorkCompleted: function(id, e){
  833. var options = {"workCompletedId": id};
  834. this.view.fireEvent("openDocument", [options, this]);
  835. layout.desktop.openApplication(e, "process.Work", options);
  836. },
  837. setEvent: function(){
  838. if (this.view.json.select==="single" || this.view.json.select==="multi"){
  839. this.node.addEvents({
  840. "mouseover": function(){
  841. if (!this.isSelected){
  842. var iconName = "checkbox";
  843. if (this.view.json.select==="single") iconName = "radiobox";
  844. this.selectTd.setStyles({"background": "url("+"/x_component_query_Query/$Viewer/default/icon/"+iconName+".png) center center no-repeat"});
  845. }
  846. }.bind(this),
  847. "mouseout": function(){
  848. if (!this.isSelected) this.selectTd.setStyles({"background": "transparent"});
  849. }.bind(this),
  850. "click": function(){this.select();}.bind(this)
  851. });
  852. }
  853. },
  854. select: function(){
  855. if (this.isSelected){
  856. if (this.view.json.select==="single"){
  857. this.unSelectedSingle();
  858. }else{
  859. this.unSelected();
  860. }
  861. }else{
  862. if (this.view.json.select==="single"){
  863. this.selectedSingle();
  864. }else{
  865. this.selected();
  866. }
  867. }
  868. this.view.fireEvent("select");
  869. },
  870. selected: function(){
  871. this.view.selectedItems.push(this);
  872. this.selectTd.setStyles({"background": "url("+"/x_component_query_Query/$Viewer/default/icon/checkbox_checked.png) center center no-repeat"});
  873. this.node.setStyles(this.css.viewContentTrNode_selected);
  874. this.isSelected = true;
  875. },
  876. unSelected: function(){
  877. this.view.selectedItems.erase(this);
  878. this.selectTd.setStyles({"background": "transparent"});
  879. this.node.setStyles(this.css.viewContentTrNode);
  880. this.isSelected = false;
  881. },
  882. selectedSingle: function(){
  883. if (this.view.currentSelectedItem) this.view.currentSelectedItem.unSelectedSingle();
  884. this.view.selectedItems = [this];
  885. this.view.currentSelectedItem = this;
  886. this.selectTd.setStyles({"background": "url("+"/x_component_query_Query/$Viewer/default/icon/radiobox_checked.png) center center no-repeat"});
  887. this.node.setStyles(this.css.viewContentTrNode_selected);
  888. this.isSelected = true;
  889. },
  890. unSelectedSingle: function(){
  891. this.view.selectedItems = [];
  892. this.view.currentSelectedItem = null;
  893. this.selectTd.setStyles({"background": "transparent"});
  894. this.node.setStyles(this.css.viewContentTrNode);
  895. this.isSelected = false;
  896. }
  897. });
  898. MWF.xApplication.query.Query.Viewer.ItemCategory = new Class({
  899. initialize: function(view, data){
  900. this.view = view;
  901. this.data = data;
  902. this.css = this.view.css;
  903. this.items = [];
  904. this.loadChild = false;
  905. this.load();
  906. },
  907. load: function(){
  908. this.node = new Element("tr", {"styles": this.css.viewContentTrNode}).inject(this.view.viewTable);
  909. //if (this.view.json.select==="single" || this.view.json.select==="multi"){
  910. this.selectTd = new Element("td", {"styles": this.css.viewContentCategoryTdNode}).inject(this.node);
  911. if (this.view.json.itemStyles) this.selectTd.setStyles(this.view.json.itemStyles);
  912. //}
  913. this.categoryTd = new Element("td", {
  914. "styles": this.css.viewContentCategoryTdNode,
  915. "colspan": this.view.viewJson.selectList.length
  916. }).inject(this.node);
  917. this.groupColumn = null;
  918. for (var c = 0; c<this.view.viewJson.selectList.length; c++){
  919. if (this.view.viewJson.selectList[c].column === this.view.viewJson.group.column){
  920. this.groupColumn = this.view.viewJson.selectList[c];
  921. break;
  922. }
  923. }
  924. if (this.groupColumn){
  925. var text = (this.groupColumn.code) ? MWF.Macro.exec(this.groupColumn.code, {"value": this.data.group, "gridData": this.view.gridJson, "data": this.view.viewData, "entry": this.data}) : this.data.group;
  926. }else{
  927. var text = this.data.group;
  928. }
  929. this.categoryTd.set("html", "<span style='font-family: Webdings'><img src='/x_component_query_Query/$Viewer/"+this.view.options.style+"/icon/expand.png'/></span> "+text);
  930. if (this.view.json.itemStyles) this.categoryTd.setStyles(this.view.json.itemStyles);
  931. this.setEvent();
  932. },
  933. setEvent: function(){
  934. //if (this.selectTd){
  935. this.node.addEvents({
  936. "click": function(){this.expandOrCollapse();}.bind(this)
  937. });
  938. //}
  939. },
  940. expandOrCollapse: function(){
  941. var t = this.node.getElement("span").get("html");
  942. if (t.indexOf("expand.png")===-1){
  943. this.collapse();
  944. }else{
  945. this.expand();
  946. }
  947. },
  948. collapse: function(){
  949. this.items.each(function(item){
  950. item.node.setStyle("display", "none");
  951. }.bind(this));
  952. this.node.getElement("span").set("html", "<img src='/x_component_query_Query/$Viewer/"+this.view.options.style+"/icon/expand.png'/>");
  953. },
  954. expand: function(){
  955. this.items.each(function(item){
  956. item.node.setStyle("display", "table-row");
  957. }.bind(this));
  958. this.node.getElement("span").set("html", "<img src='/x_component_query_Query/$Viewer/"+this.view.options.style+"/icon/down.png'/>");
  959. if (!this.loadChild){
  960. //window.setTimeout(function(){
  961. this.data.list.each(function(line){
  962. this.items.push(new MWF.xApplication.query.Query.Viewer.Item(this.view, line, this));
  963. }.bind(this));
  964. this.loadChild = true;
  965. //}.bind(this), 10);
  966. }
  967. }
  968. });
  969. MWF.xApplication.query.Query.Viewer.Filter = new Class({
  970. initialize: function(viewer, data, node){
  971. this.viewer = viewer;
  972. this.data = data;
  973. this.css = this.viewer.css;
  974. this.content = node;
  975. this.load();
  976. },
  977. load: function(){
  978. this.node = new Element("div", {"styles": this.css.viewSearchFilterNode}).inject(this.content);
  979. if (this.viewer.filterItems.length){
  980. this.logicNode = new Element("div", {"styles": this.css.viewSearchFilterSelectAreaNode}).inject(this.node);
  981. this.logicSelectNode = new Element("div", {
  982. "styles": this.css.viewSearchFilterSelectNode,
  983. "text": this.viewer.lp.and,
  984. "value": "and"
  985. }).inject(this.logicNode);
  986. this.logicSelectButtonNode = new Element("div", {"styles": this.css.viewSearchFilterSelectButtonNode}).inject(this.logicNode);
  987. this.logicNode.addEvents({
  988. "click": function(){
  989. var v = this.logicSelectNode.get("value");
  990. if (v==="and"){
  991. this.logicSelectButtonNode.setStyle("float", "left");
  992. this.logicSelectNode.setStyle("float", "right");
  993. this.logicSelectNode.set({
  994. "text": this.viewer.lp.or,
  995. "value": "or"
  996. });
  997. this.data.logic = "or";
  998. }else{
  999. this.logicSelectButtonNode.setStyle("float", "right");
  1000. this.logicSelectNode.setStyle("float", "left");
  1001. this.logicSelectNode.set({
  1002. "text": this.viewer.lp.and,
  1003. "value": "and"
  1004. });
  1005. this.data.logic = "and";
  1006. }
  1007. this.viewer.searchCustomView();
  1008. }.bind(this)
  1009. });
  1010. }
  1011. this.titleNode = new Element("div", {"styles": this.css.viewSearchFilterTextNode, "text": this.data.title}).inject(this.node);
  1012. this.comparisonTitleNode = new Element("div", {"styles": this.css.viewSearchFilterTextNode, "text": this.data.comparisonTitle}).inject(this.node);
  1013. this.valueNode = new Element("div", {"styles": this.css.viewSearchFilterTextNode, "text": "\""+this.data.value+"\""}).inject(this.node);
  1014. this.deleteNode = new Element("div", {"styles": this.css.viewSearchFilterDeleteNode}).inject(this.node);
  1015. this.node.addEvents({
  1016. "mouseover": function(){
  1017. this.node.setStyles(this.css.viewSearchFilterNode_over);
  1018. this.deleteNode.setStyles(this.css.viewSearchFilterDeleteNode_over);
  1019. }.bind(this),
  1020. "mouseout": function(){
  1021. this.node.setStyles(this.css.viewSearchFilterNode);
  1022. this.deleteNode.setStyles(this.css.viewSearchFilterDeleteNode);
  1023. }.bind(this)
  1024. });
  1025. this.deleteNode.addEvent("click", function(){
  1026. this.viewer.searchViewRemoveFilter(this);
  1027. }.bind(this));
  1028. },
  1029. destroy: function(){
  1030. this.node.destroy();
  1031. MWF.release(this);
  1032. }
  1033. });