Property.js 61 KB

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