Property.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  1. MWF.require("MWF.widget.UUID", null,false);
  2. MWF.require("MWF.widget.JsonTemplate", null, false);
  3. MWF.xApplication.process.ProcessDesigner.Property = new Class({
  4. Implements: [Options, Events],
  5. load: function(){
  6. if (!this.process.options.isView){
  7. if (this.fireEvent("queryLoad")){
  8. MWF.getRequestText(this.htmlPath, function(responseText, responseXML){
  9. this.htmlString = responseText;
  10. this.fireEvent("postLoad");
  11. }.bind(this));
  12. }
  13. this.process.propertyListNode.addEvent("keydown", function(e){e.stopPropagation();});
  14. }
  15. },
  16. editProperty: function(td){
  17. },
  18. getHtmlString: function(callback){
  19. if (!this.htmlString){
  20. MWF.getRequestText(this.htmlPath, function(responseText, responseXML){
  21. this.htmlString = responseText;
  22. if (callback) callback();
  23. }.bind(this));
  24. }else{
  25. if (callback) callback();
  26. }
  27. },
  28. show: function(){
  29. if (!this.process.options.isView){
  30. if (!this.propertyContent){
  31. this.getHtmlString(function(){
  32. this.propertyContent = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.process.propertyListNode);
  33. this.process.panel.propertyTabPage.showTabIm();
  34. this.JsonTemplate = new MWF.widget.JsonTemplate(this.data, this.htmlString);
  35. this.propertyContent.set("html", this.JsonTemplate.load());
  36. this.process.panel.data = this.data;
  37. this.setEditNodeEvent();
  38. this.setEditNodeStyles(this.propertyContent);
  39. this.loadPropertyTab();
  40. this.loadFormFieldInput();
  41. this.loadPersonInput();
  42. this.loadScriptInput();
  43. this.loadScriptText();
  44. this.loadConditionInput();
  45. this.loadFormSelect();
  46. this.loadSerial();
  47. this.loadSericalActivitySelect();
  48. this.loadApplicationSelector();
  49. this.loadProcessSelector();
  50. this.loadIconSelect();
  51. this.loadContextRoot();
  52. }.bind(this));
  53. //this.loadDutySelector();
  54. }else{
  55. this.propertyContent.setStyle("display", "block");
  56. }
  57. // this.process.isFocus = true;
  58. }
  59. },
  60. //hide: function(){
  61. // if (!this.process.options.isView) {
  62. // this.JsonTemplate = null;
  63. //
  64. // this.scriptTexts.each(function(script){
  65. // MWF.release(script);
  66. // }.bind(this));
  67. // this.scriptTexts = null;
  68. //
  69. // this.propertyContent.set("html", "");
  70. // }
  71. //},
  72. hide: function(){
  73. if (!this.process.options.isView) {
  74. if (this.propertyContent) this.propertyContent.setStyle("display", "none");
  75. }
  76. },
  77. loadPropertyTab: function(){
  78. var tabNodes = this.propertyContent.getElements(".MWFTab");
  79. if (tabNodes.length){
  80. var tmpNode = this.propertyContent.getFirst();
  81. var tabAreaNode = new Element("div", {
  82. "styles": this.process.css.propertyTabNode
  83. }).inject(tmpNode, "before");
  84. MWF.require("MWF.widget.Tab", function(){
  85. var tab = new MWF.widget.Tab(tabAreaNode, {"style": "moduleList"});
  86. tab.load();
  87. var tabPages = [];
  88. tabNodes.each(function(node){
  89. var tabPage = tab.addTab(node, node.get("title"), false);
  90. tabPages.push(tabPage);
  91. }.bind(this));
  92. tabPages[0].showTab();
  93. }.bind(this));
  94. }
  95. },
  96. setEditNodeEvent: function(){
  97. debugger;
  98. var property = this;
  99. // var inputs = this.propertyContent.getElements(".editTableInput");
  100. var inputs = this.propertyContent.getElements("input");
  101. inputs.each(function(input){
  102. var jsondata = input.get("name");
  103. var id = this.process.process.id;
  104. if (this.activity) id = this.activity.data.id;
  105. if (this.route) id = this.route.data.id;
  106. input.set("name", id+jsondata);
  107. if (jsondata){
  108. var inputType = input.get("type").toLowerCase();
  109. switch (inputType){
  110. case "radio":
  111. input.addEvent("change", function(e){
  112. property.setRadioValue(jsondata, this);
  113. });
  114. input.addEvent("blur", function(e){
  115. property.setRadioValue(jsondata, this);
  116. });
  117. input.addEvent("keydown", function(e){
  118. e.stopPropagation();
  119. });
  120. property.setRadioValue(jsondata, input);
  121. break;
  122. case "checkbox":
  123. input.addEvent("keydown", function(e){
  124. e.stopPropagation();
  125. });
  126. break;
  127. default:
  128. input.addEvent("change", function(e){
  129. property.setValue(jsondata, this.value);
  130. });
  131. input.addEvent("blur", function(e){
  132. property.setValue(jsondata, this.value);
  133. });
  134. input.addEvent("keydown", function(e){
  135. if (e.code===13){
  136. property.setValue(jsondata, this.value);
  137. }
  138. e.stopPropagation();
  139. });
  140. property.setValue(jsondata, input.get("value"));
  141. }
  142. }
  143. }.bind(this));
  144. var selects = this.propertyContent.getElements("select");
  145. selects.each(function(select){
  146. var jsondata = select.get("name");
  147. if (jsondata){
  148. select.addEvent("change", function(e){
  149. property.setSelectValue(jsondata, this);
  150. });
  151. }
  152. });
  153. var textareas = this.propertyContent.getElements("textarea");
  154. textareas.each(function(input){
  155. var jsondata = input.get("name");
  156. if (jsondata){
  157. input.addEvent("change", function(e){
  158. property.setValue(jsondata, this.value);
  159. });
  160. input.addEvent("blur", function(e){
  161. property.setValue(jsondata, this.value);
  162. });
  163. input.addEvent("keydown", function(e){
  164. e.stopPropagation();
  165. });
  166. }
  167. }.bind(this));
  168. },
  169. setSelectValue: function(name, select){
  170. var idx = select.selectedIndex;
  171. var options = select.getElements("option");
  172. var value = "";
  173. if (options[idx]){
  174. value = options[idx].get("value");
  175. }
  176. this.data[name] = value;
  177. },
  178. setRadioValue: function(name, input){
  179. if (input.checked){
  180. var oldValue = this.data[name];
  181. var value = input.value;
  182. if (value=="false") value = false;
  183. if (value=="true") value = true;
  184. this.data[name] = value;
  185. if (this.route) this.route._setEditProperty(name, input, oldValue);
  186. }
  187. },
  188. setValue: function(name, value){
  189. var oldValue = this.data[name];
  190. this.data[name] = value;
  191. if (name=="name"){
  192. if (!value) this.data[name] = MWF.APPPD.LP.unnamed;
  193. // this.activity.redraw();
  194. }
  195. if (this.route) this.route._setEditProperty(name, input, oldValue);
  196. },
  197. setEditNodeStyles: function(node){
  198. var nodes = node.getChildren();
  199. if (nodes.length){
  200. nodes.each(function(el){
  201. var cName = el.get("class");
  202. if (cName){
  203. if (this.process.css[cName]) el.setStyles(this.process.css[cName]);
  204. }
  205. this.setEditNodeStyles(el);
  206. }.bind(this));
  207. }
  208. },
  209. loadScriptText: function(){
  210. this.scriptTexts = [];
  211. var scriptNodes = this.propertyContent.getElements(".MWFScriptText");
  212. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.ScriptText", function(){
  213. var _self = this;
  214. scriptNodes.each(function(node){
  215. var script = new MWF.xApplication.process.ProcessDesigner.widget.ScriptText(node, this.data[node.get("name")], this.process.designer, {
  216. "maskNode": this.process.designer.content,
  217. "maxObj": this.process.designer.paperNode,
  218. "onChange": function(code){
  219. _self.data[node.get("name")] = code;
  220. }
  221. });
  222. this.scriptTexts.push(script);
  223. //this.setScriptItems(script, node);
  224. }.bind(this));
  225. }.bind(this));
  226. },
  227. loadScriptInput: function(){
  228. var scriptNodes = this.propertyContent.getElements(".MWFScript");
  229. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.ScriptSelector", function(){
  230. var _self = this;
  231. scriptNodes.each(function(node){
  232. var script = new MWF.xApplication.process.ProcessDesigner.widget.ScriptSelector(node, this.data[node.get("name")], this.process.designer, {
  233. "maskNode": this.process.designer.content,
  234. "onSelected": function(scriptData){
  235. _self.data[node.get("name")] = scriptData.name;
  236. },
  237. "onDelete": function(){
  238. _self.data[node.get("name")] = "";
  239. node.empty();
  240. }
  241. //"onPostSave": function(script){
  242. // this.saveScriptItem(node, script);
  243. //}.bind(this),
  244. //"onQueryDelete": function(script){
  245. // this.deleteScriptItem(node, script);
  246. //}.bind(this)
  247. });
  248. //this.setScriptItems(script, node);
  249. }.bind(this));
  250. }.bind(this));
  251. },
  252. loadFormFieldInput: function(){
  253. var fieldNodes = this.propertyContent.getElements(".MWFFormFieldPerson");
  254. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function(){
  255. fieldNodes.each(function(node){
  256. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.process.designer, {
  257. "type": "formField",
  258. "application": this.process.process.application,
  259. "fieldType": "person",
  260. "names": this.data[node.get("name")] || [],
  261. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  262. });
  263. }.bind(this));
  264. }.bind(this));
  265. },
  266. loadPersonInput: function(){
  267. var personIdentityNodes = this.propertyContent.getElements(".MWFPersonIdentity");
  268. var personDepartmentNodes = this.propertyContent.getElements(".MWFPersonDepartment");
  269. var personCompanyNodes = this.propertyContent.getElements(".MWFPersonCompany");
  270. var dutyNodes = this.propertyContent.getElements(".MWFDutySelector");
  271. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function(){
  272. debugger;
  273. personIdentityNodes.each(function(node){
  274. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.process.designer, {
  275. "type": "identity",
  276. "names": this.data[node.get("name")],
  277. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  278. });
  279. }.bind(this));
  280. personDepartmentNodes.each(function(node){
  281. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.process.designer, {
  282. "type": "department",
  283. "names": this.data[node.get("name")],
  284. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  285. });
  286. }.bind(this));
  287. personCompanyNodes.each(function(node){
  288. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.process.designer, {
  289. "type": "company",
  290. "names": this.data[node.get("name")],
  291. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  292. });
  293. }.bind(this));
  294. dutyNodes.each(function(node){
  295. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.process.designer, {
  296. "type": "duty",
  297. "names": this.data[node.get("name")],
  298. "onChange": function(ids){this.addDutyItem(node, ids);}.bind(this),
  299. "onRemoveDuty": function(item){this.removeDutyItem(node, item);}.bind(this)
  300. });
  301. }.bind(this));
  302. }.bind(this));
  303. },
  304. removeDutyItem: function(node, item){
  305. if (item.data.id){
  306. var values = JSON.decode(this.data[node.get("name")]) || [];
  307. var value = values.filter(function(v){
  308. return v.id == item.data.id;
  309. });
  310. value.each(function(v) {
  311. values = values.erase(v);
  312. });
  313. this.data[node.get("name")] = JSON.encode(values);
  314. }
  315. item.node.destroy();
  316. MWF.release(item);
  317. delete item;
  318. },
  319. addDutyItem: function(node, ids){
  320. var value = this.data[node.get("name")] || "";
  321. if (!value) value = "[]";
  322. var values = JSON.decode(value);
  323. ids.each(function(id){
  324. if (id.data.id){
  325. for (var i=0; i<values.length; i++){
  326. if (values[i].id==id.data.id){
  327. values[i].name = id.data.name;
  328. values[i].code = id.data.code;
  329. break;
  330. }
  331. }
  332. }else{
  333. id.data.id = new MWF.widget.UUID().toString();
  334. values.push({"name": id.data.name, "id": id.data.id, "code": id.data.code});
  335. }
  336. }.bind(this));
  337. this.data[node.get("name")] = JSON.encode(values);
  338. },
  339. savePersonItem: function(node, ids){
  340. var values = [];
  341. ids.each(function(id){
  342. values.push(id.data.name);
  343. }.bind(this));
  344. this.data[node.get("name")] = values;
  345. },
  346. loadConditionInput: function(){
  347. var conditionNodes = this.propertyContent.getElements(".MWFCondition");
  348. conditionNodes.each(function(node){
  349. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.ConditionEditor", function(){
  350. var script = new MWF.xApplication.process.ProcessDesigner.widget.ConditionEditor(node, {
  351. "onPostSave": function(script){
  352. this.saveScriptItem(node, script);
  353. }.bind(this),
  354. "onQueryDelete": function(script){
  355. this.deleteScriptItem(node, script);
  356. }.bind(this)
  357. });
  358. this.setScriptItems(script, node);
  359. }.bind(this));
  360. }.bind(this));
  361. },
  362. loadFormSelect: function(){
  363. var formNodes = this.propertyContent.getElements(".MWFFormSelect");
  364. if (formNodes.length){
  365. this.getFormList(function(){
  366. formNodes.each(function(node){
  367. var select = new Element("select").inject(node);
  368. var option = new Element("option", {"text": "none"}).inject(select);
  369. select.addEvent("change", function(e){
  370. this.setValue(e.target.getParent("div").get("name"), e.target.options[e.target.selectedIndex].value);
  371. }.bind(this));
  372. this.setFormSelectOptions(node, select);
  373. var refreshNode = new Element("div", {"styles": this.process.css.propertyRefreshFormNode}).inject(node);
  374. refreshNode.addEvent("click", function(e){
  375. this.getFormList(function(){
  376. this.setFormSelectOptions(node, select);
  377. }.bind(this), true);
  378. }.bind(this));
  379. }.bind(this));
  380. }.bind(this));
  381. }
  382. },
  383. setFormSelectOptions: function(node, select){
  384. var name = node.get("name");
  385. select.empty();
  386. var option = new Element("option", {"text": "none"}).inject(select);
  387. this.forms.each(function(form){
  388. var option = new Element("option", {
  389. "text": form.name,
  390. "value": form.id,
  391. "selected": (this.data[name]==form.id)
  392. }).inject(select);
  393. }.bind(this));
  394. },
  395. getFormList: function(callback, refresh){
  396. if (!this.forms || refresh){
  397. this.process.designer.actions.listForm(this.process.designer.application.id, function(json){
  398. this.forms = json.data;
  399. if (callback) callback();
  400. }.bind(this));
  401. }else{
  402. if (callback) callback();
  403. }
  404. },
  405. loadSerial: function(){
  406. var serialNodes = this.propertyContent.getElements(".MWFSerial");
  407. if (serialNodes.length){
  408. // this.getSerialRule(function(){
  409. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.SerialEditor", function(){
  410. serialNodes.each(function(node){
  411. var serialEditor = new MWF.xApplication.process.ProcessDesigner.widget.SerialEditor(node, this.data[node.get("name")]);
  412. serialEditor.addEvent("change", function(e){
  413. this.setValue(node.get("name"), JSON.encode(serialEditor.getData()));
  414. }.bind(this));
  415. serialEditor.process = this.process;
  416. serialEditor.load();
  417. }.bind(this));
  418. }.bind(this));
  419. // }.bind(this));
  420. }
  421. },
  422. loadSericalActivitySelect: function(){
  423. var serialNodes = this.propertyContent.getElements(".MWFSericalActivitySelect");
  424. if (serialNodes.length){
  425. serialNodes.each(function(node){
  426. var select = new Element("select").inject(node);
  427. select.addEvent("change", function(e){
  428. this.setValue(e.target.getParent("div").get("name"), e.target.options[e.target.selectedIndex].value);
  429. }.bind(this));
  430. this.listSericalActivityOptions(node, select);
  431. var refreshNode = new Element("div", {"styles": this.process.css.propertyRefreshFormNode}).inject(node);
  432. refreshNode.addEvent("click", function(e){
  433. this.listSericalActivityOptions(node, select);
  434. }.bind(this));
  435. }.bind(this));
  436. }
  437. },
  438. listSericalActivityOptions: function(node, select){
  439. var name = node.get("name");
  440. select.empty();
  441. var option = new Element("option", {"text": "none"}).inject(select);
  442. var option = new Element("option", {
  443. "text": this.process.process.begin.name,
  444. "value": this.process.process.begin.id
  445. }).inject(select);
  446. this.listSericalActivitys("endList", name, select);
  447. this.listSericalActivitys("cancelList", name, select);
  448. this.listSericalActivitys("manualList", name, select);
  449. this.listSericalActivitys("conditionList", name, select);
  450. this.listSericalActivitys("choiceList", name, select);
  451. this.listSericalActivitys("splitList", name, select);
  452. this.listSericalActivitys("parallelList", name, select);
  453. this.listSericalActivitys("mergeList", name, select);
  454. this.listSericalActivitys("embedList", name, select);
  455. this.listSericalActivitys("delayList", name, select);
  456. this.listSericalActivitys("invokeList", name, select);
  457. this.listSericalActivitys("serviceList", name, select);
  458. this.listSericalActivitys("agentList", name, select);
  459. this.listSericalActivitys("messageList", name, select);
  460. },
  461. listSericalActivitys: function(p, name, select){
  462. var datas = this.process.process[p];
  463. if (datas){
  464. var count = datas.length;
  465. if (count){
  466. datas.each(function(data){
  467. var option = new Element("option", {
  468. "text": data.name,
  469. "value": data.id,
  470. "selected": (this.data[name]==data.id)
  471. }).inject(select);
  472. }.bind(this));
  473. }
  474. }
  475. },
  476. loadApplicationSelector: function(){
  477. var nodes = this.propertyContent.getElements(".MWFApplicationSelect");
  478. if (nodes.length){
  479. this._getAppSelector(function(){
  480. nodes.each(function(node){
  481. var title = new Element("div", {"styles": this.process.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  482. var action = new Element("div", {"styles": this.process.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  483. var content = new Element("div", {"styles": this.process.css.applicationSelectContent}).inject(node);
  484. action.addEvent("click", function(e){
  485. this.appSelector.load(function(apps){
  486. content.empty();
  487. if (apps.length){
  488. this.data.targetApplication = apps[0].id;
  489. this.data.targetApplicationName = apps[0].name;
  490. this.data.targetApplicationAlias = apps[0].alias;
  491. new Element("div", {
  492. "styles": this.process.css.applicationSelectItem,
  493. "text": apps[0].name
  494. }).inject(content);
  495. }else{
  496. this.data.targetApplication = "";
  497. this.data.targetApplicationName = "";
  498. this.data.targetApplicationAlias = "";
  499. }
  500. var processNodes = this.propertyContent.getElements(".MWFProcessSelect");
  501. processNodes.each(function(n){
  502. this.data.targetProcess = "";
  503. this.data.targetProcessName = "";
  504. this.data.targetProcessAlias = "";
  505. var processContent = n.getLast();
  506. processContent.empty();
  507. }.bind(this));
  508. }.bind(this));
  509. }.bind(this));
  510. if (this.data.targetApplication){
  511. new Element("div", {
  512. "styles": this.process.css.applicationSelectItem,
  513. "text": this.data.targetApplicationName
  514. }).inject(content);
  515. }
  516. }.bind(this));
  517. }.bind(this));
  518. }
  519. },
  520. _getAppSelector: function(callback){
  521. if (!this.appSelector){
  522. MWF.xDesktop.requireApp("process.ProcessManager", "widget.ApplicationSelector", function(){
  523. this.appSelector = new MWF.xApplication.process.ProcessManager.widget.ApplicationSelector(this.process.designer, {"maskNode": this.process.designer.content, "multi": false});
  524. if (callback) callback();
  525. }.bind(this));
  526. }else{
  527. if (callback) callback();
  528. }
  529. },
  530. loadProcessSelector: function(){
  531. var nodes = this.propertyContent.getElements(".MWFProcessSelect");
  532. if (nodes.length){
  533. this._getProcessSelector(function(){
  534. nodes.each(function(node){
  535. var title = new Element("div", {"styles": this.process.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  536. var action = new Element("div", {"styles": this.process.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  537. var content = new Element("div", {"styles": this.process.css.applicationSelectContent}).inject(node);
  538. action.addEvent("click", function(e){
  539. var id = this.data.targetApplication;
  540. this.processSelector.load([id], function(pros){
  541. content.empty();
  542. if (pros.length){
  543. this.data.targetProcess = pros[0].id;
  544. this.data.targetProcessName = pros[0].name;
  545. this.data.targetProcessAlias = pros[0].alias;
  546. new Element("div", {
  547. "styles": this.process.css.applicationSelectItem,
  548. "text": pros[0].name
  549. }).inject(content);
  550. }else{
  551. this.data.targetProcess = "";
  552. this.data.targetProcessName = "";
  553. this.data.targetProcessAlias = "";
  554. }
  555. }.bind(this));
  556. }.bind(this));
  557. if (this.data.targetProcess){
  558. new Element("div", {
  559. "styles": this.process.css.applicationSelectItem,
  560. "text": this.data.targetProcessName
  561. }).inject(content);
  562. }
  563. }.bind(this));
  564. }.bind(this));
  565. }
  566. },
  567. _getProcessSelector: function(callback){
  568. if (!this.processSelector){
  569. MWF.xDesktop.requireApp("process.ProcessManager", "widget.ProcessSelector", function(){
  570. this.processSelector = new MWF.xApplication.process.ProcessManager.widget.ProcessSelector(this.process.designer, {"maskNode": this.process.designer.content, "multi": false});
  571. if (callback) callback();
  572. }.bind(this));
  573. }else{
  574. if (callback) callback();
  575. }
  576. },
  577. loadIconSelect: function(){
  578. var nodes = this.propertyContent.getElements(".MWFIcon");
  579. if (nodes.length){
  580. nodes.each(function(node){
  581. var id = node.get("name");
  582. var icon = this.data[id];
  583. var iconNode = new Element("div", {"styles": this.process.css.processIconNode}).inject(node);
  584. if (icon) iconNode.setStyles({"background": "url("+icon+") center center no-repeat"});
  585. var selectNode = new Element("div", {"styles": this.process.css.processIconSelectNode, "text": this.process.designer.lp.selectIcon}).inject(node);
  586. selectNode.addEvent("click", function(){
  587. this.selectIcon(node);
  588. }.bind(this));
  589. }.bind(this));
  590. }
  591. },
  592. loadContextRoot: function(){
  593. var nodes = this.propertyContent.getElements(".MWFContextRoot");
  594. if (nodes){
  595. nodes.each(function(node){
  596. var name = node.get("name");
  597. var value = this.data[name];
  598. var select = new Element("select").inject(node);
  599. Object.each(layout.desktop.serviceAddressList, function(v, key){
  600. var option = new Element("option", {"value": key, "text": key, "selected": (value==key)}).inject(select);
  601. }.bind(this));
  602. select.addEvent("change", function(){
  603. var data = select.options[select.selectedIndex].value;
  604. // this.changeJsonDate(name, data);
  605. // this.changeData(name, node, value);
  606. this.setValue(name, data);
  607. }.bind(this));
  608. }.bind(this));
  609. }
  610. },
  611. selectIcon: function(node){
  612. if (!node.iconMenu){
  613. var iconSelectMenu = new MWF.widget.Menu(node, {"event": "click", "style": "processIcon"});
  614. iconSelectMenu.load();
  615. node.iconMenu = iconSelectMenu;
  616. var _self = this;
  617. for (var i=0; i<=48; i++){
  618. var icon = "/x_component_process_ProcessManager/$Explorer/default/processIcon/process_icon_"+i+".png";
  619. var item = iconSelectMenu.addMenuItem("", "click", function(){
  620. var id = node.get("name");
  621. var src = this.item.getElement("img").get("src");
  622. _self.data[id] = src;
  623. node.getFirst("div").setStyle("background-image", "url("+src+")");
  624. }, icon);
  625. item.iconName = icon;
  626. }
  627. }
  628. },
  629. deleteScriptItem: function(node, script){
  630. var jsondata = node.get("name");
  631. this.data[jsondata].erase(script.data.id);
  632. this.process.scripts[script.data.id] = null;
  633. delete this.process.scripts[script.data.id];
  634. this.process.process.scriptList.erase(script.data);
  635. },
  636. saveScriptItem: function(node, script){
  637. var jsondata = node.get("name");
  638. var scriptList = this.data[jsondata];
  639. var data = script.data;
  640. var scriptData = this.process.scripts[script.data.id];
  641. if (!scriptData){
  642. this.process.process.scriptList.push(data);
  643. this.process.scripts[script.data.id] = data;
  644. }
  645. if (scriptList.indexOf(data.id) == -1){
  646. this.data[jsondata].push(data.id);
  647. }
  648. },
  649. setScriptItems: function(script, node){
  650. var jsondata = node.get("name");
  651. var scriptList = this.data[jsondata];
  652. if (scriptList){
  653. scriptList.each(function(id){
  654. if (id){
  655. var data = this.process.scripts[id];
  656. if (data) script.setScriptItem(data);
  657. }
  658. }.bind(this));
  659. }
  660. },
  661. showMultiActivity: function(activitys){
  662. this.hide();
  663. var multiActivityTable = new HtmlTable({
  664. "properties": this.process.css.activityListTable
  665. }).inject(this.propertyContent);
  666. activitys.each(function(activity){
  667. this.row = multiActivityTable.push([
  668. {
  669. "content": " ",
  670. "properties": {
  671. "styles": activity.style.listIcon
  672. }
  673. },
  674. {
  675. "content": activity.data.name,
  676. "properties": {
  677. "width": "80px",
  678. "styles": this.process.css.list.listText
  679. }
  680. },
  681. {
  682. "content": " "+activity.data.description,
  683. "properties": {
  684. "styles": this.process.css.list.listTextDescription
  685. }
  686. }
  687. ]);
  688. }.bind(this));
  689. }
  690. });