Property.js 29 KB

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