WorkExplorer.js 74 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687
  1. //MWF.require("MWF.xAction.org.express.RestActions", null,false);
  2. MWF.require("MWF.widget.Mask", null, false);
  3. MWF.require("MWF.widget.O2Identity", null,false);
  4. //MWF.xDesktop.requireApp("Organization", "Selector.package", null, false);
  5. MWF.xDesktop.requireApp("Selector", "package", null, false);
  6. MWF.xDesktop.requireApp("process.ProcessManager", "DictionaryExplorer", null, false);
  7. MWF.xApplication.process.Application.WorkExplorer = new Class({
  8. Extends: MWF.xApplication.process.ProcessManager.DictionaryExplorer,
  9. Implements: [Options, Events],
  10. initialize: function(node, actions, options){
  11. this.setOptions(options);
  12. this.setTooltip();
  13. this.path = "/x_component_process_Application/$WorkExplorer/";
  14. this.cssPath = "/x_component_process_Application/$WorkExplorer/"+this.options.style+"/css.wcss";
  15. this._loadCss();
  16. this.actions = actions;
  17. this.node = $(node);
  18. this.items=[];
  19. this.works = {};
  20. this.filter = null;
  21. this.isItemsLoaded = false;
  22. this.isItemLoadding = false;
  23. this.loadItemQueue = 0;
  24. this.pageCount = 20;
  25. //if (!this.personActions) this.personActions = new MWF.xApplication.Org.Actions.RestActions();
  26. this.initData();
  27. },
  28. load: function(){
  29. this.loadToolbar();
  30. this.loadFilterNode();
  31. this.loadFilterConditionNode();
  32. this.loadContentNode();
  33. this.setNodeScroll();
  34. this.mask = new MWF.widget.Mask({"style": "desktop"});
  35. this.mask.loadNode(this.node);
  36. this.loadElementList();
  37. },
  38. createSearchElementNode: function(){
  39. this.toCompletedNode = new Element("div", {
  40. "styles": this.css.toCompletedNode,
  41. "text": this.app.lp.toCompleted
  42. }).inject(this.toolbarNode);
  43. this.toCompletedNode.addEvents({
  44. "mouseover": function(){
  45. this.toCompletedNode.setStyles(this.css.toCompletedNode_over);
  46. }.bind(this),
  47. "mouseout": function(){
  48. this.toCompletedNode.setStyles(this.css.toCompletedNode);
  49. }.bind(this),
  50. "click": function(){
  51. this.app.workCompletedConfig();
  52. }.bind(this)
  53. });
  54. },
  55. clearWorks: function(){
  56. MWF.release(this.items);
  57. this.isCountShow = false;
  58. this.works = null;
  59. this.items=[];
  60. this.works = {};
  61. this.elementContentListNode.empty();
  62. this.isItemsLoaded = false;
  63. this.isItemLoadding = false;
  64. this.loadItemQueue = 0;
  65. },
  66. loadFilterNode: function(){
  67. this.filterNode = new Element("div", {"styles": this.css.filterNode}).inject(this.node);
  68. this.filterAllProcessNode = new Element("div", {"styles": this.css.filterAllProcessNode, "text": this.app.lp.all}).inject(this.filterNode);
  69. new Element("span", {"styles": this.css.filterAllProcessCountNode}).inject(this.filterAllProcessNode);
  70. this.filterAllProcessNode.addEvent("click", function(){
  71. if (this.currentProcessNode) this.currentProcessNode.setStyles(this.css.filterProcessNode);
  72. this.currentProcessNode = null;
  73. this.filter = null;
  74. this.reloadWorks();
  75. }.bind(this));
  76. this.filterActionAreaNode = new Element("div", {"styles": this.css.filterActionAreaNode}).inject(this.filterNode);
  77. this.filterActionNode = new Element("div", {"styles": this.css.filterActionNode, "text": this.app.lp.filter}).inject(this.filterActionAreaNode);
  78. this.filterActionNode.addEvent("click", function(e){
  79. this.showOrHideFilter();e.stopPropagation();
  80. }.bind(this));
  81. this.filterProcessAreaNode = new Element("div", {"styles": this.css.filterProcessAreaNode}).inject(this.filterNode);
  82. this.filterProcessListNode = new Element("div", {"styles": this.css.filterProcessListNode}).inject(this.filterProcessAreaNode);
  83. this.loadProcess();
  84. },
  85. showOrHideFilter: function(){
  86. if (!this.isFilterOpen){
  87. if (!this.filterAreaMorph || !this.filterAreaMorph.isRunning()) this.showFilter();
  88. }else{
  89. if (this.filterAreaMorph || !this.filterAreaMorph.isRunning()) this.hideFilter();
  90. }
  91. },
  92. showFilter: function(){
  93. this.filterActionNode.setStyles(this.css.filterActionNode_over);
  94. if (!this.filterAreaNode) this.createFilterAreaNode();
  95. this.filterAreaTipNode.setStyle("display", "block");
  96. this.filterAreaNode.setStyle("display", "block");
  97. this.resizeFilterAreaNode();
  98. var toStyle = {
  99. "width": "460px",
  100. "height": "500px"
  101. };
  102. this.isFilterOpen = true;
  103. this.filterAreaMorph.start(toStyle).chain(function(){
  104. this.createFilterAreaTitle();
  105. this.createFilterAreaContent();
  106. this.hideFilterFun = this.hideFilter.bind(this);
  107. $(document.body).addEvent("click", this.hideFilterFun);
  108. }.bind(this));
  109. },
  110. hideFilter: function(){
  111. if (this.filterAreaNode){
  112. var toStyle = {
  113. "width": "460px",
  114. "height": "0px"
  115. };
  116. this.filterAreaNode.empty();
  117. this.isFilterOpen = false;
  118. this.filterAreaMorph.start(toStyle).chain(function(){
  119. this.filterAreaNode.eliminate("input");
  120. this.filterAreaNode.setStyle("display", "none");
  121. this.filterAreaTipNode.setStyle("display", "none");
  122. this.filterActionNode.setStyles(this.css.filterActionNode);
  123. $(document.body).removeEvent("click", this.hideFilterFun);
  124. }.bind(this));
  125. $(document.body).removeEvent("click", this.hideFilterFun);
  126. }
  127. },
  128. createFilterAreaNode: function(){
  129. this.filterAreaNode = new Element("div", {"styles": this.css.filterAreaNode}).inject(this.app.content);
  130. this.filterAreaNode.addEvent("click", function(e){e.stopPropagation();});
  131. this.filterAreaTipNode = new Element("div", {"styles": this.css.filterAreaTipNode}).inject(this.app.content);
  132. //var size = this.filterActionNode.getSize();
  133. this.filterAreaNode.setStyles({
  134. "width": "460px",
  135. "height": "0px"
  136. });
  137. this.filterAreaNode.position({
  138. relativeTo: this.filterNode,
  139. position: 'bottomRight',
  140. edge: 'upperRight',
  141. offset: {x:-20, y: -1}
  142. });
  143. this.filterAreaTipNode.position({
  144. relativeTo: this.filterNode,
  145. position: 'bottomRight',
  146. edge: 'bottomRight',
  147. offset: {x:-38, y: 0}
  148. });
  149. this.app.addEvent("resize", function(){
  150. this.resizeFilterAreaNode();
  151. }.bind(this));
  152. this.filterAreaMorph = new Fx.Morph(this.filterAreaNode, {
  153. duration: '100',
  154. transition: Fx.Transitions.Sine.easeInOut
  155. });
  156. },
  157. resizeFilterAreaNode: function(){
  158. if (this.filterAreaNode){
  159. this.filterAreaNode.position({
  160. relativeTo: this.filterNode,
  161. position: 'bottomRight',
  162. edge: 'upperRight',
  163. offset: {x:-20, y: -1}
  164. });
  165. if (this.filterAreaTipNode){
  166. this.filterAreaTipNode.position({
  167. relativeTo: this.filterNode,
  168. position: 'bottomRight',
  169. edge: 'bottomRight',
  170. offset: {x:-38, y: 0}
  171. });
  172. }
  173. }
  174. },
  175. createFilterAreaTitle: function(){
  176. var titleNode = new Element("div", {"styles": this.css.filterAreaTitleNode}).inject(this.filterAreaNode);
  177. var okNode = new Element("div", {"styles": this.css.filterAreaTitleActionOkNode, "text": this.app.lp.ok}).inject(titleNode);
  178. var clearNode = new Element("div", {"styles": this.css.filterAreaTitleActionClearNode, "text": this.app.lp.clear}).inject(titleNode);
  179. clearNode.addEvent("click", function(){
  180. this.filterAreaNode.getElements(".filterItem").each(function(el){
  181. this.unSelectedFilterItem(el);
  182. }.bind(this));
  183. var input = this.filterAreaNode.retrieve("input");
  184. input.set("value", "");
  185. this.filter = null;
  186. this.hideFilter();
  187. this.reloadWorks();
  188. }.bind(this));
  189. okNode.addEvent("click", function(){
  190. var input = this.filterAreaNode.retrieve("input");
  191. if (!this.filter) this.filter = {};
  192. var key = input.get("value");
  193. if (key && key!=this.app.lp.searchKey){
  194. this.filter.key = key;
  195. }else{
  196. this.filter.key = "";
  197. delete this.filter.key
  198. }
  199. this.hideFilter();
  200. this.reloadWorks();
  201. }.bind(this));
  202. var searchNode = new Element("div", {"styles": this.css.filterAreaTitleSearchNode}).inject(titleNode);
  203. var searchIconNode = new Element("div", {"styles": this.css.filterAreaTitleSearchIconNode}).inject(searchNode);
  204. var searchInputAreaNode = new Element("div", {"styles": this.css.filterAreaTitleSearchInputAreaNode}).inject(searchNode);
  205. var searchInputNode = new Element("input", {"styles": this.css.filterAreaTitleSearchInputNode, "value": this.app.lp.searchKey}).inject(searchInputAreaNode);
  206. if (this.filter){
  207. if (this.filter.key) searchInputNode.set("value", this.filter.key);
  208. }
  209. this.filterAreaNode.store("input", searchInputNode);
  210. var key = this.app.lp.searchKey;
  211. searchInputNode.addEvents({
  212. "blur": function(){if (!this.get("value")) this.set("value", key)},
  213. "focus": function(){if (this.get("value")==key) this.set("value", "")},
  214. "keydown": function(e){
  215. if (e.code==13){
  216. var input = this.filterAreaNode.retrieve("input");
  217. if (!this.filter) this.filter = {};
  218. var key = input.get("value");
  219. if (key && key!=this.app.lp.searchKey){
  220. this.filter.key = key;
  221. }else{
  222. this.filter.key = "";
  223. delete this.filter.key
  224. }
  225. this.hideFilter();
  226. this.reloadWorks();
  227. }
  228. }.bind(this)
  229. });
  230. },
  231. createFilterAreaContent: function(){
  232. var contentScrollNode = new Element("div", {"styles": this.css.applicationFilterAreaContentScrollNode}).inject(this.filterAreaNode);
  233. var contentNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(contentScrollNode);
  234. MWF.require("MWF.widget.ScrollBar", function(){
  235. new MWF.widget.ScrollBar(contentScrollNode, {
  236. "style":"xApp_filter", "where": "after", "distance": 30, "friction": 4, "axis": {"x": false, "y": true}
  237. });
  238. }.bind(this));
  239. var _self = this;
  240. this._getFilterCount(function(json){
  241. var obj = json.data;
  242. Object.each(obj, function(v, key){
  243. var categoryNode = new Element("div", {"styles": this.css.applicationFilterCategoryNode}).inject(contentNode);
  244. categoryNode.set("text", this.app.lp[key]);
  245. var itemAreaNode = new Element("div", {"styles": this.css.applicationFilterItemAreaNode}).inject(contentNode);
  246. // for (var x=0; x<10; x++){
  247. v.each(function(item){
  248. if (item.value){
  249. var itemNode = new Element("div", {"styles": this.css.applicationFilterItemNode}).inject(itemAreaNode);
  250. //itemNode.set("text", item.name+"("+item.count+")");
  251. itemNode.set("text", item.name);
  252. itemNode.store("value", item.value);
  253. itemNode.store("textname", item.name);
  254. itemNode.store("key", key);
  255. itemNode.addEvent("click", function(){
  256. if (this.hasClass("applicationFilterItemNode_over")){
  257. _self.unSelectedFilterItem(this);
  258. }else{
  259. _self.selectedFilterItem(this);
  260. }
  261. });
  262. if (this.filter){
  263. if (this.filter[key]){
  264. if (this.filter[key].some(function(o){return o.value===item.value;})){
  265. this.selectedFilterItem(itemNode);
  266. }
  267. }
  268. }
  269. }
  270. }.bind(this));
  271. // }
  272. }.bind(this));
  273. }.bind(this));
  274. },
  275. _getFilterCount: function(callback){
  276. this.actions.listFilterAttributeManage(this.app.options.id, function(json){
  277. if (callback) callback(json);
  278. });
  279. },
  280. unSelectedFilterItem: function(item){
  281. if (item.hasClass("applicationFilterItemNode_over")){
  282. var value = item.retrieve("value");
  283. var name = item.retrieve("textname");
  284. var key = item.retrieve("key");
  285. item.setStyles(this.css.applicationFilterItemNode);
  286. item.removeClass("applicationFilterItemNode_over");
  287. item.addClass("applicationFilterItemNode");
  288. if (!this.filter){
  289. this.filter = {};
  290. }else{
  291. if (this.filter[key]){
  292. this.filter[key] = this.filter[key].filter(function(o){
  293. return o.value!=value;
  294. });
  295. if (!this.filter[key].length) delete this.filter[key];
  296. }
  297. }
  298. // this.filter[key] = null;
  299. // delete this.filter[key];
  300. item.getParent().eliminate("current");
  301. }
  302. },
  303. selectedFilterItem: function(item){
  304. if (!item.hasClass("applicationFilterItemNode_over")){
  305. var current = item.getParent().retrieve("current");
  306. //if (current) this.unSelectedFilterItem(current);
  307. var value = item.retrieve("value");
  308. var key = item.retrieve("key");
  309. var name = item.retrieve("textname");
  310. item.setStyles(this.css.applicationFilterItemNode_over);
  311. item.removeClass("applicationFilterItemNode");
  312. item.addClass("applicationFilterItemNode_over");
  313. if (!this.filter) this.filter = {};
  314. if (!this.filter[key]) this.filter[key] = [];
  315. if (!this.filter[key].some(function(o){return o.value===value;})){
  316. this.filter[key].push({"value": value, "name": name});
  317. }
  318. //this.filter[key] = [value];
  319. item.getParent().store("current", item);
  320. }
  321. },
  322. searchElement: function(){
  323. if (!this.filter) this.filter = {};
  324. var key = this.searchElementInputNode.get("value");
  325. if (key && key!=this.app.lp.searchKey){
  326. this.filter.key = key;
  327. this.hideFilter();
  328. this.reloadWorks();
  329. }
  330. },
  331. loadFilterConditionNode: function(){
  332. this.filterConditionNode = new Element("div", {"styles": this.css.filterConditionNode}).inject(this.node);
  333. this.setFilterConditions();
  334. },
  335. setFilterConditions: function(){
  336. this.filterConditionNode.empty();
  337. if (this.filter && Object.keys(this.filter).length){
  338. Object.each(this.filter, function(v, key){
  339. if (key!=="key"){
  340. v.each(function(i){
  341. this.createFilterItemNode(key, i);
  342. }.bind(this));
  343. }
  344. }.bind(this));
  345. if (this.filter.key){
  346. this.createFilterItemNode("key", {"name": this.filter.key});
  347. }
  348. this.filterProcessListNode.setStyle("display", "none");
  349. }else{
  350. this.filterProcessListNode.setStyle("display", "block");
  351. }
  352. },
  353. createFilterItemNode: function(key, v){
  354. var _self = this;
  355. var node = new Element("div", {"styles": this.css.filterListItemNode}).inject(this.filterConditionNode);
  356. var actionNode = new Element("div", {"styles": this.css.filterListItemActionNode}).inject(node);
  357. var textNode = new Element("div", {"styles": this.css.filterListItemTextNode}).inject(node);
  358. textNode.set("text", this.app.lp[key]+": "+ v.name);
  359. actionNode.store("key", key);
  360. actionNode.store("value", v.name);
  361. actionNode.store("valueId", v.value);
  362. node.addEvents({
  363. "mouseover": function(){
  364. this.setStyles(_self.css.filterListItemNode_over);
  365. this.getLast().setStyles(_self.css.filterListItemTextNode_over);
  366. this.getFirst().setStyles(_self.css.filterListItemActionNode_over);
  367. },
  368. "mouseout": function(){
  369. this.setStyles(_self.css.filterListItemNode);
  370. this.getLast().setStyles(_self.css.filterListItemTextNode);
  371. this.getFirst().setStyles(_self.css.filterListItemActionNode);
  372. }
  373. });
  374. actionNode.addEvent("click", function(){
  375. var key = this.retrieve("key");
  376. var value = this.retrieve("value");
  377. var valueId = this.retrieve("valueId");
  378. if (_self.filter[key]){
  379. _self.filter[key] = _self.filter[key].filter(function(o){
  380. return o.value!==valueId;
  381. });
  382. if (!_self.filter[key].length) delete _self.filter[key];
  383. }
  384. // if (_self.filter[key]) _self.filter[key] = null;
  385. // delete _self.filter[key];
  386. this.destroy();
  387. _self.reloadWorks();
  388. });
  389. },
  390. loadProcess: function(){
  391. this.actions.listProcessCountManage(this.app.options.id, function(json){
  392. json.data.each(function(process){
  393. this.loadProcessNode(process);
  394. }.bind(this));
  395. }.bind(this));
  396. },
  397. loadProcessNode: function(process){
  398. var filterProcessNode = new Element("div", {"styles": this.css.filterProcessNode}).inject(this.filterProcessListNode);
  399. filterProcessNode.set("text", process.name+"("+process.count+")");
  400. filterProcessNode.store("process", process);
  401. var _self = this;
  402. filterProcessNode.addEvent("click", function(){
  403. _self.setCurrentProcess(this);
  404. _self.reloadWorks();
  405. });
  406. },
  407. setCurrentProcess: function(node){
  408. if (this.currentProcessNode) this.currentProcessNode.setStyles(this.css.filterProcessNode);
  409. node.setStyles(this.css.filterProcessNode_current);
  410. this.currentProcessNode = node;
  411. var process = node.retrieve("process");
  412. this.filter = {"processList": [{"name": process.name, "value": process.value}]};
  413. },
  414. reloadWorks: function(){
  415. this.clearWorks();
  416. this.setFilterConditions();
  417. this.createWorkListHead();
  418. this.loadElementList();
  419. },
  420. loadContentNode: function(){
  421. this.elementContentNode = new Element("div", {
  422. "styles": this.css.elementContentNode
  423. }).inject(this.node);
  424. this.elementContentListNode = new Element("div", {
  425. "styles": this.css.elementContentListNode
  426. }).inject(this.elementContentNode);
  427. this.createWorkListHead();
  428. this.setContentSize();
  429. this.setContentSizeFun = this.setContentSize.bind(this);
  430. this.app.addEvent("resize", this.setContentSizeFun);
  431. },
  432. setNodeScroll: function(){
  433. //MWF.require("MWF.widget.DragScroll", function(){
  434. // new MWF.widget.DragScroll(this.elementContentNode);
  435. //}.bind(this));
  436. //MWF.require("MWF.widget.ScrollBar", function(){
  437. // new MWF.widget.ScrollBar(this.elementContentNode, {"indent": false});
  438. //}.bind(this));
  439. var _self = this;
  440. this.elementContentNode.addEvent("scroll", function(){
  441. var y = _self.elementContentNode.scrollTop.toFloat();
  442. var scrollSize = _self.elementContentNode.getScrollSize();
  443. var clientSize = _self.elementContentNode.getSize();
  444. var scrollHeight = scrollSize.y-clientSize.y;
  445. if (y+200>scrollHeight) {
  446. if (!_self.isItemsLoaded) _self.loadElementList();
  447. }
  448. });
  449. //
  450. //var _self = this;
  451. //MWF.require("MWF.widget.ScrollBar", function(){
  452. // new MWF.widget.ScrollBar(this.elementContentNode, {
  453. // "indent": false,"style":"xApp_TaskList", "where": "before", "distance": 30, "friction": 4, "axis": {"x": false, "y": true},
  454. // "onScroll": function(y){
  455. // var scrollSize = _self.elementContentNode.getScrollSize();
  456. // var clientSize = _self.elementContentNode.getSize();
  457. // var scrollHeight = scrollSize.y-clientSize.y;
  458. // if (y+200>scrollHeight) {
  459. // if (!_self.isItemsLoaded) _self.loadElementList();
  460. // }
  461. // }
  462. // });
  463. //}.bind(this));
  464. },
  465. createWorkListHead: function(){
  466. var headNode = new Element("div", {"styles": this.css.workItemHeadNode}).inject(this.elementContentListNode);
  467. var html = "<div class='headArea1Node'><div class='checkAreaHeadNode'></div><div class='iconAreaHeadNode'></div><div class='titleAreaHeadNode'>"+this.app.lp.workTitle+"</div></div>" +
  468. "<div class='headArea2Node'><div class='statusAreaHeadNode'>"+this.app.lp.status+"</div><div class='activityAreaHeadNode'>"+this.app.lp.activity+"</div></div>" +
  469. "<div class='headArea3Node'><div class='actionAreaHeadNode'>"+this.app.lp.action+"</div><div class='expireAreaHeadNode'>"+this.app.lp.expire+"</div><div class='personAreaHeadNode'>"+this.app.lp.person+"</div></div>";
  470. headNode.set("html", html);
  471. headNode.getElement(".headArea1Node").setStyles(this.css.headArea1Node);
  472. headNode.getElement(".headArea2Node").setStyles(this.css.headArea2Node);
  473. headNode.getElement(".headArea3Node").setStyles(this.css.headArea3Node);
  474. headNode.getElement(".checkAreaHeadNode").setStyles(this.css.checkAreaHeadNode);
  475. headNode.getElement(".iconAreaHeadNode").setStyles(this.css.iconAreaHeadNode);
  476. headNode.getElement(".titleAreaHeadNode").setStyles(this.css.titleAreaHeadNode);
  477. headNode.getElement(".statusAreaHeadNode").setStyles(this.css.statusAreaHeadNode);
  478. headNode.getElement(".activityAreaHeadNode").setStyles(this.css.activityAreaHeadNode);
  479. headNode.getElement(".personAreaHeadNode").setStyles(this.css.personAreaHeadNode);
  480. headNode.getElement(".actionAreaHeadNode").setStyles(this.css.actionAreaHeadNode);
  481. headNode.getElement(".expireAreaHeadNode").setStyles(this.css.expireAreaHeadNode);
  482. },
  483. createCreateElementNode: function(){},
  484. setContentSize: function(){
  485. var toolbarSize = this.toolbarNode.getSize();
  486. var nodeSize = this.node.getSize();
  487. var pt = this.elementContentNode.getStyle("padding-top").toFloat();
  488. var pb = this.elementContentNode.getStyle("padding-bottom").toFloat();
  489. var filterSize = this.filterNode.getSize();
  490. var filterConditionSize = this.filterConditionNode.getSize();
  491. var height = nodeSize.y-toolbarSize.y-pt-pb-filterSize.y-filterConditionSize.y;
  492. this.elementContentNode.setStyle("height", ""+height+"px");
  493. this.pageCount = (height/40).toInt()+5;
  494. if (this.items.length<this.pageCount){
  495. this.loadElementList(this.pageCount-this.items.length);
  496. }
  497. if (this.options.noCreate) this.createElementNode.destroy();
  498. },
  499. _getCurrentPageData: function(callback, count){
  500. var id = (this.items.length) ? this.items[this.items.length-1].data.id : "(0)";
  501. if (this.filter){
  502. var filterData = {};
  503. Object.each(this.filter, function(v, k){
  504. if (k!="key"){
  505. if (!filterData[k]) filterData[k] = [];
  506. v.each(function(o){
  507. filterData[k].push(o.value);
  508. });
  509. }else{
  510. filterData[k] = v;
  511. }
  512. });
  513. this.actions.listWorkFilterManage(id, count || this.pageCount, this.app.options.id, filterData, function(json){
  514. if (callback) callback(json);
  515. });
  516. }else{
  517. this.actions.listWorkNextManage(id, count || this.pageCount, this.app.options.id, function(json){
  518. if (callback) callback(json);
  519. });
  520. }
  521. },
  522. loadElementList: function(count){
  523. if (!this.isItemsLoaded){
  524. if (!this.isItemLoadding){
  525. this.isItemLoadding = true;
  526. this._getCurrentPageData(function(json){
  527. this.count = json.count;
  528. if (!this.isCountShow){
  529. this.filterAllProcessNode.getFirst("span").set("text", "("+this.count+")");
  530. this.isCountShow = true;
  531. }
  532. if (json.count<=this.items.length){
  533. this.isItemsLoaded = true;
  534. }
  535. json.data.each(function(data){
  536. if (!this.works[data.id]){
  537. var item = this._createItem(data);
  538. this.items.push(item);
  539. this.works[data.id] = item;
  540. }
  541. }.bind(this));
  542. this.isItemLoadding = false;
  543. if (this.loadItemQueue>0){
  544. this.loadItemQueue--;
  545. this.loadElementList();
  546. }
  547. this.mask.hide();
  548. }.bind(this), count);
  549. }else{
  550. this.loadItemQueue++;
  551. }
  552. }
  553. },
  554. _createItem: function(data){
  555. return new MWF.xApplication.process.Application.WorkExplorer.Work(data, this);
  556. },
  557. removeWork: function(work, all){
  558. this.actions.removeWork(work.data.id, this.app.options.id, all, function(json){
  559. json.data.each(function(item){
  560. this.items.erase(this.works[item.id]);
  561. this.works[item.id].destroy();
  562. MWF.release(this.works[item.id]);
  563. delete this.works[item.id];
  564. }.bind(this));
  565. }.bind(this));
  566. }
  567. });
  568. MWF.xApplication.process.Application.WorkExplorer.Work = new Class({
  569. initialize: function(data, explorer, relative){
  570. this.explorer = explorer;
  571. this.data = data;
  572. this.container = this.explorer.elementContentListNode;
  573. this.relative = relative;
  574. this.css = this.explorer.css;
  575. this.tasks = [];
  576. this.dones = [];
  577. this.reads = [];
  578. this.readeds = [];
  579. this.taskChildren = {};
  580. this.doneChildren = {};
  581. this.readChildren = {};
  582. this.readedChildren = {};
  583. this.relativeWorks = [];
  584. this.load();
  585. },
  586. load: function(){
  587. this.node = new Element("div", {"styles": this.css.workItemNode});
  588. if (this.relative){
  589. this.node.inject(this.relative.node, "after");
  590. }else{
  591. this.node.inject(this.container);
  592. }
  593. this.workAreaNode = new Element("div", {"styles": this.css.workItemWorkNode}).inject(this.node);
  594. //this.otherWorkAreaNode = new Element("div", {"styles": this.css.workItemWorkNode}).inject(this.node);
  595. var html = "<div class='area1Node'><div class='checkAreaNode'></div><div class='iconAreaNode'></div><div class='titleAreaNode'><div class='titleAreaTextNode'>"+this.data.title+"</div></div></div>" +
  596. "<div class='area2Node'><div class='statusAreaNode'></div><div class='activityAreaNode'><div class='activityAreaTextNode'>"+this.data.activityName+"</div></div></div>" +
  597. "<div class='area3Node'><div class='actionAreaNode'></div><div class='expireAreaNode'></div><div class='personAreaNode'></div></div>";
  598. this.workAreaNode.set("html", html);
  599. this.workAreaNode.getElement(".area1Node").setStyles(this.css.headArea1Node);
  600. this.workAreaNode.getElement(".area2Node").setStyles(this.css.headArea2Node);
  601. this.workAreaNode.getElement(".area3Node").setStyles(this.css.headArea3Node);
  602. this.checkAreaNode = this.workAreaNode.getElement(".checkAreaNode").setStyles(this.css.checkAreaHeadNode);
  603. this.iconAreaNode = this.workAreaNode.getElement(".iconAreaNode").setStyles(this.css.iconAreaHeadNode);
  604. this.titleAreaNode = this.workAreaNode.getElement(".titleAreaNode").setStyles(this.css.titleAreaHeadNode);
  605. this.statusAreaNode = this.workAreaNode.getElement(".statusAreaNode").setStyles(this.css.statusAreaHeadNode);
  606. this.activityAreaNode = this.workAreaNode.getElement(".activityAreaNode").setStyles(this.css.activityAreaHeadNode);
  607. this.personAreaNode = this.workAreaNode.getElement(".personAreaNode").setStyles(this.css.personAreaHeadNode);
  608. this.actionAreaNode = this.workAreaNode.getElement(".actionAreaNode").setStyles(this.css.actionAreaHeadNode);
  609. this.expireAreaNode = this.workAreaNode.getElement(".expireAreaNode").setStyles(this.css.expireAreaHeadNode);
  610. this.activityAreaTextNode = this.workAreaNode.getElement(".activityAreaTextNode").setStyles(this.css.activityAreaTextNode);
  611. this.titleAreaTextNode = this.workAreaNode.getElement(".titleAreaTextNode").setStyles(this.css.titleAreaTextNode);
  612. //expireAreaNode
  613. if (this.data.expireTime){
  614. var d = Date.parse(this.data.expireTime);
  615. var today = new Date();
  616. if (today.diff(d, "second")<0){
  617. this.expireAreaNode.setStyle("color", "#FF0000");
  618. }
  619. this.expireAreaNode.set("text", this.data.expireTime);
  620. }else{
  621. this.expireAreaNode.set("text", this.explorer.app.lp.noExpire);
  622. }
  623. this.expireAreaNode.setStyles(this.css.expireAreaNode);
  624. //这是一段测试----------------------
  625. //if (this.data.rank==1){
  626. // this.checkAreaNode.setStyles({
  627. // "min-height": "40px",
  628. // "height": "100%",
  629. // "background": "url("+"/x_component_process_Application/$WorkExplorer/default/icon/groupTop.png) no-repeat center bottom",
  630. // });
  631. //}
  632. //if (this.data.rank==2 || this.data.rank==3){
  633. // this.checkAreaNode.setStyles({
  634. // "min-height": "40px",
  635. // "height": "100%",
  636. // "background": "url("+"/x_component_process_Application/$WorkExplorer/default/icon/groupCenter.png) repeat center top",
  637. // });
  638. //}
  639. //if (this.data.rank==4){
  640. // this.checkAreaNode.setStyles({
  641. // "min-height": "40px",
  642. // "height": "100%",
  643. // "background": "url("+"/x_component_process_Application/$WorkExplorer/default/icon/groupBottom.png) no-repeat center top",
  644. // });
  645. //}
  646. //这是一段测试----------------------
  647. if (!this.data.control.allowVisit){
  648. this.node.setStyles(this.css.workItemNode_noread);
  649. this.checkAreaNode.setStyles(this.css.actionStopWorkNode);
  650. this.actionAreaNode.setStyles(this.css.actionStopWorkActionNode);
  651. }
  652. this.iconAreaNode.setStyles(this.css.iconWorkNode);
  653. this.titleAreaNode.setStyles(this.css.titleWorkNode);
  654. this.setPersonData();
  655. this.setStatusData();
  656. this.setActions();
  657. this.setEvents();
  658. if (!this.relative) this.listRelatives();
  659. },
  660. reload: function(callback){
  661. if (this.relative){
  662. this.relative.reload();
  663. }else{
  664. this.explorer.actions.getWork(this.data.id, function(json){
  665. this.data = json.data;
  666. this.titleAreaTextNode.set("text", this.data.title);
  667. this.activityAreaTextNode.set("text", this.data.activityName);
  668. this.statusAreaNode.empty();
  669. this.setStatusData();
  670. if (this.relativeWorks.length){
  671. this.relativeWorks.each(function(work){
  672. work.destroy();
  673. });
  674. }
  675. this.relativeWorks = [];
  676. this.listRelatives();
  677. if (callback) callback();
  678. }.bind(this));
  679. }
  680. },
  681. listRelatives: function() {
  682. if (this.data.splitting){
  683. this.explorer.actions.listRelatives(this.data.id, function(json){
  684. if (json.data){
  685. if (json.data.length) this.loadRelativeWorks(json.data);
  686. }
  687. }.bind(this));
  688. }
  689. },
  690. loadRelativeWorks: function(list){
  691. this.checkAreaNode.setStyles(this.css.relativeTop);
  692. this.workAreaNode.setStyle("height", "40px");
  693. for (var idx=list.length-1; idx>=0; idx--){
  694. var data = list[idx];
  695. var work = this.explorer.works[data.id];
  696. if (work){
  697. work.node.inject(this.node, "after");
  698. work.relative = this;
  699. }else{
  700. var work = new MWF.xApplication.process.Application.WorkExplorer.Work(data, this.explorer, this);
  701. this.explorer.works[data.id] = work
  702. }
  703. work.workAreaNode.setStyle("height", "40px");
  704. if (idx == (list.length-1)){
  705. work.checkAreaNode.setStyles(this.css.relativeBottom);
  706. }else{
  707. work.checkAreaNode.setStyles(this.css.relativeCenter);
  708. }
  709. this.relativeWorks.push(work);
  710. }
  711. },
  712. setEvents: function(){
  713. if (this.openNode){
  714. this.openNode.addEvents({
  715. "mouseover": function(){this.openNode.setStyles(this.css.actionOpenNode_over);}.bind(this),
  716. "mouseout": function(){this.openNode.setStyles(this.css.actionOpenNode);}.bind(this),
  717. "mousedown": function(){this.openNode.setStyles(this.css.actionOpenNode_down);}.bind(this),
  718. "mouseup": function(){this.openNode.setStyles(this.css.actionOpenNode_over);}.bind(this),
  719. "click": function(e){
  720. this.openWork(e);
  721. }.bind(this)
  722. });
  723. }
  724. if (this.processNode){
  725. this.processNode.addEvents({
  726. "mouseover": function(){this.processNode.setStyles(this.css.actionProcessNode_over);}.bind(this),
  727. "mouseout": function(){this.processNode.setStyles(this.css.actionProcessNode);}.bind(this),
  728. "mousedown": function(){this.processNode.setStyles(this.css.actionProcessNode_down);}.bind(this),
  729. "mouseup": function(){this.processNode.setStyles(this.css.actionProcessNode_over);}.bind(this),
  730. "click": function(e){
  731. this.processWork(e);
  732. }.bind(this)
  733. });
  734. }
  735. if (this.rerouteNode){
  736. this.rerouteNode.addEvents({
  737. "mouseover": function(){this.rerouteNode.setStyles(this.css.actionRerouteNode_over);}.bind(this),
  738. "mouseout": function(){this.rerouteNode.setStyles(this.css.actionRerouteNode);}.bind(this),
  739. "mousedown": function(){this.rerouteNode.setStyles(this.css.actionRerouteNode_down);}.bind(this),
  740. "mouseup": function(){this.rerouteNode.setStyles(this.css.actionRerouteNode_over);}.bind(this),
  741. "click": function(e){
  742. this.rerouteWork(e);
  743. }.bind(this)
  744. });
  745. }
  746. if (this.deleteNode){
  747. this.deleteNode.addEvents({
  748. "mouseover": function(){this.deleteNode.setStyles(this.css.actionDeleteNode_over);}.bind(this),
  749. "mouseout": function(){this.deleteNode.setStyles(this.css.actionDeleteNode);}.bind(this),
  750. "mousedown": function(){this.deleteNode.setStyles(this.css.actionDeleteNode_down);}.bind(this),
  751. "mouseup": function(){this.deleteNode.setStyles(this.css.actionDeleteNode_over);}.bind(this),
  752. "click": function(e){
  753. this.remove(e);
  754. }.bind(this)
  755. });
  756. }
  757. if (this.data.control.allowVisit) {
  758. this.workAreaNode.addEvents({
  759. "mouseover": function(){if (!this.readyRemove && !this.readyFlow) this.workAreaNode.setStyles(this.css.workItemWorkNode_over);}.bind(this),
  760. "mouseout": function(){if (!this.readyRemove && !this.readyFlow) this.workAreaNode.setStyles(this.css.workItemWorkNode);}.bind(this)
  761. });
  762. this.titleAreaNode.addEvent("click", function(){
  763. this.loadChild();
  764. }.bind(this));
  765. }
  766. },
  767. processWork: function(e){
  768. var lp = this.explorer.app.lp;
  769. var text = lp.flowWork.replace(/{title}/g, this.data.title);
  770. var _self = this;
  771. this.workAreaNode.setStyles(this.css.workItemWorkNode_action);
  772. this.readyFlow = true;
  773. this.explorer.app.confirm("warn", e, lp.flowWorkTitle, text, 380, 130, function(){
  774. debugger;
  775. _self.explorer.actions.flowWork(_self.data.id, {}, function(json){
  776. if (json.data.id){
  777. _self.explorer.actions.getWork(_self.data.id, function(workJson){
  778. _self.workAreaNode.setStyles(_self.css.workItemWorkNode);
  779. _self.readyFlow = false;
  780. _self.reload();
  781. }.bind(this));
  782. }else{
  783. _self.reload();
  784. }
  785. this.close();
  786. }.bind(this), function(){
  787. _self.workAreaNode.setStyles(_self.css.workItemWorkNode);
  788. _self.readyFlow = false;
  789. _self.reload();
  790. this.close();
  791. }.bind(this));
  792. }, function(){
  793. _self.workAreaNode.setStyles(_self.css.workItemWorkNode);
  794. _self.readyFlow = false;
  795. this.close();
  796. });
  797. },
  798. rerouteWork: function(){
  799. var lp = this.explorer.app.lp;
  800. this.workAreaNode.setStyles(this.css.workItemWorkNode_action);
  801. this.readyReroute = true;
  802. MWF.require("MWF.xDesktop.Dialog", function(){
  803. var width = 480;
  804. var height = 160;
  805. var p = MWF.getCenterPosition(this.explorer.app.content, width, height);
  806. var _self = this;
  807. var _self = this;
  808. var dlg = new MWF.xDesktop.Dialog({
  809. "title": lp.reroute,
  810. "style": "work",
  811. "top": p.y-100,
  812. "left": p.x,
  813. "fromTop": p.y-100,
  814. "fromLeft": p.x,
  815. "width": width,
  816. "height": height,
  817. "url": this.explorer.app.path+"reroute.html",
  818. "container": this.explorer.app.content,
  819. "isClose": true,
  820. "onPostShow": function(){
  821. $("rerouteWork_okButton").addEvent("click", function(){
  822. _self.doRerouteWork(this);
  823. }.bind(this));
  824. $("rerouteWork_cancelButton").addEvent("click", function(){
  825. this.close();
  826. }.bind(this));
  827. var select = $("rerouteWork_selectActivity");
  828. _self.explorer.actions.getRerouteTo(_self.data.process, function(json){
  829. if (json.data.agentList) json.data.agentList.each(function(activity){
  830. new Element("option", {
  831. "value": activity.id+"#agent",
  832. "text": activity.name
  833. }).inject(select);
  834. }.bind(_self));
  835. if (json.data.cancelList) json.data.cancelList.each(function(activity){
  836. new Element("option", {
  837. "value": activity.id+"#cancel",
  838. "text": activity.name
  839. }).inject(select);
  840. }.bind(_self));
  841. if (json.data.choiceList) json.data.choiceList.each(function(activity){
  842. new Element("option", {
  843. "value": activity.id+"#choice",
  844. "text": activity.name
  845. }).inject(select);
  846. }.bind(_self));
  847. if (json.data.conditionList) json.data.conditionList.each(function(activity){
  848. new Element("option", {
  849. "value": activity.id+"#condition",
  850. "text": activity.name
  851. }).inject(select);
  852. }.bind(_self));
  853. if (json.data.delayList) json.data.delayList.each(function(activity){
  854. new Element("option", {
  855. "value": activity.id+"#delay",
  856. "text": activity.name
  857. }).inject(select);
  858. }.bind(_self));
  859. if (json.data.embedList) json.data.embedList.each(function(activity){
  860. new Element("option", {
  861. "value": activity.id+"#embed",
  862. "text": activity.name
  863. }).inject(select);
  864. }.bind(_self));
  865. if (json.data.endList) json.data.endList.each(function(activity){
  866. new Element("option", {
  867. "value": activity.id+"#end",
  868. "text": activity.name
  869. }).inject(select);
  870. }.bind(_self));
  871. if (json.data.invokeList) json.data.invokeList.each(function(activity){
  872. new Element("option", {
  873. "value": activity.id+"#invoke",
  874. "text": activity.name
  875. }).inject(select);
  876. }.bind(_self));
  877. if (json.data.manualList) json.data.manualList.each(function(activity){
  878. new Element("option", {
  879. "value": activity.id+"#manual",
  880. "text": activity.name
  881. }).inject(select);
  882. }.bind(_self));
  883. if (json.data.mergeList) json.data.mergeList.each(function(activity){
  884. new Element("option", {
  885. "value": activity.id+"#merge",
  886. "text": activity.name
  887. }).inject(select);
  888. }.bind(_self));
  889. if (json.data.messageList) json.data.messageList.each(function(activity){
  890. new Element("option", {
  891. "value": activity.id+"#message",
  892. "text": activity.name
  893. }).inject(select);
  894. }.bind(_self));
  895. if (json.data.parallelList) json.data.parallelList.each(function(activity){
  896. new Element("option", {
  897. "value": activity.id+"#parallel",
  898. "text": activity.name
  899. }).inject(select);
  900. }.bind(_self));
  901. if (json.data.serviceList) json.data.serviceList.each(function(activity){
  902. new Element("option", {
  903. "value": activity.id+"#service",
  904. "text": activity.name
  905. }).inject(select);
  906. }.bind(_self));
  907. if (json.data.splitList) json.data.splitList.each(function(activity){
  908. new Element("option", {
  909. "value": activity.id+"#split",
  910. "text": activity.name
  911. }).inject(select);
  912. }.bind(_self));
  913. }.bind(_self));
  914. }
  915. });
  916. dlg.show();
  917. }.bind(this));
  918. },
  919. doRerouteWork: function(dlg){
  920. var opinion = $("rerouteWork_opinion").get("value");
  921. var select = $("rerouteWork_selectActivity");
  922. var activity = select.options[select.selectedIndex].get("value");
  923. var activityName = select.options[select.selectedIndex].get("text");
  924. var tmp = activity.split("#");
  925. activity = tmp[0];
  926. var type = tmp[1];
  927. MWF.require("MWF.widget.Mask", function(){
  928. this.mask = new MWF.widget.Mask({"style": "desktop", "zIndex": 50000});
  929. this.mask.loadNode(this.explorer.app.content);
  930. this.rerouteWorkToActivity(activity, type, opinion, function(){
  931. this.explorer.actions.getWork(this.data.id, function(workJson){
  932. this.data = workJson.data;
  933. this.workAreaNode.setStyles(this.css.workItemWorkNode);
  934. this.readyReroute = false;
  935. this.reload();
  936. }.bind(this));
  937. dlg.close();
  938. if (this.mask) {this.mask.hide(); this.mask = null;}
  939. }.bind(this), function(xhr, text, error){
  940. var errorText = error+":"+text;
  941. if (xhr) errorText = xhr.responseText;
  942. this.app.notice("request json error: "+errorText, "error", dlg.node);
  943. if (this.mask) {this.mask.hide(); this.mask = null;}
  944. }.bind(this));
  945. }.bind(this));
  946. },
  947. rerouteWorkToActivity: function(activity, type, opinion, success, failure){
  948. this.explorer.actions.rerouteWork(this.data.id, activity, type, null, function(json){
  949. if (success) success();
  950. }.bind(this), function(xhr, text, error){
  951. if (failure) failure(xhr, text, error);
  952. });
  953. },
  954. openWork: function(e){
  955. var options = {"workId": this.data.id, "isControl": this.explorer.app.options.application.allowControl};
  956. this.explorer.app.desktop.openApplication(e, "process.Work", options);
  957. },
  958. remove: function(e){
  959. var lp = this.explorer.app.lp;
  960. var text = lp.deleteWork.replace(/{title}/g, this.data.title);
  961. var _self = this;
  962. this.workAreaNode.setStyles(this.css.workItemWorkNode_remove);
  963. this.readyRemove = true;
  964. this.explorer.app.confirm("warn", e, lp.deleteWorkTitle, text, 350, 120, function(){
  965. this.close();
  966. _self.explorer.app.confirm("warn", e, lp.deleteWorkTitle, {"html": lp.deleteAllWork}, 400, 220, function(){
  967. var inputs = this.content.getElements("input");
  968. var flag = "";
  969. for (var i=0; i<inputs.length; i++){
  970. if (inputs[i].checked){
  971. flag = inputs[i].get("value");
  972. break;
  973. }
  974. }
  975. if (flag){
  976. if (flag=="all"){
  977. _self.explorer.removeWork(_self, true);
  978. }else{
  979. _self.explorer.removeWork(_self, false);
  980. }
  981. this.close();
  982. }else{
  983. this.content.getElement("#deleteWork_checkInfor").set("text", lp.deleteAllWorkCheck).setStyle("color", "red");
  984. }
  985. }, function(){
  986. //_self.explorer.removeWork(_self, false);
  987. _self.workAreaNode.setStyles(_self.css.workItemWorkNode);
  988. this.close();
  989. });
  990. }, function(){
  991. _self.workAreaNode.setStyles(_self.css.workItemWorkNode);
  992. _self.readyRemove = false;
  993. this.close();
  994. });
  995. },
  996. destroy: function(){
  997. this.node.destroy();
  998. },
  999. loadChild: function(){
  1000. if (!this.childNode){
  1001. this.createChildNode();
  1002. this.listAssignments();
  1003. }else{
  1004. if (this.childNode.getStyle("display")=="none"){
  1005. this.childNode.setStyle("display", "block");
  1006. }else{
  1007. this.childNode.setStyle("display", "none");
  1008. }
  1009. }
  1010. },
  1011. createChildNode: function(){
  1012. this.childNode = new Element("div", {"styles": this.css.workItemChildNode}).inject(this.node);
  1013. this.taskAreaNode = new Element("div", {"styles": this.css.workItemTaskNode}).inject(this.childNode);
  1014. this.doneAreaNode = new Element("div", {"styles": this.css.workItemDonwNode}).inject(this.childNode);
  1015. this.readAreaNode = new Element("div", {"styles": this.css.workItemReadNode}).inject(this.childNode);
  1016. this.readedAreaNode = new Element("div", {"styles": this.css.workItemReadedNode}).inject(this.childNode);
  1017. this.taskAreaTitleAreaNode = new Element("div", {"styles": this.css.workItemListTitleNode}).inject(this.taskAreaNode);
  1018. this.doneAreaTitleAreaNode = new Element("div", {"styles": this.css.workItemListTitleNode}).inject(this.doneAreaNode);
  1019. this.readAreaTitleAreaNode = new Element("div", {"styles": this.css.workItemListTitleNode}).inject(this.readAreaNode);
  1020. this.readedAreaTitleAreaNode = new Element("div", {"styles": this.css.workItemListTitleNode}).inject(this.readedAreaNode);
  1021. var taskAreaTitleNode = new Element("div", {"styles": this.css.workItemTaskTitleNode, "text": this.explorer.app.lp.task}).inject(this.taskAreaTitleAreaNode);
  1022. var doneAreaTitleNode = new Element("div", {"styles": this.css.workItemDoneTitleNode, "text": this.explorer.app.lp.done}).inject(this.doneAreaTitleAreaNode);
  1023. var readAreaTitleNode = new Element("div", {"styles": this.css.workItemReadTitleNode, "text": this.explorer.app.lp.read}).inject(this.readAreaTitleAreaNode);
  1024. var readedAreaTitleNode = new Element("div", {"styles": this.css.workItemReadedTitleNode, "text": this.explorer.app.lp.readed}).inject(this.readedAreaTitleAreaNode);
  1025. this.taskAreaContentNode = new Element("div", {"styles": this.css.taskAreaContentNode}).inject(this.taskAreaNode);
  1026. this.doneAreaContentNode = new Element("div", {"styles": this.css.doneAreaContentNode}).inject(this.doneAreaNode);
  1027. this.readAreaContentNode = new Element("div", {"styles": this.css.readAreaContentNode}).inject(this.readAreaNode);
  1028. this.readedAreaContentNode = new Element("div", {"styles": this.css.readedAreaContentNode}).inject(this.readedAreaNode);
  1029. },
  1030. listAssignments: function(){
  1031. this.explorer.actions.listAssignments(this.data.id, function(json){
  1032. this.listTasks(json.data.taskList);
  1033. this.listDones(json.data.taskCompletedList);
  1034. this.listReads(json.data.readList);
  1035. this.listReadeds(json.data.readCompletedList);
  1036. }.bind(this));
  1037. },
  1038. listTasks: function(list){
  1039. if (list.length){
  1040. list.each(function(data){
  1041. var item = new MWF.xApplication.process.Application.WorkExplorer.Task(data, this.taskAreaContentNode, this.explorer, this);
  1042. this.tasks.push(item);
  1043. this.taskChildren[data.id] = item;
  1044. }.bind(this));
  1045. }else{
  1046. new Element("div", {"styles": this.css.noListText, "text": "["+this.explorer.app.lp.noTask+"]"}).inject(this.taskAreaTitleAreaNode);
  1047. }
  1048. },
  1049. listDones: function(list){
  1050. if (list.length){
  1051. list.each(function(data){
  1052. var item = new MWF.xApplication.process.Application.WorkExplorer.Done(data, this.doneAreaContentNode, this.explorer, this);
  1053. this.dones.push(item);
  1054. this.doneChildren[data.id] = item;
  1055. }.bind(this));
  1056. }else{
  1057. new Element("div", {"styles": this.css.noListText, "text": "["+this.explorer.app.lp.noDone+"]"}).inject(this.doneAreaTitleAreaNode);
  1058. }
  1059. },
  1060. listReads: function(list){
  1061. if (list.length){
  1062. list.each(function(data){
  1063. var item = new MWF.xApplication.process.Application.WorkExplorer.Read(data, this.readAreaContentNode, this.explorer, this);
  1064. this.reads.push(item);
  1065. this.readChildren[data.id] = item;
  1066. }.bind(this));
  1067. }else{
  1068. new Element("div", {"styles": this.css.noListText, "text": "["+this.explorer.app.lp.noRead+"]"}).inject(this.readAreaTitleAreaNode);
  1069. }
  1070. },
  1071. listReadeds: function(list){
  1072. if (list.length){
  1073. list.each(function(data){
  1074. var item = new MWF.xApplication.process.Application.WorkExplorer.Readed(data, this.readedAreaContentNode, this.explorer, this);
  1075. this.readeds.push(item);
  1076. this.readedChildren[data.id] = item;
  1077. }.bind(this));
  1078. }else{
  1079. new Element("div", {"styles": this.css.noListText, "text": "["+this.explorer.app.lp.noReaded+"]"}).inject(this.readedAreaTitleAreaNode);
  1080. }
  1081. },
  1082. setPersonData: function(){
  1083. // var data = {
  1084. // "name": MWF.name.cn(this.data.creatorIdentity),
  1085. // "unitName": (this.data.creatorUnit) ? MWF.name.cn(this.data.creatorUnit) : "",
  1086. // "id": this.data.creatorIdentity
  1087. // };
  1088. this.personAreaNode.set("text", MWF.name.cn(this.data.creatorIdentity)+"("+((this.data.creatorUnit) ? MWF.name.cn(this.data.creatorUnit) : "")+")");
  1089. //new MWF.widget.O2Identity(data, this.personAreaNode, {"style": "work", "lazy": true});
  1090. },
  1091. setStatusData: function(){
  1092. this.createStatusIcon("start");
  1093. this.createStatusIcon("processing");
  1094. this.createStatusIcon("hanging");
  1095. this.statusAreaNode.set("title", this.explorer.app.lp[this.data.workStatus]);
  1096. },
  1097. createStatusIcon: function(name){
  1098. var node = new Element("div", {"styles": this.css.statusIconNode}).inject(this.statusAreaNode);
  1099. var iconName = (this.data.workStatus==name) ? "status_"+name+"_red.png" : "status_"+name+".png";
  1100. var icon = "url("+"/x_component_process_Application/$WorkExplorer/"+this.explorer.options.style+"/icon/"+iconName+")"
  1101. node.setStyle("background-image", icon);
  1102. },
  1103. setActions: function(){
  1104. if (this.data.control.allowVisit){
  1105. this.openNode = new Element("div", {"styles": this.css.actionOpenNode, "title": this.explorer.app.lp.open}).inject(this.actionAreaNode);
  1106. }
  1107. if (this.data.control.allowReroute){
  1108. this.processNode = new Element("div", {"styles": this.css.actionProcessNode, "title": this.explorer.app.lp.flowManager}).inject(this.actionAreaNode);
  1109. }
  1110. if (this.data.control.allowReroute){
  1111. this.rerouteNode = new Element("div", {"styles": this.css.actionRerouteNode, "title": this.explorer.app.lp.reroute}).inject(this.actionAreaNode);
  1112. }
  1113. //if (this.explorer.app.options.application.allowControl){
  1114. if (this.data.control.allowDelete){
  1115. this.deleteNode = new Element("div", {"styles": this.css.actionDeleteNode, "title": this.explorer.app.lp.delete}).inject(this.actionAreaNode);
  1116. }
  1117. },
  1118. removeTask: function(task){
  1119. var id = task.data.id;
  1120. this.explorer.actions.removeTask(id, function(json){
  1121. this.tasks.erase(this.taskChildren[id]);
  1122. this.taskChildren[id].destroy();
  1123. MWF.release(this.taskChildren[id]);
  1124. delete this.taskChildren[id];
  1125. }.bind(this));
  1126. },
  1127. removeDone: function(done){
  1128. var id = done.data.id;
  1129. this.explorer.actions.removeDone(id, function(json){
  1130. this.dones.erase(this.doneChildren[id]);
  1131. this.doneChildren[id].destroy();
  1132. MWF.release(this.doneChildren[id]);
  1133. delete this.doneChildren[id];
  1134. }.bind(this));
  1135. },
  1136. removeRead: function(read){
  1137. var id = read.data.id
  1138. this.explorer.actions.removeRead(id, function(json){
  1139. this.reads.erase(this.readChildren[id]);
  1140. this.readChildren[id].destroy();
  1141. MWF.release(this.readChildren[id]);
  1142. delete this.readChildren[id];
  1143. }.bind(this));
  1144. },
  1145. removeReaded: function(readed){
  1146. var id = readed.data.id
  1147. this.explorer.actions.removeReaded(id, function(json){
  1148. this.readeds.erase(this.readedChildren[id]);
  1149. this.readedChildren[id].destroy();
  1150. MWF.release(this.readedChildren[id]);
  1151. delete this.readedChildren[id];
  1152. }.bind(this));
  1153. }
  1154. });
  1155. MWF.xApplication.process.Application.WorkExplorer.Task = new Class({
  1156. initialize: function (data, container, explorer, work) {
  1157. this.explorer = explorer;
  1158. this.work = work;
  1159. this.data = data;
  1160. this.container = container;
  1161. this.css = this.explorer.css;
  1162. this.load();
  1163. },
  1164. load: function () {
  1165. this.node = new Element("div", {"styles": this.css.taskItemNode}).inject(this.container);
  1166. var taskArea1Node = new Element("div", {"styles": this.css.taskArea1Node}).inject(this.node);
  1167. var taskArea2Node = new Element("div", {"styles": this.css.taskArea2Node}).inject(this.node);
  1168. var taskArea3Node = new Element("div", {"styles": this.css.taskArea3Node}).inject(this.node);
  1169. this.iconAreaNode = new Element("div", {"styles": this.css.taskItemIconAreaNode}).inject(taskArea1Node);
  1170. this.personAreaNode = new Element("div", {"styles": this.css.taskItemPersonAreaNode}).inject(taskArea1Node);
  1171. this.timeAreaNode = new Element("div", {"styles": this.css.taskItemTimeAreaNode}).inject(taskArea2Node);
  1172. this.actionAreaNode = new Element("div", {"styles": this.css.taskItemActionNode}).inject(taskArea3Node);
  1173. this.activityAreaNode = new Element("div", {"styles": this.css.taskItemActivityNode}).inject(taskArea3Node);
  1174. this.setTaskContent();
  1175. this.setActions();
  1176. this.setEvents();
  1177. },
  1178. setTaskContent: function () {
  1179. debugger;
  1180. //var time = new Date().parse(this.data.startTime).format("%Y-%m-%d %H:%M");
  1181. this.personAreaNode.set("text", o2.name.cn(this.data.identity)+"("+o2.name.cn(this.data.unit)+")");
  1182. //new MWF.widget.O2Identity({"name": this.data.identity}, this.personAreaNode, {"style": "task"});
  1183. var time = new Date().parse(this.data.startTime).format("%Y-%m-%d %H:%M");
  1184. this.timeAreaNode.set("text", time);
  1185. this.activityAreaNode.set("text", this.data.activityName);
  1186. },
  1187. setActions: function () {
  1188. //if (this.explorer.app.options.application.allowControl || this.explorer.app.desktop.session.user.name == this.data.person) {
  1189. if (this.data.control.allowReset){
  1190. this.resetNode = new Element("div", {
  1191. "styles": this.css.taskActionResetNode,
  1192. "title": this.explorer.app.lp.reset
  1193. }).inject(this.actionAreaNode);
  1194. }
  1195. //if (this.explorer.app.options.application.allowControl) {
  1196. if (this.data.control.allowProcessing) {
  1197. this.flowNode = new Element("div", {
  1198. "styles": this.css.taskActionFlowNode,
  1199. "title": this.explorer.app.lp.flow
  1200. }).inject(this.actionAreaNode);
  1201. }
  1202. if (this.data.control.allowDelete){
  1203. this.deleteNode = new Element("div", {
  1204. "styles": this.css.taskActionDeleteNode,
  1205. "title": this.explorer.app.lp.delete
  1206. }).inject(this.actionAreaNode);
  1207. }
  1208. },
  1209. setEvents: function () {
  1210. if (this.resetNode) {
  1211. this.resetNode.addEvents({
  1212. "mouseover": function () {
  1213. this.resetNode.setStyles(this.css.taskActionResetNode_over);
  1214. }.bind(this),
  1215. "mouseout": function () {
  1216. this.resetNode.setStyles(this.css.taskActionResetNode);
  1217. }.bind(this),
  1218. "mousedown": function () {
  1219. this.resetNode.setStyles(this.css.taskActionResetNode_down);
  1220. }.bind(this),
  1221. "mouseup": function () {
  1222. this.resetNode.setStyles(this.css.taskActionResetNode_over);
  1223. }.bind(this),
  1224. "click": function () {
  1225. this.reset();
  1226. }.bind(this)
  1227. });
  1228. }
  1229. if (this.flowNode) {
  1230. this.flowNode.addEvents({
  1231. "mouseover": function () {
  1232. this.flowNode.setStyles(this.css.taskActionFlowNode_over);
  1233. }.bind(this),
  1234. "mouseout": function () {
  1235. this.flowNode.setStyles(this.css.taskActionFlowNode);
  1236. }.bind(this),
  1237. "mousedown": function () {
  1238. this.flowNode.setStyles(this.css.taskActionFlowNode_down);
  1239. }.bind(this),
  1240. "mouseup": function () {
  1241. this.flowNode.setStyles(this.css.taskActionFlowNode_over);
  1242. }.bind(this),
  1243. "click": function (e) {
  1244. this.flow(e);
  1245. }.bind(this)
  1246. });
  1247. }
  1248. if (this.deleteNode) {
  1249. this.deleteNode.addEvents({
  1250. "mouseover": function () {
  1251. this.deleteNode.setStyles(this.css.taskActionDeleteNode_over);
  1252. }.bind(this),
  1253. "mouseout": function () {
  1254. this.deleteNode.setStyles(this.css.taskActionDeleteNode);
  1255. }.bind(this),
  1256. "mousedown": function () {
  1257. this.deleteNode.setStyles(this.css.taskActionDeleteNode_down);
  1258. }.bind(this),
  1259. "mouseup": function () {
  1260. this.deleteNode.setStyles(this.css.taskActionDeleteNode_over);
  1261. }.bind(this),
  1262. "click": function (e) {
  1263. this.remove(e);
  1264. }.bind(this)
  1265. });
  1266. }
  1267. },
  1268. reset: function () {
  1269. this.node.setStyles(this.css.taskItemNode_action);
  1270. var options = {
  1271. "type": "identity",
  1272. "title": this.explorer.app.lp.reset,
  1273. "onComplete": function (items) {
  1274. if (items.length) {
  1275. this.resetPeople(items);
  1276. } else {
  1277. this.node.setStyles(this.css.taskItemNode);
  1278. }
  1279. }.bind(this),
  1280. "onCancel": function () {
  1281. this.node.setStyles(this.css.taskItemNode);
  1282. }.bind(this)
  1283. };
  1284. var selector = new MWF.O2Selector(this.explorer.app.content, options);
  1285. },
  1286. resetPeople: function (items) {
  1287. var nameList = [];
  1288. items.each(function(item){
  1289. nameList.push(item.data.distinguishedName);
  1290. });
  1291. var data = {
  1292. "routeName": this.explorer.app.lp.reset,
  1293. "opinion": this.explorer.app.lp.reset+": "+nameList.join(", "),
  1294. "identityList": nameList
  1295. };
  1296. this.explorer.actions.resetTask(this.data.id, data, function(){
  1297. this.work.childNode.destroy();
  1298. this.work.childNode = null;
  1299. this.work.loadChild();
  1300. }.bind(this));
  1301. },
  1302. flow: function(e){
  1303. this.node.setStyles(this.css.taskItemNode_action);
  1304. this.processNode = new Element("div", {"styles": this.css.taskItemFlowNode}).inject(this.explorer.app.content);
  1305. MWF.require("MWF.xDesktop.Dialog", function(){
  1306. var width = 540;
  1307. var height = 260;
  1308. var size = this.explorer.app.content.getSize();
  1309. var x = size.x/2-width/2;
  1310. var y = size.y/2-height/2;
  1311. if (x+parseFloat(width)>size.x){
  1312. x = x-parseFloat(width);
  1313. }
  1314. if (x<0) x = 0;
  1315. if (y+parseFloat(height)>size.y){
  1316. y = y-parseFloat(height);
  1317. }
  1318. if (y<0) y = 0;
  1319. var dlg = new MWF.xDesktop.Dialog({
  1320. "title": "",
  1321. "style": "application",
  1322. "top": y,
  1323. "left": x-20,
  1324. "fromTop":y,
  1325. "fromLeft": x-20,
  1326. "width": width,
  1327. "height": height,
  1328. "content": this.processNode,
  1329. "container": this.explorer.app.content,
  1330. "onPostShow": function(){
  1331. var _self = this;
  1332. MWF.xDesktop.requireApp("process.Work", "Processor", function(){
  1333. new MWF.xApplication.process.Work.Processor(this.processNode, this.data, {
  1334. "style": "task",
  1335. "onCancel": function(){
  1336. dlg.close();
  1337. _self.node.setStyles(_self.css.taskItemNode);
  1338. delete this;
  1339. },
  1340. "onSubmit": function(routeName, opinion){
  1341. _self.submitTask(routeName, opinion, this, dlg);
  1342. delete this;
  1343. }
  1344. })
  1345. }.bind(this));
  1346. }.bind(this)
  1347. });
  1348. dlg.show();
  1349. }.bind(this));
  1350. },
  1351. submitTask: function(routeName, opinion, processer, dlg){
  1352. var data = {
  1353. "routeName": routeName,
  1354. "opinion": opinion
  1355. }
  1356. this.explorer.actions.flowTask(this.data.id, data, function(){
  1357. processer.destroy();
  1358. dlg.close();
  1359. this.work.childNode.destroy();
  1360. this.work.childNode = null;
  1361. this.work.reload(function(){
  1362. this.work.loadChild();
  1363. }.bind(this));
  1364. }.bind(this));
  1365. },
  1366. remove: function(e){
  1367. var lp = this.explorer.app.lp;
  1368. var text = lp.deleteTask.replace(/{people}/g, this.data.person);
  1369. var _self = this;
  1370. this.node.setStyles(this.css.taskItemNode_remove);
  1371. this.explorer.app.confirm("warn", e, lp.deleteTaskTitle, text, 350, 120, function(){
  1372. this.close();
  1373. _self.work.removeTask(_self);
  1374. }, function(){
  1375. _self.node.setStyles(_self.css.taskItemNode);
  1376. this.close();
  1377. });
  1378. },
  1379. destroy: function(){
  1380. this.node.destroy();
  1381. }
  1382. });
  1383. MWF.xApplication.process.Application.WorkExplorer.Done = new Class({
  1384. Extends: MWF.xApplication.process.Application.WorkExplorer.Task,
  1385. setActions: function(){
  1386. //if (this.explorer.app.options.application.allowControl){
  1387. if (this.data.control.allowDelete){
  1388. this.deleteNode = new Element("div", {"styles": this.css.taskActionDeleteNode, "title": this.explorer.app.lp.delete}).inject(this.actionAreaNode);
  1389. }
  1390. },
  1391. setEvents: function(){
  1392. if (this.deleteNode){
  1393. this.deleteNode.addEvents({
  1394. "mouseover": function(){this.deleteNode.setStyles(this.css.taskActionDeleteNode_over);}.bind(this),
  1395. "mouseout": function(){this.deleteNode.setStyles(this.css.taskActionDeleteNode);}.bind(this),
  1396. "mousedown": function(){this.deleteNode.setStyles(this.css.taskActionDeleteNode_down);}.bind(this),
  1397. "mouseup": function(){this.deleteNode.setStyles(this.css.taskActionDeleteNode_over);}.bind(this),
  1398. "click": function(e){
  1399. this.remove(e);
  1400. }.bind(this)
  1401. });
  1402. }
  1403. },
  1404. remove: function(e){
  1405. var lp = this.explorer.app.lp;
  1406. var text = lp.deleteDone.replace(/{people}/g, this.data.person);
  1407. var _self = this;
  1408. this.node.setStyles(this.css.taskItemNode_remove);
  1409. this.explorer.app.confirm("warn", e, lp.deleteDoneTitle, text, 350, 120, function(){
  1410. this.close();
  1411. _self.work.removeDone(_self);
  1412. }, function(){
  1413. _self.node.setStyles(_self.css.taskItemNode);
  1414. this.close();
  1415. });
  1416. }
  1417. });
  1418. MWF.xApplication.process.Application.WorkExplorer.Read = new Class({
  1419. Extends: MWF.xApplication.process.Application.WorkExplorer.Task,
  1420. setActions: function(){
  1421. //if (this.explorer.app.options.application.allowControl || this.explorer.app.desktop.session.user.name==this.data.person){
  1422. if (this.data.control.allowReadReset){
  1423. this.resetNode = new Element("div", {"styles": this.css.taskActionResetNode, "title": this.explorer.app.lp.reset}).inject(this.actionAreaNode);
  1424. }
  1425. if (this.data.control.allowRead){
  1426. this.flagNode = new Element("div", {"styles": this.css.readActionFlagNode, "title": this.explorer.app.lp.flag}).inject(this.actionAreaNode);
  1427. }
  1428. //if (this.explorer.app.options.application.allowControl){
  1429. if (this.data.control.allowDelete){
  1430. this.deleteNode = new Element("div", {"styles": this.css.taskActionDeleteNode, "title": this.explorer.app.lp.delete}).inject(this.actionAreaNode);
  1431. }
  1432. },
  1433. setEvents: function(){
  1434. if (this.resetNode){
  1435. this.resetNode.addEvents({
  1436. "mouseover": function(){this.resetNode.setStyles(this.css.taskActionResetNode_over);}.bind(this),
  1437. "mouseout": function(){this.resetNode.setStyles(this.css.taskActionResetNode);}.bind(this),
  1438. "mousedown": function(){this.resetNode.setStyles(this.css.taskActionResetNode_down);}.bind(this),
  1439. "mouseup": function(){this.resetNode.setStyles(this.css.taskActionResetNode_over);}.bind(this),
  1440. "click": function(){
  1441. this.reset();
  1442. }.bind(this)
  1443. });
  1444. }
  1445. if (this.flagNode){
  1446. this.flagNode.addEvents({
  1447. "mouseover": function(){this.flagNode.setStyles(this.css.readActionFlagNode_over);}.bind(this),
  1448. "mouseout": function(){this.flagNode.setStyles(this.css.readActionFlagNode);}.bind(this),
  1449. "mousedown": function(){this.flagNode.setStyles(this.css.readActionFlagNode_down);}.bind(this),
  1450. "mouseup": function(){this.flagNode.setStyles(this.css.readActionFlagNode_over);}.bind(this),
  1451. "click": function(){
  1452. this.flagRead();
  1453. }.bind(this)
  1454. });
  1455. }
  1456. if (this.deleteNode){
  1457. this.deleteNode.addEvents({
  1458. "mouseover": function(){this.deleteNode.setStyles(this.css.taskActionDeleteNode_over);}.bind(this),
  1459. "mouseout": function(){this.deleteNode.setStyles(this.css.taskActionDeleteNode);}.bind(this),
  1460. "mousedown": function(){this.deleteNode.setStyles(this.css.taskActionDeleteNode_down);}.bind(this),
  1461. "mouseup": function(){this.deleteNode.setStyles(this.css.taskActionDeleteNode_over);}.bind(this),
  1462. "click": function(e){
  1463. this.remove(e);
  1464. }.bind(this)
  1465. });
  1466. }
  1467. },
  1468. reset: function () {
  1469. this.node.setStyles(this.css.taskItemNode_action);
  1470. var options = {
  1471. "type": "identity",
  1472. "title": this.explorer.app.lp.reset,
  1473. "onComplete": function (items) {
  1474. if (items.length) {
  1475. this.resetPeople(items);
  1476. } else {
  1477. this.node.setStyles(this.css.taskItemNode);
  1478. }
  1479. }.bind(this),
  1480. "onCancel": function () {
  1481. this.node.setStyles(this.css.taskItemNode);
  1482. }.bind(this)
  1483. };
  1484. var selector = new MWF.O2Selector(this.explorer.app.content, options);
  1485. },
  1486. resetPeople: function (items) {
  1487. var nameList = [];
  1488. items.each(function(item){
  1489. nameList.push(item.data.distinguishedName);
  1490. });
  1491. var data = {
  1492. "routeName": this.explorer.app.lp.resetTo,
  1493. "opinion": this.explorer.app.lp.resetTo+": "+nameList.join(", "),
  1494. "identityList": nameList
  1495. };
  1496. this.explorer.actions.resetRead(this.data.id, data, function(){
  1497. this.work.childNode.destroy();
  1498. this.work.childNode = null;
  1499. this.work.loadChild();
  1500. }.bind(this));
  1501. },
  1502. remove: function(e){
  1503. var lp = this.explorer.app.lp;
  1504. var text = lp.deleteRead.replace(/{people}/g, this.data.person);
  1505. var _self = this;
  1506. this.node.setStyles(this.css.taskItemNode_remove);
  1507. this.explorer.app.confirm("warn", e, lp.deleteReadTitle, text, 350, 120, function(){
  1508. this.close();
  1509. _self.work.removeRead(_self);
  1510. }, function(){
  1511. _self.node.setStyles(_self.css.taskItemNode);
  1512. this.close();
  1513. });
  1514. },
  1515. flagRead: function(){
  1516. var lp = this.explorer.app.lp;
  1517. var text = lp.flagRead.replace(/{people}/g, this.data.person);
  1518. var _self = this;
  1519. this.node.setStyles(this.css.taskItemNode_action);
  1520. this.explorer.app.confirm("warn", e, lp.flagReadTitle, text, 350, 120, function(){
  1521. this.close();
  1522. _self.doFlagRead();
  1523. }, function(){
  1524. _self.node.setStyles(_self.css.taskItemNode);
  1525. this.close();
  1526. });
  1527. },
  1528. doFlagRead: function(){
  1529. this.explorer.actions.flagRead(this.data.id, {}, function(){
  1530. this.work.childNode.destroy();
  1531. this.work.childNode = null;
  1532. this.work.loadChild();
  1533. }.bind(this));
  1534. }
  1535. });
  1536. MWF.xApplication.process.Application.WorkExplorer.Readed = new Class({
  1537. Extends: MWF.xApplication.process.Application.WorkExplorer.Done,
  1538. remove: function(e){
  1539. var lp = this.explorer.app.lp;
  1540. var text = lp.deleteReaded.replace(/{people}/g, this.data.person);
  1541. var _self = this;
  1542. this.node.setStyles(this.css.taskItemNode_remove);
  1543. this.explorer.app.confirm("warn", e, lp.deleteReadedTitle, text, 350, 120, function(){
  1544. this.close();
  1545. _self.work.removeReaded(_self);
  1546. }, function(){
  1547. _self.node.setStyles(_self.css.taskItemNode);
  1548. this.close();
  1549. });
  1550. }
  1551. });