WorkExplorer.js 77 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751
  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 = 560;
  804. var height = 260;
  805. var p = MWF.getCenterPosition(this.explorer.app.content, width, height);
  806. var _self = this;
  807. var dlg = new MWF.xDesktop.Dialog({
  808. "title": lp.reroute,
  809. "style": "work",
  810. "top": p.y-100,
  811. "left": p.x,
  812. "fromTop": p.y-100,
  813. "fromLeft": p.x,
  814. "width": width,
  815. "height": height,
  816. "url": this.explorer.app.path+"reroute.html",
  817. "container": this.explorer.app.content,
  818. "isClose": true,
  819. "onPostShow": function(){
  820. $("rerouteWork_okButton").addEvent("click", function(){
  821. _self.doRerouteWork(this);
  822. }.bind(this));
  823. $("rerouteWork_cancelButton").addEvent("click", function(){
  824. this.close();
  825. }.bind(this));
  826. var select = $("rerouteWork_selectActivity");
  827. _self.explorer.actions.getRerouteTo(_self.data.process, function(json){
  828. if (json.data.agentList) json.data.agentList.each(function(activity){
  829. new Element("option", {
  830. "value": activity.id+"#agent",
  831. "text": activity.name
  832. }).inject(select);
  833. }.bind(_self));
  834. if (json.data.cancelList) json.data.cancelList.each(function(activity){
  835. new Element("option", {
  836. "value": activity.id+"#cancel",
  837. "text": activity.name
  838. }).inject(select);
  839. }.bind(_self));
  840. if (json.data.choiceList) json.data.choiceList.each(function(activity){
  841. new Element("option", {
  842. "value": activity.id+"#choice",
  843. "text": activity.name
  844. }).inject(select);
  845. }.bind(_self));
  846. if (json.data.conditionList) json.data.conditionList.each(function(activity){
  847. new Element("option", {
  848. "value": activity.id+"#condition",
  849. "text": activity.name
  850. }).inject(select);
  851. }.bind(_self));
  852. if (json.data.delayList) json.data.delayList.each(function(activity){
  853. new Element("option", {
  854. "value": activity.id+"#delay",
  855. "text": activity.name
  856. }).inject(select);
  857. }.bind(_self));
  858. if (json.data.embedList) json.data.embedList.each(function(activity){
  859. new Element("option", {
  860. "value": activity.id+"#embed",
  861. "text": activity.name
  862. }).inject(select);
  863. }.bind(_self));
  864. if (json.data.endList) json.data.endList.each(function(activity){
  865. new Element("option", {
  866. "value": activity.id+"#end",
  867. "text": activity.name
  868. }).inject(select);
  869. }.bind(_self));
  870. if (json.data.invokeList) json.data.invokeList.each(function(activity){
  871. new Element("option", {
  872. "value": activity.id+"#invoke",
  873. "text": activity.name
  874. }).inject(select);
  875. }.bind(_self));
  876. if (json.data.manualList) json.data.manualList.each(function(activity){
  877. new Element("option", {
  878. "value": activity.id+"#manual",
  879. "text": activity.name
  880. }).inject(select);
  881. }.bind(_self));
  882. if (json.data.mergeList) json.data.mergeList.each(function(activity){
  883. new Element("option", {
  884. "value": activity.id+"#merge",
  885. "text": activity.name
  886. }).inject(select);
  887. }.bind(_self));
  888. if (json.data.messageList) json.data.messageList.each(function(activity){
  889. new Element("option", {
  890. "value": activity.id+"#message",
  891. "text": activity.name
  892. }).inject(select);
  893. }.bind(_self));
  894. if (json.data.parallelList) json.data.parallelList.each(function(activity){
  895. new Element("option", {
  896. "value": activity.id+"#parallel",
  897. "text": activity.name
  898. }).inject(select);
  899. }.bind(_self));
  900. if (json.data.serviceList) json.data.serviceList.each(function(activity){
  901. new Element("option", {
  902. "value": activity.id+"#service",
  903. "text": activity.name
  904. }).inject(select);
  905. }.bind(_self));
  906. if (json.data.splitList) json.data.splitList.each(function(activity){
  907. new Element("option", {
  908. "value": activity.id+"#split",
  909. "text": activity.name
  910. }).inject(select);
  911. }.bind(_self));
  912. }.bind(_self));
  913. var selPeopleButton = this.content.getElement(".rerouteWork_selPeopleButton");
  914. selPeopleButton.addEvent("click", function () {
  915. _self.selectReroutePeople(this);
  916. }.bind(this));
  917. }
  918. });
  919. dlg.show();
  920. }.bind(this));
  921. },
  922. selectReroutePeople: function(dlg){
  923. var names = dlg.identityList || [];
  924. var areaNode = dlg.content.getElement(".rerouteWork_selPeopleArea");
  925. var options = {
  926. "values": names,
  927. "type": "identity",
  928. "count": 0,
  929. "title": this.explorer.app.lp.reroute,
  930. "onComplete": function (items) {
  931. areaNode.empty();
  932. var identityList = [];
  933. items.each(function (item) {
  934. new MWF.widget.O2Identity(item.data, areaNode, { "style": "reset" });
  935. identityList.push(item.data.distinguishedName);
  936. }.bind(this));
  937. dlg.identityList = identityList;
  938. }.bind(this)
  939. };
  940. MWF.xDesktop.requireApp("Selector", "package", function () {
  941. var selector = new MWF.O2Selector(this.explorer.app.content, options);
  942. }.bind(this));
  943. },
  944. doRerouteWork: function(dlg){
  945. var opinion = $("rerouteWork_opinion").get("value");
  946. var select = $("rerouteWork_selectActivity");
  947. var activity = select.options[select.selectedIndex].get("value");
  948. var activityName = select.options[select.selectedIndex].get("text");
  949. var tmp = activity.split("#");
  950. activity = tmp[0];
  951. var type = tmp[1];
  952. var nameArr = [];
  953. var names = dlg.identityList || [];
  954. names.each(function (n) { nameArr.push(n); });
  955. MWF.require("MWF.widget.Mask", function(){
  956. this.mask = new MWF.widget.Mask({"style": "desktop", "zIndex": 50000});
  957. this.mask.loadNode(this.explorer.app.content);
  958. this.rerouteWorkToActivity(activity, type, opinion, nameArr, function(){
  959. this.explorer.actions.getWork(this.data.id, function(workJson){
  960. this.data = workJson.data;
  961. this.workAreaNode.setStyles(this.css.workItemWorkNode);
  962. this.readyReroute = false;
  963. this.reload();
  964. }.bind(this));
  965. dlg.close();
  966. if (this.mask) {this.mask.hide(); this.mask = null;}
  967. }.bind(this), function(xhr, text, error){
  968. var errorText = error+":"+text;
  969. if (xhr) errorText = xhr.responseText;
  970. this.app.notice("request json error: "+errorText, "error", dlg.node);
  971. if (this.mask) {this.mask.hide(); this.mask = null;}
  972. }.bind(this));
  973. }.bind(this));
  974. },
  975. rerouteWorkToActivity: function(activity, type, opinion, nameArr, success, failure){
  976. var body = {
  977. "activity": activity,
  978. "activityType": type,
  979. "mergeWork": false,
  980. "manualForceTaskIdentityList": nameArr
  981. };
  982. o2.Actions.load("x_processplatform_assemble_surface").WorkAction.V2Reroute(this.data.id, body, function(){
  983. if (success) success();
  984. }.bind(this), function (xhr, text, error) {
  985. if (failure) failure(xhr, text, error);
  986. });
  987. // this.explorer.actions.rerouteWork(this.data.id, activity, type, null, function(json){
  988. // if (success) success();
  989. // }.bind(this), function(xhr, text, error){
  990. // if (failure) failure(xhr, text, error);
  991. // });
  992. },
  993. openWork: function(e){
  994. var options = {"workId": this.data.id, "isControl": this.explorer.app.options.application.allowControl};
  995. this.explorer.app.desktop.openApplication(e, "process.Work", options);
  996. },
  997. remove: function(e){
  998. var lp = this.explorer.app.lp;
  999. var text = lp.deleteWork.replace(/{title}/g, this.data.title);
  1000. var _self = this;
  1001. this.workAreaNode.setStyles(this.css.workItemWorkNode_remove);
  1002. this.readyRemove = true;
  1003. this.explorer.app.confirm("warn", e, lp.deleteWorkTitle, text, 350, 120, function(){
  1004. this.close();
  1005. _self.explorer.app.confirm("warn", e, lp.deleteWorkTitle, {"html": lp.deleteAllWork}, 400, 220, function(){
  1006. var inputs = this.content.getElements("input");
  1007. var flag = "";
  1008. for (var i=0; i<inputs.length; i++){
  1009. if (inputs[i].checked){
  1010. flag = inputs[i].get("value");
  1011. break;
  1012. }
  1013. }
  1014. if (flag){
  1015. if (flag=="all"){
  1016. _self.explorer.removeWork(_self, true);
  1017. }else{
  1018. _self.explorer.removeWork(_self, false);
  1019. }
  1020. this.close();
  1021. }else{
  1022. this.content.getElement("#deleteWork_checkInfor").set("text", lp.deleteAllWorkCheck).setStyle("color", "red");
  1023. }
  1024. }, function(){
  1025. //_self.explorer.removeWork(_self, false);
  1026. _self.workAreaNode.setStyles(_self.css.workItemWorkNode);
  1027. this.close();
  1028. });
  1029. }, function(){
  1030. _self.workAreaNode.setStyles(_self.css.workItemWorkNode);
  1031. _self.readyRemove = false;
  1032. this.close();
  1033. });
  1034. },
  1035. destroy: function(){
  1036. this.node.destroy();
  1037. },
  1038. loadChild: function(){
  1039. if (!this.childNode){
  1040. this.createChildNode();
  1041. this.listAssignments();
  1042. }else{
  1043. if (this.childNode.getStyle("display")=="none"){
  1044. this.childNode.setStyle("display", "block");
  1045. }else{
  1046. this.childNode.setStyle("display", "none");
  1047. }
  1048. }
  1049. },
  1050. createChildNode: function(){
  1051. this.childNode = new Element("div", {"styles": this.css.workItemChildNode}).inject(this.node);
  1052. this.taskAreaNode = new Element("div", {"styles": this.css.workItemTaskNode}).inject(this.childNode);
  1053. this.doneAreaNode = new Element("div", {"styles": this.css.workItemDonwNode}).inject(this.childNode);
  1054. this.readAreaNode = new Element("div", {"styles": this.css.workItemReadNode}).inject(this.childNode);
  1055. this.readedAreaNode = new Element("div", {"styles": this.css.workItemReadedNode}).inject(this.childNode);
  1056. this.taskAreaTitleAreaNode = new Element("div", {"styles": this.css.workItemListTitleNode}).inject(this.taskAreaNode);
  1057. this.doneAreaTitleAreaNode = new Element("div", {"styles": this.css.workItemListTitleNode}).inject(this.doneAreaNode);
  1058. this.readAreaTitleAreaNode = new Element("div", {"styles": this.css.workItemListTitleNode}).inject(this.readAreaNode);
  1059. this.readedAreaTitleAreaNode = new Element("div", {"styles": this.css.workItemListTitleNode}).inject(this.readedAreaNode);
  1060. var taskAreaTitleNode = new Element("div", {"styles": this.css.workItemTaskTitleNode, "text": this.explorer.app.lp.task}).inject(this.taskAreaTitleAreaNode);
  1061. var doneAreaTitleNode = new Element("div", {"styles": this.css.workItemDoneTitleNode, "text": this.explorer.app.lp.done}).inject(this.doneAreaTitleAreaNode);
  1062. var readAreaTitleNode = new Element("div", {"styles": this.css.workItemReadTitleNode, "text": this.explorer.app.lp.read}).inject(this.readAreaTitleAreaNode);
  1063. var readedAreaTitleNode = new Element("div", {"styles": this.css.workItemReadedTitleNode, "text": this.explorer.app.lp.readed}).inject(this.readedAreaTitleAreaNode);
  1064. this.taskAreaContentNode = new Element("div", {"styles": this.css.taskAreaContentNode}).inject(this.taskAreaNode);
  1065. this.doneAreaContentNode = new Element("div", {"styles": this.css.doneAreaContentNode}).inject(this.doneAreaNode);
  1066. this.readAreaContentNode = new Element("div", {"styles": this.css.readAreaContentNode}).inject(this.readAreaNode);
  1067. this.readedAreaContentNode = new Element("div", {"styles": this.css.readedAreaContentNode}).inject(this.readedAreaNode);
  1068. },
  1069. listAssignments: function(){
  1070. this.explorer.actions.listAssignments(this.data.id, function(json){
  1071. this.listTasks(json.data.taskList);
  1072. this.listDones(json.data.taskCompletedList);
  1073. this.listReads(json.data.readList);
  1074. this.listReadeds(json.data.readCompletedList);
  1075. }.bind(this));
  1076. },
  1077. listTasks: function(list){
  1078. if (list.length){
  1079. list.each(function(data){
  1080. var item = new MWF.xApplication.process.Application.WorkExplorer.Task(data, this.taskAreaContentNode, this.explorer, this);
  1081. this.tasks.push(item);
  1082. this.taskChildren[data.id] = item;
  1083. }.bind(this));
  1084. }else{
  1085. new Element("div", {"styles": this.css.noListText, "text": "["+this.explorer.app.lp.noTask+"]"}).inject(this.taskAreaTitleAreaNode);
  1086. }
  1087. },
  1088. listDones: function(list){
  1089. if (list.length){
  1090. list.each(function(data){
  1091. var item = new MWF.xApplication.process.Application.WorkExplorer.Done(data, this.doneAreaContentNode, this.explorer, this);
  1092. this.dones.push(item);
  1093. this.doneChildren[data.id] = item;
  1094. }.bind(this));
  1095. }else{
  1096. new Element("div", {"styles": this.css.noListText, "text": "["+this.explorer.app.lp.noDone+"]"}).inject(this.doneAreaTitleAreaNode);
  1097. }
  1098. },
  1099. listReads: function(list){
  1100. if (list.length){
  1101. list.each(function(data){
  1102. var item = new MWF.xApplication.process.Application.WorkExplorer.Read(data, this.readAreaContentNode, this.explorer, this);
  1103. this.reads.push(item);
  1104. this.readChildren[data.id] = item;
  1105. }.bind(this));
  1106. }else{
  1107. new Element("div", {"styles": this.css.noListText, "text": "["+this.explorer.app.lp.noRead+"]"}).inject(this.readAreaTitleAreaNode);
  1108. }
  1109. },
  1110. listReadeds: function(list){
  1111. if (list.length){
  1112. list.each(function(data){
  1113. var item = new MWF.xApplication.process.Application.WorkExplorer.Readed(data, this.readedAreaContentNode, this.explorer, this);
  1114. this.readeds.push(item);
  1115. this.readedChildren[data.id] = item;
  1116. }.bind(this));
  1117. }else{
  1118. new Element("div", {"styles": this.css.noListText, "text": "["+this.explorer.app.lp.noReaded+"]"}).inject(this.readedAreaTitleAreaNode);
  1119. }
  1120. },
  1121. setPersonData: function(){
  1122. // var data = {
  1123. // "name": MWF.name.cn(this.data.creatorIdentity),
  1124. // "unitName": (this.data.creatorUnit) ? MWF.name.cn(this.data.creatorUnit) : "",
  1125. // "id": this.data.creatorIdentity
  1126. // };
  1127. this.personAreaNode.set("text", MWF.name.cn(this.data.creatorIdentity)+"("+((this.data.creatorUnit) ? MWF.name.cn(this.data.creatorUnit) : "")+")");
  1128. //new MWF.widget.O2Identity(data, this.personAreaNode, {"style": "work", "lazy": true});
  1129. },
  1130. setStatusData: function(){
  1131. this.createStatusIcon("start");
  1132. this.createStatusIcon("processing");
  1133. this.createStatusIcon("hanging");
  1134. this.statusAreaNode.set("title", this.explorer.app.lp[this.data.workStatus]);
  1135. },
  1136. createStatusIcon: function(name){
  1137. var node = new Element("div", {"styles": this.css.statusIconNode}).inject(this.statusAreaNode);
  1138. var iconName = (this.data.workStatus==name) ? "status_"+name+"_red.png" : "status_"+name+".png";
  1139. var icon = "url("+"/x_component_process_Application/$WorkExplorer/"+this.explorer.options.style+"/icon/"+iconName+")"
  1140. node.setStyle("background-image", icon);
  1141. },
  1142. setActions: function(){
  1143. if (this.data.control.allowVisit){
  1144. this.openNode = new Element("div", {"styles": this.css.actionOpenNode, "title": this.explorer.app.lp.open}).inject(this.actionAreaNode);
  1145. }
  1146. if (this.data.control.allowReroute){
  1147. this.processNode = new Element("div", {"styles": this.css.actionProcessNode, "title": this.explorer.app.lp.flowManager}).inject(this.actionAreaNode);
  1148. }
  1149. if (this.data.control.allowReroute){
  1150. this.rerouteNode = new Element("div", {"styles": this.css.actionRerouteNode, "title": this.explorer.app.lp.reroute}).inject(this.actionAreaNode);
  1151. }
  1152. //if (this.explorer.app.options.application.allowControl){
  1153. if (this.data.control.allowDelete){
  1154. this.deleteNode = new Element("div", {"styles": this.css.actionDeleteNode, "title": this.explorer.app.lp.delete}).inject(this.actionAreaNode);
  1155. }
  1156. },
  1157. removeTask: function(task){
  1158. var id = task.data.id;
  1159. this.explorer.actions.removeTask(id, function(json){
  1160. this.tasks.erase(this.taskChildren[id]);
  1161. this.taskChildren[id].destroy();
  1162. MWF.release(this.taskChildren[id]);
  1163. delete this.taskChildren[id];
  1164. }.bind(this));
  1165. },
  1166. removeDone: function(done){
  1167. var id = done.data.id;
  1168. this.explorer.actions.removeDone(id, function(json){
  1169. this.dones.erase(this.doneChildren[id]);
  1170. this.doneChildren[id].destroy();
  1171. MWF.release(this.doneChildren[id]);
  1172. delete this.doneChildren[id];
  1173. }.bind(this));
  1174. },
  1175. removeRead: function(read){
  1176. var id = read.data.id
  1177. this.explorer.actions.removeRead(id, function(json){
  1178. this.reads.erase(this.readChildren[id]);
  1179. this.readChildren[id].destroy();
  1180. MWF.release(this.readChildren[id]);
  1181. delete this.readChildren[id];
  1182. }.bind(this));
  1183. },
  1184. removeReaded: function(readed){
  1185. var id = readed.data.id
  1186. this.explorer.actions.removeReaded(id, function(json){
  1187. this.readeds.erase(this.readedChildren[id]);
  1188. this.readedChildren[id].destroy();
  1189. MWF.release(this.readedChildren[id]);
  1190. delete this.readedChildren[id];
  1191. }.bind(this));
  1192. }
  1193. });
  1194. MWF.xApplication.process.Application.WorkExplorer.Task = new Class({
  1195. initialize: function (data, container, explorer, work) {
  1196. this.explorer = explorer;
  1197. this.work = work;
  1198. this.data = data;
  1199. this.container = container;
  1200. this.css = this.explorer.css;
  1201. this.load();
  1202. },
  1203. load: function () {
  1204. this.node = new Element("div", {"styles": this.css.taskItemNode}).inject(this.container);
  1205. var taskArea1Node = new Element("div", {"styles": this.css.taskArea1Node}).inject(this.node);
  1206. var taskArea2Node = new Element("div", {"styles": this.css.taskArea2Node}).inject(this.node);
  1207. var taskArea3Node = new Element("div", {"styles": this.css.taskArea3Node}).inject(this.node);
  1208. this.iconAreaNode = new Element("div", {"styles": this.css.taskItemIconAreaNode}).inject(taskArea1Node);
  1209. this.personAreaNode = new Element("div", {"styles": this.css.taskItemPersonAreaNode}).inject(taskArea1Node);
  1210. this.timeAreaNode = new Element("div", {"styles": this.css.taskItemTimeAreaNode}).inject(taskArea2Node);
  1211. this.actionAreaNode = new Element("div", {"styles": this.css.taskItemActionNode}).inject(taskArea3Node);
  1212. this.activityAreaNode = new Element("div", {"styles": this.css.taskItemActivityNode}).inject(taskArea3Node);
  1213. this.setTaskContent();
  1214. this.setActions();
  1215. this.setEvents();
  1216. },
  1217. setTaskContent: function () {
  1218. debugger;
  1219. //var time = new Date().parse(this.data.startTime).format("%Y-%m-%d %H:%M");
  1220. this.personAreaNode.set("text", o2.name.cn(this.data.identity)+"("+o2.name.cn(this.data.unit)+")");
  1221. //new MWF.widget.O2Identity({"name": this.data.identity}, this.personAreaNode, {"style": "task"});
  1222. var time = new Date().parse(this.data.startTime).format("%Y-%m-%d %H:%M");
  1223. this.timeAreaNode.set("text", time);
  1224. this.activityAreaNode.set("text", this.data.activityName);
  1225. },
  1226. setActions: function () {
  1227. //if (this.explorer.app.options.application.allowControl || this.explorer.app.desktop.session.user.name == this.data.person) {
  1228. if (this.data.control.allowReset){
  1229. this.resetNode = new Element("div", {
  1230. "styles": this.css.taskActionResetNode,
  1231. "title": this.explorer.app.lp.reset
  1232. }).inject(this.actionAreaNode);
  1233. }
  1234. //if (this.explorer.app.options.application.allowControl) {
  1235. if (this.data.control.allowProcessing) {
  1236. this.flowNode = new Element("div", {
  1237. "styles": this.css.taskActionFlowNode,
  1238. "title": this.explorer.app.lp.flow
  1239. }).inject(this.actionAreaNode);
  1240. }
  1241. if (this.data.control.allowDelete){
  1242. this.deleteNode = new Element("div", {
  1243. "styles": this.css.taskActionDeleteNode,
  1244. "title": this.explorer.app.lp.delete
  1245. }).inject(this.actionAreaNode);
  1246. }
  1247. },
  1248. setEvents: function () {
  1249. if (this.resetNode) {
  1250. this.resetNode.addEvents({
  1251. "mouseover": function () {
  1252. this.resetNode.setStyles(this.css.taskActionResetNode_over);
  1253. }.bind(this),
  1254. "mouseout": function () {
  1255. this.resetNode.setStyles(this.css.taskActionResetNode);
  1256. }.bind(this),
  1257. "mousedown": function () {
  1258. this.resetNode.setStyles(this.css.taskActionResetNode_down);
  1259. }.bind(this),
  1260. "mouseup": function () {
  1261. this.resetNode.setStyles(this.css.taskActionResetNode_over);
  1262. }.bind(this),
  1263. "click": function () {
  1264. this.reset();
  1265. }.bind(this)
  1266. });
  1267. }
  1268. if (this.flowNode) {
  1269. this.flowNode.addEvents({
  1270. "mouseover": function () {
  1271. this.flowNode.setStyles(this.css.taskActionFlowNode_over);
  1272. }.bind(this),
  1273. "mouseout": function () {
  1274. this.flowNode.setStyles(this.css.taskActionFlowNode);
  1275. }.bind(this),
  1276. "mousedown": function () {
  1277. this.flowNode.setStyles(this.css.taskActionFlowNode_down);
  1278. }.bind(this),
  1279. "mouseup": function () {
  1280. this.flowNode.setStyles(this.css.taskActionFlowNode_over);
  1281. }.bind(this),
  1282. "click": function (e) {
  1283. this.flow(e);
  1284. }.bind(this)
  1285. });
  1286. }
  1287. if (this.deleteNode) {
  1288. this.deleteNode.addEvents({
  1289. "mouseover": function () {
  1290. this.deleteNode.setStyles(this.css.taskActionDeleteNode_over);
  1291. }.bind(this),
  1292. "mouseout": function () {
  1293. this.deleteNode.setStyles(this.css.taskActionDeleteNode);
  1294. }.bind(this),
  1295. "mousedown": function () {
  1296. this.deleteNode.setStyles(this.css.taskActionDeleteNode_down);
  1297. }.bind(this),
  1298. "mouseup": function () {
  1299. this.deleteNode.setStyles(this.css.taskActionDeleteNode_over);
  1300. }.bind(this),
  1301. "click": function (e) {
  1302. this.remove(e);
  1303. }.bind(this)
  1304. });
  1305. }
  1306. },
  1307. reset: function () {
  1308. this.node.setStyles(this.css.taskItemNode_action);
  1309. var options = {
  1310. "type": "identity",
  1311. "title": this.explorer.app.lp.reset,
  1312. "onComplete": function (items) {
  1313. if (items.length) {
  1314. this.resetPeople(items);
  1315. } else {
  1316. this.node.setStyles(this.css.taskItemNode);
  1317. }
  1318. }.bind(this),
  1319. "onCancel": function () {
  1320. this.node.setStyles(this.css.taskItemNode);
  1321. }.bind(this)
  1322. };
  1323. var selector = new MWF.O2Selector(this.explorer.app.content, options);
  1324. },
  1325. resetPeople: function (items) {
  1326. var nameList = [];
  1327. var nameShortList = [];
  1328. items.each(function(item){
  1329. nameList.push(item.data.distinguishedName);
  1330. nameShortList.push(item.data.name);
  1331. });
  1332. var data = {
  1333. "routeName": this.explorer.app.lp.reset,
  1334. "opinion": this.explorer.app.lp.reset+": "+nameShortList.join(", "),
  1335. "identityList": nameList
  1336. };
  1337. this.explorer.actions.resetTask(this.data.id, data, function(){
  1338. this.work.childNode.destroy();
  1339. this.work.childNode = null;
  1340. this.work.loadChild();
  1341. }.bind(this));
  1342. },
  1343. flow: function(e){
  1344. this.node.setStyles(this.css.taskItemNode_action);
  1345. this.processNode = new Element("div", {"styles": this.css.taskItemFlowNode}).inject(this.explorer.app.content);
  1346. MWF.require("MWF.xDesktop.Dialog", function(){
  1347. var width = 540;
  1348. var height = 260;
  1349. var size = this.explorer.app.content.getSize();
  1350. var x = size.x/2-width/2;
  1351. var y = size.y/2-height/2;
  1352. if (x+parseFloat(width)>size.x){
  1353. x = x-parseFloat(width);
  1354. }
  1355. if (x<0) x = 0;
  1356. if (y+parseFloat(height)>size.y){
  1357. y = y-parseFloat(height);
  1358. }
  1359. if (y<0) y = 0;
  1360. var dlg = new MWF.xDesktop.Dialog({
  1361. "title": "",
  1362. "style": "application",
  1363. "top": y,
  1364. "left": x-20,
  1365. "fromTop":y,
  1366. "fromLeft": x-20,
  1367. "width": width,
  1368. "height": height,
  1369. "content": this.processNode,
  1370. "container": this.explorer.app.content,
  1371. "onPostShow": function(){
  1372. var _self = this;
  1373. MWF.xDesktop.requireApp("process.Work", "Processor", function(){
  1374. new MWF.xApplication.process.Work.Processor(this.processNode, this.data, {
  1375. "style": "task",
  1376. "isManagerProcess" : true,
  1377. "onCancel": function(){
  1378. dlg.close();
  1379. _self.node.setStyles(_self.css.taskItemNode);
  1380. delete this;
  1381. },
  1382. "onSubmit": function(routeName, opinion){
  1383. _self.submitTask(routeName, opinion, this, dlg);
  1384. delete this;
  1385. },
  1386. "onResize": function () {
  1387. var processNodeSize = this.node.getSize();
  1388. if (!dlg || !dlg.node) return;
  1389. dlg.node.setStyle("display", "block");
  1390. //var size = dlg.node.getSize();
  1391. //dlg.options.contentHeight = processNodeSize.y;
  1392. dlg.content.setStyles({
  1393. "height": processNodeSize.y,
  1394. "width": processNodeSize.x
  1395. });
  1396. var s = dlg.setContentSize("auto",null);
  1397. //alert( JSON.stringify(s) )
  1398. if (dlg.content.getStyle("overflow-y") === "auto" && dlg.content.getStyle("overflow-x") !== "auto") {
  1399. dlg.node.setStyle("width", dlg.node.getStyle("width").toInt() + 20 + "px");
  1400. dlg.content.setStyle("width", dlg.content.getStyle("width").toInt() + 20 + "px");
  1401. }
  1402. dlg.reCenter();
  1403. }
  1404. })
  1405. }.bind(this));
  1406. }.bind(this)
  1407. });
  1408. dlg.show();
  1409. }.bind(this));
  1410. },
  1411. submitTask: function(routeName, opinion, processer, dlg){
  1412. var data = {
  1413. "routeName": routeName,
  1414. "opinion": opinion
  1415. }
  1416. this.explorer.actions.flowTask(this.data.id, data, function(){
  1417. processer.destroy();
  1418. dlg.close();
  1419. this.work.childNode.destroy();
  1420. this.work.childNode = null;
  1421. this.work.reload(function(){
  1422. this.work.loadChild();
  1423. }.bind(this));
  1424. }.bind(this));
  1425. },
  1426. remove: function(e){
  1427. var lp = this.explorer.app.lp;
  1428. var text = lp.deleteTask.replace(/{people}/g, this.data.person);
  1429. var _self = this;
  1430. this.node.setStyles(this.css.taskItemNode_remove);
  1431. this.explorer.app.confirm("warn", e, lp.deleteTaskTitle, text, 350, 120, function(){
  1432. this.close();
  1433. _self.work.removeTask(_self);
  1434. }, function(){
  1435. _self.node.setStyles(_self.css.taskItemNode);
  1436. this.close();
  1437. });
  1438. },
  1439. destroy: function(){
  1440. this.node.destroy();
  1441. }
  1442. });
  1443. MWF.xApplication.process.Application.WorkExplorer.Done = new Class({
  1444. Extends: MWF.xApplication.process.Application.WorkExplorer.Task,
  1445. setActions: function(){
  1446. //if (this.explorer.app.options.application.allowControl){
  1447. if (this.data.control.allowDelete){
  1448. this.deleteNode = new Element("div", {"styles": this.css.taskActionDeleteNode, "title": this.explorer.app.lp.delete}).inject(this.actionAreaNode);
  1449. }
  1450. },
  1451. setEvents: function(){
  1452. if (this.deleteNode){
  1453. this.deleteNode.addEvents({
  1454. "mouseover": function(){this.deleteNode.setStyles(this.css.taskActionDeleteNode_over);}.bind(this),
  1455. "mouseout": function(){this.deleteNode.setStyles(this.css.taskActionDeleteNode);}.bind(this),
  1456. "mousedown": function(){this.deleteNode.setStyles(this.css.taskActionDeleteNode_down);}.bind(this),
  1457. "mouseup": function(){this.deleteNode.setStyles(this.css.taskActionDeleteNode_over);}.bind(this),
  1458. "click": function(e){
  1459. this.remove(e);
  1460. }.bind(this)
  1461. });
  1462. }
  1463. },
  1464. remove: function(e){
  1465. var lp = this.explorer.app.lp;
  1466. var text = lp.deleteDone.replace(/{people}/g, this.data.person);
  1467. var _self = this;
  1468. this.node.setStyles(this.css.taskItemNode_remove);
  1469. this.explorer.app.confirm("warn", e, lp.deleteDoneTitle, text, 350, 120, function(){
  1470. this.close();
  1471. _self.work.removeDone(_self);
  1472. }, function(){
  1473. _self.node.setStyles(_self.css.taskItemNode);
  1474. this.close();
  1475. });
  1476. }
  1477. });
  1478. MWF.xApplication.process.Application.WorkExplorer.Read = new Class({
  1479. Extends: MWF.xApplication.process.Application.WorkExplorer.Task,
  1480. setActions: function(){
  1481. //if (this.explorer.app.options.application.allowControl || this.explorer.app.desktop.session.user.name==this.data.person){
  1482. if (this.data.control.allowReadReset){
  1483. this.resetNode = new Element("div", {"styles": this.css.taskActionResetNode, "title": this.explorer.app.lp.reset}).inject(this.actionAreaNode);
  1484. }
  1485. if (this.data.control.allowRead){
  1486. this.flagNode = new Element("div", {"styles": this.css.readActionFlagNode, "title": this.explorer.app.lp.flag}).inject(this.actionAreaNode);
  1487. }
  1488. //if (this.explorer.app.options.application.allowControl){
  1489. if (this.data.control.allowDelete){
  1490. this.deleteNode = new Element("div", {"styles": this.css.taskActionDeleteNode, "title": this.explorer.app.lp.delete}).inject(this.actionAreaNode);
  1491. }
  1492. },
  1493. setEvents: function(){
  1494. if (this.resetNode){
  1495. this.resetNode.addEvents({
  1496. "mouseover": function(){this.resetNode.setStyles(this.css.taskActionResetNode_over);}.bind(this),
  1497. "mouseout": function(){this.resetNode.setStyles(this.css.taskActionResetNode);}.bind(this),
  1498. "mousedown": function(){this.resetNode.setStyles(this.css.taskActionResetNode_down);}.bind(this),
  1499. "mouseup": function(){this.resetNode.setStyles(this.css.taskActionResetNode_over);}.bind(this),
  1500. "click": function(){
  1501. this.reset();
  1502. }.bind(this)
  1503. });
  1504. }
  1505. if (this.flagNode){
  1506. this.flagNode.addEvents({
  1507. "mouseover": function(){this.flagNode.setStyles(this.css.readActionFlagNode_over);}.bind(this),
  1508. "mouseout": function(){this.flagNode.setStyles(this.css.readActionFlagNode);}.bind(this),
  1509. "mousedown": function(){this.flagNode.setStyles(this.css.readActionFlagNode_down);}.bind(this),
  1510. "mouseup": function(){this.flagNode.setStyles(this.css.readActionFlagNode_over);}.bind(this),
  1511. "click": function(){
  1512. this.flagRead();
  1513. }.bind(this)
  1514. });
  1515. }
  1516. if (this.deleteNode){
  1517. this.deleteNode.addEvents({
  1518. "mouseover": function(){this.deleteNode.setStyles(this.css.taskActionDeleteNode_over);}.bind(this),
  1519. "mouseout": function(){this.deleteNode.setStyles(this.css.taskActionDeleteNode);}.bind(this),
  1520. "mousedown": function(){this.deleteNode.setStyles(this.css.taskActionDeleteNode_down);}.bind(this),
  1521. "mouseup": function(){this.deleteNode.setStyles(this.css.taskActionDeleteNode_over);}.bind(this),
  1522. "click": function(e){
  1523. this.remove(e);
  1524. }.bind(this)
  1525. });
  1526. }
  1527. },
  1528. reset: function () {
  1529. this.node.setStyles(this.css.taskItemNode_action);
  1530. var options = {
  1531. "type": "identity",
  1532. "title": this.explorer.app.lp.reset,
  1533. "onComplete": function (items) {
  1534. if (items.length) {
  1535. this.resetPeople(items);
  1536. } else {
  1537. this.node.setStyles(this.css.taskItemNode);
  1538. }
  1539. }.bind(this),
  1540. "onCancel": function () {
  1541. this.node.setStyles(this.css.taskItemNode);
  1542. }.bind(this)
  1543. };
  1544. var selector = new MWF.O2Selector(this.explorer.app.content, options);
  1545. },
  1546. resetPeople: function (items) {
  1547. var nameList = [];
  1548. items.each(function(item){
  1549. nameList.push(item.data.distinguishedName);
  1550. });
  1551. var data = {
  1552. "routeName": this.explorer.app.lp.resetTo,
  1553. "opinion": this.explorer.app.lp.resetTo+": "+nameList.join(", "),
  1554. "identityList": nameList
  1555. };
  1556. this.explorer.actions.resetRead(this.data.id, data, function(){
  1557. this.work.childNode.destroy();
  1558. this.work.childNode = null;
  1559. this.work.loadChild();
  1560. }.bind(this));
  1561. },
  1562. remove: function(e){
  1563. var lp = this.explorer.app.lp;
  1564. var text = lp.deleteRead.replace(/{people}/g, this.data.person);
  1565. var _self = this;
  1566. this.node.setStyles(this.css.taskItemNode_remove);
  1567. this.explorer.app.confirm("warn", e, lp.deleteReadTitle, text, 350, 120, function(){
  1568. this.close();
  1569. _self.work.removeRead(_self);
  1570. }, function(){
  1571. _self.node.setStyles(_self.css.taskItemNode);
  1572. this.close();
  1573. });
  1574. },
  1575. flagRead: function(){
  1576. var lp = this.explorer.app.lp;
  1577. var text = lp.flagRead.replace(/{people}/g, this.data.person);
  1578. var _self = this;
  1579. this.node.setStyles(this.css.taskItemNode_action);
  1580. this.explorer.app.confirm("warn", e, lp.flagReadTitle, text, 350, 180, function(){
  1581. this.close();
  1582. _self.doFlagRead();
  1583. }, function(){
  1584. _self.node.setStyles(_self.css.taskItemNode);
  1585. this.close();
  1586. });
  1587. },
  1588. doFlagRead: function(){
  1589. this.explorer.actions.flagRead(this.data.id, {}, function(){
  1590. this.work.childNode.destroy();
  1591. this.work.childNode = null;
  1592. this.work.loadChild();
  1593. }.bind(this));
  1594. }
  1595. });
  1596. MWF.xApplication.process.Application.WorkExplorer.Readed = new Class({
  1597. Extends: MWF.xApplication.process.Application.WorkExplorer.Done,
  1598. remove: function(e){
  1599. var lp = this.explorer.app.lp;
  1600. var text = lp.deleteReaded.replace(/{people}/g, this.data.person);
  1601. var _self = this;
  1602. this.node.setStyles(this.css.taskItemNode_remove);
  1603. this.explorer.app.confirm("warn", e, lp.deleteReadedTitle, text, 350, 120, function(){
  1604. this.close();
  1605. _self.work.removeReaded(_self);
  1606. }, function(){
  1607. _self.node.setStyles(_self.css.taskItemNode);
  1608. this.close();
  1609. });
  1610. }
  1611. });