Property.js 60 KB

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