Property.js 57 KB

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