Property.js 58 KB

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