Property.js 56 KB

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