Property.js 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782
  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 personDepartmentNodes = this.propertyContent.getElements(".MWFPersonDepartment");
  299. // var personCompanyNodes = this.propertyContent.getElements(".MWFPersonCompany");
  300. var dutyNodes = this.propertyContent.getElements(".MWFDutySelector");
  301. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function(){
  302. personIdentityNodes.each(function(node){
  303. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.process.designer, {
  304. "type": "identity",
  305. "names": this.data[node.get("name")],
  306. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  307. });
  308. }.bind(this));
  309. personNodes.each(function(node){
  310. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.process.designer, {
  311. "type": "person",
  312. "names": this.data[node.get("name")],
  313. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  314. });
  315. }.bind(this));
  316. personUnitNodes.each(function(node){
  317. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.process.designer, {
  318. "type": "unit",
  319. "names": this.data[node.get("name")],
  320. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  321. });
  322. }.bind(this));
  323. dutyNodes.each(function(node){
  324. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.process.designer, {
  325. "type": "duty",
  326. "names": this.data[node.get("name")],
  327. "onChange": function(ids){this.addDutyItem(node, ids);}.bind(this),
  328. "onRemoveDuty": function(item){this.removeDutyItem(node, item);}.bind(this)
  329. });
  330. }.bind(this));
  331. // personDepartmentNodes.each(function(node){
  332. // new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.process.designer, {
  333. // "type": "department",
  334. // "names": this.data[node.get("name")],
  335. // "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  336. // });
  337. // }.bind(this));
  338. // personCompanyNodes.each(function(node){
  339. // new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.process.designer, {
  340. // "type": "company",
  341. // "names": this.data[node.get("name")],
  342. // "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  343. // });
  344. // }.bind(this));
  345. // dutyNodes.each(function(node){
  346. // new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.process.designer, {
  347. // "type": "duty",
  348. // "names": this.data[node.get("name")],
  349. // "onChange": function(ids){this.addDutyItem(node, ids);}.bind(this),
  350. // "onRemoveDuty": function(item){this.removeDutyItem(node, item);}.bind(this)
  351. // });
  352. // }.bind(this));
  353. }.bind(this));
  354. },
  355. removeDutyItem: function(node, item){
  356. if (item.data.id){
  357. var values = JSON.decode(this.data[node.get("name")]) || [];
  358. var value = values.filter(function(v){
  359. return v.id == item.data.id;
  360. });
  361. value.each(function(v) {
  362. values = values.erase(v);
  363. });
  364. this.data[node.get("name")] = JSON.encode(values);
  365. }
  366. item.node.destroy();
  367. MWF.release(item);
  368. delete item;
  369. },
  370. addDutyItem: function(node, ids){
  371. var value = this.data[node.get("name")] || "";
  372. if (!value) value = "[]";
  373. var values = JSON.decode(value);
  374. ids.each(function(id){
  375. if (id.data.dutyId){
  376. for (var i=0; i<values.length; i++){
  377. if (values[i].dutyId===id.data.dutyId){
  378. values[i].name = id.data.name;
  379. values[i].code = id.data.code;
  380. break;
  381. }
  382. }
  383. }else{
  384. id.data.dutyId = new MWF.widget.UUID().toString();
  385. values.push({"name": id.data.name, "id": id.data.id, "dutyId": id.data.dutyId, "code": id.data.code});
  386. }
  387. }.bind(this));
  388. this.data[node.get("name")] = JSON.encode(values);
  389. },
  390. savePersonItem: function(node, ids){
  391. var values = [];
  392. ids.each(function(id){
  393. values.push(id.data.distinguishedName || id.data.id);
  394. }.bind(this));
  395. this.data[node.get("name")] = values;
  396. },
  397. loadConditionInput: function(){
  398. var conditionNodes = this.propertyContent.getElements(".MWFCondition");
  399. conditionNodes.each(function(node){
  400. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.ConditionEditor", function(){
  401. var script = new MWF.xApplication.process.ProcessDesigner.widget.ConditionEditor(node, {
  402. "onPostSave": function(script){
  403. this.saveScriptItem(node, script);
  404. }.bind(this),
  405. "onQueryDelete": function(script){
  406. this.deleteScriptItem(node, script);
  407. }.bind(this)
  408. });
  409. this.setScriptItems(script, node);
  410. }.bind(this));
  411. }.bind(this));
  412. },
  413. loadFormSelect: function(){
  414. var formNodes = this.propertyContent.getElements(".MWFFormSelect");
  415. if (formNodes.length){
  416. this.getFormList(function(){
  417. formNodes.each(function(node){
  418. var select = new Element("select").inject(node);
  419. var option = new Element("option", {"text": "none"}).inject(select);
  420. select.addEvent("change", function(e){
  421. this.setValue(e.target.getParent("div").get("name"), e.target.options[e.target.selectedIndex].value);
  422. }.bind(this));
  423. this.setFormSelectOptions(node, select);
  424. var refreshNode = new Element("div", {"styles": this.process.css.propertyRefreshFormNode}).inject(node);
  425. refreshNode.addEvent("click", function(e){
  426. this.getFormList(function(){
  427. this.setFormSelectOptions(node, select);
  428. }.bind(this), true);
  429. }.bind(this));
  430. }.bind(this));
  431. }.bind(this));
  432. }
  433. },
  434. setFormSelectOptions: function(node, select){
  435. var name = node.get("name");
  436. select.empty();
  437. var option = new Element("option", {"text": "none"}).inject(select);
  438. this.forms.each(function(form){
  439. var option = new Element("option", {
  440. "text": form.name,
  441. "value": form.id,
  442. "selected": (this.data[name]==form.id)
  443. }).inject(select);
  444. }.bind(this));
  445. },
  446. getFormList: function(callback, refresh){
  447. if (!this.forms || refresh){
  448. this.process.designer.actions.listForm(this.process.designer.application.id, function(json){
  449. this.forms = json.data;
  450. if (callback) callback();
  451. }.bind(this));
  452. }else{
  453. if (callback) callback();
  454. }
  455. },
  456. loadSerial: function(){
  457. var serialNodes = this.propertyContent.getElements(".MWFSerial");
  458. if (serialNodes.length){
  459. // this.getSerialRule(function(){
  460. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.SerialEditor", function(){
  461. serialNodes.each(function(node){
  462. var serialEditor = new MWF.xApplication.process.ProcessDesigner.widget.SerialEditor(node, this.data[node.get("name")]);
  463. serialEditor.addEvent("change", function(e){
  464. this.setValue(node.get("name"), JSON.encode(serialEditor.getData()));
  465. }.bind(this));
  466. serialEditor.process = this.process;
  467. serialEditor.load();
  468. }.bind(this));
  469. }.bind(this));
  470. // }.bind(this));
  471. }
  472. },
  473. loadSericalActivitySelect: function(){
  474. var serialNodes = this.propertyContent.getElements(".MWFSericalActivitySelect");
  475. if (serialNodes.length){
  476. serialNodes.each(function(node){
  477. var select = new Element("select").inject(node);
  478. select.addEvent("change", function(e){
  479. this.setValue(e.target.getParent("div").get("name"), e.target.options[e.target.selectedIndex].value);
  480. }.bind(this));
  481. this.listSericalActivityOptions(node, select);
  482. var refreshNode = new Element("div", {"styles": this.process.css.propertyRefreshFormNode}).inject(node);
  483. refreshNode.addEvent("click", function(e){
  484. this.listSericalActivityOptions(node, select);
  485. }.bind(this));
  486. }.bind(this));
  487. }
  488. },
  489. listSericalActivityOptions: function(node, select){
  490. var name = node.get("name");
  491. select.empty();
  492. var option = new Element("option", {"text": "none"}).inject(select);
  493. var option = new Element("option", {
  494. "text": this.process.process.begin.name,
  495. "value": this.process.process.begin.id,
  496. "selected": (this.data[name]===this.process.process.begin.id)
  497. }).inject(select);
  498. this.listSericalActivitys("endList", name, select);
  499. this.listSericalActivitys("cancelList", name, select);
  500. this.listSericalActivitys("manualList", name, select);
  501. this.listSericalActivitys("conditionList", name, select);
  502. this.listSericalActivitys("choiceList", name, select);
  503. this.listSericalActivitys("splitList", name, select);
  504. this.listSericalActivitys("parallelList", name, select);
  505. this.listSericalActivitys("mergeList", name, select);
  506. this.listSericalActivitys("embedList", name, select);
  507. this.listSericalActivitys("delayList", name, select);
  508. this.listSericalActivitys("invokeList", name, select);
  509. this.listSericalActivitys("serviceList", name, select);
  510. this.listSericalActivitys("agentList", name, select);
  511. this.listSericalActivitys("messageList", name, select);
  512. },
  513. listSericalActivitys: function(p, name, select){
  514. var datas = this.process.process[p];
  515. if (datas){
  516. var count = datas.length;
  517. if (count){
  518. datas.each(function(data){
  519. var option = new Element("option", {
  520. "text": data.name,
  521. "value": data.id,
  522. "selected": (this.data[name]===data.id)
  523. }).inject(select);
  524. }.bind(this));
  525. }
  526. }
  527. },
  528. loadApplicationSelector: function(){
  529. var nodes = this.propertyContent.getElements(".MWFApplicationSelect");
  530. if (nodes.length){
  531. this._getAppSelector(function(){
  532. nodes.each(function(node){
  533. var title = new Element("div", {"styles": this.process.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  534. var action = new Element("div", {"styles": this.process.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  535. var content = new Element("div", {"styles": this.process.css.applicationSelectContent}).inject(node);
  536. action.addEvent("click", function(e){
  537. this.appSelector.load(function(apps){
  538. content.empty();
  539. if (apps.length){
  540. this.data.targetApplication = apps[0].id;
  541. this.data.targetApplicationName = apps[0].name;
  542. this.data.targetApplicationAlias = apps[0].alias;
  543. new Element("div", {
  544. "styles": this.process.css.applicationSelectItem,
  545. "text": apps[0].name
  546. }).inject(content);
  547. }else{
  548. this.data.targetApplication = "";
  549. this.data.targetApplicationName = "";
  550. this.data.targetApplicationAlias = "";
  551. }
  552. var processNodes = this.propertyContent.getElements(".MWFProcessSelect");
  553. processNodes.each(function(n){
  554. this.data.targetProcess = "";
  555. this.data.targetProcessName = "";
  556. this.data.targetProcessAlias = "";
  557. var processContent = n.getLast();
  558. processContent.empty();
  559. }.bind(this));
  560. }.bind(this));
  561. }.bind(this));
  562. if (this.data.targetApplication){
  563. new Element("div", {
  564. "styles": this.process.css.applicationSelectItem,
  565. "text": this.data.targetApplicationName
  566. }).inject(content);
  567. }
  568. }.bind(this));
  569. }.bind(this));
  570. }
  571. },
  572. _getAppSelector: function(callback){
  573. if (!this.appSelector){
  574. MWF.xDesktop.requireApp("process.ProcessManager", "widget.ApplicationSelector", function(){
  575. this.appSelector = new MWF.xApplication.process.ProcessManager.widget.ApplicationSelector(this.process.designer, {"maskNode": this.process.designer.content, "multi": false});
  576. if (callback) callback();
  577. }.bind(this));
  578. }else{
  579. if (callback) callback();
  580. }
  581. },
  582. loadProcessSelector: function(){
  583. var nodes = this.propertyContent.getElements(".MWFProcessSelect");
  584. if (nodes.length){
  585. this._getProcessSelector(function(){
  586. nodes.each(function(node){
  587. var title = new Element("div", {"styles": this.process.css.applicationSelectTitle, "text": node.get("title")}).inject(node);
  588. var action = new Element("div", {"styles": this.process.css.applicationSelectAction, "text": node.get("title")}).inject(node);
  589. var content = new Element("div", {"styles": this.process.css.applicationSelectContent}).inject(node);
  590. action.addEvent("click", function(e){
  591. var id = this.data.targetApplication;
  592. this.processSelector.load([id], function(pros){
  593. content.empty();
  594. if (pros.length){
  595. this.data.targetProcess = pros[0].id;
  596. this.data.targetProcessName = pros[0].name;
  597. this.data.targetProcessAlias = pros[0].alias;
  598. new Element("div", {
  599. "styles": this.process.css.applicationSelectItem,
  600. "text": pros[0].name
  601. }).inject(content);
  602. }else{
  603. this.data.targetProcess = "";
  604. this.data.targetProcessName = "";
  605. this.data.targetProcessAlias = "";
  606. }
  607. }.bind(this));
  608. }.bind(this));
  609. if (this.data.targetProcess){
  610. new Element("div", {
  611. "styles": this.process.css.applicationSelectItem,
  612. "text": this.data.targetProcessName
  613. }).inject(content);
  614. }
  615. }.bind(this));
  616. }.bind(this));
  617. }
  618. },
  619. _getProcessSelector: function(callback){
  620. if (!this.processSelector){
  621. MWF.xDesktop.requireApp("process.ProcessManager", "widget.ProcessSelector", function(){
  622. this.processSelector = new MWF.xApplication.process.ProcessManager.widget.ProcessSelector(this.process.designer, {"maskNode": this.process.designer.content, "multi": false});
  623. if (callback) callback();
  624. }.bind(this));
  625. }else{
  626. if (callback) callback();
  627. }
  628. },
  629. loadIconSelect: function(){
  630. var nodes = this.propertyContent.getElements(".MWFIcon");
  631. if (nodes.length){
  632. nodes.each(function(node){
  633. var id = node.get("name");
  634. var icon = this.data[id];
  635. var iconNode = new Element("div", {"styles": this.process.css.processIconNode}).inject(node);
  636. if (icon) iconNode.setStyles({"background": "url("+icon+") center center no-repeat"});
  637. var selectNode = new Element("div", {"styles": this.process.css.processIconSelectNode, "text": this.process.designer.lp.selectIcon}).inject(node);
  638. selectNode.addEvent("click", function(){
  639. this.selectIcon(node);
  640. }.bind(this));
  641. }.bind(this));
  642. }
  643. },
  644. loadContextRoot: function(){
  645. var nodes = this.propertyContent.getElements(".MWFContextRoot");
  646. if (nodes){
  647. nodes.each(function(node){
  648. var name = node.get("name");
  649. var value = this.data[name];
  650. var select = new Element("select").inject(node);
  651. Object.each(layout.desktop.serviceAddressList, function(v, key){
  652. var option = new Element("option", {"value": key, "text": v.name, "selected": (value==key)}).inject(select);
  653. }.bind(this));
  654. select.addEvent("change", function(){
  655. var data = select.options[select.selectedIndex].value;
  656. // this.changeJsonDate(name, data);
  657. // this.changeData(name, node, value);
  658. this.setValue(name, data);
  659. }.bind(this));
  660. }.bind(this));
  661. }
  662. },
  663. selectIcon: function(node){
  664. if (!node.iconMenu){
  665. var iconSelectMenu = new MWF.widget.Menu(node, {"event": "click", "style": "processIcon"});
  666. iconSelectMenu.load();
  667. node.iconMenu = iconSelectMenu;
  668. var _self = this;
  669. for (var i=0; i<=48; i++){
  670. var icon = "/x_component_process_ProcessManager/$Explorer/default/processIcon/process_icon_"+i+".png";
  671. var item = iconSelectMenu.addMenuItem("", "click", function(){
  672. var id = node.get("name");
  673. var src = this.item.getElement("img").get("src");
  674. _self.data[id] = src;
  675. node.getFirst("div").setStyle("background-image", "url("+src+")");
  676. }, icon);
  677. item.iconName = icon;
  678. }
  679. }
  680. },
  681. deleteScriptItem: function(node, script){
  682. var jsondata = node.get("name");
  683. this.data[jsondata].erase(script.data.id);
  684. this.process.scripts[script.data.id] = null;
  685. delete this.process.scripts[script.data.id];
  686. this.process.process.scriptList.erase(script.data);
  687. },
  688. saveScriptItem: function(node, script){
  689. var jsondata = node.get("name");
  690. var scriptList = this.data[jsondata];
  691. var data = script.data;
  692. var scriptData = this.process.scripts[script.data.id];
  693. if (!scriptData){
  694. this.process.process.scriptList.push(data);
  695. this.process.scripts[script.data.id] = data;
  696. }
  697. if (scriptList.indexOf(data.id) == -1){
  698. this.data[jsondata].push(data.id);
  699. }
  700. },
  701. setScriptItems: function(script, node){
  702. var jsondata = node.get("name");
  703. var scriptList = this.data[jsondata];
  704. if (scriptList){
  705. scriptList.each(function(id){
  706. if (id){
  707. var data = this.process.scripts[id];
  708. if (data) script.setScriptItem(data);
  709. }
  710. }.bind(this));
  711. }
  712. },
  713. showMultiActivity: function(activitys){
  714. this.hide();
  715. var multiActivityTable = new HtmlTable({
  716. "properties": this.process.css.activityListTable
  717. }).inject(this.propertyContent);
  718. activitys.each(function(activity){
  719. this.row = multiActivityTable.push([
  720. {
  721. "content": " ",
  722. "properties": {
  723. "styles": activity.style.listIcon
  724. }
  725. },
  726. {
  727. "content": activity.data.name,
  728. "properties": {
  729. "width": "80px",
  730. "styles": this.process.css.list.listText
  731. }
  732. },
  733. {
  734. "content": " "+activity.data.description,
  735. "properties": {
  736. "styles": this.process.css.list.listTextDescription
  737. }
  738. }
  739. ]);
  740. }.bind(this));
  741. }
  742. });