Property.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. MWF.require("MWF.widget.Common", null, false);
  2. MWF.require("MWF.widget.JsonTemplate", null, false);
  3. MWF.xApplication.query.StatDesigner.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.htmlPath = this.options.path;
  16. this.designer = designer;
  17. this.propertyNode = propertyNode;
  18. },
  19. load: function(){
  20. if (this.fireEvent("queryLoad")){
  21. MWF.getRequestText(this.htmlPath, function(responseText, responseXML){
  22. this.htmlString = responseText;
  23. this.fireEvent("postLoad");
  24. }.bind(this));
  25. }
  26. this.propertyNode.addEvent("keydown", function(e){e.stopPropagation();});
  27. },
  28. editProperty: function(td){
  29. },
  30. getHtmlString: function(callback){
  31. if (!this.htmlString){
  32. MWF.getRequestText(this.htmlPath, function(responseText, responseXML){
  33. this.htmlString = responseText;
  34. if (callback) callback();
  35. }.bind(this));
  36. }else{
  37. if (callback) callback();
  38. }
  39. },
  40. show: function(){
  41. if (!this.propertyContent){
  42. this.getHtmlString(function(){
  43. if (this.htmlString){
  44. this.JsonTemplate = new MWF.widget.JsonTemplate(this.data, this.htmlString);
  45. this.propertyContent = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.propertyNode);
  46. this.propertyContent.set("html", this.JsonTemplate.load());
  47. this.setEditNodeEvent();
  48. this.setEditNodeStyles(this.propertyContent);
  49. this.loadPropertyTab();
  50. this.loadPersonInput();
  51. this.loadPersonSelectInput();
  52. this.loadViewSelect();
  53. this.loadStatColumnSelect();
  54. this.loadArrayList();
  55. this.loadScriptArea();
  56. this.loadJSONArea();
  57. //this.view.changeViewSelected();
  58. this.module.changeViewSelected();
  59. }
  60. }.bind(this));
  61. }else{
  62. this.propertyContent.setStyle("display", "block");
  63. }
  64. },
  65. hide: function(){
  66. //this.JsonTemplate = null;
  67. //this.propertyNode.set("html", "");
  68. if (this.propertyContent) this.propertyContent.setStyle("display", "none");
  69. },
  70. loadJSONArea: function(){
  71. var jsonNode = this.propertyContent.getElement(".MWFJSONArea");
  72. if (jsonNode){
  73. this.propertyTab.pages.each(function(page){
  74. if (page.contentNode == jsonNode.parentElement){
  75. page.setOptions({
  76. "onShow": function(){
  77. jsonNode.empty();
  78. MWF.require("MWF.widget.JsonParse", function(){
  79. this.json = new MWF.widget.JsonParse(this.module.json, jsonNode, null);
  80. this.json.load();
  81. }.bind(this));
  82. }.bind(this)
  83. });
  84. }
  85. }.bind(this));
  86. }
  87. },
  88. loadPropertyTab: function(){
  89. var tabNodes = this.propertyContent.getElements(".MWFTab");
  90. if (tabNodes.length){
  91. var tmpNode = this.propertyContent.getFirst();
  92. var tabAreaNode = new Element("div", {
  93. "styles": this.view.css.propertyTabNode
  94. }).inject(tmpNode, "before");
  95. MWF.require("MWF.widget.Tab", function(){
  96. var tab = new MWF.widget.Tab(tabAreaNode, {"style": "formPropertyList"});
  97. tab.load();
  98. var tabPages = [];
  99. tabNodes.each(function(node){
  100. var page = tab.addTab(node, node.get("title"), false);
  101. tabPages.push(page);
  102. this.setScrollBar(page.contentNodeArea, "small", null, null);
  103. }.bind(this));
  104. tabPages[0].showTab();
  105. this.propertyTab = tab;
  106. this.designer.resizeNode();
  107. }.bind(this), false);
  108. }
  109. },
  110. setEditNodeEvent: function(){
  111. var property = this;
  112. // var inputs = this.process.propertyListNode.getElements(".editTableInput");
  113. var inputs = this.propertyContent.getElements("input");
  114. inputs.each(function(input){
  115. var jsondata = input.get("name");
  116. if (jsondata && jsondata.substr(0,1)!="_"){
  117. if (this.module){
  118. var id = this.module.json.id;
  119. input.set("name", id+jsondata);
  120. }
  121. if (jsondata){
  122. var inputType = input.get("type").toLowerCase();
  123. switch (inputType){
  124. case "radio":
  125. input.addEvent("change", function(e){
  126. property.setRadioValue(jsondata, this);
  127. });
  128. //input.addEvent("blur", function(e){
  129. // property.setRadioValue(jsondata, this);
  130. //});
  131. input.addEvent("keydown", function(e){
  132. e.stopPropagation();
  133. });
  134. property.setRadioValue(jsondata, input);
  135. break;
  136. case "checkbox":
  137. input.addEvent("change", function(e){
  138. property.setCheckboxValue(jsondata, this);
  139. });
  140. input.addEvent("click", function(e){
  141. property.setCheckboxValue(jsondata, this);
  142. });
  143. input.addEvent("keydown", function(e){
  144. e.stopPropagation();
  145. });
  146. break;
  147. default:
  148. input.addEvent("change", function(e){
  149. property.setValue(jsondata, this.value, this);
  150. });
  151. input.addEvent("blur", function(e){
  152. property.setValue(jsondata, this.value, this);
  153. });
  154. input.addEvent("keydown", function(e){
  155. if (e.code==13){
  156. property.setValue(jsondata, this.value, this);
  157. }
  158. e.stopPropagation();
  159. });
  160. if (input.hasClass("editTableInputDate")){
  161. this.loadCalendar(input);
  162. }
  163. }
  164. }
  165. }
  166. }.bind(this));
  167. var selects = this.propertyContent.getElements("select");
  168. selects.each(function(select){
  169. var jsondata = select.get("name");
  170. if (jsondata){
  171. select.addEvent("change", function(e){
  172. property.setSelectValue(jsondata, this);
  173. });
  174. //property.setSelectValue(jsondata, select);
  175. }
  176. });
  177. var textareas = this.propertyContent.getElements("textarea");
  178. textareas.each(function(input){
  179. var jsondata = input.get("name");
  180. if (jsondata){
  181. input.addEvent("change", function(e){
  182. property.setValue(jsondata, this.value);
  183. });
  184. input.addEvent("blur", function(e){
  185. property.setValue(jsondata, this.value);
  186. });
  187. input.addEvent("keydown", function(e){
  188. e.stopPropagation();
  189. });
  190. }
  191. }.bind(this));
  192. },
  193. loadCalendar: function(node){
  194. MWF.require("MWF.widget.Calendar", function(){
  195. this.calendar = new MWF.widget.Calendar(node, {
  196. "style": "xform",
  197. "isTime": false,
  198. "target": this.module.designer.content,
  199. "format": "%Y-%m-%d",
  200. "onComplate": function(){
  201. //this.validationMode();
  202. //this.validation();
  203. //this.fireEvent("complete");
  204. }.bind(this)
  205. });
  206. //this.calendar.show();
  207. }.bind(this));
  208. },
  209. changeStyle: function(name){
  210. this.module.setPropertiesOrStyles(name);
  211. },
  212. changeData: function(name, input, oldValue){
  213. this.module._setEditStyle(name, input, oldValue);
  214. },
  215. changeJsonDate: function(key, value){
  216. if (typeOf(key)!="array") key = [key];
  217. var o = this.data;
  218. var len = key.length-1;
  219. key.each(function(n, i){
  220. if (!o[n]) o[n] = {};
  221. if (i<len) o = o[n];
  222. }.bind(this));
  223. o[key[len]] = value;
  224. },
  225. setRadioValue: function(name, input){
  226. if (input.checked){
  227. var i = name.indexOf("*");
  228. var names = (i==-1) ? name.split(".") : name.substr(i+1, name.length).split(".");
  229. var value = input.value;
  230. if (value=="false") value = false;
  231. if (value=="true") value = true;
  232. var oldValue = this.data;
  233. for (var idx = 0; idx<names.length; idx++){
  234. if (!oldValue[names[idx]]){
  235. oldValue = null;
  236. break;
  237. }else{
  238. oldValue = oldValue[names[idx]];
  239. }
  240. }
  241. //var oldValue = this.data[name];
  242. this.changeJsonDate(names, value);
  243. this.changeData(name, input, oldValue);
  244. }
  245. },
  246. setCheckboxValue: function(name, input){
  247. var i = name.indexOf("*");
  248. var names = (i==-1) ? name.split(".") : name.substr(i+1, name.length).split(".");
  249. var id = this.module.json.id;
  250. var checkboxList = $$("input[name='"+id+name+"']");
  251. var values = [];
  252. checkboxList.each(function(checkbox){
  253. if (checkbox.get("checked")){
  254. values.push(checkbox.value);
  255. }
  256. });
  257. var o = this.data;
  258. names.each(function(k){ o = o[k]; }.bind(this));
  259. var oldValue = o;
  260. this.changeJsonDate(names, values);
  261. this.changeData(name, input, oldValue);
  262. },
  263. setSelectValue: function(name, select){
  264. var idx = select.selectedIndex;
  265. var options = select.getElements("option");
  266. var value = "";
  267. if (options[idx]){
  268. value = options[idx].get("value");
  269. }
  270. var oldValue = this.data[name];
  271. //this.data[name] = value;
  272. var names = name.split(".");
  273. this.changeJsonDate(names, value);
  274. this.changeData(name, select, oldValue);
  275. },
  276. setValue: function(name, value, obj){
  277. var names = name.split(".");
  278. var oldValue = this.data;
  279. for (var idx = 0; idx<names.length; idx++){
  280. if (!oldValue[names[idx]]){
  281. oldValue = null;
  282. break;
  283. }else{
  284. oldValue = oldValue[names[idx]];
  285. }
  286. }
  287. //var oldValue = this.data[name];
  288. //this.data[name] = value;
  289. this.changeJsonDate(names, value);
  290. this.changeData(name, obj, oldValue);
  291. },
  292. setEditNodeStyles: function(node){
  293. var nodes = node.getChildren();
  294. if (nodes.length){
  295. nodes.each(function(el){
  296. var cName = el.get("class");
  297. if (cName){
  298. if (this.view.css[cName]) el.setStyles(this.view.css[cName]);
  299. }
  300. this.setEditNodeStyles(el);
  301. }.bind(this));
  302. }
  303. },
  304. loadPersonInput: function(){
  305. var personIdentityNodes = this.propertyContent.getElements(".MWFPersonIdentity");
  306. var personUnitNodes = this.propertyContent.getElements(".MWFPersonUnit");
  307. var dutyNodes = this.propertyContent.getElements(".MWFDutySelector");
  308. var dutyNameNodes = this.propertyContent.getElements(".MWFPersonDuty");
  309. var viewNodes = this.propertyContent.getElements(".MWFViewSelect");
  310. var cmsviewNodes = this.propertyContent.getElements(".MWFCMSViewSelect");
  311. var queryviewNodes = this.propertyContent.getElements(".MWFQueryViewSelect");
  312. var querystatNodes = this.propertyContent.getElements(".MWFQueryStatSelect");
  313. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function(){
  314. personIdentityNodes.each(function(node){
  315. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  316. "type": "identity",
  317. "names": this.data[node.get("name")],
  318. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  319. });
  320. }.bind(this));
  321. personUnitNodes.each(function(node){
  322. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  323. "type": "unit",
  324. "names": this.data[node.get("name")],
  325. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  326. });
  327. }.bind(this));
  328. dutyNodes.each(function(node){
  329. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  330. "type": "duty",
  331. "names": this.data[node.get("name")],
  332. "onChange": function(ids){this.addDutyItem(node, ids);}.bind(this),
  333. "onRemoveDuty": function(item){this.removeDutyItem(node, item);}.bind(this)
  334. });
  335. }.bind(this));
  336. dutyNameNodes.each(function(node){
  337. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  338. "type": "dutyName",
  339. "names": this.data[node.get("name")],
  340. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  341. });
  342. }.bind(this));
  343. viewNodes.each(function(node){
  344. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  345. "type": "View",
  346. "count": 1,
  347. "names": [this.data[node.get("name")]],
  348. "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
  349. });
  350. }.bind(this));
  351. cmsviewNodes.each(function(node){
  352. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  353. "type": "CMSView",
  354. "count": 1,
  355. "names": [this.data[node.get("name")]],
  356. "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
  357. });
  358. }.bind(this));
  359. queryviewNodes.each(function(node){
  360. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  361. "type": "QueryView",
  362. "count": 1,
  363. "names": [this.data[node.get("name")]],
  364. "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
  365. });
  366. }.bind(this));
  367. querystatNodes.each(function(node){
  368. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  369. "type": "QueryStat",
  370. "count": 1,
  371. "names": [this.data[node.get("name")]],
  372. "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
  373. });
  374. }.bind(this));
  375. }.bind(this));
  376. // var identityNodes = this.propertyContent.getElements(".MWFPersonIdentity");
  377. // var personUnitNodes = this.propertyContent.getElements(".MWFPersonUnit");
  378. //
  379. // MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function(){
  380. // identityNodes.each(function(node){
  381. // new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  382. // "type": "identity",
  383. // "names": this.data[node.get("name")],
  384. // "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  385. // });
  386. // }.bind(this));
  387. //
  388. // personUnitNodes.each(function(node){
  389. // new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  390. // "type": "unit",
  391. // "names": this.data[node.get("name")],
  392. // "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  393. // });
  394. // }.bind(this));
  395. // }.bind(this));
  396. },
  397. saveViewItem: function(node, ids){
  398. var oldValue = this.data[node.get("name")];
  399. if (ids[0]){
  400. var view = ids[0].data;
  401. var data = {
  402. "name": view.name,
  403. "alias": view.alias,
  404. "id": view.id,
  405. "appName" : view.appName || view.applicationName,
  406. "appId": view.appId,
  407. "application": view.application
  408. };
  409. this.data[node.get("name")] = view.id;
  410. }else{
  411. this.data[node.get("name")] = null;
  412. }
  413. this.changeData(node.get("name"), node, oldValue);
  414. //if (this.module._checkView) this.module._checkView();
  415. },
  416. removeViewItem: function(node, item){
  417. },
  418. savePersonItem: function(node, ids){
  419. var values = [];
  420. ids.each(function(id){
  421. //values.push({"name": (id.data.distinguishedName || id.data.name), "id": id.data.id});
  422. values.push((id.data.distinguishedName || id.data.id || id.data.name));
  423. }.bind(this));
  424. var name = node.get("name");
  425. key = name.split(".");
  426. var o = this.data;
  427. var len = key.length-1;
  428. key.each(function(n, i){
  429. if (!o[n]) o[n] = {};
  430. if (i<len) o = o[n];
  431. }.bind(this));
  432. o[key[len]] = values;
  433. //this.data.data.restrictWhereEntry[node.get("name")] = values;
  434. },
  435. loadPersonSelectInput: function(){
  436. var applicationNodes = this.propertyContent.getElements(".MWFSelectApplication");
  437. var processNodes = this.propertyContent.getElements(".MWFSelectProcess");
  438. // var companyNodes = this.propertyContent.getElements(".MWFSelectCompany");
  439. // var departmentNodes = this.propertyContent.getElements(".MWFSelectDepartment");
  440. var personNodes = this.propertyContent.getElements(".MWFSelectPerson");
  441. var identityNodes = this.propertyContent.getElements(".MWFSelectIdentity");
  442. var personUnitNodes = this.propertyContent.getElements(".MWFSelectUnit");
  443. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function(){
  444. applicationNodes.each(function(node){
  445. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  446. "type": "application",
  447. "names": (this.data.data.restrictWhereEntry) ? this.data.data.restrictWhereEntry.applicationList : [],
  448. "onChange": function(ids){this.savePersonSelectItem(node, ids);}.bind(this)
  449. });
  450. }.bind(this));
  451. processNodes.each(function(node){
  452. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  453. "type": "process",
  454. "names": (this.data.data.restrictWhereEntry) ? this.data.data.restrictWhereEntry.processList : [],
  455. "onChange": function(ids){this.savePersonSelectItem(node, ids);}.bind(this)
  456. });
  457. }.bind(this));
  458. personUnitNodes.each(function(node){
  459. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  460. "type": "unit",
  461. "names": (this.data.data.restrictWhereEntry) ? this.data.data.restrictWhereEntry.unitList : [],
  462. "onChange": function(ids){this.savePersonSelectItem(node, ids);}.bind(this)
  463. });
  464. }.bind(this));
  465. personNodes.each(function(node){
  466. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  467. "type": "person",
  468. "names": (this.data.data.restrictWhereEntry) ? this.data.data.restrictWhereEntry.personList : [],
  469. "onChange": function(ids){this.savePersonSelectItem(node, ids);}.bind(this)
  470. });
  471. }.bind(this));
  472. identityNodes.each(function(node){
  473. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  474. "type": "identity",
  475. "names": (this.data.data.restrictWhereEntry) ? this.data.data.restrictWhereEntry.identityList : [],
  476. "onChange": function(ids){this.savePersonSelectItem(node, ids);}.bind(this)
  477. });
  478. }.bind(this));
  479. }.bind(this));
  480. },
  481. savePersonSelectItem: function(node, ids){
  482. //this.initWhereEntryData();
  483. var values = [];
  484. ids.each(function(id){
  485. values.push({"name": id.data.name, "id": id.data.id});
  486. }.bind(this));
  487. var name = node.get("name");
  488. key = name.split(".");
  489. var o = this.data;
  490. var len = key.length-1;
  491. key.each(function(n, i){
  492. if (!o[n]) o[n] = {};
  493. if (i<len) o = o[n];
  494. }.bind(this));
  495. o[key[len]] = values;
  496. //this.data.data.restrictWhereEntry[node.get("name")] = values;
  497. },
  498. loadArrayList: function(){
  499. var arrays = this.propertyContent.getElements(".MWFArraylist");
  500. arrays.each(function(node){
  501. var title = node.get("title");
  502. var name = node.get("name");
  503. var names = name.split(".");
  504. var arr = this.data;
  505. for (var idx = 0; idx<names.length; idx++){
  506. if (!arr[names[idx]]){
  507. arr = null;
  508. break;
  509. }else{
  510. arr = arr[names[idx]];
  511. }
  512. }
  513. //var arr = this.data[name];
  514. if (!arr) arr = [];
  515. MWF.require("MWF.widget.Arraylist", function(){
  516. var arraylist = new MWF.widget.Arraylist(node, {
  517. "title": title,
  518. "onChange": function(){
  519. this.setValue(name, arraylist.toArray(), node);
  520. //this.data[name] = arraylist.toArray();
  521. }.bind(this)
  522. });
  523. arraylist.load(arr);
  524. }.bind(this));
  525. node.addEvent("keydown", function(e){e.stopPropagation();});
  526. }.bind(this));
  527. },
  528. loadStatColumnSelect: function(){
  529. var columnNodes = this.propertyContent.getElements(".MWFStatSelectColumn");
  530. if (columnNodes.length){
  531. columnNodes.each(function(node){
  532. var key = node.get("name");
  533. var v = this.data[key];
  534. node.empty();
  535. new Element("option", {
  536. "value": "",
  537. "selected": true,
  538. "text": this.module.designer.lp.category
  539. }).inject(node);
  540. this.module.items.each(function(item){
  541. new Element("option", {
  542. "value": item.json.id,
  543. "selected": (v===item.json.id),
  544. "text": item.json.displayName
  545. }).inject(node);
  546. }.bind(this));
  547. }.bind(this));
  548. }
  549. },
  550. loadViewSelect: function(){
  551. var viewNodes = this.propertyContent.getElements(".MWFViewSelect");
  552. if (viewNodes.length){
  553. this.getViewList(function(){
  554. viewNodes.each(function(node){
  555. var select = new Element("select").inject(node);
  556. select.addEvent("change", function(e){
  557. var viewId = e.target.options[e.target.selectedIndex].value;
  558. var viewName = e.target.options[e.target.selectedIndex].get("text");
  559. this.setValue(e.target.getParent("div").get("name"), viewId);
  560. this.setValue(e.target.getParent("div").get("name")+"Name", viewName);
  561. }.bind(this));
  562. this.setViewSelectOptions(node, select);
  563. var refreshNode = new Element("div", {"styles": this.view.css.propertyRefreshFormNode}).inject(node);
  564. refreshNode.addEvent("click", function(e){
  565. this.getViewList(function(){
  566. this.setViewSelectOptions(node, select);
  567. }.bind(this), true);
  568. }.bind(this));
  569. //select.addEvent("click", function(e){
  570. // this.setFormSelectOptions(node, select);
  571. //}.bind(this));
  572. }.bind(this));
  573. }.bind(this));
  574. }
  575. },
  576. setViewSelectOptions: function(node, select){
  577. var name = node.get("name");
  578. select.empty();
  579. var option = new Element("option", {"text": "(none)"}).inject(select);
  580. this.views.each(function(view){
  581. var option = new Element("option", {
  582. "text": view.name,
  583. "value": view.id,
  584. "selected": (this.data[name]==view.id)
  585. }).inject(select);
  586. }.bind(this));
  587. },
  588. getViewList: function(callback, refresh){
  589. if (!this.views || refresh){
  590. this.view.designer.actions.listView(this.view.designer.application.id, function(json){
  591. this.views = json.data;
  592. if (callback) callback();
  593. }.bind(this));
  594. }else{
  595. if (callback) callback();
  596. }
  597. },
  598. loadScriptArea: function(){
  599. var scriptAreas = this.propertyContent.getElements(".MWFScriptArea");
  600. var formulaAreas = this.propertyContent.getElements(".MWFFormulaArea");
  601. this.loadScriptEditor(scriptAreas);
  602. this.loadScriptEditor(formulaAreas, "formula");
  603. },
  604. loadScriptEditor: function(scriptAreas, style){
  605. scriptAreas.each(function(node){
  606. var title = node.get("title");
  607. var name = node.get("name");
  608. var scriptContent = this.data[name];
  609. MWF.require("MWF.widget.ScriptArea", function(){
  610. var scriptArea = new MWF.widget.ScriptArea(node, {
  611. "title": title,
  612. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  613. "maxObj": this.designer.editContentNode,
  614. "onChange": function(){
  615. this.data[name] = scriptArea.toJson().code;
  616. }.bind(this),
  617. "onSave": function(){
  618. this.designer.saveView();
  619. }.bind(this),
  620. "style": style || "default"
  621. });
  622. scriptArea.load({"code": scriptContent});
  623. }.bind(this));
  624. }.bind(this));
  625. }
  626. });