Property.js 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369
  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. "runtime": "server"
  345. });
  346. scriptArea.load({"code": scriptContent});
  347. }.bind(this));
  348. }.bind(this));
  349. },
  350. loadStatColumnSelect: function(){},
  351. loadPersonInput: function(){
  352. var identityNodes = this.propertyContent.getElements(".MWFPersonIdentity");
  353. var personUnitNodes = this.propertyContent.getElements(".MWFPersonUnit");
  354. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function(){
  355. identityNodes.each(function(node){
  356. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  357. "type": "identity",
  358. "names": this.data[node.get("name")],
  359. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  360. });
  361. }.bind(this));
  362. personUnitNodes.each(function(node){
  363. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  364. "type": "unit",
  365. "names": this.data[node.get("name")],
  366. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  367. });
  368. }.bind(this));
  369. }.bind(this));
  370. },
  371. savePersonItem: function(node, ids){
  372. var values = [];
  373. ids.each(function(id){
  374. //values.push({"name": (id.data.distinguishedName || id.data.name), "id": id.data.id});
  375. values.push((id.data.distinguishedName || id.data.id || id.data.name));
  376. }.bind(this));
  377. var name = node.get("name");
  378. key = name.split(".");
  379. var o = this.data;
  380. var len = key.length-1;
  381. key.each(function(n, i){
  382. if (!o[n]) o[n] = {};
  383. if (i<len) o = o[n];
  384. }.bind(this));
  385. o[key[len]] = values;
  386. //this.data.data.restrictWhereEntry[node.get("name")] = values;
  387. },
  388. loadPersonSelectInput: function(){
  389. var applicationNodes = this.propertyContent.getElements(".MWFSelectApplication");
  390. var processNodes = this.propertyContent.getElements(".MWFSelectProcess");
  391. // var companyNodes = this.propertyContent.getElements(".MWFSelectCompany");
  392. // var departmentNodes = this.propertyContent.getElements(".MWFSelectDepartment");
  393. var personNodes = this.propertyContent.getElements(".MWFSelectPerson");
  394. var identityNodes = this.propertyContent.getElements(".MWFSelectIdentity");
  395. var personUnitNodes = this.propertyContent.getElements(".MWFSelectUnit");
  396. var cmsapplicationNodes = this.propertyContent.getElements(".MWFSelectCMSApplication");
  397. var cmscategoryNodes = this.propertyContent.getElements(".MWFSelecCMStCategory");
  398. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function(){
  399. applicationNodes.each(function(node){
  400. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  401. "type": "application",
  402. "names": (this.data.data.where) ? this.data.data.where.applicationList : [],
  403. "onChange": function(ids){this.savePersonSelectItem(node, ids);}.bind(this)
  404. });
  405. }.bind(this));
  406. processNodes.each(function(node){
  407. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  408. "type": "process",
  409. "names": (this.data.data.where) ? this.data.data.where.processList : [],
  410. "onChange": function(ids){this.savePersonSelectItem(node, ids);}.bind(this)
  411. });
  412. }.bind(this));
  413. personUnitNodes.each(function(node){
  414. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  415. "type": "unit",
  416. "names": (this.data.data.where) ? this.data.data.where.creatorUnitList : [],
  417. "onChange": function(ids){this.savePersonSelectItem(node, ids);}.bind(this)
  418. });
  419. }.bind(this));
  420. personNodes.each(function(node){
  421. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  422. "type": "person",
  423. "names": (this.data.data.where) ? this.data.data.where.creatorPersonList : [],
  424. "onChange": function(ids){this.savePersonSelectItem(node, ids);}.bind(this)
  425. });
  426. }.bind(this));
  427. identityNodes.each(function(node){
  428. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  429. "type": "identity",
  430. "names": (this.data.data.where) ? this.data.data.where.creatorIdentityList : [],
  431. "onChange": function(ids){this.savePersonSelectItem(node, ids);}.bind(this)
  432. });
  433. }.bind(this));
  434. cmsapplicationNodes.each(function(node){
  435. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  436. "type": "CMSApplication",
  437. "names": (this.data.data.where) ? this.data.data.where.appInfoList : [],
  438. "onChange": function(ids){this.savePersonSelectItem(node, ids);}.bind(this)
  439. });
  440. }.bind(this));
  441. cmscategoryNodes.each(function(node){
  442. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  443. "type": "CMSCategory",
  444. "names": (this.data.data.where) ? this.data.data.where.categoryInfoList : [],
  445. "onChange": function(ids){this.savePersonSelectItem(node, ids);}.bind(this)
  446. });
  447. }.bind(this));
  448. }.bind(this));
  449. },
  450. savePersonSelectItem: function(node, ids){
  451. //this.initWhereEntryData();
  452. var values = [];
  453. ids.each(function(id){
  454. values.push({"name": (id.data.distinguishedName || id.data.name), "id": id.data.id});
  455. //values.push((id.data.distinguishedName || id.data.id || id.data.name));
  456. }.bind(this));
  457. var name = node.get("name");
  458. key = name.split(".");
  459. var o = this.data;
  460. var len = key.length-1;
  461. key.each(function(n, i){
  462. if (!o[n]) o[n] = {};
  463. if (i<len) o = o[n];
  464. }.bind(this));
  465. o[key[len]] = values;
  466. //this.data.data.restrictWhereEntry[node.get("name")] = values;
  467. },
  468. //loadWorkDataEditor: function(){
  469. // var workDataNodes = this.propertyContent.getElements(".MWFWorkData");
  470. // workDataNodes.each(function(node){
  471. // var select = node.getElement("select");
  472. // for (var i=0; i<select.options.length; i++){
  473. // if (select.options[i].value==this.data.name){
  474. // select.options[i].set("selected", true);
  475. // break;
  476. // }
  477. // }
  478. // if (!this.data.type) this.data.type = "text";
  479. // select.addEvent("change", function(e){
  480. // delete this.data.path;
  481. // this.data.name = select.options[select.selectedIndex].value;
  482. // this.module.listNode.getLast().set("text", this.data.text+"("+this.data.name+")");
  483. // this.setDataType();
  484. // }.bind(this));
  485. //
  486. // this.setDataType();
  487. // }.bind(this));
  488. // var nodes = this.propertyContent.getElements(".MWFWorkDataCheck");
  489. // nodes.each(function(node){
  490. // if (this.data.name) node.set("checked", true);
  491. // }.bind(this));
  492. //},
  493. //setDataType: function(){
  494. // switch (this.data.name){
  495. // case "startTime":case "completedTime":
  496. // this.data.type ="date";
  497. // break;
  498. // case "completed":
  499. // this.data.type ="boolean";
  500. // break;
  501. // default:
  502. // this.data.type ="text";
  503. // }
  504. //},
  505. //loadDataDataEditor: function(){
  506. // var nodes = this.propertyContent.getElements(".MWFDataData");
  507. // nodes.each(function(node){
  508. // var input = node.getElement("input");
  509. // input.set("value", this.data.path);
  510. // input.addEvent("change", function(e){
  511. // delete this.data.name;
  512. // this.data.path = input.get("value");
  513. // this.module.listNode.getLast().set("text", this.data.text+"("+this.data.path+")");
  514. // }.bind(this));
  515. // input.addEvent("blur", function(e){
  516. // delete this.data.name;
  517. // this.data.path = input.get("value");
  518. // this.module.listNode.getLast().set("text", this.data.text+"("+this.data.path+")");
  519. // }.bind(this));
  520. // input.addEvent("keydown", function(e){
  521. // if (e.code==13){
  522. // delete this.data.name;
  523. // this.data.path = input.get("value");
  524. // this.module.listNode.getLast().set("text", this.data.text+"("+this.data.path+")");
  525. // }
  526. // e.stopPropagation();
  527. // }.bind(this));
  528. //
  529. // var select = node.getElement("select");
  530. // for (var i=0; i<select.options.length; i++){
  531. // if (select.options[i].value==this.data.type){
  532. // select.options[i].set("selected", true);
  533. // break;
  534. // }
  535. // }
  536. // if (!this.data.type) this.data.type = "text";
  537. // select.addEvent("change", function(e){
  538. // this.data.type = select.options[select.selectedIndex].value;
  539. // }.bind(this));
  540. //
  541. // }.bind(this));
  542. // var nodes = this.propertyContent.getElements(".MWFDataDataCheck");
  543. // nodes.each(function(node){
  544. // if (this.data.path) node.set("checked", true);
  545. // }.bind(this));
  546. //},
  547. loadColumnExportEditor: function(){
  548. var _self = this;
  549. var nodes = this.propertyContent.getElements(".MWFColumnExport");
  550. nodes.each(function(node){
  551. //if (!this.data.export) this.data.export = {};
  552. //var sort = this.data.export.sort || "";
  553. //var sortOrder = this.data.export.sortOrder || "1";
  554. var select = node.getElement("select");
  555. var sortList = this.view.data.data.orderList;
  556. sortList.each(function(order){
  557. if (order.column==this.data.column){
  558. if (order.orderType=="asc") select.options[1].set("selected", true);
  559. if (order.orderType=="desc") select.options[1].set("selected", false);
  560. }
  561. }.bind(this));
  562. select.addEvent("change", function(e){
  563. debugger;
  564. var sortList = this.view.data.data.orderList;
  565. var v = select.options[select.selectedIndex].value;
  566. if (v!="none"){
  567. var flag = false;
  568. sortList.each(function(order){
  569. if (order.column==this.data.column){
  570. flag = true;
  571. order.orderType=select.options[select.selectedIndex].value;
  572. }
  573. }.bind(this));
  574. if (!flag) sortList.push({"column": this.data.column, "orderType": select.options[select.selectedIndex].value});
  575. var oldOrderList = Array.clone(this.view.data.data.orderList);
  576. this.view.data.data.orderList = [];
  577. this.view.json.data.selectList.each( function ( sel ) {
  578. oldOrderList.each(function(order){
  579. if (order.column == sel.column){
  580. this.view.data.data.orderList.push( order );
  581. }
  582. }.bind(this));
  583. }.bind(this));
  584. }else{
  585. var sortList = this.view.data.data.orderList;
  586. var deleteItem = null;
  587. sortList.each(function(order){
  588. if (order.column==this.data.column){
  589. deleteItem = order;
  590. }
  591. }.bind(this));
  592. if (deleteItem) sortList.erase(deleteItem);
  593. }
  594. }.bind(this));
  595. var radios = node.getElements("input[name='"+this.module.json.id+"groupEntry']");
  596. var group = this.view.data.data.group;
  597. if (group.column==this.data.column) radios[0].set("checked", true);
  598. radios.addEvent("click", function(e){
  599. if (this.checked){
  600. if (this.value=="true") {
  601. _self.view.data.data.group.column = _self.data.column;
  602. _self.view.items.each(function(col){
  603. if (col.property){
  604. var groupRadios = col.property.propertyContent.getElement(".MWFColumnExportGroup").getElements("input");
  605. groupRadios.each(function(r){
  606. if (r.value=="true") r.set("checked", false);
  607. if (r.value=="false") r.set("checked", true);
  608. });
  609. }
  610. });
  611. ( _self.view.data.data.selectList ).each(function(s) {
  612. if( s.column !== _self.data.column )s.groupEntry = false;
  613. });
  614. this.set("checked", true);
  615. }else{
  616. if (group.column ==_self.data.column) _self.view.data.data.group = {};
  617. }
  618. }
  619. });
  620. }.bind(this));
  621. },
  622. loadViewFilter: function(){
  623. var nodes = this.propertyContent.getElements(".MWFViewFilter");
  624. var filtrData = this.view.data.data.filterList;
  625. var customData = this.view.data.data.customFilterList;
  626. nodes.each(function(node){
  627. MWF.xDesktop.requireApp("query.ViewDesigner", "widget.ViewFilter", function(){
  628. var _slef = this;
  629. new MWF.xApplication.query.ViewDesigner.widget.ViewFilter(node, this.view.designer, {"filtrData": filtrData, "customData": customData}, {
  630. "onChange": function(ids){
  631. var data = this.getData();
  632. _slef.changeJsonDate(["data", "filterList"], data.data);
  633. _slef.changeJsonDate(["data", "customFilterList"], data.customData);
  634. }
  635. });
  636. }.bind(this));
  637. }.bind(this));
  638. },
  639. loadColumnFilter: function(){
  640. var nodes = this.propertyContent.getElements(".MWFColumnFilter");
  641. nodes.each(function(node){
  642. this.module.filterAreaNode = node;
  643. var table = new Element("table", {
  644. "styles": {"width": "100%"},
  645. "border": "0px",
  646. "cellPadding": "0",
  647. "cellSpacing": "0"
  648. }).inject(node);
  649. var tr = new Element("tr", {"styles": this.module.css.filterTableTitle}).inject(table);
  650. var html = "<th style='width:24px;border-right:1px solid #CCC;border-bottom:1px solid #999;'></th>" +
  651. "<th style='border-right:1px solid #CCC;border-left:1px solid #FFF;border-bottom:1px solid #999;'>逻辑</th>" +
  652. "<th style='border-right:1px solid #CCC;border-left:1px solid #FFF;border-bottom:1px solid #999;'>路径</th>" +
  653. "<th style='border-right:1px solid #CCC;border-left:1px solid #FFF;border-bottom:1px solid #999;'>比较</th>" +
  654. "<th style='border-left:1px solid #FFF;border-bottom:1px solid #999;'>值</th>";
  655. tr.set("html", html);
  656. var addActionNode = new Element("div", {"styles": this.module.css.filterAddActionNode}).inject(tr.getFirst("th"));
  657. addActionNode.addEvent("click", function(){
  658. this.addFilter(table);
  659. }.bind(this));
  660. if (this.data.filterList) {
  661. this.data.filterList.each(function (op) {
  662. new MWF.xApplication.query.ViewDesigner.Property.Filter(op, table, this);
  663. }.bind(this));
  664. }
  665. }.bind(this));
  666. },
  667. addFilter: function(table){
  668. op = {
  669. "logic": "and",
  670. "comparison": "",
  671. "value": ""
  672. }
  673. if (!this.data.filterList) this.data.filterList = [];
  674. this.data.filterList.push(op);
  675. var filter = new MWF.xApplication.query.ViewDesigner.Property.Filter(op, table, this);
  676. filter.editMode();
  677. },
  678. loadViewStylesArea: function(){
  679. var _self = this;
  680. var viewAreas = this.propertyContent.getElements(".MWFViewStylesArea");
  681. viewAreas.each(function(node){
  682. var name = node.get("name");
  683. var d = this.data;
  684. Array.each( name.split("."), function(n){
  685. if(d)d = d[n];
  686. });
  687. var viewStyles = d || {};
  688. MWF.require("MWF.widget.Maplist", function(){
  689. var maps = [];
  690. Object.each(viewStyles, function(v, k){
  691. var mapNode = new Element("div").inject(node);
  692. mapNode.empty();
  693. var maplist = new MWF.widget.Maplist(mapNode, {
  694. "title": k,
  695. "collapse": true,
  696. "onChange": function(){
  697. // var oldData = _self.data[name];
  698. var oldData = this.data;
  699. Array.each( name.split("."), function(n){
  700. if(oldData)oldData = oldData[n];
  701. });
  702. maps.each(function(o){
  703. d[o.key] = o.map.toJson();
  704. }.bind(this));
  705. _self.changeData(name, node, oldData);
  706. }
  707. });
  708. maps.push({"key": k, "map": maplist});
  709. maplist.load(v);
  710. }.bind(this));
  711. }.bind(this));
  712. }.bind(this));
  713. },
  714. loadActionStylesArea: function(){
  715. var _self = this;
  716. var actionAreas = this.propertyContent.getElements(".MWFActionStylesArea");
  717. actionAreas.each(function(node){
  718. var name = node.get("name");
  719. var actionStyles = this.data[name];
  720. MWF.require("MWF.widget.Maplist", function(){
  721. var maps = [];
  722. Object.each(actionStyles, function(v, k){
  723. var mapNode = new Element("div").inject(node);
  724. mapNode.empty();
  725. var maplist = new MWF.widget.Maplist(mapNode, {
  726. "title": k,
  727. "collapse": true,
  728. "onChange": function(){
  729. var oldData = _self.data[name];
  730. maps.each(function(o){
  731. _self.data[name][o.key] = o.map.toJson();
  732. }.bind(this));
  733. _self.changeData(name, node, oldData);
  734. }
  735. });
  736. maps.push({"key": k, "map": maplist});
  737. maplist.load(v);
  738. }.bind(this));
  739. }.bind(this));
  740. }.bind(this));
  741. },
  742. loadPagingStylesArea: function(){
  743. var _self = this;
  744. var pagingAreas = this.propertyContent.getElements(".MWFPagingStylesArea");
  745. pagingAreas.each(function(node){
  746. var name = node.get("name");
  747. var pagingStyles = this.data[name];
  748. MWF.require("MWF.widget.Maplist", function(){
  749. var maps = [];
  750. Object.each(pagingStyles, function(v, k){
  751. var mapNode = new Element("div").inject(node);
  752. mapNode.empty();
  753. var maplist = new MWF.widget.Maplist(mapNode, {
  754. "title": k,
  755. "collapse": true,
  756. "onChange": function(){
  757. var oldData = _self.data[name];
  758. maps.each(function(o){
  759. _self.data[name][o.key] = o.map.toJson();
  760. }.bind(this));
  761. _self.changeData(name, node, oldData);
  762. }
  763. });
  764. maps.push({"key": k, "map": maplist});
  765. maplist.load(v);
  766. }.bind(this));
  767. }.bind(this));
  768. }.bind(this));
  769. },
  770. loadEventsEditor: function(){
  771. MWF.xApplication.process = MWF.xApplication.process || {};
  772. MWF.APPFD = MWF.xApplication.process.FormDesigner = MWF.xApplication.process.FormDesigner || {};
  773. MWF.xDesktop.requireApp("process.FormDesigner", "lp."+o2.language, null, false);
  774. var events = this.propertyContent.getElement(".MWFEventsArea");
  775. if (events){
  776. var name = events.get("name");
  777. var eventsObj = this.data;
  778. Array.each( name.split("."), function(n){
  779. if(eventsObj)eventsObj = eventsObj[n];
  780. })
  781. MWF.xDesktop.requireApp("process.FormDesigner", "widget.EventsEditor", function(){
  782. var eventsEditor = new MWF.xApplication.process.FormDesigner.widget.EventsEditor(events, this.designer, {
  783. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  784. "maxObj": this.designer.contentNode
  785. });
  786. eventsEditor.load(eventsObj, this.data, name);
  787. }.bind(this));
  788. }
  789. },
  790. loadActionArea: function(){
  791. MWF.xApplication.process = MWF.xApplication.process || {};
  792. MWF.APPFD = MWF.xApplication.process.FormDesigner = MWF.xApplication.process.FormDesigner || {};
  793. MWF.xDesktop.requireApp("process.FormDesigner", "lp."+o2.language, null, false);
  794. var actionAreas = this.propertyContent.getElements(".MWFActionArea");
  795. actionAreas.each(function(node){
  796. var name = node.get("name");
  797. var actionContent = this.data[name];
  798. MWF.xDesktop.requireApp("process.FormDesigner", "widget.ActionsEditor", function(){
  799. // debugger;
  800. // var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, {
  801. // "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  802. // "noCreate": true,
  803. // "noDelete": true,
  804. // "noCode": true,
  805. // "onChange": function(){
  806. // this.data[name] = actionEditor.data;
  807. // }.bind(this)
  808. // });
  809. // actionEditor.load(this.module.defaultToolBarsData);
  810. var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
  811. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  812. "noEditShow" : true,
  813. "noReadShow" : true,
  814. "onChange": function(){
  815. this.data[name] = actionEditor.data;
  816. this.changeData(name);
  817. }.bind(this)
  818. });
  819. actionEditor.load(actionContent);
  820. }.bind(this));
  821. }.bind(this));
  822. var actionAreas = this.propertyContent.getElements(".MWFDefaultActionArea");
  823. actionAreas.each(function(node){
  824. var name = node.get("name");
  825. var actionContent = this.data[name] || this.module.defaultToolBarsData;
  826. MWF.xDesktop.requireApp("process.FormDesigner", "widget.ActionsEditor", function(){
  827. var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
  828. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  829. "isSystemTool" : true,
  830. "systemToolsAddress" : "../x_component_query_ViewDesigner/$View/toolbars.json",
  831. "noCreate": true,
  832. "noDelete": false,
  833. "noCode": true,
  834. "noReadShow": true,
  835. "noEditShow": true,
  836. "onChange": function(){
  837. this.data[name] = actionEditor.data;
  838. this.changeData(name);
  839. }.bind(this)
  840. });
  841. actionEditor.load(actionContent);
  842. // var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, {
  843. // "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  844. // "onChange": function(){
  845. // this.data[name] = actionEditor.data;
  846. // }.bind(this)
  847. // });
  848. // actionEditor.load(actionContent);
  849. }.bind(this));
  850. }.bind(this));
  851. },
  852. loadStylesList: function(){
  853. var styleSelNodes = this.propertyContent.getElements(".MWFViewStyle");
  854. styleSelNodes.each(function(node){
  855. debugger;
  856. if (this.module.stylesList){
  857. if (!this.data.data.viewStyleType) this.data.data.viewStyleType = "default";
  858. // var mode = ( this.form.options.mode || "" ).toLowerCase() === "mobile" ? "mobile" : "pc";
  859. Object.each(this.module.stylesList, function(s, key){
  860. // if( s.mode.contains( mode ) ){
  861. new Element("option", {
  862. "text": s.name,
  863. "value": key,
  864. "selected": ((!this.data.data.viewStyleType && key=="default") || (this.data.data.viewStyleType==key))
  865. }).inject(node)
  866. // }
  867. }.bind(this));
  868. }else{
  869. node.getParent("tr").setStyle("display", "none");
  870. }
  871. }.bind(this));
  872. }
  873. //initWhereEntryData: function(){
  874. // if (!this.data.data.restrictWhereEntry) this.data.data.restrictWhereEntry = {
  875. // "applicationList": [],
  876. // "processList": [],
  877. // "companyList": [],
  878. // "departmentList": [],
  879. // "personList": [],
  880. // "identityList": []
  881. // };
  882. //},
  883. //loadApplicationSelector: function(){
  884. // var nodes = this.propertyContent.getElements(".MWFApplicationSelect");
  885. // if (nodes.length){
  886. // MWF.xDesktop.requireApp("Organization", "Selector.package", function(){
  887. // nodes.each(function(node){
  888. // var title = new Element("div", {"styles": this.view.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  889. // var content = new Element("div", {"styles": this.view.css.applicationSelectContent}).inject(node);
  890. // var action = new Element("div", {"styles": this.view.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  891. // action.addEvent("click", function(e){
  892. // var values = [];
  893. // if (this.data.data.whereEntry){
  894. // if (this.data.data.whereEntry.applicationList.length){
  895. // this.data.data.whereEntry.applicationList.each(function(item){
  896. // values.push(item.id);
  897. // }.bind(this));
  898. // }
  899. // }
  900. // var options = {
  901. // "type": "application",
  902. // "count": 0,
  903. // "values": values,
  904. // //"title": this.app.lp.monthly.selectSortApplication,
  905. // "onComplete": function(items){
  906. // this.initWhereEntryData();
  907. // this.data.data.whereEntry.applicationList = [];
  908. // content.empty();
  909. // items.each(function(item){
  910. // this.data.data.whereEntry.applicationList.push({
  911. // "id": item.data.id,
  912. // "name": item.data.name
  913. // });
  914. // new Element("div", {
  915. // "styles": this.view.css.applicationSelectItem,
  916. // "text": item.data.name
  917. // }).inject(content);
  918. // }.bind(this));
  919. // }.bind(this)
  920. // };
  921. // var selector = new MWF.OrgSelector(this.view.designer.content, options);
  922. // }.bind(this));
  923. //
  924. // this.initWhereEntryData();
  925. // this.data.data.whereEntry.applicationList.each(function(app){
  926. // new Element("div", {
  927. // "styles": this.view.css.applicationSelectItem,
  928. // "text": app.name
  929. // }).inject(content);
  930. // }.bind(this));
  931. // }.bind(this));
  932. // }.bind(this));
  933. // }
  934. //},
  935. //loadApplicationSelector1: function(){
  936. // var nodes = this.propertyContent.getElements(".MWFApplicationSelect");
  937. // if (nodes.length){
  938. // this._getAppSelector(function(){
  939. // nodes.each(function(node){
  940. // var title = new Element("div", {"styles": this.view.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  941. // var content = new Element("div", {"styles": this.view.css.applicationSelectContent}).inject(node);
  942. // var action = new Element("div", {"styles": this.view.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  943. // action.addEvent("click", function(e){
  944. // this.appSelector.load(function(apps){
  945. // if (!this.data.data.select) this.data.data.select = {"applicationRestrictList": [], "processRestrictList": []};
  946. // this.data.data.select.applicationRestrictList = [];
  947. // content.empty();
  948. // if (apps.length){
  949. // apps.each(function(app){
  950. // var o = {
  951. // "name": app.name,
  952. // "id": app.id,
  953. // "alias": app.alias
  954. // }
  955. // this.data.data.select.applicationRestrictList.push(o);
  956. //
  957. // new Element("div", {
  958. // "styles": this.view.css.applicationSelectItem,
  959. // "text": app.name
  960. // }).inject(content);
  961. //
  962. // }.bind(this));
  963. // }
  964. // }.bind(this));
  965. // }.bind(this));
  966. // if (!this.data.data.select) this.data.data.select = {"applicationRestrictList": [], "processRestrictList": []};
  967. // this.data.data.select.applicationRestrictList.each(function(app){
  968. // new Element("div", {
  969. // "styles": this.view.css.applicationSelectItem,
  970. // "text": app.name
  971. // }).inject(content);
  972. // }.bind(this));
  973. //
  974. // }.bind(this));
  975. // }.bind(this));
  976. // }
  977. //},
  978. //
  979. //_getAppSelector: function(callback){
  980. // if (!this.appSelector){
  981. // MWF.xDesktop.requireApp("process.ProcessManager", "widget.ApplicationSelector", function(){
  982. // this.appSelector = new MWF.xApplication.process.ProcessManager.widget.ApplicationSelector(this.view.designer, {"maskNode": this.view.designer.content});
  983. // if (callback) callback();
  984. // }.bind(this));
  985. // }else{
  986. // if (callback) callback();
  987. // }
  988. //},
  989. //this.initWhereEntryData();
  990. //loadProcessSelector: function(){
  991. // var nodes = this.propertyContent.getElements(".MWFApplicationSelect");
  992. // if (nodes.length){
  993. // MWF.xDesktop.requireApp("Organization", "Selector.package", function(){
  994. // nodes.each(function(node){
  995. // var title = new Element("div", {"styles": this.view.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  996. // var content = new Element("div", {"styles": this.view.css.applicationSelectContent}).inject(node);
  997. // var action = new Element("div", {"styles": this.view.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  998. // action.addEvent("click", function(e){
  999. // var values = [];
  1000. // if (this.data.data.whereEntry){
  1001. // if (this.data.data.whereEntry.processList.length){
  1002. // this.data.data.whereEntry.processList.each(function(item){
  1003. // values.push(item.id);
  1004. // }.bind(this));
  1005. // }
  1006. // }
  1007. // var options = {
  1008. // "type": "process",
  1009. // "count": 0,
  1010. // "values": values,
  1011. // "onComplete": function(items){
  1012. // this.initWhereEntryData();
  1013. // this.data.data.whereEntry.processList = [];
  1014. // content.empty();
  1015. // items.each(function(item){
  1016. // this.data.data.whereEntry.processList.push({
  1017. // "id": item.data.id,
  1018. // "name": item.data.name
  1019. // });
  1020. // new Element("div", {
  1021. // "styles": this.view.css.applicationSelectItem,
  1022. // "text": item.data.name
  1023. // }).inject(content);
  1024. // }.bind(this));
  1025. // }.bind(this)
  1026. // };
  1027. // var selector = new MWF.OrgSelector(this.view.designer.content, options);
  1028. // }.bind(this));
  1029. //
  1030. // this.initWhereEntryData();
  1031. // this.data.data.whereEntry.processList.each(function(app){
  1032. // new Element("div", {
  1033. // "styles": this.view.css.applicationSelectItem,
  1034. // "text": app.name
  1035. // }).inject(content);
  1036. // }.bind(this));
  1037. // }.bind(this));
  1038. // }.bind(this));
  1039. // }
  1040. //}
  1041. //loadProcessSelector1: function(){
  1042. // var nodes = this.propertyContent.getElements(".MWFProcessSelect");
  1043. // if (nodes.length){
  1044. // this._getProcessSelector(function(){
  1045. // nodes.each(function(node){
  1046. // var title = new Element("div", {"styles": this.view.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  1047. // var content = new Element("div", {"styles": this.view.css.applicationSelectContent}).inject(node);
  1048. // var action = new Element("div", {"styles": this.view.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  1049. // action.addEvent("click", function(e){
  1050. // var ids=[];
  1051. // this.data.data.select.applicationRestrictList.each(function(app){
  1052. // ids.push(app.id);
  1053. // });
  1054. // this.processSelector.load(ids, function(apps){
  1055. // if (!this.data.data.select) this.data.data.select = {"applicationRestrictList": [], "processRestrictList": []};
  1056. // this.data.data.select.processRestrictList = [];
  1057. // content.empty();
  1058. // if (apps.length){
  1059. // apps.each(function(app){
  1060. // var o = {
  1061. // "name": app.name,
  1062. // "id": app.id,
  1063. // "alias": app.alias
  1064. // }
  1065. // this.data.data.select.processRestrictList.push(o);
  1066. //
  1067. // new Element("div", {
  1068. // "styles": this.view.css.applicationSelectItem,
  1069. // "text": app.name
  1070. // }).inject(content);
  1071. //
  1072. // }.bind(this));
  1073. // }
  1074. // }.bind(this));
  1075. // }.bind(this));
  1076. // if (!this.data.data.select) this.data.data.select = {"applicationRestrictList": [], "processRestrictList": []};
  1077. // this.data.data.select.processRestrictList.each(function(app){
  1078. // new Element("div", {
  1079. // "styles": this.view.css.applicationSelectItem,
  1080. // "text": app.name
  1081. // }).inject(content);
  1082. // }.bind(this));
  1083. //
  1084. // }.bind(this));
  1085. // }.bind(this));
  1086. // }
  1087. //},
  1088. //_getProcessSelector: function(callback){
  1089. // if (!this.processSelector){
  1090. // MWF.xDesktop.requireApp("process.ProcessManager", "widget.ProcessSelector", function(){
  1091. // this.processSelector = new MWF.xApplication.process.ProcessManager.widget.ProcessSelector(this.view.designer, {"maskNode": this.view.designer.content});
  1092. // if (callback) callback();
  1093. // }.bind(this));
  1094. // }else{
  1095. // if (callback) callback();
  1096. // }
  1097. //}
  1098. });
  1099. MWF.xApplication.query.ViewDesigner.Property.Filter = new Class({
  1100. Implements: [Events],
  1101. initialize: function(json, table, property){
  1102. this.property = property;
  1103. this.module = property.module;
  1104. this.table = table;
  1105. this.data = json;
  1106. this.load();
  1107. },
  1108. load: function(){
  1109. this.node = new Element("tr", {"styles": this.module.css.filterTableTd}).inject(this.table);
  1110. var html = "<td style='widtd:24px;border-right:1px solid #CCC;border-bottom:1px solid #999;'></td>" +
  1111. "<td style='padding:3px;border-right:1px solid #CCC;border-bottom:1px solid #999; width:60px'>"+this.data.logic+"</td>" +
  1112. "<td style='padding:3px;border-right:1px solid #CCC;border-bottom:1px solid #999; width:30px'>列值</td>" +
  1113. "<td style='padding:3px;border-right:1px solid #CCC;border-bottom:1px solid #999;'>"+this.data.comparison+"</td>" +
  1114. "<td style='padding:3px;border-bottom:1px solid #999;'>"+this.data.value+"</td>";
  1115. this.node.set("html", html);
  1116. var tds = this.node.getElements("td");
  1117. this.delActionNode = new Element("div", {"styles": this.module.css.filterDelActionNode}).inject(tds[0]);
  1118. this.delActionNode.addEvent("click", function(e){
  1119. this.delFilter(e);
  1120. e.stopPropagation();
  1121. }.bind(this));
  1122. this.logicNode = tds[1];
  1123. this.comparisonNode = tds[3];
  1124. this.valueNode = tds[4];
  1125. this.node.addEvent("click", function(){
  1126. if (!this.isEditMode) this.editMode();
  1127. }.bind(this));
  1128. this.node.addEvent("blur", function(){
  1129. if (this.isEditMode) this.readMode();
  1130. }.bind(this));
  1131. },
  1132. delFilter: function(e){
  1133. var _self = this;
  1134. this.property.designer.confirm("warn", e, MWF.APPDVD.LP.notice.deleteFilterTitle, MWF.APPDVD.LP.notice.deleteFilter, 300, 120, function(){
  1135. _self.node.destroy();
  1136. _self.property.data.filterList.erase(_self.data);
  1137. MWF.release(_self);
  1138. this.close();
  1139. }, function(){
  1140. this.close();
  1141. }, null);
  1142. },
  1143. editMode: function(){
  1144. if (this.property.editModeFilter){
  1145. if (this.property.editModeFilter!=this) this.property.editModeFilter.readMode();
  1146. }
  1147. var width = this.logicNode.getSize().x-9;
  1148. this.logicNode.empty();
  1149. var logicSelect = new Element("select", {"styles": {"width": "90%"}}).inject(this.logicNode);
  1150. var html = "";
  1151. if (this.data.logic=="and"){
  1152. html = "<option value=\"and\" selected>and</option><option value=\"or\">or</option>";
  1153. }else{
  1154. html = "<option value=\"and\">and</option><option value=\"or\" selected>or</option>";
  1155. }
  1156. logicSelect.set("html", html);
  1157. logicSelect.addEvent("change", function(){
  1158. this.data.logic = logicSelect.options[logicSelect.selectedIndex].value;
  1159. }.bind(this));
  1160. width = this.comparisonNode.getSize().x-9;
  1161. this.comparisonNode.empty();
  1162. var comparisonSelect = new Element("select", {"styles": {"width": "90%"}}).inject(this.comparisonNode);
  1163. html = "";
  1164. switch (this.property.data.type){
  1165. case "text":
  1166. html += "<option value=''></option><option value='==' "+((this.data.comparison=="==") ? "selected": "")+">等于(==)</option>" +
  1167. "<option value='!=' "+((this.data.comparison=="!=") ? "selected": "")+">不等于(!=)</option>" +
  1168. "<option value='@' "+((this.data.comparison=="@") ? "selected": "")+">包含(@)</option>";
  1169. break;
  1170. case "date":
  1171. html += "<option value=''></option><option value='&gt;' "+((this.data.comparison==">") ? "selected": "")+">大于(&gt;)</option>" +
  1172. "<option value='&lt;' "+((this.data.comparison=="<") ? "selected": "")+">小于(&lt;)</option>" +
  1173. "<option value='&gt;=' "+((this.data.comparison==">=") ? "selected": "")+">大于等于(&gt;=)</option>" +
  1174. "<option value='&lt;=' "+((this.data.comparison=="<=") ? "selected": "")+">小于等于(&lt;=)</option>";
  1175. break;
  1176. case "number":
  1177. html += "<option value=''></option><option value='==' "+((this.data.comparison=="==") ? "selected": "")+">等于(==)</option>" +
  1178. "<option value='!=' "+((this.data.comparison=="!=") ? "selected": "")+">不等于(!=)</option>" +
  1179. "<option value='&gt;' "+((this.data.comparison==">") ? "selected": "")+">大于(&gt;)</option>" +
  1180. "<option value='&lt;' "+((this.data.comparison=="<") ? "selected": "")+">小于(&lt;)</option>" +
  1181. "<option value='&gt;=' "+((this.data.comparison==">=") ? "selected": "")+">大于等于(&gt;=)</option>" +
  1182. "<option value='&lt;=' "+((this.data.comparison=="<=") ? "selected": "")+">小于等于(&lt;=)</option>";
  1183. break;
  1184. case "boolean":
  1185. html += "<option value=''></option><option value='==' "+((this.data.comparison=="==") ? "selected": "")+">等于(==)</option>" +
  1186. "<option value='!=' "+((this.data.comparison=="!=") ? "selected": "")+">不等于(!=)</option>";
  1187. break;
  1188. }
  1189. comparisonSelect.set("html", html);
  1190. comparisonSelect.addEvent("change", function(){
  1191. this.data.comparison = comparisonSelect.options[comparisonSelect.selectedIndex].value;
  1192. }.bind(this));
  1193. width = this.valueNode.getSize().x-9;
  1194. this.valueNode.empty();
  1195. var type = "text";
  1196. switch (this.property.data.type){
  1197. case "date":
  1198. var valueInput = new Element("input", {"styles": {"width": "90%"},
  1199. "type": "text",
  1200. "value": this.data.value
  1201. }).inject(this.valueNode);
  1202. MWF.require("MWF.widget.Calendar", function(){
  1203. this.calendar = new MWF.widget.Calendar(valueInput, {
  1204. "style": "xform",
  1205. "isTime": true,
  1206. "secondEnable": true,
  1207. "target": this.property.designer.content,
  1208. "format": "%Y-%m-%d %H:%M:%S"
  1209. });
  1210. //this.calendar.show();
  1211. }.bind(this));
  1212. break;
  1213. case "number":
  1214. var valueInput = new Element("input", {"styles": {"width": "90%"},
  1215. "type": "number",
  1216. "value": this.data.value
  1217. }).inject(this.valueNode);
  1218. break;
  1219. case "boolean":
  1220. var valueInput = new Element("select", {"styles": {"width": ""+width+"px"},
  1221. "html": "<option value=\"\"></option><option value=\"true\" "+((this.data.value) ? "selected": "")+">true</option><option value=\"false\" "+((!this.data.value) ? "selected": "")+">false</option>"
  1222. }).inject(this.valueNode);
  1223. break;
  1224. default:
  1225. var valueInput = new Element("input", {"styles": {"width": "90%"},
  1226. "type": "text",
  1227. "value": this.data.value
  1228. }).inject(this.valueNode);
  1229. }
  1230. if (valueInput.tagName.toLowerCase()=="select"){
  1231. valueInput.addEvent("change", function(){
  1232. var v = valueInput.options[valueInput.selectedIndex].value;
  1233. this.data.value = (v="true") ? true : false;
  1234. }.bind(this));
  1235. }else{
  1236. valueInput.addEvent("change", function(e){
  1237. this.data.value = valueInput.get("value");
  1238. }.bind(this));
  1239. valueInput.addEvent("blur", function(e){
  1240. this.data.value = valueInput.get("value");
  1241. }.bind(this));
  1242. valueInput.addEvent("keydown", function(e){
  1243. if (e.code==13){
  1244. this.data.value = valueInput.get("value");
  1245. this.readMode();
  1246. }
  1247. e.stopPropagation();
  1248. }.bind(this));
  1249. }
  1250. this.isEditMode = true;
  1251. this.property.editModeFilter = this;
  1252. },
  1253. readMode: function(){
  1254. if (this.isEditMode){
  1255. var logicSelect = this.logicNode.getElement("select");
  1256. this.data.logic = logicSelect.options[logicSelect.selectedIndex].value;
  1257. var comparisonSelect = this.comparisonNode.getElement("select");
  1258. this.data.comparison = comparisonSelect.options[comparisonSelect.selectedIndex].value;
  1259. var valueInput = this.valueNode.getFirst();
  1260. if (valueInput.tagName.toLowerCase()=="select"){
  1261. var v = valueInput.options[valueInput.selectedIndex].value;
  1262. this.data.value = (v="true") ? true : false;
  1263. }else{
  1264. this.data.value = valueInput.get("value");
  1265. }
  1266. this.logicNode.empty();
  1267. this.comparisonNode.empty();
  1268. this.valueNode.empty();
  1269. this.logicNode.set("text", this.data.logic);
  1270. this.comparisonNode.set("text", this.data.comparison);
  1271. this.valueNode.set("text", this.data.value);
  1272. this.isEditMode = false;
  1273. this.property.editModeFilter = null;
  1274. }
  1275. }
  1276. });