Property.js 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344
  1. MWF.require("MWF.widget.Common", null, false);
  2. MWF.require("MWF.widget.JsonTemplate", null, false);
  3. MWF.xApplication.query.ViewDesigner.Property = MWF.FVProperty = new Class({
  4. Extends: MWF.widget.Common,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "path": "/x_component_query_FormDesigner/property/property.html"
  9. },
  10. initialize: function(module, propertyNode, designer, options){
  11. this.setOptions(options);
  12. this.module = module;
  13. this.view = module.view;
  14. this.data = module.json;
  15. this.data.vid = this.view.json.id;
  16. this.data.vtype = this.view.json.type;
  17. this.data.pid = this.view.json.id+this.data.id;
  18. this.htmlPath = this.options.path;
  19. this.designer = designer;
  20. this.propertyNode = propertyNode;
  21. },
  22. load: function(){
  23. if (this.fireEvent("queryLoad")){
  24. MWF.getRequestText(this.htmlPath, function(responseText, responseXML){
  25. this.htmlString = responseText;
  26. this.fireEvent("postLoad");
  27. }.bind(this));
  28. }
  29. this.propertyNode.addEvent("keydown", function(e){e.stopPropagation();});
  30. },
  31. editProperty: function(td){
  32. },
  33. getHtmlString: function(callback){
  34. if (!this.htmlString){
  35. MWF.getRequestText(this.htmlPath, function(responseText, responseXML){
  36. this.htmlString = responseText;
  37. if (callback) callback();
  38. }.bind(this));
  39. }else{
  40. if (callback) callback();
  41. }
  42. },
  43. show: function(){
  44. if (!this.propertyContent){
  45. this.getHtmlString(function(){
  46. if (this.htmlString){
  47. this.JsonTemplate = new MWF.widget.JsonTemplate(this.data, this.htmlString);
  48. this.propertyContent = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.propertyNode);
  49. this.propertyContent.set("html", this.JsonTemplate.load());
  50. this.setEditNodeEvent();
  51. this.setEditNodeStyles(this.propertyContent);
  52. this.loadPropertyTab();
  53. this.loadPersonInput();
  54. this.loadPersonSelectInput();
  55. this.loadViewFilter();
  56. this.loadScriptArea();
  57. this.loadColumnExportEditor();
  58. this.loadJSONArea();
  59. this.loadEventsEditor();
  60. this.loadViewStylesArea();
  61. this.loadPagingStylesArea();
  62. this.loadActionStylesArea();
  63. this.loadActionArea();
  64. this.loadStylesList();
  65. }
  66. }.bind(this));
  67. }else{
  68. this.propertyContent.setStyle("display", "block");
  69. }
  70. },
  71. hide: function(){
  72. //this.JsonTemplate = null;
  73. //this.propertyNode.set("html", "");
  74. if (this.propertyContent) this.propertyContent.setStyle("display", "none");
  75. },
  76. loadJSONArea: function(){
  77. var jsonNode = this.propertyContent.getElement(".MWFJSONArea");
  78. if (jsonNode){
  79. this.propertyTab.pages.each(function(page){
  80. if (page.contentNode == jsonNode.parentElement){
  81. page.setOptions({
  82. "onShow": function(){
  83. jsonNode.empty();
  84. MWF.require("MWF.widget.JsonParse", function(){
  85. this.json = new MWF.widget.JsonParse(this.module.json, jsonNode, null);
  86. this.json.load();
  87. }.bind(this));
  88. }.bind(this)
  89. });
  90. }
  91. }.bind(this));
  92. }
  93. },
  94. loadPropertyTab: function(){
  95. var tabNodes = this.propertyContent.getElements(".MWFTab");
  96. if (tabNodes.length){
  97. var tmpNode = this.propertyContent.getFirst();
  98. var tabAreaNode = new Element("div", {
  99. "styles": this.view.css.propertyTabNode
  100. }).inject(tmpNode, "before");
  101. MWF.require("MWF.widget.Tab", function(){
  102. var tab = new MWF.widget.Tab(tabAreaNode, {"style": "formPropertyList"});
  103. tab.load();
  104. var tabPages = [];
  105. tabNodes.each(function(node){
  106. var page = tab.addTab(node, node.get("title"), false);
  107. tabPages.push(page);
  108. this.setScrollBar(page.contentNodeArea, "small", null, null);
  109. }.bind(this));
  110. tabPages[0].showTab();
  111. this.propertyTab = tab;
  112. this.designer.resizeNode();
  113. }.bind(this), false);
  114. }
  115. },
  116. setEditNodeEvent: function(){
  117. var property = this;
  118. // var inputs = this.process.propertyListNode.getElements(".editTableInput");
  119. var inputs = this.propertyContent.getElements("input");
  120. inputs.each(function(input){
  121. var jsondata = input.get("name");
  122. if (jsondata && jsondata.substr(0,1)!="_"){
  123. if (this.module){
  124. var id = this.module.json.id;
  125. input.set("name", id+jsondata);
  126. }
  127. if (jsondata){
  128. var inputType = input.get("type").toLowerCase();
  129. switch (inputType){
  130. case "radio":
  131. input.addEvent("change", function(e){
  132. property.setRadioValue(jsondata, this);
  133. });
  134. input.addEvent("blur", function(e){
  135. property.setRadioValue(jsondata, this);
  136. });
  137. input.addEvent("keydown", function(e){
  138. e.stopPropagation();
  139. });
  140. property.setRadioValue(jsondata, input);
  141. break;
  142. case "checkbox":
  143. input.addEvent("change", function(e){
  144. property.setCheckboxValue(jsondata, this);
  145. });
  146. input.addEvent("click", function(e){
  147. property.setCheckboxValue(jsondata, this);
  148. });
  149. input.addEvent("keydown", function(e){
  150. e.stopPropagation();
  151. });
  152. break;
  153. default:
  154. input.addEvent("change", function(e){
  155. property.setValue(jsondata, this.value, this);
  156. });
  157. input.addEvent("blur", function(e){
  158. property.setValue(jsondata, this.value, this);
  159. });
  160. input.addEvent("keydown", function(e){
  161. if (e.code==13){
  162. property.setValue(jsondata, this.value, this);
  163. }
  164. e.stopPropagation();
  165. });
  166. if (input.hasClass("editTableInputDate")){
  167. this.loadCalendar(input, jsondata);
  168. }
  169. }
  170. }
  171. }
  172. }.bind(this));
  173. var selects = this.propertyContent.getElements("select");
  174. selects.each(function(select){
  175. var jsondata = select.get("name");
  176. if (jsondata){
  177. select.addEvent("change", function(e){
  178. property.setSelectValue(jsondata, this);
  179. });
  180. //property.setSelectValue(jsondata, select);
  181. }
  182. });
  183. var textareas = this.propertyContent.getElements("textarea");
  184. textareas.each(function(input){
  185. var jsondata = input.get("name");
  186. if (jsondata){
  187. input.addEvent("change", function(e){
  188. property.setValue(jsondata, this.value);
  189. });
  190. input.addEvent("blur", function(e){
  191. property.setValue(jsondata, this.value);
  192. });
  193. input.addEvent("keydown", function(e){
  194. e.stopPropagation();
  195. });
  196. }
  197. }.bind(this));
  198. },
  199. loadCalendar: function(node, jsondata){
  200. MWF.require("MWF.widget.Calendar", function(){
  201. this.calendar = new MWF.widget.Calendar(node, {
  202. "style": "xform",
  203. "isTime": false,
  204. "target": this.module.designer.content,
  205. "format": "%Y-%m-%d",
  206. "onComplate": function(){
  207. this.setValue(jsondata, node.value, node);
  208. //this.validationMode();
  209. //this.validation();
  210. //this.fireEvent("complete");
  211. }.bind(this)
  212. });
  213. //this.calendar.show();
  214. }.bind(this));
  215. },
  216. changeStyle: function(name){
  217. this.module.setPropertiesOrStyles(name);
  218. },
  219. changeData: function(name, input, oldValue){
  220. var i = name.lastIndexOf("*");
  221. var n = (i!=-1) ? name.substr(i+1, name.length) : name;
  222. this.module._setEditStyle(n, input, oldValue);
  223. },
  224. changeJsonDate: function(key, value){
  225. if (typeOf(key)!="array") key = [key];
  226. var o = this.data;
  227. var len = key.length-1;
  228. key.each(function(n, i){
  229. if (!o[n]) o[n] = {};
  230. if (i<len) o = o[n];
  231. }.bind(this));
  232. o[key[len]] = value;
  233. },
  234. setRadioValue: function(name, input){
  235. if (input.checked){
  236. var i = name.indexOf("*");
  237. var names = (i==-1) ? name.split(".") : name.substr(i+1, name.length).split(".");
  238. var value = input.value;
  239. if (value=="false") value = false;
  240. if (value=="true") value = true;
  241. var oldValue = this.data;
  242. for (var idx = 0; idx<names.length; idx++){
  243. if (!oldValue[names[idx]]){
  244. oldValue = null;
  245. break;
  246. }else{
  247. oldValue = oldValue[names[idx]];
  248. }
  249. }
  250. //var oldValue = this.data[name];
  251. this.changeJsonDate(names, value);
  252. this.changeData(name, input, oldValue);
  253. }
  254. },
  255. setCheckboxValue: function(name, input){
  256. var id = this.module.json.id;
  257. var checkboxList = $$("input[name='"+id+name+"']");
  258. var values = [];
  259. checkboxList.each(function(checkbox){
  260. if (checkbox.get("checked")){
  261. values.push(checkbox.value);
  262. }
  263. });
  264. var oldValue = this.data[name];
  265. //this.data[name] = values;
  266. this.changeJsonDate(name, values);
  267. this.changeData(name, input, oldValue);
  268. },
  269. setSelectValue: function(name, select){
  270. var idx = select.selectedIndex;
  271. var options = select.getElements("option");
  272. var value = "";
  273. if (options[idx]){
  274. value = options[idx].get("value");
  275. }
  276. var i = name.indexOf("*");
  277. var names = (i==-1) ? name.split(".") : name.substr(i+1, name.length).split(".");
  278. //var oldValue = this.data[name];
  279. var oldValue = this.data;
  280. for (var idx = 0; idx<names.length; idx++){
  281. if (!oldValue[names[idx]]){
  282. oldValue = null;
  283. break;
  284. }else{
  285. oldValue = oldValue[names[idx]];
  286. }
  287. }
  288. //var oldValue = this.data[name];
  289. //this.data[name] = value;
  290. this.changeJsonDate(names, value);
  291. this.changeData(name, select, oldValue);
  292. },
  293. setValue: function(name, value, obj){
  294. var names = name.split(".");
  295. var oldValue = this.data;
  296. for (var idx = 0; idx<names.length; idx++){
  297. if (!oldValue[names[idx]]){
  298. oldValue = null;
  299. break;
  300. }else{
  301. oldValue = oldValue[names[idx]];
  302. }
  303. }
  304. //var oldValue = this.data[name];
  305. //this.data[name] = value;
  306. this.changeJsonDate(names, value);
  307. this.changeData(name, obj, oldValue);
  308. },
  309. setEditNodeStyles: function(node){
  310. var nodes = node.getChildren();
  311. if (nodes.length){
  312. nodes.each(function(el){
  313. var cName = el.get("class");
  314. if (cName){
  315. if (this.view.css[cName]) el.setStyles(this.view.css[cName]);
  316. }
  317. this.setEditNodeStyles(el);
  318. }.bind(this));
  319. }
  320. },
  321. loadScriptArea: function(){
  322. var scriptAreas = this.propertyContent.getElements(".MWFScriptArea");
  323. var formulaAreas = this.propertyContent.getElements(".MWFFormulaArea");
  324. this.loadScriptEditor(scriptAreas);
  325. this.loadScriptEditor(formulaAreas, "formula");
  326. },
  327. loadScriptEditor: function(scriptAreas, style){
  328. scriptAreas.each(function(node){
  329. var title = node.get("title");
  330. var name = node.get("name");
  331. var scriptContent = this.data[name];
  332. MWF.require("MWF.widget.ScriptArea", function(){
  333. var scriptArea = new MWF.widget.ScriptArea(node, {
  334. "title": title,
  335. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  336. "maxObj": this.designer.editContentNode,
  337. "onChange": function(){
  338. this.data[name] = scriptArea.toJson().code;
  339. }.bind(this),
  340. "onSave": function(){
  341. this.designer.saveView();
  342. }.bind(this),
  343. "style": style || "default"
  344. });
  345. scriptArea.load({"code": scriptContent});
  346. }.bind(this));
  347. }.bind(this));
  348. },
  349. loadStatColumnSelect: function(){},
  350. loadPersonInput: function(){
  351. var identityNodes = this.propertyContent.getElements(".MWFPersonIdentity");
  352. var personUnitNodes = this.propertyContent.getElements(".MWFPersonUnit");
  353. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function(){
  354. identityNodes.each(function(node){
  355. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  356. "type": "identity",
  357. "names": this.data[node.get("name")],
  358. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  359. });
  360. }.bind(this));
  361. personUnitNodes.each(function(node){
  362. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  363. "type": "unit",
  364. "names": this.data[node.get("name")],
  365. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  366. });
  367. }.bind(this));
  368. }.bind(this));
  369. },
  370. savePersonItem: function(node, ids){
  371. var values = [];
  372. ids.each(function(id){
  373. //values.push({"name": (id.data.distinguishedName || id.data.name), "id": id.data.id});
  374. values.push((id.data.distinguishedName || id.data.id || id.data.name));
  375. }.bind(this));
  376. var name = node.get("name");
  377. key = name.split(".");
  378. var o = this.data;
  379. var len = key.length-1;
  380. key.each(function(n, i){
  381. if (!o[n]) o[n] = {};
  382. if (i<len) o = o[n];
  383. }.bind(this));
  384. o[key[len]] = values;
  385. //this.data.data.restrictWhereEntry[node.get("name")] = values;
  386. },
  387. loadPersonSelectInput: function(){
  388. var applicationNodes = this.propertyContent.getElements(".MWFSelectApplication");
  389. var processNodes = this.propertyContent.getElements(".MWFSelectProcess");
  390. // var companyNodes = this.propertyContent.getElements(".MWFSelectCompany");
  391. // var departmentNodes = this.propertyContent.getElements(".MWFSelectDepartment");
  392. var personNodes = this.propertyContent.getElements(".MWFSelectPerson");
  393. var identityNodes = this.propertyContent.getElements(".MWFSelectIdentity");
  394. var personUnitNodes = this.propertyContent.getElements(".MWFSelectUnit");
  395. var cmsapplicationNodes = this.propertyContent.getElements(".MWFSelectCMSApplication");
  396. var cmscategoryNodes = this.propertyContent.getElements(".MWFSelecCMStCategory");
  397. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function(){
  398. applicationNodes.each(function(node){
  399. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  400. "type": "application",
  401. "names": (this.data.data.where) ? this.data.data.where.applicationList : [],
  402. "onChange": function(ids){this.savePersonSelectItem(node, ids);}.bind(this)
  403. });
  404. }.bind(this));
  405. processNodes.each(function(node){
  406. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  407. "type": "process",
  408. "names": (this.data.data.where) ? this.data.data.where.processList : [],
  409. "onChange": function(ids){this.savePersonSelectItem(node, ids);}.bind(this)
  410. });
  411. }.bind(this));
  412. personUnitNodes.each(function(node){
  413. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  414. "type": "unit",
  415. "names": (this.data.data.where) ? this.data.data.where.unitList : [],
  416. "onChange": function(ids){this.savePersonSelectItem(node, ids);}.bind(this)
  417. });
  418. }.bind(this));
  419. personNodes.each(function(node){
  420. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  421. "type": "person",
  422. "names": (this.data.data.where) ? this.data.data.where.personList : [],
  423. "onChange": function(ids){this.savePersonSelectItem(node, ids);}.bind(this)
  424. });
  425. }.bind(this));
  426. identityNodes.each(function(node){
  427. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  428. "type": "identity",
  429. "names": (this.data.data.where) ? this.data.data.where.identityList : [],
  430. "onChange": function(ids){this.savePersonSelectItem(node, ids);}.bind(this)
  431. });
  432. }.bind(this));
  433. cmsapplicationNodes.each(function(node){
  434. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  435. "type": "CMSApplication",
  436. "names": (this.data.data.where) ? this.data.data.where.appInfoList : [],
  437. "onChange": function(ids){this.savePersonSelectItem(node, ids);}.bind(this)
  438. });
  439. }.bind(this));
  440. cmscategoryNodes.each(function(node){
  441. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  442. "type": "CMSCategory",
  443. "names": (this.data.data.where) ? this.data.data.where.categoryInfoList : [],
  444. "onChange": function(ids){this.savePersonSelectItem(node, ids);}.bind(this)
  445. });
  446. }.bind(this));
  447. }.bind(this));
  448. },
  449. savePersonSelectItem: function(node, ids){
  450. //this.initWhereEntryData();
  451. var values = [];
  452. ids.each(function(id){
  453. values.push({"name": (id.data.distinguishedName || id.data.name), "id": id.data.id});
  454. //values.push((id.data.distinguishedName || id.data.id || id.data.name));
  455. }.bind(this));
  456. var name = node.get("name");
  457. key = name.split(".");
  458. var o = this.data;
  459. var len = key.length-1;
  460. key.each(function(n, i){
  461. if (!o[n]) o[n] = {};
  462. if (i<len) o = o[n];
  463. }.bind(this));
  464. o[key[len]] = values;
  465. //this.data.data.restrictWhereEntry[node.get("name")] = values;
  466. },
  467. //loadWorkDataEditor: function(){
  468. // var workDataNodes = this.propertyContent.getElements(".MWFWorkData");
  469. // workDataNodes.each(function(node){
  470. // var select = node.getElement("select");
  471. // for (var i=0; i<select.options.length; i++){
  472. // if (select.options[i].value==this.data.name){
  473. // select.options[i].set("selected", true);
  474. // break;
  475. // }
  476. // }
  477. // if (!this.data.type) this.data.type = "text";
  478. // select.addEvent("change", function(e){
  479. // delete this.data.path;
  480. // this.data.name = select.options[select.selectedIndex].value;
  481. // this.module.listNode.getLast().set("text", this.data.text+"("+this.data.name+")");
  482. // this.setDataType();
  483. // }.bind(this));
  484. //
  485. // this.setDataType();
  486. // }.bind(this));
  487. // var nodes = this.propertyContent.getElements(".MWFWorkDataCheck");
  488. // nodes.each(function(node){
  489. // if (this.data.name) node.set("checked", true);
  490. // }.bind(this));
  491. //},
  492. //setDataType: function(){
  493. // switch (this.data.name){
  494. // case "startTime":case "completedTime":
  495. // this.data.type ="date";
  496. // break;
  497. // case "completed":
  498. // this.data.type ="boolean";
  499. // break;
  500. // default:
  501. // this.data.type ="text";
  502. // }
  503. //},
  504. //loadDataDataEditor: function(){
  505. // var nodes = this.propertyContent.getElements(".MWFDataData");
  506. // nodes.each(function(node){
  507. // var input = node.getElement("input");
  508. // input.set("value", this.data.path);
  509. // input.addEvent("change", function(e){
  510. // delete this.data.name;
  511. // this.data.path = input.get("value");
  512. // this.module.listNode.getLast().set("text", this.data.text+"("+this.data.path+")");
  513. // }.bind(this));
  514. // input.addEvent("blur", function(e){
  515. // delete this.data.name;
  516. // this.data.path = input.get("value");
  517. // this.module.listNode.getLast().set("text", this.data.text+"("+this.data.path+")");
  518. // }.bind(this));
  519. // input.addEvent("keydown", function(e){
  520. // if (e.code==13){
  521. // delete this.data.name;
  522. // this.data.path = input.get("value");
  523. // this.module.listNode.getLast().set("text", this.data.text+"("+this.data.path+")");
  524. // }
  525. // e.stopPropagation();
  526. // }.bind(this));
  527. //
  528. // var select = node.getElement("select");
  529. // for (var i=0; i<select.options.length; i++){
  530. // if (select.options[i].value==this.data.type){
  531. // select.options[i].set("selected", true);
  532. // break;
  533. // }
  534. // }
  535. // if (!this.data.type) this.data.type = "text";
  536. // select.addEvent("change", function(e){
  537. // this.data.type = select.options[select.selectedIndex].value;
  538. // }.bind(this));
  539. //
  540. // }.bind(this));
  541. // var nodes = this.propertyContent.getElements(".MWFDataDataCheck");
  542. // nodes.each(function(node){
  543. // if (this.data.path) node.set("checked", true);
  544. // }.bind(this));
  545. //},
  546. loadColumnExportEditor: function(){
  547. var _self = this;
  548. var nodes = this.propertyContent.getElements(".MWFColumnExport");
  549. nodes.each(function(node){
  550. //if (!this.data.export) this.data.export = {};
  551. //var sort = this.data.export.sort || "";
  552. //var sortOrder = this.data.export.sortOrder || "1";
  553. var select = node.getElement("select");
  554. var sortList = this.view.data.data.orderList;
  555. sortList.each(function(order){
  556. if (order.column==this.data.column){
  557. if (order.orderType=="asc") select.options[1].set("selected", true);
  558. if (order.orderType=="desc") select.options[1].set("selected", false);
  559. }
  560. }.bind(this));
  561. select.addEvent("change", function(e){
  562. var v = select.options[select.selectedIndex].value;
  563. if (v!="none"){
  564. var flag = false;
  565. sortList.each(function(order){
  566. if (order.column==this.data.column){
  567. flag = true;
  568. order.orderType=select.options[select.selectedIndex].value;
  569. }
  570. }.bind(this));
  571. if (!flag) sortList.push({"column": this.data.column, "orderType": select.options[select.selectedIndex].value});
  572. }else{
  573. var deleteItem = null;
  574. sortList.each(function(order){
  575. if (order.column==this.data.column){
  576. deleteItem = order;
  577. }
  578. }.bind(this));
  579. if (deleteItem) sortList.erase(deleteItem);
  580. }
  581. }.bind(this));
  582. var radios = node.getElements("input");
  583. var group = this.view.data.data.group;
  584. if (group.column==this.data.column) radios[0].set("checked", true);
  585. radios.addEvent("click", function(e){
  586. if (this.checked){
  587. if (this.value=="true") {
  588. _self.view.data.data.group.column = _self.data.column;
  589. _self.view.items.each(function(col){
  590. if (col.property){
  591. var groupRadios = col.property.propertyContent.getElement(".MWFColumnExportGroup").getElements("input");
  592. groupRadios.each(function(r){
  593. if (r.value=="true") r.set("checked", false);
  594. if (r.value=="false") r.set("checked", true);
  595. });
  596. }
  597. });
  598. this.set("checked", true);
  599. }else{
  600. if (group.column ==_self.data.column) _self.view.data.data.group = {};
  601. }
  602. }
  603. });
  604. }.bind(this));
  605. },
  606. loadViewFilter: function(){
  607. var nodes = this.propertyContent.getElements(".MWFViewFilter");
  608. var filtrData = this.view.data.data.filterList;
  609. var customData = this.view.data.data.customFilterList;
  610. nodes.each(function(node){
  611. MWF.xDesktop.requireApp("query.ViewDesigner", "widget.ViewFilter", function(){
  612. var _slef = this;
  613. new MWF.xApplication.query.ViewDesigner.widget.ViewFilter(node, this.view.designer, {"filtrData": filtrData, "customData": customData}, {
  614. "onChange": function(ids){
  615. var data = this.getData();
  616. _slef.changeJsonDate(["data", "filterList"], data.data);
  617. _slef.changeJsonDate(["data", "customFilterList"], data.customData);
  618. }
  619. });
  620. }.bind(this));
  621. }.bind(this));
  622. },
  623. loadColumnFilter: function(){
  624. var nodes = this.propertyContent.getElements(".MWFColumnFilter");
  625. nodes.each(function(node){
  626. this.module.filterAreaNode = node;
  627. var table = new Element("table", {
  628. "styles": {"width": "100%"},
  629. "border": "0px",
  630. "cellPadding": "0",
  631. "cellSpacing": "0"
  632. }).inject(node);
  633. var tr = new Element("tr", {"styles": this.module.css.filterTableTitle}).inject(table);
  634. var html = "<th style='width:24px;border-right:1px solid #CCC;border-bottom:1px solid #999;'></th>" +
  635. "<th style='border-right:1px solid #CCC;border-left:1px solid #FFF;border-bottom:1px solid #999;'>逻辑</th>" +
  636. "<th style='border-right:1px solid #CCC;border-left:1px solid #FFF;border-bottom:1px solid #999;'>路径</th>" +
  637. "<th style='border-right:1px solid #CCC;border-left:1px solid #FFF;border-bottom:1px solid #999;'>比较</th>" +
  638. "<th style='border-left:1px solid #FFF;border-bottom:1px solid #999;'>值</th>";
  639. tr.set("html", html);
  640. var addActionNode = new Element("div", {"styles": this.module.css.filterAddActionNode}).inject(tr.getFirst("th"));
  641. addActionNode.addEvent("click", function(){
  642. this.addFilter(table);
  643. }.bind(this));
  644. if (this.data.filterList) {
  645. this.data.filterList.each(function (op) {
  646. new MWF.xApplication.query.ViewDesigner.Property.Filter(op, table, this);
  647. }.bind(this));
  648. }
  649. }.bind(this));
  650. },
  651. addFilter: function(table){
  652. op = {
  653. "logic": "and",
  654. "comparison": "",
  655. "value": ""
  656. }
  657. if (!this.data.filterList) this.data.filterList = [];
  658. this.data.filterList.push(op);
  659. var filter = new MWF.xApplication.query.ViewDesigner.Property.Filter(op, table, this);
  660. filter.editMode();
  661. },
  662. loadViewStylesArea: function(){
  663. var _self = this;
  664. var viewAreas = this.propertyContent.getElements(".MWFViewStylesArea");
  665. viewAreas.each(function(node){
  666. var name = node.get("name");
  667. var viewStyles = this.data[name] || {};
  668. MWF.require("MWF.widget.Maplist", function(){
  669. var maps = [];
  670. Object.each(viewStyles, function(v, k){
  671. var mapNode = new Element("div").inject(node);
  672. mapNode.empty();
  673. var maplist = new MWF.widget.Maplist(mapNode, {
  674. "title": k,
  675. "collapse": true,
  676. "onChange": function(){
  677. var oldData = _self.data[name];
  678. maps.each(function(o){
  679. _self.data[name][o.key] = o.map.toJson();
  680. }.bind(this));
  681. _self.changeData(name, node, oldData);
  682. }
  683. });
  684. maps.push({"key": k, "map": maplist});
  685. maplist.load(v);
  686. }.bind(this));
  687. }.bind(this));
  688. }.bind(this));
  689. },
  690. loadActionStylesArea: function(){
  691. var _self = this;
  692. var actionAreas = this.propertyContent.getElements(".MWFActionStylesArea");
  693. actionAreas.each(function(node){
  694. var name = node.get("name");
  695. var actionStyles = this.data[name];
  696. MWF.require("MWF.widget.Maplist", function(){
  697. var maps = [];
  698. Object.each(actionStyles, function(v, k){
  699. var mapNode = new Element("div").inject(node);
  700. mapNode.empty();
  701. var maplist = new MWF.widget.Maplist(mapNode, {
  702. "title": k,
  703. "collapse": true,
  704. "onChange": function(){
  705. var oldData = _self.data[name];
  706. maps.each(function(o){
  707. _self.data[name][o.key] = o.map.toJson();
  708. }.bind(this));
  709. _self.changeData(name, node, oldData);
  710. }
  711. });
  712. maps.push({"key": k, "map": maplist});
  713. maplist.load(v);
  714. }.bind(this));
  715. }.bind(this));
  716. }.bind(this));
  717. },
  718. loadPagingStylesArea: function(){
  719. var _self = this;
  720. var pagingAreas = this.propertyContent.getElements(".MWFPagingStylesArea");
  721. pagingAreas.each(function(node){
  722. var name = node.get("name");
  723. var pagingStyles = this.data[name];
  724. MWF.require("MWF.widget.Maplist", function(){
  725. var maps = [];
  726. Object.each(pagingStyles, function(v, k){
  727. var mapNode = new Element("div").inject(node);
  728. mapNode.empty();
  729. var maplist = new MWF.widget.Maplist(mapNode, {
  730. "title": k,
  731. "collapse": true,
  732. "onChange": function(){
  733. var oldData = _self.data[name];
  734. maps.each(function(o){
  735. _self.data[name][o.key] = o.map.toJson();
  736. }.bind(this));
  737. _self.changeData(name, node, oldData);
  738. }
  739. });
  740. maps.push({"key": k, "map": maplist});
  741. maplist.load(v);
  742. }.bind(this));
  743. }.bind(this));
  744. }.bind(this));
  745. },
  746. loadEventsEditor: function(){
  747. MWF.xApplication.process = MWF.xApplication.process || {};
  748. MWF.APPFD = MWF.xApplication.process.FormDesigner = MWF.xApplication.process.FormDesigner || {};
  749. MWF.xDesktop.requireApp("process.FormDesigner", "lp."+o2.language, null, false);
  750. var events = this.propertyContent.getElement(".MWFEventsArea");
  751. if (events){
  752. var name = events.get("name");
  753. var eventsObj = this.data;
  754. Array.each( name.split("."), function(n){
  755. if(eventsObj)eventsObj = eventsObj[n];
  756. })
  757. MWF.xDesktop.requireApp("process.FormDesigner", "widget.EventsEditor", function(){
  758. var eventsEditor = new MWF.xApplication.process.FormDesigner.widget.EventsEditor(events, this.designer, {
  759. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  760. "maxObj": this.designer.contentNode
  761. });
  762. eventsEditor.load(eventsObj, this.data, name);
  763. }.bind(this));
  764. }
  765. },
  766. loadActionArea: function(){
  767. MWF.xApplication.process = MWF.xApplication.process || {};
  768. MWF.APPFD = MWF.xApplication.process.FormDesigner = MWF.xApplication.process.FormDesigner || {};
  769. MWF.xDesktop.requireApp("process.FormDesigner", "lp."+o2.language, null, false);
  770. var actionAreas = this.propertyContent.getElements(".MWFActionArea");
  771. actionAreas.each(function(node){
  772. var name = node.get("name");
  773. var actionContent = this.data[name];
  774. MWF.xDesktop.requireApp("process.FormDesigner", "widget.ActionsEditor", function(){
  775. // debugger;
  776. // var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, {
  777. // "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  778. // "noCreate": true,
  779. // "noDelete": true,
  780. // "noCode": true,
  781. // "onChange": function(){
  782. // this.data[name] = actionEditor.data;
  783. // }.bind(this)
  784. // });
  785. // actionEditor.load(this.module.defaultToolBarsData);
  786. var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
  787. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  788. "noEditShow" : true,
  789. "noReadShow" : true,
  790. "onChange": function(){
  791. this.data[name] = actionEditor.data;
  792. this.changeData(name);
  793. }.bind(this)
  794. });
  795. actionEditor.load(actionContent);
  796. }.bind(this));
  797. }.bind(this));
  798. var actionAreas = this.propertyContent.getElements(".MWFDefaultActionArea");
  799. actionAreas.each(function(node){
  800. var name = node.get("name");
  801. var actionContent = this.data[name] || this.module.defaultToolBarsData;
  802. MWF.xDesktop.requireApp("process.FormDesigner", "widget.ActionsEditor", function(){
  803. var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
  804. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  805. "isSystemTool" : true,
  806. "systemToolsAddress" : "/x_component_query_ViewDesigner/$View/toolbars.json",
  807. "noCreate": true,
  808. "noDelete": false,
  809. "noCode": true,
  810. "noReadShow": true,
  811. "noEditShow": true,
  812. "onChange": function(){
  813. this.data[name] = actionEditor.data;
  814. this.changeData(name);
  815. }.bind(this)
  816. });
  817. actionEditor.load(actionContent);
  818. // var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, {
  819. // "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  820. // "onChange": function(){
  821. // this.data[name] = actionEditor.data;
  822. // }.bind(this)
  823. // });
  824. // actionEditor.load(actionContent);
  825. }.bind(this));
  826. }.bind(this));
  827. },
  828. loadStylesList: function(){
  829. var styleSelNodes = this.propertyContent.getElements(".MWFViewStyle");
  830. styleSelNodes.each(function(node){
  831. debugger;
  832. if (this.module.stylesList){
  833. if (!this.data.data.viewStyleType) this.data.data.viewStyleType = "default";
  834. // var mode = ( this.form.options.mode || "" ).toLowerCase() === "mobile" ? "mobile" : "pc";
  835. Object.each(this.module.stylesList, function(s, key){
  836. // if( s.mode.contains( mode ) ){
  837. new Element("option", {
  838. "text": s.name,
  839. "value": key,
  840. "selected": ((!this.data.data.viewStyleType && key=="default") || (this.data.data.viewStyleType==key))
  841. }).inject(node)
  842. // }
  843. }.bind(this));
  844. }else{
  845. node.getParent("tr").setStyle("display", "none");
  846. }
  847. }.bind(this));
  848. }
  849. //initWhereEntryData: function(){
  850. // if (!this.data.data.restrictWhereEntry) this.data.data.restrictWhereEntry = {
  851. // "applicationList": [],
  852. // "processList": [],
  853. // "companyList": [],
  854. // "departmentList": [],
  855. // "personList": [],
  856. // "identityList": []
  857. // };
  858. //},
  859. //loadApplicationSelector: function(){
  860. // var nodes = this.propertyContent.getElements(".MWFApplicationSelect");
  861. // if (nodes.length){
  862. // MWF.xDesktop.requireApp("Organization", "Selector.package", function(){
  863. // nodes.each(function(node){
  864. // var title = new Element("div", {"styles": this.view.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  865. // var content = new Element("div", {"styles": this.view.css.applicationSelectContent}).inject(node);
  866. // var action = new Element("div", {"styles": this.view.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  867. // action.addEvent("click", function(e){
  868. // var values = [];
  869. // if (this.data.data.whereEntry){
  870. // if (this.data.data.whereEntry.applicationList.length){
  871. // this.data.data.whereEntry.applicationList.each(function(item){
  872. // values.push(item.id);
  873. // }.bind(this));
  874. // }
  875. // }
  876. // var options = {
  877. // "type": "application",
  878. // "count": 0,
  879. // "values": values,
  880. // //"title": this.app.lp.monthly.selectSortApplication,
  881. // "onComplete": function(items){
  882. // this.initWhereEntryData();
  883. // this.data.data.whereEntry.applicationList = [];
  884. // content.empty();
  885. // items.each(function(item){
  886. // this.data.data.whereEntry.applicationList.push({
  887. // "id": item.data.id,
  888. // "name": item.data.name
  889. // });
  890. // new Element("div", {
  891. // "styles": this.view.css.applicationSelectItem,
  892. // "text": item.data.name
  893. // }).inject(content);
  894. // }.bind(this));
  895. // }.bind(this)
  896. // };
  897. // var selector = new MWF.OrgSelector(this.view.designer.content, options);
  898. // }.bind(this));
  899. //
  900. // this.initWhereEntryData();
  901. // this.data.data.whereEntry.applicationList.each(function(app){
  902. // new Element("div", {
  903. // "styles": this.view.css.applicationSelectItem,
  904. // "text": app.name
  905. // }).inject(content);
  906. // }.bind(this));
  907. // }.bind(this));
  908. // }.bind(this));
  909. // }
  910. //},
  911. //loadApplicationSelector1: function(){
  912. // var nodes = this.propertyContent.getElements(".MWFApplicationSelect");
  913. // if (nodes.length){
  914. // this._getAppSelector(function(){
  915. // nodes.each(function(node){
  916. // var title = new Element("div", {"styles": this.view.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  917. // var content = new Element("div", {"styles": this.view.css.applicationSelectContent}).inject(node);
  918. // var action = new Element("div", {"styles": this.view.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  919. // action.addEvent("click", function(e){
  920. // this.appSelector.load(function(apps){
  921. // if (!this.data.data.select) this.data.data.select = {"applicationRestrictList": [], "processRestrictList": []};
  922. // this.data.data.select.applicationRestrictList = [];
  923. // content.empty();
  924. // if (apps.length){
  925. // apps.each(function(app){
  926. // var o = {
  927. // "name": app.name,
  928. // "id": app.id,
  929. // "alias": app.alias
  930. // }
  931. // this.data.data.select.applicationRestrictList.push(o);
  932. //
  933. // new Element("div", {
  934. // "styles": this.view.css.applicationSelectItem,
  935. // "text": app.name
  936. // }).inject(content);
  937. //
  938. // }.bind(this));
  939. // }
  940. // }.bind(this));
  941. // }.bind(this));
  942. // if (!this.data.data.select) this.data.data.select = {"applicationRestrictList": [], "processRestrictList": []};
  943. // this.data.data.select.applicationRestrictList.each(function(app){
  944. // new Element("div", {
  945. // "styles": this.view.css.applicationSelectItem,
  946. // "text": app.name
  947. // }).inject(content);
  948. // }.bind(this));
  949. //
  950. // }.bind(this));
  951. // }.bind(this));
  952. // }
  953. //},
  954. //
  955. //_getAppSelector: function(callback){
  956. // if (!this.appSelector){
  957. // MWF.xDesktop.requireApp("process.ProcessManager", "widget.ApplicationSelector", function(){
  958. // this.appSelector = new MWF.xApplication.process.ProcessManager.widget.ApplicationSelector(this.view.designer, {"maskNode": this.view.designer.content});
  959. // if (callback) callback();
  960. // }.bind(this));
  961. // }else{
  962. // if (callback) callback();
  963. // }
  964. //},
  965. //this.initWhereEntryData();
  966. //loadProcessSelector: function(){
  967. // var nodes = this.propertyContent.getElements(".MWFApplicationSelect");
  968. // if (nodes.length){
  969. // MWF.xDesktop.requireApp("Organization", "Selector.package", function(){
  970. // nodes.each(function(node){
  971. // var title = new Element("div", {"styles": this.view.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  972. // var content = new Element("div", {"styles": this.view.css.applicationSelectContent}).inject(node);
  973. // var action = new Element("div", {"styles": this.view.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  974. // action.addEvent("click", function(e){
  975. // var values = [];
  976. // if (this.data.data.whereEntry){
  977. // if (this.data.data.whereEntry.processList.length){
  978. // this.data.data.whereEntry.processList.each(function(item){
  979. // values.push(item.id);
  980. // }.bind(this));
  981. // }
  982. // }
  983. // var options = {
  984. // "type": "process",
  985. // "count": 0,
  986. // "values": values,
  987. // "onComplete": function(items){
  988. // this.initWhereEntryData();
  989. // this.data.data.whereEntry.processList = [];
  990. // content.empty();
  991. // items.each(function(item){
  992. // this.data.data.whereEntry.processList.push({
  993. // "id": item.data.id,
  994. // "name": item.data.name
  995. // });
  996. // new Element("div", {
  997. // "styles": this.view.css.applicationSelectItem,
  998. // "text": item.data.name
  999. // }).inject(content);
  1000. // }.bind(this));
  1001. // }.bind(this)
  1002. // };
  1003. // var selector = new MWF.OrgSelector(this.view.designer.content, options);
  1004. // }.bind(this));
  1005. //
  1006. // this.initWhereEntryData();
  1007. // this.data.data.whereEntry.processList.each(function(app){
  1008. // new Element("div", {
  1009. // "styles": this.view.css.applicationSelectItem,
  1010. // "text": app.name
  1011. // }).inject(content);
  1012. // }.bind(this));
  1013. // }.bind(this));
  1014. // }.bind(this));
  1015. // }
  1016. //}
  1017. //loadProcessSelector1: function(){
  1018. // var nodes = this.propertyContent.getElements(".MWFProcessSelect");
  1019. // if (nodes.length){
  1020. // this._getProcessSelector(function(){
  1021. // nodes.each(function(node){
  1022. // var title = new Element("div", {"styles": this.view.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  1023. // var content = new Element("div", {"styles": this.view.css.applicationSelectContent}).inject(node);
  1024. // var action = new Element("div", {"styles": this.view.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  1025. // action.addEvent("click", function(e){
  1026. // var ids=[];
  1027. // this.data.data.select.applicationRestrictList.each(function(app){
  1028. // ids.push(app.id);
  1029. // });
  1030. // this.processSelector.load(ids, function(apps){
  1031. // if (!this.data.data.select) this.data.data.select = {"applicationRestrictList": [], "processRestrictList": []};
  1032. // this.data.data.select.processRestrictList = [];
  1033. // content.empty();
  1034. // if (apps.length){
  1035. // apps.each(function(app){
  1036. // var o = {
  1037. // "name": app.name,
  1038. // "id": app.id,
  1039. // "alias": app.alias
  1040. // }
  1041. // this.data.data.select.processRestrictList.push(o);
  1042. //
  1043. // new Element("div", {
  1044. // "styles": this.view.css.applicationSelectItem,
  1045. // "text": app.name
  1046. // }).inject(content);
  1047. //
  1048. // }.bind(this));
  1049. // }
  1050. // }.bind(this));
  1051. // }.bind(this));
  1052. // if (!this.data.data.select) this.data.data.select = {"applicationRestrictList": [], "processRestrictList": []};
  1053. // this.data.data.select.processRestrictList.each(function(app){
  1054. // new Element("div", {
  1055. // "styles": this.view.css.applicationSelectItem,
  1056. // "text": app.name
  1057. // }).inject(content);
  1058. // }.bind(this));
  1059. //
  1060. // }.bind(this));
  1061. // }.bind(this));
  1062. // }
  1063. //},
  1064. //_getProcessSelector: function(callback){
  1065. // if (!this.processSelector){
  1066. // MWF.xDesktop.requireApp("process.ProcessManager", "widget.ProcessSelector", function(){
  1067. // this.processSelector = new MWF.xApplication.process.ProcessManager.widget.ProcessSelector(this.view.designer, {"maskNode": this.view.designer.content});
  1068. // if (callback) callback();
  1069. // }.bind(this));
  1070. // }else{
  1071. // if (callback) callback();
  1072. // }
  1073. //}
  1074. });
  1075. MWF.xApplication.query.ViewDesigner.Property.Filter = new Class({
  1076. Implements: [Events],
  1077. initialize: function(json, table, property){
  1078. this.property = property;
  1079. this.module = property.module;
  1080. this.table = table;
  1081. this.data = json;
  1082. this.load();
  1083. },
  1084. load: function(){
  1085. this.node = new Element("tr", {"styles": this.module.css.filterTableTd}).inject(this.table);
  1086. var html = "<td style='widtd:24px;border-right:1px solid #CCC;border-bottom:1px solid #999;'></td>" +
  1087. "<td style='padding:3px;border-right:1px solid #CCC;border-bottom:1px solid #999; width:60px'>"+this.data.logic+"</td>" +
  1088. "<td style='padding:3px;border-right:1px solid #CCC;border-bottom:1px solid #999; width:30px'>列值</td>" +
  1089. "<td style='padding:3px;border-right:1px solid #CCC;border-bottom:1px solid #999;'>"+this.data.comparison+"</td>" +
  1090. "<td style='padding:3px;border-bottom:1px solid #999;'>"+this.data.value+"</td>";
  1091. this.node.set("html", html);
  1092. var tds = this.node.getElements("td");
  1093. this.delActionNode = new Element("div", {"styles": this.module.css.filterDelActionNode}).inject(tds[0]);
  1094. this.delActionNode.addEvent("click", function(e){
  1095. this.delFilter(e);
  1096. e.stopPropagation();
  1097. }.bind(this));
  1098. this.logicNode = tds[1];
  1099. this.comparisonNode = tds[3];
  1100. this.valueNode = tds[4];
  1101. this.node.addEvent("click", function(){
  1102. if (!this.isEditMode) this.editMode();
  1103. }.bind(this));
  1104. this.node.addEvent("blur", function(){
  1105. if (this.isEditMode) this.readMode();
  1106. }.bind(this));
  1107. },
  1108. delFilter: function(e){
  1109. var _self = this;
  1110. this.property.designer.confirm("warn", e, MWF.APPDVD.LP.notice.deleteFilterTitle, MWF.APPDVD.LP.notice.deleteFilter, 300, 120, function(){
  1111. _self.node.destroy();
  1112. _self.property.data.filterList.erase(_self.data);
  1113. MWF.release(_self);
  1114. this.close();
  1115. }, function(){
  1116. this.close();
  1117. }, null);
  1118. },
  1119. editMode: function(){
  1120. if (this.property.editModeFilter){
  1121. if (this.property.editModeFilter!=this) this.property.editModeFilter.readMode();
  1122. }
  1123. var width = this.logicNode.getSize().x-9;
  1124. this.logicNode.empty();
  1125. var logicSelect = new Element("select", {"styles": {"width": "90%"}}).inject(this.logicNode);
  1126. var html = "";
  1127. if (this.data.logic=="and"){
  1128. html = "<option value=\"and\" selected>and</option><option value=\"or\">or</option>";
  1129. }else{
  1130. html = "<option value=\"and\">and</option><option value=\"or\" selected>or</option>";
  1131. }
  1132. logicSelect.set("html", html);
  1133. logicSelect.addEvent("change", function(){
  1134. this.data.logic = logicSelect.options[logicSelect.selectedIndex].value;
  1135. }.bind(this));
  1136. width = this.comparisonNode.getSize().x-9;
  1137. this.comparisonNode.empty();
  1138. var comparisonSelect = new Element("select", {"styles": {"width": "90%"}}).inject(this.comparisonNode);
  1139. html = "";
  1140. switch (this.property.data.type){
  1141. case "text":
  1142. html += "<option value=''></option><option value='==' "+((this.data.comparison=="==") ? "selected": "")+">等于(==)</option>" +
  1143. "<option value='!=' "+((this.data.comparison=="!=") ? "selected": "")+">不等于(!=)</option>" +
  1144. "<option value='@' "+((this.data.comparison=="@") ? "selected": "")+">包含(@)</option>";
  1145. break;
  1146. case "date":
  1147. html += "<option value=''></option><option value='&gt;' "+((this.data.comparison==">") ? "selected": "")+">大于(&gt;)</option>" +
  1148. "<option value='&lt;' "+((this.data.comparison=="<") ? "selected": "")+">小于(&lt;)</option>" +
  1149. "<option value='&gt;=' "+((this.data.comparison==">=") ? "selected": "")+">大于等于(&gt;=)</option>" +
  1150. "<option value='&lt;=' "+((this.data.comparison=="<=") ? "selected": "")+">小于等于(&lt;=)</option>";
  1151. break;
  1152. case "number":
  1153. html += "<option value=''></option><option value='==' "+((this.data.comparison=="==") ? "selected": "")+">等于(==)</option>" +
  1154. "<option value='!=' "+((this.data.comparison=="!=") ? "selected": "")+">不等于(!=)</option>" +
  1155. "<option value='&gt;' "+((this.data.comparison==">") ? "selected": "")+">大于(&gt;)</option>" +
  1156. "<option value='&lt;' "+((this.data.comparison=="<") ? "selected": "")+">小于(&lt;)</option>" +
  1157. "<option value='&gt;=' "+((this.data.comparison==">=") ? "selected": "")+">大于等于(&gt;=)</option>" +
  1158. "<option value='&lt;=' "+((this.data.comparison=="<=") ? "selected": "")+">小于等于(&lt;=)</option>";
  1159. break;
  1160. case "boolean":
  1161. html += "<option value=''></option><option value='==' "+((this.data.comparison=="==") ? "selected": "")+">等于(==)</option>" +
  1162. "<option value='!=' "+((this.data.comparison=="!=") ? "selected": "")+">不等于(!=)</option>";
  1163. break;
  1164. }
  1165. comparisonSelect.set("html", html);
  1166. comparisonSelect.addEvent("change", function(){
  1167. this.data.comparison = comparisonSelect.options[comparisonSelect.selectedIndex].value;
  1168. }.bind(this));
  1169. width = this.valueNode.getSize().x-9;
  1170. this.valueNode.empty();
  1171. var type = "text";
  1172. switch (this.property.data.type){
  1173. case "date":
  1174. var valueInput = new Element("input", {"styles": {"width": "90%"},
  1175. "type": "text",
  1176. "value": this.data.value
  1177. }).inject(this.valueNode);
  1178. MWF.require("MWF.widget.Calendar", function(){
  1179. this.calendar = new MWF.widget.Calendar(valueInput, {
  1180. "style": "xform",
  1181. "isTime": true,
  1182. "secondEnable": true,
  1183. "target": this.property.designer.content,
  1184. "format": "%Y-%m-%d %H:%M:%S"
  1185. });
  1186. //this.calendar.show();
  1187. }.bind(this));
  1188. break;
  1189. case "number":
  1190. var valueInput = new Element("input", {"styles": {"width": "90%"},
  1191. "type": "number",
  1192. "value": this.data.value
  1193. }).inject(this.valueNode);
  1194. break;
  1195. case "boolean":
  1196. var valueInput = new Element("select", {"styles": {"width": ""+width+"px"},
  1197. "html": "<option value=\"\"></option><option value=\"true\" "+((this.data.value) ? "selected": "")+">true</option><option value=\"false\" "+((!this.data.value) ? "selected": "")+">false</option>"
  1198. }).inject(this.valueNode);
  1199. break;
  1200. default:
  1201. var valueInput = new Element("input", {"styles": {"width": "90%"},
  1202. "type": "text",
  1203. "value": this.data.value
  1204. }).inject(this.valueNode);
  1205. }
  1206. if (valueInput.tagName.toLowerCase()=="select"){
  1207. valueInput.addEvent("change", function(){
  1208. var v = valueInput.options[valueInput.selectedIndex].value;
  1209. this.data.value = (v="true") ? true : false;
  1210. }.bind(this));
  1211. }else{
  1212. valueInput.addEvent("change", function(e){
  1213. this.data.value = valueInput.get("value");
  1214. }.bind(this));
  1215. valueInput.addEvent("blur", function(e){
  1216. this.data.value = valueInput.get("value");
  1217. }.bind(this));
  1218. valueInput.addEvent("keydown", function(e){
  1219. if (e.code==13){
  1220. this.data.value = valueInput.get("value");
  1221. this.readMode();
  1222. }
  1223. e.stopPropagation();
  1224. }.bind(this));
  1225. }
  1226. this.isEditMode = true;
  1227. this.property.editModeFilter = this;
  1228. },
  1229. readMode: function(){
  1230. if (this.isEditMode){
  1231. var logicSelect = this.logicNode.getElement("select");
  1232. this.data.logic = logicSelect.options[logicSelect.selectedIndex].value;
  1233. var comparisonSelect = this.comparisonNode.getElement("select");
  1234. this.data.comparison = comparisonSelect.options[comparisonSelect.selectedIndex].value;
  1235. var valueInput = this.valueNode.getFirst();
  1236. if (valueInput.tagName.toLowerCase()=="select"){
  1237. var v = valueInput.options[valueInput.selectedIndex].value;
  1238. this.data.value = (v="true") ? true : false;
  1239. }else{
  1240. this.data.value = valueInput.get("value");
  1241. }
  1242. this.logicNode.empty();
  1243. this.comparisonNode.empty();
  1244. this.valueNode.empty();
  1245. this.logicNode.set("text", this.data.logic);
  1246. this.comparisonNode.set("text", this.data.comparison);
  1247. this.valueNode.set("text", this.data.value);
  1248. this.isEditMode = false;
  1249. this.property.editModeFilter = null;
  1250. }
  1251. }
  1252. });