Property.js 28 KB

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