Property.js 27 KB

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