Property.js 73 KB

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