Route.js 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265
  1. MWF.xDesktop.requireApp("process.ProcessDesigner", "Property", null, false);
  2. MWF.xApplication.process.ProcessDesigner.Route = new Class({
  3. initialize: function (data, process) {
  4. this.data = data;
  5. this.process = process;
  6. this.paper = this.process.paper;
  7. if (!this.data.edition) this.data.edition = (new o2.widget.UUID()).toString();
  8. this.loaded = false;
  9. this.l1 = 8;
  10. this.l2 = 12;
  11. this.aj = 25;
  12. this.corners = [];
  13. this.toSelf = false;
  14. this.isLineEvent = false;
  15. this.isTextEvent = false;
  16. this.isSetEvent = false;
  17. this.isArrowEvent = false;
  18. this.isPointEvent = false;
  19. this.checked = false;
  20. this.isBack = false;
  21. this.isBrokenLine = false;
  22. this.tmpbeginPoint = null;
  23. this.tmpEndPoint = null;
  24. this.toActivity = this.getNextActivity();
  25. this.positionPoints = this.getRoutePoint();
  26. if (!this.process.options.isView) {
  27. this.listItem = new MWF.APPPD.Route.List(this);
  28. this.listItem.load();
  29. }
  30. },
  31. getRoutePoint: function () {
  32. var points = [];
  33. if (this.data.track) {
  34. var pointArr = this.data.track.split(/\s+/g);
  35. pointArr.each(function (p) {
  36. var pArr = p.split(/(?:,\s*){1}|(?:;\s*){1}/g);
  37. points.push({"x": pArr[0], "y": pArr[1]});
  38. }.bind(this));
  39. }
  40. return points;
  41. },
  42. reload: function (fromPath, toPath) {
  43. if (this.toActivity && this.fromActivity) {
  44. if (this.toActivity.data.id == this.fromActivity.data.id) {
  45. this.toSelf = true;
  46. } else {
  47. this.toSelf = false;
  48. }
  49. }
  50. // this.positionPoints = this.getRoutePoint();
  51. this.getPoint(fromPath, toPath);
  52. this.redraw();
  53. },
  54. load: function (fromActivity) {
  55. if (this.process.isNewProcess) {
  56. this.data.createTime = new Date().format('db');
  57. this.data.updateTime = new Date().format('db');
  58. }
  59. if (fromActivity) this.fromActivity = fromActivity;
  60. if (this.toActivity && this.fromActivity) {
  61. if (this.toActivity.data.id == this.fromActivity.data.id) {
  62. this.toSelf = true;
  63. } else {
  64. this.toSelf = false;
  65. }
  66. }
  67. this.getPoint();
  68. this.draw();
  69. this.loaded = true;
  70. },
  71. setActivity: function (toActivity, fromActivity) {
  72. if (toActivity) {
  73. if (this.toActivity) {
  74. this.toActivity.fromRoutes.erase(this);
  75. }
  76. this.toActivity = toActivity;
  77. this.data.activity = this.toActivity.data.id;
  78. this.data.activityType = this.toActivity.data.type;
  79. if (this.toActivity.fromRoutes.indexOf(this) == -1) this.toActivity.fromRoutes.push(this);
  80. }
  81. if (fromActivity) {
  82. if (this.fromActivity) {
  83. this.fromActivity.routes.erase(this);
  84. this.fromActivity.removeRouteData(this.data.id);
  85. // this.fromActivity.data.routeList.erase(this.data.id);
  86. }
  87. this.fromActivity = fromActivity;
  88. if (this.data.id) this.fromActivity.addRouteData(this.data.id);
  89. if (this.fromActivity.routes.indexOf(this) == -1) this.fromActivity.routes.push(this);
  90. }
  91. },
  92. getNextActivity: function () {
  93. var id = this.data.activity;
  94. var type = this.data.activityType;
  95. if (type) {
  96. if (type.toLowerCase() == "begin") {
  97. if (this.process.begin.data.id == id) {
  98. this.process.begin.fromRoutes.push(this);
  99. return this.process.begin;
  100. }
  101. } else {
  102. var activity = this.process[type + "s"][id];
  103. if (activity) {
  104. if (activity.fromRoutes.indexOf(this) == -1) activity.fromRoutes.push(this);
  105. return activity;
  106. }
  107. }
  108. }
  109. return null;
  110. },
  111. redraw: function () {
  112. if (this.beginPoint && this.endPoint) {
  113. if (this.set) {
  114. //this.set.show();
  115. //this.set.clear();
  116. } else {
  117. this.set = this.paper.set();
  118. }
  119. if (this.point) {
  120. this.point.show();
  121. this.point.attr("path", MWFRaphael.getCirclePath(this.beginPoint.x, this.beginPoint.y, 3));
  122. } else {
  123. this.point = this.paper.circlePath(this.beginPoint.x, this.beginPoint.y, 3);
  124. this.point.attr(this.process.css.route.decision.normal);
  125. this.set.push(this.point);
  126. }
  127. if (this.line) {
  128. this.line.show();
  129. this.line.attr("path", this.getLinePath());
  130. } else {
  131. this.line = this.paper.path(this.getLinePath());
  132. this.line.toBack();
  133. this.line.attr(this.process.css.route.line.normal);
  134. this.set.push(this.line);
  135. }
  136. this.line.toBack();
  137. if (this.text) {
  138. this.text.show();
  139. var p = this.getTextPoint();
  140. this.text.attr({
  141. "text": this.data.name || MWF.APPPD.LP.unnamed,
  142. "x": p.x,
  143. "y": p.y
  144. });
  145. } else {
  146. this.text = this.createText();
  147. this.set.push(this.text);
  148. }
  149. if (this.arrow) {
  150. this.arrow.show();
  151. var beginPoint = (this.positionPoints.length) ? this.positionPoints[this.positionPoints.length - 1] : this.beginPoint;
  152. this.arrow.attr("path", MWFRaphael.getArrowPath(beginPoint, this.endPoint, this.l1, this.l2, this.aj));
  153. } else {
  154. this.arrow = this.createArrow();
  155. this.arrow.attr(this.process.css.route.arrow.normal);
  156. this.set.push(this.arrow);
  157. }
  158. if (this.set) {
  159. this.set.attr({"transform": ""});
  160. if (this.checked) {
  161. if (this.process.currentSelected == this) {
  162. this.point.attr(this.process.css.route.decision.selected);
  163. this.line.attr(this.process.css.route.line.selected);
  164. this.arrow.attr(this.process.css.route.arrow.selected);
  165. this.text.attr(this.process.css.route.linetext.selected);
  166. } else {
  167. this.point.attr(this.process.css.route.decision.normal);
  168. this.line.attr(this.process.css.route.line.normal);
  169. this.arrow.attr(this.process.css.route.arrow.normal);
  170. this.text.attr(this.process.css.route.linetext.normal);
  171. }
  172. } else {
  173. this.point.attr(this.process.css.route.decision["no-checked"]);
  174. this.line.attr(this.process.css.route.line["no-checked"]);
  175. this.arrow.attr(this.process.css.route.arrow["no-checked"]);
  176. this.text.attr(this.process.css.route.linetext["no-checked"]);
  177. }
  178. if (this.isBack) {
  179. this.set.toBack();
  180. } else {
  181. this.set.toFront();
  182. }
  183. }
  184. } else {
  185. if (this.point) this.point.hide();
  186. if (this.line) this.line.hide();
  187. if (this.arrow) this.arrow.hide();
  188. if (this.set) this.set.hide();
  189. }
  190. this.setListItemData();
  191. this.setEvent();
  192. },
  193. draw: function () {
  194. if (this.beginPoint && this.endPoint) {
  195. this.point = this.paper.circlePath(this.beginPoint.x, this.beginPoint.y, 3);
  196. this.point.attr(this.process.css.route.decision.normal);
  197. this.line = this.paper.path(this.getLinePath());
  198. this.line.toBack();
  199. this.line.attr(this.process.css.route.line.normal);
  200. this.text = this.createText();
  201. this.arrow = this.createArrow();
  202. this.arrow.attr(this.process.css.route.arrow.normal);
  203. this.set = this.paper.set();
  204. this.set.push(this.point, this.line, this.arrow, this.text);
  205. this.point.data("bind", this);
  206. this.line.data("bind", this);
  207. this.arrow.data("bind", this);
  208. this.text.data("bind", this);
  209. if (!this.toSelf) {
  210. this.positionPoints.each(function (p, idx) {
  211. this.createCorner(p, idx);
  212. }.bind(this));
  213. }
  214. if (this.checked) {
  215. if (this.process.currentSelected == this) {
  216. this.point.attr(this.process.css.route.decision.selected);
  217. this.line.attr(this.process.css.route.line.selected);
  218. this.arrow.attr(this.process.css.route.arrow.selected);
  219. this.text.attr(this.process.css.route.linetext.selected);
  220. } else {
  221. this.point.attr(this.process.css.route.decision.normal);
  222. this.line.attr(this.process.css.route.line.normal);
  223. this.arrow.attr(this.process.css.route.arrow.normal);
  224. this.text.attr(this.process.css.route.linetext.normal);
  225. }
  226. } else {
  227. this.point.attr(this.process.css.route.decision["no-checked"]);
  228. this.line.attr(this.process.css.route.line["no-checked"]);
  229. this.arrow.attr(this.process.css.route.arrow["no-checked"]);
  230. this.text.attr(this.process.css.route.linetext["no-checked"]);
  231. }
  232. if (this.isBack) {
  233. this.set.toBack();
  234. } else {
  235. this.set.toFront();
  236. }
  237. } else {
  238. if (this.point) this.point.hide();
  239. if (this.line) this.line.hide();
  240. if (this.arrow) this.arrow.hide();
  241. if (this.text) this.text.hide();
  242. if (this.set) this.set.hide();
  243. }
  244. this.setEvent();
  245. },
  246. setEvent: function () {
  247. if (this.set) {
  248. if (!this.isSetEvent) {
  249. this.set.mousedown(function (e) {
  250. this.selected();
  251. //this.process.unSelectedEvent = false;
  252. e.stopPropagation();
  253. }.bind(this));
  254. this.set.click(function (e) {
  255. e.stopPropagation();
  256. }.bind(this));
  257. this.isSetEvent = true;
  258. }
  259. ;
  260. }
  261. if (this.line) {
  262. if (!this.isLineEvent) {
  263. this.line.mousedown(function (e) {
  264. if (!this.toSelf) {
  265. var offsetP = MWF.getOffset(e);
  266. this.checkBrokenLineBegin(offsetP.offsetX, offsetP.offsetY);
  267. //this.checkBrokenLineBegin(e.clientX, e.clientY);
  268. }
  269. }.bind(this));
  270. this.isLineEvent = true;
  271. }
  272. ;
  273. }
  274. ;
  275. if (this.arrow) {
  276. if (!this.isArrowEvent) {
  277. this.arrow.drag(
  278. function (dx, dy, x, y, e) {
  279. this.arrowMove(dx, dy, x, y.e);
  280. }.bind(this),
  281. function () {
  282. this.arrowMoveStart();
  283. }.bind(this),
  284. function () {
  285. this.arrowMoveEnd();
  286. }.bind(this)
  287. );
  288. this.arrow.hover(function () {
  289. var beginPoint = this.beginPoint;
  290. if (this.positionPoints.length) {
  291. beginPoint = this.positionPoints[this.positionPoints.length - 1];
  292. }
  293. beginPoint.x = beginPoint.x.toFloat();
  294. beginPoint.y = beginPoint.y.toFloat();
  295. var path = MWFRaphael.getArrowPath(beginPoint, this.endPoint, 20, 30, this.aj);
  296. this.arrow.attr("path", path);
  297. }.bind(this), function () {
  298. var beginPoint = this.beginPoint;
  299. if (this.positionPoints.length) {
  300. beginPoint = this.positionPoints[this.positionPoints.length - 1];
  301. }
  302. beginPoint.x = beginPoint.x.toFloat();
  303. beginPoint.y = beginPoint.y.toFloat();
  304. var path = MWFRaphael.getArrowPath(beginPoint, this.endPoint, this.l1, this.l2, this.aj);
  305. this.arrow.attr("path", path);
  306. }.bind(this));
  307. }
  308. this.isArrowEvent = true;
  309. }
  310. ;
  311. if (this.point) {
  312. if (!this.isPointEvent) {
  313. this.point.drag(
  314. function (dx, dy, x, y, e) {
  315. this.pointMove(dx, dy, x, y.e);
  316. }.bind(this),
  317. function () {
  318. this.pointMoveStart();
  319. }.bind(this),
  320. function () {
  321. this.pointMoveEnd();
  322. }.bind(this)
  323. );
  324. this.point.hover(function () {
  325. var path = MWFRaphael.getCirclePath(this.beginPoint.x, this.beginPoint.y, 8);
  326. this.point.attr("path", path);
  327. }.bind(this), function () {
  328. var path = MWFRaphael.getCirclePath(this.beginPoint.x, this.beginPoint.y, 3);
  329. this.point.attr("path", path);
  330. }.bind(this));
  331. }
  332. this.isPointEvent = true;
  333. }
  334. ;
  335. if (this.text) {
  336. if (!this.isTextEvent) {
  337. this.text.drag(
  338. function (dx, dy, x, y) {
  339. this.textMove(dx, dy, x, y);
  340. }.bind(this),
  341. function () {
  342. this.textMoveStart();
  343. }.bind(this),
  344. function () {
  345. this.textMoveEnd();
  346. }.bind(this)
  347. );
  348. this.isTextEvent = true;
  349. }
  350. }
  351. ;
  352. },
  353. arrowMoveStart: function () {
  354. this.arrow.data("originalPoint", {
  355. "x": this.endPoint.x,
  356. "y": this.endPoint.y
  357. });
  358. // this.arrow.toBack();
  359. // if (this.line) this.line.toBack();
  360. this.process.isChangeRouteTo = true;
  361. this.process.currentChangeRoute = this;
  362. },
  363. arrowMove: function (dx, dy, x, y) {
  364. this.isBack = true;
  365. var p = this.arrow.data("originalPoint");
  366. this.endPoint = {
  367. "x": p.x + dx - 6,
  368. "y": p.y + dy - 6
  369. };
  370. this.redraw();
  371. },
  372. arrowMoveEnd: function () {
  373. this.isBack = false;
  374. if (this.process.isChangeRouteTo) {
  375. this.endPoint = this.arrow.data("originalPoint");
  376. this.redraw();
  377. this.process.isChangeRouteTo = false;
  378. this.process.currentChangeRoute = null;
  379. }
  380. //this.arrow.toFront();
  381. if (this.line) this.line.toFront();
  382. },
  383. pointMoveStart: function () {
  384. this.point.data("originalPoint", {
  385. "x": this.beginPoint.x,
  386. "y": this.beginPoint.y
  387. });
  388. //this.point.toBack();
  389. //if (this.line) this.line.toBack();
  390. this.process.isChangeRouteFrom = true;
  391. this.process.currentChangeRoute = this;
  392. },
  393. pointMove: function (dx, dy, x, y) {
  394. if (dx > 10 || dy > 10) this.isBack = true;
  395. var p = this.point.data("originalPoint");
  396. this.beginPoint = {
  397. "x": p.x + dx - 4,
  398. "y": p.y + dy - 4
  399. };
  400. this.redraw();
  401. },
  402. pointMoveEnd: function () {
  403. this.isBack = false;
  404. if (this.process.isChangeRouteFrom) {
  405. this.beginPoint = this.point.data("originalPoint");
  406. this.redraw();
  407. this.process.isChangeRouteFrom = false;
  408. this.process.currentChangeRoute = null;
  409. }
  410. //this.point.toFront();
  411. if (this.line) this.line.toFront();
  412. if( this.property )this.property.checkTabShow();
  413. },
  414. cornerBrokenLineBegin: function (e, corner) {
  415. if (!this.process.isCreateRoute) {
  416. // var x = e.layerX;
  417. // var y = e.layerY;
  418. var offsetP = MWF.getOffset(e);
  419. var x = offsetP.offsetX;
  420. var y = offsetP.offsetY;
  421. var idx = this.corners.indexOf(corner);
  422. if (idx != -1) {
  423. this.process.brokenLineBeginMousemoveBind = function (e) {
  424. this.doBeginBrokenLine(e, x, y, idx - 1, corner, true);
  425. }.bind(this);
  426. this.process.brokenLineMouseupBind = function () {
  427. this.endBrokenLine();
  428. }.bind(this);
  429. this.paper.canvas.addEvent("mousemove", this.process.brokenLineBeginMousemoveBind);
  430. this.paper.canvas.addEvent("mouseup", this.process.brokenLineMouseupBind);
  431. }
  432. }
  433. },
  434. checkBrokenLineBegin: function (x, y) {
  435. if (!this.process.isCreateRoute) {
  436. var movePointIndex = this.getNearIndex(this.positionPoints, {"x": x, "y": y});
  437. if (movePointIndex === null) {
  438. var idx = this.getCornerPointIndex(x, y);
  439. this.process.brokenLineBeginMousemoveBind = function (e) {
  440. this.doBeginBrokenLine(e, x, y, idx);
  441. }.bind(this);
  442. this.process.brokenLineMouseupBind = function () {
  443. this.endBrokenLine();
  444. }.bind(this);
  445. this.paper.canvas.addEvent("mousemove", this.process.brokenLineBeginMousemoveBind);
  446. this.paper.canvas.addEvent("mouseup", this.process.brokenLineMouseupBind);
  447. } else {
  448. }
  449. }
  450. ;
  451. },
  452. getCornerPointIndex: function (x, y) {
  453. cornerPointIndex = -1;
  454. var tmpLong = 500000;
  455. if (this.positionPoints.length) {
  456. var tmpArr = this.positionPoints.concat(this.endPoint);
  457. tmpArr.unshift(this.beginPoint);
  458. for (var i = 0; i < tmpArr.length - 1; i++) {
  459. var p1 = tmpArr[i];
  460. var p2 = tmpArr[i + 1];
  461. var n = MWFRaphael.getMinDistance({"x": x, "y": y}, p1, p2).h;
  462. if (n < tmpLong) {
  463. tmpLong = n;
  464. cornerPointIndex = i - 1;
  465. }
  466. }
  467. }
  468. return cornerPointIndex;
  469. },
  470. getNearIndex: function (pList, p) {
  471. for (var i = 0; i < pList.length; i++) {
  472. var tmpp = pList[i];
  473. var lineP = {"x": tmpp.x.toFloat(), "y": tmpp.y.toFloat()};
  474. var tmp = MWFRaphael.getPointDistance(p, lineP);
  475. if (tmp <= 8) {
  476. return i;
  477. }
  478. }
  479. return null;
  480. },
  481. endBrokenLine: function () {
  482. this.process.isBrokenLine = false;
  483. if (this.removeCorner) {
  484. this.corners.splice(this.removeCorner.idx + 1, 1);
  485. this.removeCorner.corner.remove();
  486. this.positionPoints.splice(this.removeCorner.idx + 1, 1);
  487. this.removeCorner = null;
  488. }
  489. this.isBrokenLine = false;
  490. this.data.track = this.positionPointsToString();
  491. this.paper.canvas.removeEvent("mouseup", this.process.brokenLineMouseupBind);
  492. this.paper.canvas.removeEvent("mousemove", this.process.brokenLineBeginMousemoveBind);
  493. this.paper.canvas.removeEvent("mousemove", this.process.brokenLineMousemoveBind);
  494. },
  495. positionPointsToString: function () {
  496. var arr = [];
  497. this.positionPoints.each(function (p) {
  498. arr.push(p.x + "," + p.y);
  499. });
  500. return arr.join(" ");
  501. },
  502. doBeginBrokenLine: function (e, x, y, idx, corner, noCreateP) {
  503. var p1 = this.positionPoints[idx] || this.beginPoint;
  504. var p2 = this.positionPoints[idx + 2] || this.endPoint;
  505. var offsetP = MWF.getOffset(e.event);
  506. var n = MWFRaphael.getMinDistance({
  507. "x": offsetP.offsetX,
  508. "y": offsetP.offsetY
  509. }, p1, p2).h;
  510. if (n > 6) {
  511. this.process.isBrokenLine = true;
  512. this.isBrokenLine = true;
  513. if (!corner || this.removeCorner) {
  514. if (!noCreateP) this.positionPoints.splice(idx + 1, 0, {
  515. "x": offsetP.offsetX,
  516. "y": offsetP.offsetY
  517. });
  518. if (this.removeCorner) {
  519. corner = this.removeCorner.corner;
  520. this.removeCorner = null;
  521. } else {
  522. corner = this.createCorner(this.positionPoints[idx + 1], idx + 1);
  523. }
  524. }
  525. corner.attr(this.process.css.route.corner["default"]);
  526. this.paper.canvas.removeEvent("mousemove", this.process.brokenLineBeginMousemoveBind);
  527. this.reload();
  528. this.process.brokenLineMousemoveBind = function (e) {
  529. this.doBrokenLine(e, idx, corner);
  530. }.bind(this);
  531. this.paper.canvas.addEvent("mousemove", this.process.brokenLineMousemoveBind);
  532. }
  533. ;
  534. },
  535. doBrokenLine: function (e, idx, corner) {
  536. var offsetP = MWF.getOffset(e.event);
  537. var toX = offsetP.offsetX;
  538. var toY = offsetP.offsetY;
  539. // if (this.process.isGrid){
  540. toX = Raphael.snapTo(10, toX, 10);
  541. toY = Raphael.snapTo(10, toY, 10);
  542. // }
  543. var p1 = this.positionPoints[idx] || this.beginPoint;
  544. var p2 = this.positionPoints[idx + 2] || this.endPoint;
  545. var offset = MWFRaphael.getMinDistance({"x": toX, "y": toY}, p1, p2);
  546. var off = offset.h;
  547. if (off < 6) {
  548. this.removeCorner = {"corner": corner, "idx": idx};
  549. corner.attr("path", MWFRaphael.getRectPath((offset.p.x.toFloat()) - 2.5, (offset.p.y.toFloat()) - 2.5, 5, 5, 0));
  550. if (this.positionPoints[idx + 1]) this.positionPoints[idx + 1].x = offset.p.x;
  551. if (this.positionPoints[idx + 1]) this.positionPoints[idx + 1].y = offset.p.y;
  552. this.reload();
  553. this.process.brokenLineBeginMousemoveBind = function (e) {
  554. this.doBeginBrokenLine(e, toX, toY, idx, null, true);
  555. }.bind(this);
  556. this.paper.canvas.removeEvent("mousemove", this.process.brokenLineMousemoveBind);
  557. this.paper.canvas.addEvent("mousemove", this.process.brokenLineBeginMousemoveBind);
  558. } else {
  559. if (Math.abs(p1.x - toX) < 5) toX = p1.x;
  560. if (Math.abs(p1.y - toY) < 5) toY = p1.y;
  561. if (Math.abs(p2.x - toX) < 5) toX = p2.x;
  562. if (Math.abs(p2.y - toY) < 5) toY = p2.y;
  563. var path = MWFRaphael.getRectPath(toX - 2.5, toY - 2.5, 5, 5, 0);
  564. corner.attr("path", path);
  565. if (this.positionPoints[idx + 1]) this.positionPoints[idx + 1].x = toX;
  566. if (this.positionPoints[idx + 1]) this.positionPoints[idx + 1].y = toY;
  567. this.reload();
  568. }
  569. },
  570. selected: function () {
  571. this.process.unSelectedAll();
  572. if (this.line) this.line.attr(this.process.css.route.line.selected);
  573. if (this.point) this.point.attr(this.process.css.route.decision.selected);
  574. if (this.arrow) this.arrow.attr(this.process.css.route.arrow.selected);
  575. if (this.text) this.text.attr(this.process.css.route.linetext.selected);
  576. this.corners.each(function (corner) {
  577. corner.show();
  578. });
  579. this.process.currentSelected = this;
  580. if (this.listItem) this.listItem.selected();
  581. this.set.toFront();
  582. this.showProperty();
  583. },
  584. unSelected: function () {
  585. if (this.checked) {
  586. this.point.attr(this.process.css.route.decision.normal);
  587. this.line.attr(this.process.css.route.line.normal);
  588. this.arrow.attr(this.process.css.route.arrow.normal);
  589. this.text.attr(this.process.css.route.linetext.normal);
  590. } else {
  591. this.point.attr(this.process.css.route.decision["no-checked"]);
  592. this.line.attr(this.process.css.route.line["no-checked"]);
  593. this.arrow.attr(this.process.css.route.arrow["no-checked"]);
  594. this.text.attr(this.process.css.route.linetext["no-checked"]);
  595. }
  596. this.corners.each(function (corner) {
  597. corner.hide();
  598. });
  599. this.process.currentSelected = null;
  600. if (this.listItem) this.listItem.unSelected();
  601. if (this.property) this.property.hide();
  602. },
  603. textMove: function (dx, dy, x, y) {
  604. var x = (this.text.moveX.toFloat()) + parseFloat(dx);
  605. var y = (this.text.moveY.toFloat()) + parseFloat(dy);
  606. var dp = this.getDefaultTextPoint();
  607. var d = MWFRaphael.getPointDistance(dp, {"x": x, "y": y});
  608. if (d < 5) {
  609. this.text.attr({
  610. "x": dp.x,
  611. "y": dp.y
  612. });
  613. } else {
  614. this.text.attr({
  615. "x": x,
  616. "y": y
  617. });
  618. }
  619. },
  620. textMoveStart: function () {
  621. this.text.moveX = this.text.attr("x");
  622. this.text.moveY = this.text.attr("y");
  623. },
  624. textMoveEnd: function () {
  625. var x = this.text.attr("x");
  626. var y = this.text.attr("y");
  627. var dp = this.getDefaultTextPoint();
  628. var d = MWFRaphael.getPointDistance(dp, {"x": x, "y": y});
  629. if (d < 5) {
  630. this.data.position = "";
  631. } else {
  632. x = x.toInt();
  633. y = y.toInt();
  634. this.data.position = x + "," + y;
  635. }
  636. },
  637. getLinePath: function () {
  638. var path = "";
  639. if (this.beginPoint && this.endPoint) {
  640. path = "M" + this.beginPoint.x + "," + this.beginPoint.y;
  641. this.positionPoints.each(function (p, idx) {
  642. var p0;
  643. var p2;
  644. if (idx == 0) {
  645. p0 = this.beginPoint;
  646. } else {
  647. p0 = this.positionPoints[idx - 1];
  648. }
  649. if (this.positionPoints[idx + 1]) {
  650. p2 = this.positionPoints[idx + 1];
  651. } else {
  652. p2 = this.endPoint;
  653. }
  654. p.x = p.x.toFloat();
  655. p.y = p.y.toFloat();
  656. var minus1 = MWFRaphael.getMinus(Math.abs(p.x - p0.x), Math.abs(p.y - p0.y), 12);
  657. var minus2 = MWFRaphael.getMinus(Math.abs(p.x - p2.x), Math.abs(p.y - p2.y), 12);
  658. var qp0 = null;
  659. var qp2 = null;
  660. if (p.x >= p0.x && p.y >= p0.y) {
  661. qp0 = {"x": p.x - minus1.x, "y": p.y - minus1.y};
  662. } else if (p.x <= p0.x && p.y <= p0.y) {
  663. qp0 = {"x": p.x + minus1.x, "y": p.y + minus1.y};
  664. } else if (p.x >= p0.x && p.y <= p0.y) {
  665. qp0 = {"x": p.x - minus1.x, "y": p.y + minus1.y};
  666. } else if (p.x <= p0.x && p.y >= p0.y) {
  667. qp0 = {"x": p.x + minus1.x, "y": p.y - minus1.y};
  668. }
  669. if (p.x >= p2.x && p.y >= p2.y) {
  670. qp2 = {"x": p.x - minus2.x, "y": p.y - minus2.y};
  671. } else if (p.x <= p2.x && p.y <= p2.y) {
  672. qp2 = {"x": p.x + minus2.x, "y": p.y + minus2.y};
  673. } else if (p.x >= p2.x && p.y <= p2.y) {
  674. qp2 = {"x": p.x - minus2.x, "y": p.y + minus2.y};
  675. } else if (p.x <= p2.x && p.y >= p2.y) {
  676. qp2 = {"x": p.x + minus2.x, "y": p.y - minus2.y};
  677. }
  678. path += "L" + qp0.x + "," + qp0.y;
  679. path += "Q" + p.x + ", " + p.y + ", " + qp2.x + "," + qp2.y;
  680. }.bind(this));
  681. path += "L" + this.endPoint.x + "," + this.endPoint.y;
  682. }
  683. return path;
  684. },
  685. getDefaultTextPoint: function () {
  686. var x = "";
  687. var y = "";
  688. if (this.toSelf) {
  689. x = this.positionPoints[2].x + (this.positionPoints[1].x - this.positionPoints[2].x) / 2;
  690. y = this.positionPoints[2].y - 8;
  691. } else {
  692. var p1 = this.beginPoint;
  693. var p2 = this.endPoint;
  694. if (this.positionPoints[0]) p2 = this.positionPoints[0];
  695. var xoff = (p2.x.toFloat() - p1.x.toFloat()) * 0.4;
  696. var yoff = (p2.y.toFloat() - p1.y.toFloat()) * 0.4;
  697. x = p1.x.toFloat() + xoff;
  698. y = p1.y.toFloat() + yoff;
  699. }
  700. return {"x": x, "y": y};
  701. },
  702. getTextPoint: function () {
  703. var x = "";
  704. var y = "";
  705. if (this.data.position) {
  706. var pArr = this.data.position.split(/(?:,\s*){1}|(?:;\s*){1}/g);
  707. x = pArr[0];
  708. y = pArr[1];
  709. } else {
  710. var p = this.getDefaultTextPoint();
  711. x = p.x;
  712. y = p.y;
  713. }
  714. return {"x": x, "y": y};
  715. },
  716. createText: function () {
  717. var text = null;
  718. if (this.beginPoint && this.endPoint) {
  719. var p = this.getTextPoint();
  720. text = this.paper.text(p.x, p.y, this.data.name || MWF.APPPD.LP.unnamed);
  721. text.attr(this.process.css.route.linetext.normal);
  722. return text;
  723. }
  724. },
  725. createArrow: function () {
  726. var beginPoint = this.beginPoint;
  727. if (this.positionPoints.length) {
  728. beginPoint = this.positionPoints[this.positionPoints.length - 1];
  729. }
  730. beginPoint.x = beginPoint.x.toFloat();
  731. beginPoint.y = beginPoint.y.toFloat();
  732. return this.paper.arrow(beginPoint, this.endPoint, this.l1, this.l2, this.aj);
  733. },
  734. createCorner: function (p, idx) {
  735. var corner = this.paper.rectPath((p.x.toInt()) - 2.5, (p.y.toInt()) - 2.5, 5, 5, 0);
  736. corner.data("position", p);
  737. corner.attr(this.process.css.route.corner["default"]);
  738. corner.hide();
  739. this.corners.splice(idx, 0, corner);
  740. corner.mousedown(function (e) {
  741. this.cornerBrokenLineBegin(e, corner);
  742. }.bind(this));
  743. this.set.push(corner);
  744. return corner;
  745. },
  746. getPoint: function (fromPath, toPath) {
  747. var fromActivityPath = fromPath;
  748. if (this.fromActivity) {
  749. if (!fromActivityPath) fromActivityPath = this.fromActivity.shap.attr("path");
  750. }
  751. var toActivityPath = toPath;
  752. if (this.toActivity) {
  753. if (!toActivityPath) toActivityPath = this.toActivity.shap.attr("path");
  754. }
  755. if (fromActivityPath && toActivityPath) {
  756. this.checked = true;
  757. if (this.toSelf) {
  758. var p1x = this.fromActivity.center.x + this.fromActivity.width;
  759. var p1y = this.fromActivity.center.y;
  760. var p2x = this.fromActivity.center.x + this.fromActivity.width;
  761. var p2y = this.fromActivity.center.y - this.fromActivity.height;
  762. var p3x = this.fromActivity.center.x;
  763. var p3y = this.fromActivity.center.y - this.fromActivity.height;
  764. this.positionPoints = [];
  765. this.positionPoints.push({"x": p1x, "y": p1y});
  766. this.positionPoints.push({"x": p2x, "y": p2y});
  767. this.positionPoints.push({"x": p3x, "y": p3y});
  768. this.beginPoint = {
  769. "x": this.fromActivity.center.x + this.fromActivity.width / 2,
  770. "y": this.fromActivity.center.y
  771. };
  772. this.endPoint = {
  773. "x": this.fromActivity.center.x,
  774. "y": this.fromActivity.center.y - this.fromActivity.height / 2
  775. };
  776. } else {
  777. var beginLinePath;
  778. var endLinePath;
  779. if (this.positionPoints[0]) {
  780. beginLinePath = "M" + this.fromActivity.center.x + "," + this.fromActivity.center.y + "L" + this.positionPoints[0].x + "," + this.positionPoints[0].y;
  781. var p = this.positionPoints[this.positionPoints.length - 1];
  782. endLinePath = "M" + p.x + "," + p.y + "L" + this.toActivity.center.x + "," + this.toActivity.center.y;
  783. } else {
  784. beginLinePath = "M" + this.fromActivity.center.x + "," + this.fromActivity.center.y + "L" + this.toActivity.center.x + "," + this.toActivity.center.y;
  785. endLinePath = "M" + this.fromActivity.center.x + "," + this.fromActivity.center.y + "L" + this.toActivity.center.x + "," + this.toActivity.center.y;
  786. }
  787. var decisionPoints = Raphael.pathIntersection(beginLinePath, fromActivityPath);
  788. var endPoints = Raphael.pathIntersection(endLinePath, toActivityPath);
  789. this.beginPoint = decisionPoints[0] || this.fromActivity.center;
  790. this.endPoint = endPoints[0] || this.toActivity.center;
  791. }
  792. }
  793. if (!fromActivityPath && toActivityPath) {
  794. this.checked = false;
  795. var decisionY;
  796. var decisionX;
  797. if (this.tmpBeginPoint) {
  798. decisionY = this.tmpBeginPoint.y.toFloat();
  799. decisionX = this.tmpBeginPoint.x.toFloat();
  800. } else {
  801. decisionY = this.toActivity.center.y.toFloat() - 500;
  802. decisionX = this.toActivity.center.x.toFloat();
  803. }
  804. var endLinePath = "M" + decisionX + "," + decisionY + "L" + this.toActivity.center.x + "," + this.toActivity.center.y;
  805. var endPoints = Raphael.pathIntersection(endLinePath, toActivityPath);
  806. this.endPoint = endPoints[0];
  807. this.beginPoint = this.tmpBeginPoint || {"x": this.endPoint.x, "y": this.endPoint.y - 30};
  808. this.tmpBeginPoint = null;
  809. }
  810. if (fromActivityPath && !toActivityPath) {
  811. this.checked = false;
  812. var endY;
  813. var endX;
  814. if (this.tmpEndPoint) {
  815. endY = this.tmpEndPoint.y.toFloat();
  816. endX = this.tmpEndPoint.x.toFloat();
  817. } else {
  818. endY = this.fromActivity.center.y.toFloat() + 500;
  819. endX = this.fromActivity.center.x.toFloat();
  820. }
  821. var beginLinePath = "M" + this.fromActivity.center.x + "," + this.fromActivity.center.y + "L" + endX + "," + endY;
  822. var decisionPoints = Raphael.pathIntersection(beginLinePath, fromActivityPath);
  823. this.beginPoint = decisionPoints[0];
  824. this.endPoint = this.tmpEndPoint || {"x": this.beginPoint.x, "y": this.beginPoint.y + 30};
  825. this.tmpEndPoint = null;
  826. }
  827. if (!fromActivityPath && !toActivityPath) {
  828. this.checked = false;
  829. this.beginPoint = {"x": 10, "y": 10};
  830. this.endPoint = {"x": 10, "y": 30};
  831. }
  832. },
  833. setListItemData: function () {
  834. if (this.listItem) {
  835. var routeName = this.data.name || MWF.APPPD.LP.unnamed;
  836. var name = "";
  837. if (this.toActivity) {
  838. name = this.toActivity.data.name;
  839. if (!name) name = MWF.APPPD.LP.unnamed;
  840. } else {
  841. name = MWF.APPPD.LP.unknow;
  842. }
  843. this.listItem.row.tds[1].set("text", routeName + " (to " + name + ")");
  844. }
  845. },
  846. destroy: function () {
  847. if (this.fromActivity) {
  848. this.fromActivity.removeRouteData(this.data.id);
  849. // if (this.fromActivity.data.routeList){
  850. // this.fromActivity.data.routeList.erase(this.data.id);
  851. // }
  852. this.fromActivity.routes.erase(this);
  853. }
  854. if (this.listItem) {
  855. this.listItem.row.tr.destroy();
  856. }
  857. var routes = {};
  858. var routeDatas = {};
  859. for (rid in this.process.routes) {
  860. if (rid != this.data.id) {
  861. routes[rid] = this.process.routes[rid];
  862. routeDatas[rid] = this.process.routeDatas[rid];
  863. } else {
  864. this.process.routes[rid] = null;
  865. this.process.routeDatas[rid] = null;
  866. }
  867. }
  868. this.process.routes = null;
  869. this.process.routeDatas = null;
  870. this.process.routes = routes;
  871. this.process.routeDatas = routeDatas;
  872. this.process.process.routeList.erase(this.data);
  873. this.set.remove();
  874. },
  875. showProperty: function () {
  876. if (!this.property) {
  877. this.property = new MWF.APPPD.Route.Property(this, {
  878. "onPostLoad": function () {
  879. this.property.show();
  880. }.bind(this)
  881. });
  882. this.property.load();
  883. } else {
  884. this.property.show();
  885. }
  886. },
  887. _setEditProperty: function (name, input, oldValue) {
  888. // if (name === "passExpired" || name === "passSameTarget" || name === "sole" || name === "soleDirect") {
  889. if (name === "passExpired" || name === "passSameTarget" || name === "sole") {
  890. if (this.data[name]) {
  891. if (this.fromActivity) {
  892. this.fromActivity.routes.each(function(route){
  893. if (route.data.id !== this.data.id) {
  894. if (route.data[name]) {
  895. route.data[name] = false;
  896. if (route.property){
  897. var node = route.property.propertyContent.getElementById(route.data.id+name);
  898. if (node) node.getElements("input")[1].set("checked", true);
  899. }
  900. }
  901. }
  902. }.bind(this));
  903. }
  904. }
  905. }
  906. },
  907. checkRouteName: function (value) {
  908. var flag = true;
  909. if (this.fromActivity) {
  910. this.fromActivity.routes.each(function(route){
  911. if (route.data.id !== this.data.id && route.data.name === value && value !== MWF.APPPD.LP.unnamed ) {
  912. this.process.designer.notice(this.process.designer.lp.notice.routeNameConfilct, "error");
  913. flag = false;
  914. }
  915. }.bind(this));
  916. }
  917. return flag;
  918. }
  919. });
  920. MWF.xApplication.process.ProcessDesigner.Route.List = new Class({
  921. initialize: function(route){
  922. this.route = route;
  923. this.process = route.process;
  924. this.paper = this.route.paper;
  925. },
  926. load: function(){
  927. var routeName = this.route.data.name || MWF.APPPD.LP.unnamed;
  928. var name = "";
  929. if (this.route.toActivity){
  930. name = this.route.toActivity.data.name;
  931. if (!name) name = MWF.APPPD.LP.unnamed;
  932. } else {
  933. name = MWF.APPPD.LP.unknow;
  934. }
  935. this.row = this.process.routeTable.push([
  936. {
  937. "content": " ",
  938. "properties": {
  939. "styles": this.process.css.route.icon
  940. }
  941. },
  942. {
  943. "content": routeName+" (to "+name+")",
  944. "properties": {
  945. "styles": this.process.css.list.listText
  946. }
  947. },
  948. {
  949. "content": "<img src=\""+"../x_component_process_ProcessDesigner/$Process/default/icon/copy.png"+"\" />",
  950. "properties": {
  951. "styles": this.process.css.list.listIcon,
  952. "events": {
  953. "click": this.copyRoute.bind(this)
  954. }
  955. }
  956. },
  957. {
  958. "content": "<img src=\""+"../x_component_process_ProcessDesigner/$Process/default/icon/delete.png"+"\" />",
  959. "properties": {
  960. "styles": this.process.css.list.listIcon,
  961. "events": {
  962. "click": this.deleteRoute.bind(this)
  963. }
  964. }
  965. }
  966. ]
  967. );
  968. this.row.tr.addEvent("click", function(){
  969. this.listSelected();
  970. }.bind(this));
  971. },
  972. copyRoute: function(){
  973. this.process.copyRoute(this.route);
  974. },
  975. deleteRoute: function(e){
  976. this.process.deleteRoute(e, this.route);
  977. },
  978. selected: function(){
  979. if (this.process.currentListSelected) this.process.currentListSelected.listUnSelected();
  980. this.row.tr.setStyles(this.process.css.list.listRowSelected);
  981. this.process.currentListSelected = this;
  982. },
  983. unSelected: function(){
  984. this.process.currentListSelected = null;
  985. this.row.tr.setStyles(this.process.css.list.listRow);
  986. },
  987. listSelected: function(){
  988. this.route.selected();
  989. },
  990. listUnSelected: function(){
  991. this.route.unSelected();
  992. }
  993. });
  994. MWF.xApplication.process.ProcessDesigner.Route.Property = new Class({
  995. Implements: [Options, Events],
  996. Extends: MWF.APPPD.Property,
  997. initialize: function(route, options){
  998. this.setOptions(options);
  999. this.route = route;
  1000. this.process = route.process;
  1001. this.paper = this.process.paper;
  1002. this.data = route.data;
  1003. this.htmlPath = "../x_component_process_ProcessDesigner/$Process/route.html";
  1004. },
  1005. setValue: function(name, value){
  1006. if (name=="name"){
  1007. if (!value){
  1008. this.data[name] = MWF.APPPD.LP.unnamed;
  1009. }else if( this.route.checkRouteName(value) ){
  1010. this.data[name] = value;
  1011. this.route.reload();
  1012. }
  1013. }else{
  1014. this.data[name] = value;
  1015. }
  1016. },
  1017. show: function(){
  1018. if (!this.process.options.isView){
  1019. if (!this.propertyContent){
  1020. this.htmlString = o2.bindJson(this.htmlString, {"lp": o2.APPPD.LP.propertyTemplate});
  1021. this.propertyContent = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.process.propertyListNode);
  1022. this.process.panel.propertyTabPage.showTabIm();
  1023. this.JsonTemplate = new MWF.widget.JsonTemplate(this.data, this.htmlString);
  1024. this.propertyContent.set("html", this.JsonTemplate.load());
  1025. this.process.panel.data = this.data;
  1026. this.loadRouteCondition();
  1027. this.setEditNodeEvent();
  1028. this.setEditNodeStyles(this.propertyContent);
  1029. this.loadPropertyTab();
  1030. this.loadPersonInput();
  1031. this.loadScriptInput();
  1032. this.loadScriptText();
  1033. this.loadConditionInput();
  1034. this.loadFormSelect();
  1035. this.loadOrgEditor();
  1036. this.hideAdvanced();
  1037. }else{
  1038. this.propertyContent.setStyle("display", "block");
  1039. }
  1040. }
  1041. },
  1042. loadPropertyTab: function(){
  1043. var tabNodes = this.propertyContent.getElements(".MWFTab");
  1044. if (tabNodes.length){
  1045. var tmpNode = this.propertyContent.getFirst();
  1046. var tabAreaNode = new Element("div", {
  1047. "styles": this.process.css.propertyTabNode
  1048. }).inject(tmpNode, "before");
  1049. MWF.require("MWF.widget.Tab", function(){
  1050. var tab = new MWF.widget.Tab(tabAreaNode, {"style": "moduleList"});
  1051. tab.load();
  1052. var tabPages = [];
  1053. this.tabPages = tabPages;
  1054. var isFromManual = this.isFromManualActivity();
  1055. tabNodes.each(function(node){
  1056. var tabPage = tab.addTab(node, node.get("title"), false);
  1057. tabPages.push(tabPage);
  1058. if (node.hasAttribute("data-o2-advanced") && node.dataset["o2Advanced"]=="yes"){
  1059. tabPage.tabNode.setAttribute("data-o2-advanced", "yes");
  1060. }
  1061. if( !isFromManual && node.hasAttribute("data-o2-manual") && node.dataset["o2Manual"]=="yes" ){
  1062. tabPage.tabNode.hide()
  1063. }
  1064. }.bind(this));
  1065. tabPages[0].showTab();
  1066. }.bind(this));
  1067. }
  1068. },
  1069. checkTabShow: function(){
  1070. var isFromManual = this.isFromManualActivity();
  1071. var isshowed = false;
  1072. this.tabPages.each(function (tabPage) {
  1073. var node = tabPage.contentNode;
  1074. var needShow = true;
  1075. if( node && node.hasAttribute("data-o2-manual") && node.dataset["o2Manual"]=="yes" ){
  1076. if(!isFromManual) {
  1077. needShow = false;
  1078. tabPage.tabNode.hide();
  1079. }else{
  1080. tabPage.tabNode.show();
  1081. }
  1082. }
  1083. if( node && node.hasAttribute("data-o2-condition") ){
  1084. var type = this.route.fromActivity.type;
  1085. if (type=="choice" || type=="condition" || type=="parallel"){
  1086. tabPage.tabNode.show();
  1087. }else{
  1088. needShow = false;
  1089. tabPage.tabNode.hide();
  1090. }
  1091. }
  1092. if( !isshowed && needShow ){
  1093. tabPage.showTab();
  1094. isshowed = true;
  1095. }
  1096. }.bind(this));
  1097. },
  1098. isFromManualActivity: function(){
  1099. debugger;
  1100. var activity = this.route.fromActivity;
  1101. if( activity && activity.type === "manual" ){
  1102. if( activity.data && activity.data.routeList && activity.data.routeList.contains( this.data.id ) ){
  1103. return true;
  1104. }
  1105. }
  1106. return false;
  1107. },
  1108. loadRouteCondition: function(){
  1109. var routeConditionNode = this.propertyContent.getElement(".MWFRouteCondition");
  1110. var type = this.route.fromActivity.type;
  1111. if (type=="choice" || type=="condition" || type=="parallel"){
  1112. if (!routeConditionNode){
  1113. routeConditionNode = new Element("div.MWFTab", {
  1114. "data-o2-condition": "yes",
  1115. "title": MWF.APPPD.LP.condition,
  1116. "html": "<div class=\"MWFScriptText\" name=\"scriptText\"></div>"
  1117. }).inject(this.propertyContent.getFirst());
  1118. }
  1119. }else{
  1120. if (routeConditionNode) routeConditionNode.destroy();
  1121. }
  1122. }
  1123. //loadScriptText: function(){
  1124. // var node = this.propertyContent.getElement(".MWFScriptText");
  1125. // if (node){
  1126. // MWF.require("MWF.xApplication.process.ProcessDesigner.widget.ScriptText", function(){
  1127. // var _self = this;
  1128. // // scriptNodes.each(function(node){
  1129. // var data = (_self.route.fromActivity.data.extension) ? JSON.decode(_self.route.fromActivity.data.extension) : {};
  1130. // var code = (data[_self.route.data.id]) || "";
  1131. //
  1132. // var script = new MWF.xApplication.process.ProcessDesigner.widget.ScriptText(node, code, this.process.designer, {
  1133. // "maskNode": this.process.designer.content,
  1134. // "onChange": function(code){
  1135. // var id = _self.route.data.id;
  1136. // data[id] = code;
  1137. // var jsonString = JSON.encode(data);
  1138. // _self.route.fromActivity.data.extension = jsonString;
  1139. // _self.route.fromActivity.data.scriptText = "return this.library.choiceRoute('"+encodeURIComponent(jsonString)+"');";
  1140. // }
  1141. // });
  1142. // //this.setScriptItems(script, node);
  1143. // // }.bind(this));
  1144. // }.bind(this));
  1145. // }
  1146. //}
  1147. });