WorkExplorer.js 74 KB

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