Property.js 31 KB

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