Property.js 33 KB

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