Property.js 69 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535
  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. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function () {
  471. applicationNodes.each(function (node) {
  472. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  473. "type": "application",
  474. "names": (this.data.data.where) ? this.data.data.where.applicationList : [],
  475. "onChange": function (ids) {
  476. this.savePersonSelectItem(node, ids);
  477. }.bind(this)
  478. });
  479. }.bind(this));
  480. processNodes.each(function (node) {
  481. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  482. "type": "process",
  483. "names": (this.data.data.where) ? this.data.data.where.processList : [],
  484. "onChange": function (ids) {
  485. this.savePersonSelectItem(node, ids);
  486. }.bind(this)
  487. });
  488. }.bind(this));
  489. personUnitNodes.each(function (node) {
  490. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  491. "type": "unit",
  492. "names": (this.data.data.where) ? this.data.data.where.creatorUnitList : [],
  493. "onChange": function (ids) {
  494. this.savePersonSelectItem(node, ids);
  495. }.bind(this)
  496. });
  497. }.bind(this));
  498. personNodes.each(function (node) {
  499. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  500. "type": "person",
  501. "names": (this.data.data.where) ? this.data.data.where.creatorPersonList : [],
  502. "onChange": function (ids) {
  503. this.savePersonSelectItem(node, ids);
  504. }.bind(this)
  505. });
  506. }.bind(this));
  507. identityNodes.each(function (node) {
  508. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  509. "type": "identity",
  510. "names": (this.data.data.where) ? this.data.data.where.creatorIdentityList : [],
  511. "onChange": function (ids) {
  512. this.savePersonSelectItem(node, ids);
  513. }.bind(this)
  514. });
  515. }.bind(this));
  516. cmsapplicationNodes.each(function (node) {
  517. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  518. "type": "CMSApplication",
  519. "names": (this.data.data.where) ? this.data.data.where.appInfoList : [],
  520. "onChange": function (ids) {
  521. this.savePersonSelectItem(node, ids);
  522. }.bind(this)
  523. });
  524. }.bind(this));
  525. cmscategoryNodes.each(function (node) {
  526. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  527. "type": "CMSCategory",
  528. "names": (this.data.data.where) ? this.data.data.where.categoryInfoList : [],
  529. "onChange": function (ids) {
  530. this.savePersonSelectItem(node, ids);
  531. }.bind(this)
  532. });
  533. }.bind(this));
  534. }.bind(this));
  535. },
  536. savePersonSelectItem: function (node, ids) {
  537. //this.initWhereEntryData();
  538. var values = [];
  539. ids.each(function (id) {
  540. values.push({"name": (id.data.distinguishedName || id.data.name), "id": id.data.id});
  541. //values.push((id.data.distinguishedName || id.data.id || id.data.name));
  542. }.bind(this));
  543. var name = node.get("name");
  544. key = name.split(".");
  545. var o = this.data;
  546. var len = key.length - 1;
  547. key.each(function (n, i) {
  548. if (!o[n]) o[n] = {};
  549. if (i < len) o = o[n];
  550. }.bind(this));
  551. o[key[len]] = values;
  552. //this.data.data.restrictWhereEntry[node.get("name")] = values;
  553. },
  554. //loadWorkDataEditor: function(){
  555. // var workDataNodes = this.propertyContent.getElements(".MWFWorkData");
  556. // workDataNodes.each(function(node){
  557. // var select = node.getElement("select");
  558. // for (var i=0; i<select.options.length; i++){
  559. // if (select.options[i].value==this.data.name){
  560. // select.options[i].set("selected", true);
  561. // break;
  562. // }
  563. // }
  564. // if (!this.data.type) this.data.type = "text";
  565. // select.addEvent("change", function(e){
  566. // delete this.data.path;
  567. // this.data.name = select.options[select.selectedIndex].value;
  568. // this.module.listNode.getLast().set("text", this.data.text+"("+this.data.name+")");
  569. // this.setDataType();
  570. // }.bind(this));
  571. //
  572. // this.setDataType();
  573. // }.bind(this));
  574. // var nodes = this.propertyContent.getElements(".MWFWorkDataCheck");
  575. // nodes.each(function(node){
  576. // if (this.data.name) node.set("checked", true);
  577. // }.bind(this));
  578. //},
  579. //setDataType: function(){
  580. // switch (this.data.name){
  581. // case "startTime":case "completedTime":
  582. // this.data.type ="date";
  583. // break;
  584. // case "completed":
  585. // this.data.type ="boolean";
  586. // break;
  587. // default:
  588. // this.data.type ="text";
  589. // }
  590. //},
  591. //loadDataDataEditor: function(){
  592. // var nodes = this.propertyContent.getElements(".MWFDataData");
  593. // nodes.each(function(node){
  594. // var input = node.getElement("input");
  595. // input.set("value", this.data.path);
  596. // input.addEvent("change", function(e){
  597. // delete this.data.name;
  598. // this.data.path = input.get("value");
  599. // this.module.listNode.getLast().set("text", this.data.text+"("+this.data.path+")");
  600. // }.bind(this));
  601. // input.addEvent("blur", function(e){
  602. // delete this.data.name;
  603. // this.data.path = input.get("value");
  604. // this.module.listNode.getLast().set("text", this.data.text+"("+this.data.path+")");
  605. // }.bind(this));
  606. // input.addEvent("keydown", function(e){
  607. // if (e.code==13){
  608. // delete this.data.name;
  609. // this.data.path = input.get("value");
  610. // this.module.listNode.getLast().set("text", this.data.text+"("+this.data.path+")");
  611. // }
  612. // e.stopPropagation();
  613. // }.bind(this));
  614. //
  615. // var select = node.getElement("select");
  616. // for (var i=0; i<select.options.length; i++){
  617. // if (select.options[i].value==this.data.type){
  618. // select.options[i].set("selected", true);
  619. // break;
  620. // }
  621. // }
  622. // if (!this.data.type) this.data.type = "text";
  623. // select.addEvent("change", function(e){
  624. // this.data.type = select.options[select.selectedIndex].value;
  625. // }.bind(this));
  626. //
  627. // }.bind(this));
  628. // var nodes = this.propertyContent.getElements(".MWFDataDataCheck");
  629. // nodes.each(function(node){
  630. // if (this.data.path) node.set("checked", true);
  631. // }.bind(this));
  632. //},
  633. loadColumnExportEditor: function () {
  634. var _self = this;
  635. var nodes = this.propertyContent.getElements(".MWFColumnExport");
  636. nodes.each(function (node) {
  637. //if (!this.data.export) this.data.export = {};
  638. //var sort = this.data.export.sort || "";
  639. //var sortOrder = this.data.export.sortOrder || "1";
  640. var select = node.getElement("select");
  641. var sortList = this.view.data.data.orderList;
  642. sortList.each(function (order) {
  643. if (order.column == this.data.column) {
  644. if (order.orderType == "asc") select.options[1].set("selected", true);
  645. if (order.orderType == "desc") select.options[1].set("selected", false);
  646. }
  647. }.bind(this));
  648. select.addEvent("change", function (e) {
  649. debugger;
  650. var sortList = this.view.data.data.orderList;
  651. var v = select.options[select.selectedIndex].value;
  652. if (v != "none") {
  653. var flag = false;
  654. sortList.each(function (order) {
  655. if (order.column == this.data.column) {
  656. flag = true;
  657. order.orderType = select.options[select.selectedIndex].value;
  658. }
  659. }.bind(this));
  660. if (!flag) sortList.push({
  661. "column": this.data.column,
  662. "orderType": select.options[select.selectedIndex].value
  663. });
  664. var oldOrderList = Array.clone(this.view.data.data.orderList);
  665. this.view.data.data.orderList = [];
  666. this.view.json.data.selectList.each(function (sel) {
  667. oldOrderList.each(function (order) {
  668. if (order.column == sel.column) {
  669. this.view.data.data.orderList.push(order);
  670. }
  671. }.bind(this));
  672. }.bind(this));
  673. } else {
  674. var sortList = this.view.data.data.orderList;
  675. var deleteItem = null;
  676. sortList.each(function (order) {
  677. if (order.column == this.data.column) {
  678. deleteItem = order;
  679. }
  680. }.bind(this));
  681. if (deleteItem) sortList.erase(deleteItem);
  682. }
  683. }.bind(this));
  684. var radios = node.getElements("input[name='" + this.module.json.id + "groupEntry']");
  685. var group = this.view.data.data.group;
  686. if (group.column == this.data.column) radios[0].set("checked", true);
  687. radios.addEvent("click", function (e) {
  688. if (this.checked) {
  689. if (this.value == "true") {
  690. _self.view.data.data.group.column = _self.data.column;
  691. _self.view.items.each(function (col) {
  692. if (col.property) {
  693. var groupRadios = col.property.propertyContent.getElement(".MWFColumnExportGroup").getElements("input");
  694. groupRadios.each(function (r) {
  695. if (r.value == "true") r.set("checked", false);
  696. if (r.value == "false") r.set("checked", true);
  697. });
  698. }
  699. });
  700. (_self.view.data.data.selectList).each(function (s) {
  701. if (s.column !== _self.data.column) s.groupEntry = false;
  702. });
  703. this.set("checked", true);
  704. } else {
  705. if (group.column == _self.data.column) _self.view.data.data.group = {};
  706. }
  707. }
  708. });
  709. }.bind(this));
  710. },
  711. loadViewFilter: function () {
  712. var nodes = this.propertyContent.getElements(".MWFViewFilter");
  713. var filtrData = this.view.data.data.filterList;
  714. var customData = this.view.data.data.customFilterList;
  715. nodes.each(function (node) {
  716. MWF.xDesktop.requireApp("query.ViewDesigner", "widget.ViewFilter", function () {
  717. var _slef = this;
  718. new MWF.xApplication.query.ViewDesigner.widget.ViewFilter(node, this.view.designer, {
  719. "filtrData": filtrData,
  720. "customData": customData
  721. }, {
  722. "onChange": function (ids) {
  723. var data = this.getData();
  724. _slef.changeJsonDate(["data", "filterList"], data.data);
  725. _slef.changeJsonDate(["data", "customFilterList"], data.customData);
  726. }
  727. });
  728. }.bind(this));
  729. }.bind(this));
  730. },
  731. loadColumnFilter: function () {
  732. var nodes = this.propertyContent.getElements(".MWFColumnFilter");
  733. nodes.each(function (node) {
  734. this.module.filterAreaNode = node;
  735. var table = new Element("table", {
  736. "styles": {"width": "100%"},
  737. "border": "0px",
  738. "cellPadding": "0",
  739. "cellSpacing": "0"
  740. }).inject(node);
  741. var tr = new Element("tr", {"styles": this.module.css.filterTableTitle}).inject(table);
  742. var lp = MWF.APPDVD.LP.filter;
  743. var html = "<th style='width:24px;border-right:1px solid #CCC;border-bottom:1px solid #999;'></th>" +
  744. "<th style='border-right:1px solid #CCC;border-left:1px solid #FFF;border-bottom:1px solid #999;'>"+lp.logic+"</th>" +
  745. "<th style='border-right:1px solid #CCC;border-left:1px solid #FFF;border-bottom:1px solid #999;'>"+lp.path+"</th>" +
  746. "<th style='border-right:1px solid #CCC;border-left:1px solid #FFF;border-bottom:1px solid #999;'>"+lp.compare+"</th>" +
  747. "<th style='border-left:1px solid #FFF;border-bottom:1px solid #999;'>"+lp.value+"</th>";
  748. tr.set("html", html);
  749. var addActionNode = new Element("div", {"styles": this.module.css.filterAddActionNode}).inject(tr.getFirst("th"));
  750. addActionNode.addEvent("click", function () {
  751. this.addFilter(table);
  752. }.bind(this));
  753. if (this.data.filterList) {
  754. this.data.filterList.each(function (op) {
  755. new MWF.xApplication.query.ViewDesigner.Property.Filter(op, table, this);
  756. }.bind(this));
  757. }
  758. }.bind(this));
  759. },
  760. addFilter: function (table) {
  761. op = {
  762. "logic": "and",
  763. "comparison": "",
  764. "value": ""
  765. }
  766. if (!this.data.filterList) this.data.filterList = [];
  767. this.data.filterList.push(op);
  768. var filter = new MWF.xApplication.query.ViewDesigner.Property.Filter(op, table, this);
  769. filter.editMode();
  770. },
  771. loadViewStylesArea: function () {
  772. var _self = this;
  773. var viewAreas = this.propertyContent.getElements(".MWFViewStylesArea");
  774. viewAreas.each(function (node) {
  775. var name = node.get("name");
  776. var d = this.data;
  777. Array.each(name.split("."), function (n) {
  778. if (d) d = d[n];
  779. });
  780. var viewStyles = d || {};
  781. MWF.require("MWF.widget.Maplist", function () {
  782. var maps = [];
  783. Object.each(viewStyles, function (v, k) {
  784. var mapNode = new Element("div").inject(node);
  785. mapNode.empty();
  786. var maplist = new MWF.widget.Maplist(mapNode, {
  787. "title": k,
  788. "collapse": true,
  789. "onChange": function () {
  790. // var oldData = _self.data[name];
  791. var oldData = this.data;
  792. Array.each(name.split("."), function (n) {
  793. if (oldData) oldData = oldData[n];
  794. });
  795. maps.each(function (o) {
  796. d[o.key] = o.map.toJson();
  797. }.bind(this));
  798. _self.changeData(name, node, oldData);
  799. }
  800. });
  801. maps.push({"key": k, "map": maplist});
  802. maplist.load(v);
  803. }.bind(this));
  804. }.bind(this));
  805. }.bind(this));
  806. },
  807. loadMaplist: function(){
  808. var maplists = this.propertyContent.getElements(".MWFMaplist");
  809. debugger;
  810. maplists.each(function(node){
  811. var title = node.get("title");
  812. var name = node.get("name");
  813. var lName = name.toLowerCase();
  814. var collapse = node.get("collapse");
  815. var mapObj = this.data[name];
  816. if (!mapObj) mapObj = {};
  817. MWF.require("MWF.widget.Maplist", function(){
  818. node.empty();
  819. var maplist = new MWF.widget.Maplist(node, {
  820. "title": title,
  821. "collapse": (collapse) ? true : false,
  822. "onChange": function(){
  823. //this.data[name] = maplist.toJson();
  824. //
  825. var oldData = this.data[name];
  826. this.changeJsonDate(name, maplist.toJson());
  827. this.changeStyle(name, oldData);
  828. this.changeData(name);
  829. }.bind(this),
  830. "onDelete": function(key){
  831. debugger;
  832. this.module.deletePropertiesOrStyles(name, key);
  833. }.bind(this),
  834. "isProperty": (lName.contains("properties") || lName.contains("property") || lName.contains("attribute"))
  835. });
  836. maplist.load(mapObj);
  837. this.maplists[name] = maplist;
  838. }.bind(this));
  839. }.bind(this));
  840. },
  841. loadActionStylesArea: function () {
  842. var _self = this;
  843. var actionAreas = this.propertyContent.getElements(".MWFActionStylesArea");
  844. actionAreas.each(function (node) {
  845. var name = node.get("name");
  846. var actionStyles = this.data[name];
  847. MWF.require("MWF.widget.Maplist", function () {
  848. var maps = [];
  849. Object.each(actionStyles, function (v, k) {
  850. var mapNode = new Element("div").inject(node);
  851. mapNode.empty();
  852. var maplist = new MWF.widget.Maplist(mapNode, {
  853. "title": k,
  854. "collapse": true,
  855. "onChange": function () {
  856. var oldData = _self.data[name];
  857. maps.each(function (o) {
  858. _self.data[name][o.key] = o.map.toJson();
  859. }.bind(this));
  860. _self.changeData(name, node, oldData);
  861. }
  862. });
  863. maps.push({"key": k, "map": maplist});
  864. maplist.load(v);
  865. }.bind(this));
  866. }.bind(this));
  867. }.bind(this));
  868. },
  869. loadPagingStylesArea: function () {
  870. var _self = this;
  871. var pagingAreas = this.propertyContent.getElements(".MWFPagingStylesArea");
  872. pagingAreas.each(function (node) {
  873. var name = node.get("name");
  874. var pagingStyles = this.data[name];
  875. MWF.require("MWF.widget.Maplist", function () {
  876. var maps = [];
  877. Object.each(pagingStyles, function (v, k) {
  878. var mapNode = new Element("div").inject(node);
  879. mapNode.empty();
  880. var maplist = new MWF.widget.Maplist(mapNode, {
  881. "title": k,
  882. "collapse": true,
  883. "onChange": function () {
  884. var oldData = _self.data[name];
  885. maps.each(function (o) {
  886. _self.data[name][o.key] = o.map.toJson();
  887. }.bind(this));
  888. _self.changeData(name, node, oldData);
  889. }
  890. });
  891. maps.push({"key": k, "map": maplist});
  892. maplist.load(v);
  893. }.bind(this));
  894. }.bind(this));
  895. }.bind(this));
  896. },
  897. loadEventsEditor: function () {
  898. MWF.xApplication.process = MWF.xApplication.process || {};
  899. MWF.APPFD = MWF.xApplication.process.FormDesigner = MWF.xApplication.process.FormDesigner || {};
  900. MWF.xDesktop.requireApp("process.FormDesigner", "lp." + o2.language, null, false);
  901. var events = this.propertyContent.getElement(".MWFEventsArea");
  902. if (events) {
  903. var name = events.get("name");
  904. var eventsObj = this.data;
  905. Array.each(name.split("."), function (n) {
  906. if (eventsObj) eventsObj = eventsObj[n];
  907. })
  908. MWF.xDesktop.requireApp("process.FormDesigner", "widget.EventsEditor", function () {
  909. var eventsEditor = new MWF.xApplication.process.FormDesigner.widget.EventsEditor(events, this.designer, {
  910. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  911. "maxObj": this.designer.editContentNode || this.designer.contentNode
  912. });
  913. eventsEditor.load(eventsObj, this.data, name);
  914. }.bind(this));
  915. }
  916. },
  917. loadActionArea: function () {
  918. debugger;
  919. MWF.xApplication.process = MWF.xApplication.process || {};
  920. MWF.APPFD = MWF.xApplication.process.FormDesigner = MWF.xApplication.process.FormDesigner || {};
  921. MWF.xDesktop.requireApp("process.FormDesigner", "lp." + o2.language, null, false);
  922. var multiActionArea = this.propertyContent.getElements(".MWFMultiActionArea");
  923. multiActionArea.each(function(node){
  924. var name = node.get("name");
  925. var actionContent = this.data[name];
  926. MWF.xDesktop.requireApp("process.FormDesigner", "widget.ActionsEditor", function(){
  927. var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
  928. "maxObj": this.designer.editContentNode || this.propertyNode.parentElement.parentElement.parentElement,
  929. "scriptMaxObj": this.designer.editContentNode,
  930. "systemToolsAddress": "../x_component_query_ViewDesigner/$View/toolbars.json",
  931. "isSystemTool" : true,
  932. "noEditShow": true,
  933. "noReadShow": true,
  934. "onChange": function(){
  935. this.data[name] = actionEditor.data;
  936. this.changeData(name);
  937. }.bind(this)
  938. });
  939. actionEditor.load(actionContent);
  940. }.bind(this));
  941. }.bind(this));
  942. var actionAreas = this.propertyContent.getElements(".MWFActionArea");
  943. actionAreas.each(function (node) {
  944. var name = node.get("name");
  945. var actionContent = this.data[name];
  946. MWF.xDesktop.requireApp("process.FormDesigner", "widget.ActionsEditor", function () {
  947. // debugger;
  948. // var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, {
  949. // "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  950. // "noCreate": true,
  951. // "noDelete": true,
  952. // "noCode": true,
  953. // "onChange": function(){
  954. // this.data[name] = actionEditor.data;
  955. // }.bind(this)
  956. // });
  957. // actionEditor.load(this.module.defaultToolBarsData);
  958. var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
  959. "maxObj": this.designer.editContentNode || this.propertyNode.parentElement.parentElement,
  960. "scriptMaxObj": this.designer.editContentNode,
  961. "noEditShow": true,
  962. "noReadShow": true,
  963. "onChange": function () {
  964. this.data[name] = actionEditor.data;
  965. this.changeData(name);
  966. }.bind(this)
  967. });
  968. actionEditor.load(actionContent);
  969. }.bind(this));
  970. }.bind(this));
  971. var actionAreas = this.propertyContent.getElements(".MWFDefaultActionArea");
  972. actionAreas.each(function (node) {
  973. var name = node.get("name");
  974. var actionContent = this.data[name] || this.module.defaultToolBarsData;
  975. MWF.xDesktop.requireApp("process.FormDesigner", "widget.ActionsEditor", function () {
  976. var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
  977. "maxObj": this.designer.editContentNode || this.propertyNode.parentElement.parentElement,
  978. "scriptMaxObj": this.designer.editContentNode,
  979. "isSystemTool": true,
  980. "systemToolsAddress": "../x_component_query_ViewDesigner/$View/toolbars.json",
  981. "noCreate": true,
  982. "noDelete": false,
  983. "noCode": true,
  984. "noReadShow": true,
  985. "noEditShow": true,
  986. "onChange": function () {
  987. this.data[name] = actionEditor.data;
  988. this.changeData(name);
  989. }.bind(this)
  990. });
  991. actionEditor.load(actionContent);
  992. // var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, {
  993. // "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  994. // "onChange": function(){
  995. // this.data[name] = actionEditor.data;
  996. // }.bind(this)
  997. // });
  998. // actionEditor.load(actionContent);
  999. }.bind(this));
  1000. }.bind(this));
  1001. },
  1002. loadStylesList: function () {
  1003. var styleSelNodes = this.propertyContent.getElements(".MWFViewStyle");
  1004. styleSelNodes.each(function (node) {
  1005. debugger;
  1006. if (this.module.stylesList) {
  1007. if (!this.data.data.viewStyleType) this.data.data.viewStyleType = "default";
  1008. // var mode = ( this.form.options.mode || "" ).toLowerCase() === "mobile" ? "mobile" : "pc";
  1009. Object.each(this.module.stylesList, function (s, key) {
  1010. // if( s.mode.contains( mode ) ){
  1011. new Element("option", {
  1012. "text": s.name,
  1013. "value": key,
  1014. "selected": ((!this.data.data.viewStyleType && key == "default") || (this.data.data.viewStyleType == key))
  1015. }).inject(node)
  1016. // }
  1017. }.bind(this));
  1018. } else {
  1019. node.getParent("tr").setStyle("display", "none");
  1020. }
  1021. }.bind(this));
  1022. }
  1023. //initWhereEntryData: function(){
  1024. // if (!this.data.data.restrictWhereEntry) this.data.data.restrictWhereEntry = {
  1025. // "applicationList": [],
  1026. // "processList": [],
  1027. // "companyList": [],
  1028. // "departmentList": [],
  1029. // "personList": [],
  1030. // "identityList": []
  1031. // };
  1032. //},
  1033. //loadApplicationSelector: function(){
  1034. // var nodes = this.propertyContent.getElements(".MWFApplicationSelect");
  1035. // if (nodes.length){
  1036. // MWF.xDesktop.requireApp("Organization", "Selector.package", function(){
  1037. // nodes.each(function(node){
  1038. // var title = new Element("div", {"styles": this.view.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  1039. // var content = new Element("div", {"styles": this.view.css.applicationSelectContent}).inject(node);
  1040. // var action = new Element("div", {"styles": this.view.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  1041. // action.addEvent("click", function(e){
  1042. // var values = [];
  1043. // if (this.data.data.whereEntry){
  1044. // if (this.data.data.whereEntry.applicationList.length){
  1045. // this.data.data.whereEntry.applicationList.each(function(item){
  1046. // values.push(item.id);
  1047. // }.bind(this));
  1048. // }
  1049. // }
  1050. // var options = {
  1051. // "type": "application",
  1052. // "count": 0,
  1053. // "values": values,
  1054. // //"title": this.app.lp.monthly.selectSortApplication,
  1055. // "onComplete": function(items){
  1056. // this.initWhereEntryData();
  1057. // this.data.data.whereEntry.applicationList = [];
  1058. // content.empty();
  1059. // items.each(function(item){
  1060. // this.data.data.whereEntry.applicationList.push({
  1061. // "id": item.data.id,
  1062. // "name": item.data.name
  1063. // });
  1064. // new Element("div", {
  1065. // "styles": this.view.css.applicationSelectItem,
  1066. // "text": item.data.name
  1067. // }).inject(content);
  1068. // }.bind(this));
  1069. // }.bind(this)
  1070. // };
  1071. // var selector = new MWF.OrgSelector(this.view.designer.content, options);
  1072. // }.bind(this));
  1073. //
  1074. // this.initWhereEntryData();
  1075. // this.data.data.whereEntry.applicationList.each(function(app){
  1076. // new Element("div", {
  1077. // "styles": this.view.css.applicationSelectItem,
  1078. // "text": app.name
  1079. // }).inject(content);
  1080. // }.bind(this));
  1081. // }.bind(this));
  1082. // }.bind(this));
  1083. // }
  1084. //},
  1085. //loadApplicationSelector1: function(){
  1086. // var nodes = this.propertyContent.getElements(".MWFApplicationSelect");
  1087. // if (nodes.length){
  1088. // this._getAppSelector(function(){
  1089. // nodes.each(function(node){
  1090. // var title = new Element("div", {"styles": this.view.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  1091. // var content = new Element("div", {"styles": this.view.css.applicationSelectContent}).inject(node);
  1092. // var action = new Element("div", {"styles": this.view.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  1093. // action.addEvent("click", function(e){
  1094. // this.appSelector.load(function(apps){
  1095. // if (!this.data.data.select) this.data.data.select = {"applicationRestrictList": [], "processRestrictList": []};
  1096. // this.data.data.select.applicationRestrictList = [];
  1097. // content.empty();
  1098. // if (apps.length){
  1099. // apps.each(function(app){
  1100. // var o = {
  1101. // "name": app.name,
  1102. // "id": app.id,
  1103. // "alias": app.alias
  1104. // }
  1105. // this.data.data.select.applicationRestrictList.push(o);
  1106. //
  1107. // new Element("div", {
  1108. // "styles": this.view.css.applicationSelectItem,
  1109. // "text": app.name
  1110. // }).inject(content);
  1111. //
  1112. // }.bind(this));
  1113. // }
  1114. // }.bind(this));
  1115. // }.bind(this));
  1116. // if (!this.data.data.select) this.data.data.select = {"applicationRestrictList": [], "processRestrictList": []};
  1117. // this.data.data.select.applicationRestrictList.each(function(app){
  1118. // new Element("div", {
  1119. // "styles": this.view.css.applicationSelectItem,
  1120. // "text": app.name
  1121. // }).inject(content);
  1122. // }.bind(this));
  1123. //
  1124. // }.bind(this));
  1125. // }.bind(this));
  1126. // }
  1127. //},
  1128. //
  1129. //_getAppSelector: function(callback){
  1130. // if (!this.appSelector){
  1131. // MWF.xDesktop.requireApp("process.ProcessManager", "widget.ApplicationSelector", function(){
  1132. // this.appSelector = new MWF.xApplication.process.ProcessManager.widget.ApplicationSelector(this.view.designer, {"maskNode": this.view.designer.content});
  1133. // if (callback) callback();
  1134. // }.bind(this));
  1135. // }else{
  1136. // if (callback) callback();
  1137. // }
  1138. //},
  1139. //this.initWhereEntryData();
  1140. //loadProcessSelector: function(){
  1141. // var nodes = this.propertyContent.getElements(".MWFApplicationSelect");
  1142. // if (nodes.length){
  1143. // MWF.xDesktop.requireApp("Organization", "Selector.package", function(){
  1144. // nodes.each(function(node){
  1145. // var title = new Element("div", {"styles": this.view.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  1146. // var content = new Element("div", {"styles": this.view.css.applicationSelectContent}).inject(node);
  1147. // var action = new Element("div", {"styles": this.view.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  1148. // action.addEvent("click", function(e){
  1149. // var values = [];
  1150. // if (this.data.data.whereEntry){
  1151. // if (this.data.data.whereEntry.processList.length){
  1152. // this.data.data.whereEntry.processList.each(function(item){
  1153. // values.push(item.id);
  1154. // }.bind(this));
  1155. // }
  1156. // }
  1157. // var options = {
  1158. // "type": "process",
  1159. // "count": 0,
  1160. // "values": values,
  1161. // "onComplete": function(items){
  1162. // this.initWhereEntryData();
  1163. // this.data.data.whereEntry.processList = [];
  1164. // content.empty();
  1165. // items.each(function(item){
  1166. // this.data.data.whereEntry.processList.push({
  1167. // "id": item.data.id,
  1168. // "name": item.data.name
  1169. // });
  1170. // new Element("div", {
  1171. // "styles": this.view.css.applicationSelectItem,
  1172. // "text": item.data.name
  1173. // }).inject(content);
  1174. // }.bind(this));
  1175. // }.bind(this)
  1176. // };
  1177. // var selector = new MWF.OrgSelector(this.view.designer.content, options);
  1178. // }.bind(this));
  1179. //
  1180. // this.initWhereEntryData();
  1181. // this.data.data.whereEntry.processList.each(function(app){
  1182. // new Element("div", {
  1183. // "styles": this.view.css.applicationSelectItem,
  1184. // "text": app.name
  1185. // }).inject(content);
  1186. // }.bind(this));
  1187. // }.bind(this));
  1188. // }.bind(this));
  1189. // }
  1190. //}
  1191. //loadProcessSelector1: function(){
  1192. // var nodes = this.propertyContent.getElements(".MWFProcessSelect");
  1193. // if (nodes.length){
  1194. // this._getProcessSelector(function(){
  1195. // nodes.each(function(node){
  1196. // var title = new Element("div", {"styles": this.view.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  1197. // var content = new Element("div", {"styles": this.view.css.applicationSelectContent}).inject(node);
  1198. // var action = new Element("div", {"styles": this.view.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  1199. // action.addEvent("click", function(e){
  1200. // var ids=[];
  1201. // this.data.data.select.applicationRestrictList.each(function(app){
  1202. // ids.push(app.id);
  1203. // });
  1204. // this.processSelector.load(ids, function(apps){
  1205. // if (!this.data.data.select) this.data.data.select = {"applicationRestrictList": [], "processRestrictList": []};
  1206. // this.data.data.select.processRestrictList = [];
  1207. // content.empty();
  1208. // if (apps.length){
  1209. // apps.each(function(app){
  1210. // var o = {
  1211. // "name": app.name,
  1212. // "id": app.id,
  1213. // "alias": app.alias
  1214. // }
  1215. // this.data.data.select.processRestrictList.push(o);
  1216. //
  1217. // new Element("div", {
  1218. // "styles": this.view.css.applicationSelectItem,
  1219. // "text": app.name
  1220. // }).inject(content);
  1221. //
  1222. // }.bind(this));
  1223. // }
  1224. // }.bind(this));
  1225. // }.bind(this));
  1226. // if (!this.data.data.select) this.data.data.select = {"applicationRestrictList": [], "processRestrictList": []};
  1227. // this.data.data.select.processRestrictList.each(function(app){
  1228. // new Element("div", {
  1229. // "styles": this.view.css.applicationSelectItem,
  1230. // "text": app.name
  1231. // }).inject(content);
  1232. // }.bind(this));
  1233. //
  1234. // }.bind(this));
  1235. // }.bind(this));
  1236. // }
  1237. //},
  1238. //_getProcessSelector: function(callback){
  1239. // if (!this.processSelector){
  1240. // MWF.xDesktop.requireApp("process.ProcessManager", "widget.ProcessSelector", function(){
  1241. // this.processSelector = new MWF.xApplication.process.ProcessManager.widget.ProcessSelector(this.view.designer, {"maskNode": this.view.designer.content});
  1242. // if (callback) callback();
  1243. // }.bind(this));
  1244. // }else{
  1245. // if (callback) callback();
  1246. // }
  1247. //}
  1248. });
  1249. MWF.xApplication.query.ViewDesigner.Property.Filter = new Class({
  1250. Implements: [Events],
  1251. initialize: function (json, table, property) {
  1252. this.property = property;
  1253. this.module = property.module;
  1254. this.table = table;
  1255. this.data = json;
  1256. this.load();
  1257. },
  1258. load: function () {
  1259. var lp = MWF.APPDVD.LP.filter;
  1260. this.node = new Element("tr", {"styles": this.module.css.filterTableTd}).inject(this.table);
  1261. var html = "<td style='widtd:24px;border-right:1px solid #CCC;border-bottom:1px solid #999;'></td>" +
  1262. "<td style='padding:3px;border-right:1px solid #CCC;border-bottom:1px solid #999; width:60px'>" + this.data.logic + "</td>" +
  1263. "<td style='padding:3px;border-right:1px solid #CCC;border-bottom:1px solid #999; width:30px'>"+lp.columnValue+"</td>" +
  1264. "<td style='padding:3px;border-right:1px solid #CCC;border-bottom:1px solid #999;'>" + this.data.comparison + "</td>" +
  1265. "<td style='padding:3px;border-bottom:1px solid #999;'>" + this.data.value + "</td>";
  1266. this.node.set("html", html);
  1267. var tds = this.node.getElements("td");
  1268. this.delActionNode = new Element("div", {"styles": this.module.css.filterDelActionNode}).inject(tds[0]);
  1269. this.delActionNode.addEvent("click", function (e) {
  1270. this.delFilter(e);
  1271. e.stopPropagation();
  1272. }.bind(this));
  1273. this.logicNode = tds[1];
  1274. this.comparisonNode = tds[3];
  1275. this.valueNode = tds[4];
  1276. this.node.addEvent("click", function () {
  1277. if (!this.isEditMode) this.editMode();
  1278. }.bind(this));
  1279. this.node.addEvent("blur", function () {
  1280. if (this.isEditMode) this.readMode();
  1281. }.bind(this));
  1282. },
  1283. delFilter: function (e) {
  1284. var _self = this;
  1285. this.property.designer.confirm("warn", e, MWF.APPDVD.LP.notice.deleteFilterTitle, MWF.APPDVD.LP.notice.deleteFilter, 300, 120, function () {
  1286. _self.node.destroy();
  1287. _self.property.data.filterList.erase(_self.data);
  1288. MWF.release(_self);
  1289. this.close();
  1290. }, function () {
  1291. this.close();
  1292. }, null);
  1293. },
  1294. editMode: function () {
  1295. if (this.property.editModeFilter) {
  1296. if (this.property.editModeFilter != this) this.property.editModeFilter.readMode();
  1297. }
  1298. var width = this.logicNode.getSize().x - 9;
  1299. this.logicNode.empty();
  1300. var logicSelect = new Element("select", {"styles": {"width": "90%"}}).inject(this.logicNode);
  1301. var html = "";
  1302. if (this.data.logic == "and") {
  1303. html = "<option value=\"and\" selected>and</option><option value=\"or\">or</option>";
  1304. } else {
  1305. html = "<option value=\"and\">and</option><option value=\"or\" selected>or</option>";
  1306. }
  1307. logicSelect.set("html", html);
  1308. logicSelect.addEvent("change", function () {
  1309. this.data.logic = logicSelect.options[logicSelect.selectedIndex].value;
  1310. }.bind(this));
  1311. width = this.comparisonNode.getSize().x - 9;
  1312. this.comparisonNode.empty();
  1313. var comparisonSelect = new Element("select", {"styles": {"width": "90%"}}).inject(this.comparisonNode);
  1314. var lp = MWF.APPDVD.LP.filter;
  1315. html = "";
  1316. switch (this.property.data.type) {
  1317. case "text":
  1318. html += "<option value=''></option><option value='==' " + ((this.data.comparison == "==") ? "selected" : "") + ">"+lp.equals+"(==)</option>" +
  1319. "<option value='!=' " + ((this.data.comparison == "!=") ? "selected" : "") + ">"+lp.notEquals+"(!=)</option>" +
  1320. "<option value='@' " + ((this.data.comparison == "@") ? "selected" : "") + ">"+lp.contain+"(@)</option>";
  1321. break;
  1322. case "date":
  1323. html += "<option value=''></option><option value='&gt;' " + ((this.data.comparison == ">") ? "selected" : "") + ">"+lp.greaterThan+"(&gt;)</option>" +
  1324. "<option value='&lt;' " + ((this.data.comparison == "<") ? "selected" : "") + ">"+lp.lessThan+"(&lt;)</option>" +
  1325. "<option value='&gt;=' " + ((this.data.comparison == ">=") ? "selected" : "") + ">"+lp.greaterThanOrEqualTo+"(&gt;=)</option>" +
  1326. "<option value='&lt;=' " + ((this.data.comparison == "<=") ? "selected" : "") + ">"+lp.lessThanOrEqualTo+"(&lt;=)</option>";
  1327. break;
  1328. case "number":
  1329. html += "<option value=''></option><option value='==' " + ((this.data.comparison == "==") ? "selected" : "") + ">"+lp.equals+"(==)</option>" +
  1330. "<option value='!=' " + ((this.data.comparison == "!=") ? "selected" : "") + ">"+lp.notEquals+"(!=)</option>" +
  1331. "<option value='&gt;' " + ((this.data.comparison == ">") ? "selected" : "") + ">"+lp.greaterThan+"(&gt;)</option>" +
  1332. "<option value='&lt;' " + ((this.data.comparison == "<") ? "selected" : "") + ">"+lp.lessThan+"(&lt;)</option>" +
  1333. "<option value='&gt;=' " + ((this.data.comparison == ">=") ? "selected" : "") + ">"+lp.greaterThanOrEqualTo+"(&gt;=)</option>" +
  1334. "<option value='&lt;=' " + ((this.data.comparison == "<=") ? "selected" : "") + ">"+lp.lessThanOrEqualTo+"(&lt;=)</option>";
  1335. break;
  1336. case "boolean":
  1337. html += "<option value=''></option><option value='==' " + ((this.data.comparison == "==") ? "selected" : "") + ">"+lp.equals+"(==)</option>" +
  1338. "<option value='!=' " + ((this.data.comparison == "!=") ? "selected" : "") + ">"+lp.notEquals+"(!=)</option>";
  1339. break;
  1340. }
  1341. comparisonSelect.set("html", html);
  1342. comparisonSelect.addEvent("change", function () {
  1343. this.data.comparison = comparisonSelect.options[comparisonSelect.selectedIndex].value;
  1344. }.bind(this));
  1345. width = this.valueNode.getSize().x - 9;
  1346. this.valueNode.empty();
  1347. var type = "text";
  1348. switch (this.property.data.type) {
  1349. case "date":
  1350. var valueInput = new Element("input", {
  1351. "styles": {"width": "90%"},
  1352. "type": "text",
  1353. "value": this.data.value
  1354. }).inject(this.valueNode);
  1355. MWF.require("MWF.widget.Calendar", function () {
  1356. this.calendar = new MWF.widget.Calendar(valueInput, {
  1357. "style": "xform",
  1358. "isTime": true,
  1359. "secondEnable": true,
  1360. "target": this.property.designer.content,
  1361. "format": "%Y-%m-%d %H:%M:%S"
  1362. });
  1363. //this.calendar.show();
  1364. }.bind(this));
  1365. break;
  1366. case "number":
  1367. var valueInput = new Element("input", {
  1368. "styles": {"width": "90%"},
  1369. "type": "number",
  1370. "value": this.data.value
  1371. }).inject(this.valueNode);
  1372. break;
  1373. case "boolean":
  1374. var valueInput = new Element("select", {
  1375. "styles": {"width": "" + width + "px"},
  1376. "html": "<option value=\"\"></option><option value=\"true\" " + ((this.data.value) ? "selected" : "") + ">true</option><option value=\"false\" " + ((!this.data.value) ? "selected" : "") + ">false</option>"
  1377. }).inject(this.valueNode);
  1378. break;
  1379. default:
  1380. var valueInput = new Element("input", {
  1381. "styles": {"width": "90%"},
  1382. "type": "text",
  1383. "value": this.data.value
  1384. }).inject(this.valueNode);
  1385. }
  1386. if (valueInput.tagName.toLowerCase() == "select") {
  1387. valueInput.addEvent("change", function () {
  1388. var v = valueInput.options[valueInput.selectedIndex].value;
  1389. this.data.value = (v = "true") ? true : false;
  1390. }.bind(this));
  1391. } else {
  1392. valueInput.addEvent("change", function (e) {
  1393. this.data.value = valueInput.get("value");
  1394. }.bind(this));
  1395. valueInput.addEvent("blur", function (e) {
  1396. this.data.value = valueInput.get("value");
  1397. }.bind(this));
  1398. valueInput.addEvent("keydown", function (e) {
  1399. if (e.code == 13) {
  1400. this.data.value = valueInput.get("value");
  1401. this.readMode();
  1402. }
  1403. e.stopPropagation();
  1404. }.bind(this));
  1405. }
  1406. this.isEditMode = true;
  1407. this.property.editModeFilter = this;
  1408. },
  1409. readMode: function () {
  1410. if (this.isEditMode) {
  1411. var logicSelect = this.logicNode.getElement("select");
  1412. this.data.logic = logicSelect.options[logicSelect.selectedIndex].value;
  1413. var comparisonSelect = this.comparisonNode.getElement("select");
  1414. this.data.comparison = comparisonSelect.options[comparisonSelect.selectedIndex].value;
  1415. var valueInput = this.valueNode.getFirst();
  1416. if (valueInput.tagName.toLowerCase() == "select") {
  1417. var v = valueInput.options[valueInput.selectedIndex].value;
  1418. this.data.value = (v = "true") ? true : false;
  1419. } else {
  1420. this.data.value = valueInput.get("value");
  1421. }
  1422. this.logicNode.empty();
  1423. this.comparisonNode.empty();
  1424. this.valueNode.empty();
  1425. this.logicNode.set("text", this.data.logic);
  1426. this.comparisonNode.set("text", this.data.comparison);
  1427. this.valueNode.set("text", this.data.value);
  1428. this.isEditMode = false;
  1429. this.property.editModeFilter = null;
  1430. }
  1431. }
  1432. });