WorkExplorer.js 77 KB

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