Explorer.js 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825
  1. MWF.xApplication.process = MWF.xApplication.process || {};
  2. MWF.APPPM = MWF.xApplication.process.ProcessManager = MWF.xApplication.process.ProcessManager || {};
  3. MWF.xDesktop.requireApp("process.ProcessManager", "lp."+MWF.language, null, false);
  4. MWF.xApplication.process.ProcessManager.Explorer = new Class({
  5. Extends: MWF.widget.Common,
  6. Implements: [Options, Events],
  7. options: {
  8. "style": "default",
  9. "tooltip": {
  10. "create": MWF.APPPM.LP.process.create,
  11. "search": MWF.APPPM.LP.process.search,
  12. "searchText": MWF.APPPM.LP.process.searchText,
  13. "noElement": MWF.APPPM.LP.process.noProcessNoticeText
  14. },
  15. "topEnable": true,
  16. "categoryEnable": true,
  17. "itemStyle": "card",
  18. "sortKeys": ['name', 'alias', 'createTime', 'updateTime'],
  19. "sortKey": '',
  20. "name": 'process.processExplorer'
  21. },
  22. initialize: function(node, actions, options){
  23. this.setOptions(options);
  24. this.setTooltip();
  25. this.path = "../x_component_process_ProcessManager/$Explorer/";
  26. this.cssPath = "../x_component_process_ProcessManager/$Explorer/"+this.options.style+"/css.wcss";
  27. this._loadCss();
  28. this.actions = actions;
  29. this.node = $(node);
  30. this.initData();
  31. },
  32. setTooltip: function(tooltip){
  33. if (tooltip) this.options.tooltip = Object.merge(this.options.tooltip, tooltip);
  34. },
  35. initData: function(){
  36. //this.categoryLoadFirst = true;
  37. //this.isLoaddingCategory = false;
  38. //this.categoryLoaded = false;
  39. //this.categorys = [];
  40. //this.dragItem = false;
  41. //this.dragCategory = false;
  42. //this.currentCategory = null;
  43. //this.loadCategoryQueue = 0;
  44. this.categoryList = [];
  45. this.deleteMarkItems = [];
  46. this.selectMarkItems = [];
  47. },
  48. reload: function(){
  49. if (this.app && this.app.content){
  50. if( this.itemList && this.itemList.length ){
  51. this.itemList.each(function (item){
  52. if(item.destroy)item.destroy();
  53. });
  54. }
  55. this.node.empty();
  56. this.isSetContentSize = false;
  57. this.load();
  58. }
  59. },
  60. load: function(){
  61. this.loadToolbar();
  62. this.loadContentNode();
  63. this.setNodeScroll();
  64. this.getUd( function (){
  65. this.loadElementList();
  66. }.bind(this));
  67. },
  68. getUd: function ( callback ){
  69. var id = (this.app.options && this.app.options.application) ? this.app.options.application.id : "";
  70. MWF.UD.getDataJson(this.options.name + "_" + id, function (data){
  71. if( data ){
  72. this.options.itemStyle = data.itemStyle;
  73. this.options.sortKey = data.sortKey;
  74. }
  75. callback();
  76. }.bind(this));
  77. },
  78. setUd: function (){
  79. var data = {
  80. itemStyle: this.options.itemStyle,
  81. sortKey: this.options.sortKey,
  82. };
  83. var id = (this.app.options && this.app.options.application) ? this.app.options.application.id : "";
  84. MWF.UD.putData(this.options.name+ "_" + id, data);
  85. },
  86. loadToolbar: function(){
  87. this.toolbarNode = new Element("div", {"styles": this.css.toolbarNode});
  88. this.createCreateElementNode();
  89. this.createIconElementNode();
  90. this.createTitleElementNode();
  91. this.createSearchElementNode();
  92. this.toolbarNode.inject(this.node);
  93. this.createCategoryElementNode();
  94. },
  95. createIconElementNode: function(){
  96. this.iconElementNode = new Element("div", {
  97. "styles": this.css.iconElementNode
  98. }).inject(this.toolbarNode);
  99. if (this.app.options && this.app.options.application){
  100. if (this.app.options.application.icon){
  101. this.iconElementNode.setStyle("background-image", "url(data:image/png;base64,"+this.app.options.application.icon+")");
  102. }else{
  103. this.iconElementNode.setStyle("background-image", "url("+"../x_component_process_ApplicationExplorer/$Main/default/icon/application.png)");
  104. }
  105. }
  106. },
  107. createCreateElementNode: function(){
  108. this.createElementNode = new Element("div", {
  109. "styles": this.css.createElementNode,
  110. "title": this.options.tooltip.create
  111. }).inject(this.toolbarNode);
  112. this.createElementNode.addEvent("click", function(e){
  113. this._createElement(e);
  114. }.bind(this));
  115. },
  116. createTitleElementNode: function() {
  117. this.titleElementNode = new Element("div", {
  118. "styles": this.css.titleElementNode,
  119. "text": this.app.options.application.name
  120. }).inject(this.toolbarNode);
  121. },
  122. openFindDesigner: function(){
  123. this.app.options.application.moduleType = "processPlatform";
  124. var options = {
  125. "filter": {
  126. "moduleList": ["processPlatform"],
  127. "appList": [this.app.options.application]
  128. }
  129. };
  130. layout.openApplication(null, "FindDesigner", options);
  131. },
  132. createSearchElementNode: function(){
  133. debugger
  134. this.searchElementNode = new Element("div.searchElementNode", {
  135. "styles": this.css.searchElementNode,
  136. "title": this.app.lp.findDesigner
  137. }).inject(this.toolbarNode);
  138. this.searchElementNode.addEvent("click", function(){
  139. this.openFindDesigner();
  140. }.bind(this));
  141. //@todo
  142. return false;
  143. //this.searchElementButtonNode = new Element("div", {"styles": this.css.searchElementButtonNode,"title": this.options.tooltip.search}).inject(this.searchElementNode);
  144. //
  145. //this.searchElementInputAreaNode = new Element("div", {
  146. // "styles": this.css.searchElementInputAreaNode
  147. //}).inject(this.searchElementNode);
  148. //
  149. //this.searchElementInputBoxNode = new Element("div", {
  150. // "styles": this.css.searchElementInputBoxNode
  151. //}).inject(this.searchElementInputAreaNode);
  152. //
  153. //this.searchElementInputNode = new Element("input", {
  154. // "type": "text",
  155. // "value": this.options.tooltip.searchText,
  156. // "styles": this.css.searchElementInputNode,
  157. // "x-webkit-speech": "1"
  158. //}).inject(this.searchElementInputBoxNode);
  159. //var _self = this;
  160. //this.searchElementInputNode.addEvents({
  161. // "focus": function(){
  162. // if (this.value==_self.options.tooltip.searchText) this.set("value", "");
  163. // },
  164. // "blur": function(){if (!this.value) this.set("value", _self.options.tooltip.searchText);},
  165. // "keydown": function(e){
  166. // if (e.code==13){
  167. // this.searchElement();
  168. // e.preventDefault();
  169. // }
  170. // }.bind(this),
  171. // "selectstart": function(e){
  172. // e.preventDefault();
  173. // }
  174. //});
  175. //this.searchElementButtonNode.addEvent("click", function(){this.searchElement();}.bind(this));
  176. },
  177. createCategoryElementNode: function(){
  178. this.categoryElementNode = new Element("div", {
  179. "styles": this.css.categoryElementNode
  180. }).inject(this.node);
  181. },
  182. searchElement: function(){
  183. //-----------------------------------------
  184. //-----------------------------------------
  185. //-----search category---------------------
  186. //-----------------------------------------
  187. //-----------------------------------------
  188. // alert("search Element");
  189. },
  190. loadContentNode: function(){
  191. this.elementContentNode = new Element("div", {
  192. "styles": this.css.elementContentNode
  193. }).inject(this.node);
  194. this.elementContentNode.addEvent("click", function(){
  195. while (this.selectMarkItems.length){
  196. this.selectMarkItems[0].unSelected();
  197. }
  198. }.bind(this));
  199. this.elementContentListNode = new Element("div", {
  200. "styles": this.css.elementContentListNode
  201. }).inject(this.elementContentNode);
  202. if( !this.setContentSizeFun ){
  203. this.setContentSizeFun = this.setContentSize.bind(this);
  204. this.app.addEvent("resize", this.setContentSizeFun);
  205. this.app.addEvent("close", function(){
  206. if (this.setContentSizeFun){
  207. this.app.removeEvent("resize", this.setContentSizeFun);
  208. this.setContentSizeFun = null;
  209. }
  210. }.bind(this));
  211. }
  212. },
  213. setContentSize: function(){
  214. if (this.elementContentListNode){
  215. var toolbarSize = (this.toolbarNode) ? this.toolbarNode.getSize() : {"x": 0, "y": 0};
  216. var nodeSize = (this.node) ? this.node.getSize() : {"x": 0, "y": 0};
  217. var categorySize = this.categoryElementNode ? this.categoryElementNode.getSize() : {"x": 0, "y": 0};
  218. var pt = this.elementContentNode.getStyle("padding-top").toFloat();
  219. var pb = this.elementContentNode.getStyle("padding-bottom").toFloat();
  220. var height = nodeSize.y-toolbarSize.y-categorySize.y-pt-pb;
  221. this.elementContentNode.setStyle("height", ""+height+"px");
  222. if( this.options.itemStyle === 'card' ){
  223. var count = (nodeSize.x/282).toInt();
  224. var x = count*282;
  225. var m = (nodeSize.x-x)/2-10;
  226. this.elementContentListNode.setStyles({
  227. "width": ""+x+"px",
  228. "margin-left": "" + m + "px"
  229. });
  230. }else{
  231. this.elementContentListNode.setStyles({
  232. "margin-right": "10px"
  233. });
  234. }
  235. }
  236. },
  237. setNodeScroll: function(){
  238. MWF.require("MWF.widget.DragScroll", function(){
  239. new MWF.widget.DragScroll(this.elementContentNode);
  240. }.bind(this));
  241. MWF.require("MWF.widget.ScrollBar", function(){
  242. new MWF.widget.ScrollBar(this.elementContentNode, {"indent": false});
  243. }.bind(this));
  244. },
  245. loadElementList: function(){
  246. this.itemList = [];
  247. this._loadItemDataList(function(json){
  248. if (json.data.length){
  249. this.checkSort(json.data);
  250. json.data.each(function(item){
  251. if (this.categoryList.indexOf(item.category) === -1) if (item.category) this.categoryList.push(item.category);
  252. if (!this.elementCategory || (item.category === this.elementCategory)){
  253. var itemObj = this._getItemObject(item);
  254. itemObj.load();
  255. this.checkShow(itemObj);
  256. this.itemList.push(itemObj);
  257. }
  258. }.bind(this));
  259. }else{
  260. var noElementNode = new Element("div.noElementNode", {
  261. "styles": this.css.noElementNode,
  262. "text": this.options.tooltip.noElement
  263. }).inject(this.elementContentListNode);
  264. noElementNode.addEvent("click", function(e){
  265. this._createElement(e);
  266. }.bind(this));
  267. }
  268. if(this.options.topEnable)this.loadTopNode();
  269. if( !this.isSetContentSize ){
  270. this.setContentSize();
  271. this.isSetContentSize = true;
  272. }
  273. }.bind(this));
  274. },
  275. checkSort: function (data){
  276. if( !!this.options.sortKey ){
  277. var sortKey = this.options.sortKey.split("-");
  278. var key = sortKey[0], isDesc = sortKey[1] === 'desc';
  279. data.sort(function (a, b){
  280. var av = a[key];
  281. var bv = b[key];
  282. if( typeOf(av) === 'string' && typeOf(bv) === 'string' ){
  283. var isLetterA = /^[a-zA-Z0-9]/.test(av);
  284. var isLetterB = /^[a-zA-Z0-9]/.test(bv);
  285. if (isLetterA && !isLetterB) return isDesc ? 1 : -1; // a是字母,b不是,a排在前面
  286. if (!isLetterA && isLetterB) return isDesc ? -1 : 1; // a不是字母,b是,b排在前面
  287. return isDesc ? bv.localeCompare(av) : av.localeCompare(bv);
  288. }
  289. return isDesc ? (bv - av) : (av - bv);
  290. }.bind(this));
  291. }
  292. },
  293. checkShow: function (i){
  294. if( this.options.searchKey ){
  295. var v = this.options.searchKey;
  296. if( i.data.name.contains(v) || (i.data.alias || "").contains(v) || i.data.id.contains(v) ){
  297. //i.node.setStyle("display", "");
  298. }else{
  299. i.node.setStyle("display", "none");
  300. }
  301. }
  302. },
  303. loadTopNode: function (){
  304. if(this.options.categoryEnable)this.loadCategoryList();
  305. this.createItemStyleNode();
  306. this.createSortNode();
  307. this.createSearchNode();
  308. },
  309. loadCategoryList: function(){
  310. this.categoryElementNode.empty();
  311. var node = new Element("div", {"styles": this.css.categoryElementItemAllNode, "text": MWF.xApplication.process.ProcessManager.LP.all}).inject(this.categoryElementNode);
  312. if (!this.elementCategory) node.setStyles(this.css.categoryElementItemAllNode_current);
  313. this.categoryList.each(function(category){
  314. if( category && category !== "null" ){
  315. node = new Element("div", {"styles": this.css.categoryElementItemNode, "text": category}).inject(this.categoryElementNode);
  316. if (this.elementCategory===category){
  317. node.setStyles(this.css.categoryElementItemNode_current);
  318. }
  319. }
  320. }.bind(this));
  321. var categoryItems = this.categoryElementNode.getChildren();
  322. categoryItems.addEvent("click", function(e){
  323. var text = e.target.get("text");
  324. this.elementCategory = (text===MWF.xApplication.process.ProcessManager.LP.all) ? "" : text;
  325. // categoryItems.setStyles(this.css.categoryElementItemNode);
  326. // this.categoryElementNode.getFirst().setStyles(this.css.categoryElementItemAllNode);
  327. // e.target.setStyles((this.elementCategory) ? this.css.categoryElementItemNode_current : this.css.categoryElementItemAllNode_current);
  328. this.isSetContentSize = false;
  329. this.reload();
  330. }.bind(this));
  331. },
  332. createItemStyleNode: function (){
  333. this.itemStyleSwitchNode = new Element("div.itemStyleSwitchNode", {
  334. styles: this.css.itemStyleSwitchNode
  335. }).inject(this.categoryElementNode);
  336. ['line','card'].each(function(style){
  337. var el = new Element("div", {
  338. styles: this.css.itemStyleSwitchItemNode
  339. }).inject(this.itemStyleSwitchNode);
  340. el.setStyle('background-image',"url('../x_component_process_ProcessManager/$Explorer/default/icon/"+style+".png')");
  341. el.store("sty", style);
  342. el.addEvent("click", function(e){
  343. this.switchItemStyle(el, style);
  344. }.bind(this));
  345. if( style === this.options.itemStyle )el.click();
  346. }.bind(this));
  347. },
  348. createSortNode: function(){
  349. this.itemSortArea = new Element("div.itemStyleSwitchNode", {
  350. styles: this.css.itemSortArea
  351. }).inject(this.categoryElementNode);
  352. this.itemSortSelect = new Element('select.itemSortSelect', {
  353. styles: this.css.itemSortSelect,
  354. events: {
  355. change: function(){
  356. this.options.sortKey = this.itemSortSelect[ this.itemSortSelect.selectedIndex ].value;
  357. this.setUd();
  358. this.reload();
  359. }.bind(this)
  360. }
  361. }).inject(this.itemSortArea);
  362. new Element('option',{ 'text': this.app.lp.sorkKeyNote, 'value': "" }).inject(this.itemSortSelect);
  363. this.options.sortKeys.each(function (key){
  364. var opt = new Element('option',{ 'text': this.app.lp[key] + " " + this.app.lp.asc, 'value': key+"-asc" }).inject(this.itemSortSelect);
  365. if( this.options.sortKey === opt.get('value') )opt.set('selected', true);
  366. opt = new Element('option',{ 'text': this.app.lp[key] + " " + this.app.lp.desc, 'value': key+"-desc" }).inject(this.itemSortSelect);
  367. if( this.options.sortKey === opt.get('value') )opt.set('selected', true);
  368. }.bind(this));
  369. },
  370. createSearchNode: function (){
  371. this.searchNode = new Element("div.searchNode", {
  372. "styles": this.css.searchArea
  373. }).inject(this.categoryElementNode);
  374. this.searchInput = new Element("input.searchInput", {
  375. "styles": this.css.searchInput,
  376. "placeholder": this.app.lp.searchPlacholder,
  377. "value": this.options.searchKey || ""
  378. }).inject(this.searchNode);
  379. this.searchButton = new Element("i", {
  380. "styles": this.css.searchButton
  381. }).inject(this.searchNode);
  382. this.searchCancelButton = new Element("i", {
  383. "styles": this.css.searchCancelButton
  384. }).inject(this.searchNode);
  385. this.searchInput.addEvents({
  386. focus: function(){
  387. this.searchNode.addClass("mainColor_border");
  388. this.searchButton.addClass("mainColor_color");
  389. }.bind(this),
  390. blur: function () {
  391. this.searchNode.removeClass("mainColor_border");
  392. this.searchButton.removeClass("mainColor_color");
  393. }.bind(this),
  394. keydown: function (e) {
  395. if( (e.keyCode || e.code) === 13 ){
  396. this.search();
  397. }
  398. }.bind(this),
  399. keyup: function (e){
  400. this.searchCancelButton.setStyle('display', this.searchInput.get('value') ? '' : 'none');
  401. }.bind(this)
  402. });
  403. this.searchCancelButton.addEvent("click", function (e) {
  404. this.searchInput.set("value", "");
  405. this.searchCancelButton.hide();
  406. this.search();
  407. }.bind(this));
  408. this.searchButton.addEvent("click", function (e) {
  409. this.search();
  410. }.bind(this));
  411. },
  412. switchItemStyle: function(el){
  413. if( this.currentItemStyleSwitchItemNode ){
  414. var cur = this.currentItemStyleSwitchItemNode;
  415. cur.setStyle('background-image',"url('../x_component_process_ProcessManager/$Explorer/default/icon/"+cur.retrieve('sty')+".png')");
  416. }
  417. this.currentItemStyleSwitchItemNode = el;
  418. el.setStyle('background-image',"url('../x_component_process_ProcessManager/$Explorer/default/icon/"+el.retrieve('sty')+"_active.png')");
  419. if( el.retrieve('sty') !== this.options.itemStyle ){
  420. this.options.itemStyle = el.retrieve('sty');
  421. this.setUd();
  422. this.reload();
  423. }
  424. },
  425. showDeleteAction: function(){
  426. if (!this.deleteItemsAction){
  427. this.deleteItemsAction = new Element("div", {
  428. "styles": this.css.deleteItemsAction,
  429. "text": this.app.lp.deleteItems
  430. }).inject(this.node);
  431. this.deleteItemsAction.fade("in");
  432. this.deleteItemsAction.position({
  433. relativeTo: this.elementContentListNode,
  434. position: 'centerTop',
  435. edge: 'centerTop',
  436. "offset": {"y": this.elementContentNode.getScroll().y}
  437. });
  438. this.deleteItemsAction.addEvent("click", function(){
  439. var _self = this;
  440. this.app.confirm("warn", this.deleteItemsAction, MWF.APPPM.LP.deleteElementTitle, MWF.APPPM.LP.deleteElement, 300, 120, function(){
  441. _self.deleteItems();
  442. this.close();
  443. }, function(){
  444. this.close();
  445. });
  446. }.bind(this));
  447. }
  448. },
  449. search: function (){
  450. var v = this.searchInput.get("value");
  451. this.options.searchKey = v;
  452. this.itemList.each(function (i){
  453. if( !v ){
  454. i.node.setStyle("display", "");
  455. }else if( i.data.name.contains(v) || (i.data.alias || "").contains(v) || i.data.id.contains(v) ){
  456. i.node.setStyle("display", "");
  457. }else{
  458. i.node.setStyle("display", "none");
  459. }
  460. }.bind(this));
  461. },
  462. hideDeleteAction: function(){
  463. if (this.deleteItemsAction) this.deleteItemsAction.destroy();
  464. delete this.deleteItemsAction;
  465. },
  466. _createElement: function(e){
  467. },
  468. _loadItemDataList: function(callback){
  469. this.app.restActions.listProcess(this.app.options.application.id,callback);
  470. },
  471. _getItemObject: function(item){
  472. return MWF.xApplication.process.ProcessManager.Explorer.Item(this, item)
  473. },
  474. destroy: function(){
  475. if( this.itemList && this.itemList.length ){
  476. this.itemList.each(function (item){
  477. if(item.destroy)item.destroy();
  478. });
  479. }
  480. this.node.destroy();
  481. o2.release(this);
  482. }
  483. });
  484. MWF.xApplication.process.ProcessManager.Explorer.Item = new Class({
  485. initialize: function(explorer, item){
  486. this.explorer = explorer;
  487. this.data = item;
  488. this.container = this.explorer.elementContentListNode;
  489. this.css = this.explorer.css;
  490. this.icon = this._getIcon();
  491. },
  492. load: function(){
  493. this.createNode();
  494. this.createIconNode();
  495. //this.createDeleteNode();
  496. this.createActionNode();
  497. this.explorer.options.itemStyle === 'line' ? this.createTextNodes_line() : this.createTextNodes();
  498. this._isNew();
  499. this.createInforNode();
  500. },
  501. destroy: function (){
  502. if( this.tooltip )this.tooltip.destroy();
  503. this.node.destroy();
  504. },
  505. createNode: function(){
  506. this.node = new Element("div", {
  507. "styles": this.explorer.options.itemStyle === 'line' ? this.css.itemNode_line : this.css.itemNode,
  508. "events": {
  509. "mouseover": function(){
  510. this.deleteActionNode.fade("in");
  511. if (this.saveasActionNode) this.saveasActionNode.fade("in");
  512. }.bind(this),
  513. "mouseout": function(){
  514. this.deleteActionNode.fade("out");
  515. if (this.saveasActionNode) this.saveasActionNode.fade("out");
  516. }.bind(this)
  517. }
  518. }).inject(this.container);
  519. },
  520. createIconNode: function(){
  521. if (this.data.icon) this.icon = this.data.icon.substr(this.data.icon.lastIndexOf("/")+1, this.data.icon.length);
  522. //if (this.data.name.icon) this.icon = this.data.name.icon;
  523. var iconUrl = this.explorer.path+""+this.explorer.options.style+"/processIcon/"+this.icon;
  524. var itemIconNode = new Element("div", {
  525. "styles": this.explorer.options.itemStyle === 'line' ? this.css.itemIconNode_line : this.css.itemIconNode
  526. }).inject(this.node);
  527. itemIconNode.setStyle("background", "url("+iconUrl+") center center no-repeat");
  528. itemIconNode.addEvent("click", function(e){
  529. this.toggleSelected();
  530. e.stopPropagation();
  531. }.bind(this));
  532. itemIconNode.makeLnk({
  533. "par": this._getLnkPar()
  534. });
  535. },
  536. toggleSelected: function(){
  537. if (this.isSelected){
  538. this.unSelected();
  539. }else{
  540. this.selected();
  541. }
  542. },
  543. checkShowCopyInfor: function(){
  544. if (this.explorer.selectMarkItems.length===1){
  545. this.explorer.app.notice(this.explorer.app.lp.copyInfor, "infor");
  546. }
  547. },
  548. selected: function(){
  549. if (this.deleteMode) this.deleteItem();
  550. this.isSelected = true;
  551. this.node.setStyles(this.css.itemNode_selected);
  552. this.explorer.selectMarkItems.push(this);
  553. this.checkShowCopyInfor();
  554. },
  555. unSelected: function(){
  556. this.isSelected = false;
  557. this.node.setStyles(this.explorer.options.itemStyle === 'line' ? this.css.itemNode_line : this.css.itemNode);
  558. this.explorer.selectMarkItems.erase(this);
  559. },
  560. createActionNode: function(){
  561. this.deleteActionNode = new Element("div", {
  562. "styles": this.css.deleteActionNode
  563. }).inject(this.node);
  564. this.deleteActionNode.addEvent("click", function(e){
  565. this.deleteItem(e);
  566. }.bind(this));
  567. this.saveasActionNode = new Element("div", {
  568. "styles": this.css.saveasActionNode,
  569. "title": this.explorer.app.lp.copy
  570. }).inject(this.node);
  571. this.saveasActionNode.addEvent("click", function(e){
  572. this.saveas(e);
  573. }.bind(this));
  574. },
  575. // createDeleteNode: function(){
  576. // this.deleteActionNode = new Element("div", {
  577. // "styles": this.css.deleteActionNode
  578. // }).inject(this.node);
  579. // this.deleteActionNode.addEvent("click", function(e){
  580. // this.deleteItem(e);
  581. // }.bind(this));
  582. // },
  583. createTextNodes: function(){
  584. new Element("div", {
  585. "styles": this.css.itemTextTitleNode,
  586. "text": this.data.name,
  587. "title": this.data.name,
  588. "events": {
  589. "click": function(e){this._open(e);}.bind(this)
  590. }
  591. }).inject(this.node);
  592. new Element("div", {
  593. "styles": this.css.itemTextDescriptionNode,
  594. "text": this.data.description || "",
  595. "title": this.data.description || ""
  596. }).inject(this.node);
  597. new Element("div", {
  598. "styles": this.css.itemTextDateNode,
  599. "text": (this.data.updateTime || "")
  600. }).inject(this.node);
  601. },
  602. createTextNodes_line: function(){
  603. var inforNode = new Element("div", {
  604. "styles": this.explorer.css.itemInforNode_line
  605. }).inject(this.node);
  606. var inforBaseNode = new Element("div", {
  607. "styles": this.explorer.css.itemInforBaseNode_line
  608. }).inject(inforNode);
  609. new Element("div", {
  610. "styles": this.explorer.css.itemTextTitleNode_line,
  611. "text": this.data.name,
  612. "title": this.data.name,
  613. "events": {
  614. "click": function(e){this._open(e);e.stopPropagation();}.bind(this)
  615. }
  616. }).inject(inforBaseNode);
  617. new Element("div", {
  618. "styles": this.explorer.css.itemTextAliasNode_line,
  619. "text": this.data.alias,
  620. "title": this.data.alias
  621. }).inject(inforBaseNode);
  622. new Element("div", {
  623. "styles": this.explorer.css.itemTextDateNode_line,
  624. "text": (this.data.updateTime || "")
  625. }).inject(inforBaseNode);
  626. new Element("div", {
  627. "styles": this.explorer.css.itemTextDescriptionNode_line,
  628. "text": this.data.description || "",
  629. "title": this.data.description || ""
  630. }).inject(inforNode);
  631. },
  632. saveas: function(){
  633. MWF.xDesktop.requireApp("Selector", "package", function(){
  634. var selector = new MWF.O2Selector(this.explorer.app.content, {
  635. "title": this.explorer.app.lp.copyto,
  636. "type": "Application",
  637. "values": [this.explorer.app.options.application],
  638. "onComplete": function(items){
  639. items.each(function(item){
  640. this.saveItemAs(item.data);
  641. }.bind(this));
  642. }.bind(this),
  643. });
  644. }.bind(this));
  645. },
  646. // saveItemAs: function(item){
  647. //
  648. // },
  649. deleteItem: function(){
  650. if (this.isSelected) this.unSelected();
  651. if (!this.deleteMode){
  652. this.deleteMode = true;
  653. this.node.setStyle("background-color", "#ffb7b7");
  654. this.deleteActionNode.setStyle("background-image", "url("+"../x_component_process_ProcessManager/$Explorer/default/processIcon/deleteProcess_red1.png)");
  655. this.node.removeEvents("mouseover");
  656. this.node.removeEvents("mouseout");
  657. if (this.saveasActionNode) this.saveasActionNode.fade("out");
  658. this.explorer.deleteMarkItems.push(this);
  659. }else{
  660. this.deleteMode = false;
  661. this.node.setStyle("background", "#FFF");
  662. this.deleteActionNode.setStyle("background-image", "url("+"../x_component_process_ProcessManager/$Explorer/default/processIcon/deleteProcess.png)");
  663. if (this.saveasActionNode) this.saveasActionNode.fade("in");
  664. this.node.addEvents({
  665. "mouseover": function(){
  666. this.deleteActionNode.fade("in");
  667. if (this.saveasActionNode) this.saveasActionNode.fade("in");
  668. }.bind(this),
  669. "mouseout": function(){
  670. this.deleteActionNode.fade("out");
  671. if (this.saveasActionNode) this.saveasActionNode.fade("out");
  672. }.bind(this)
  673. });
  674. this.explorer.deleteMarkItems.erase(this);
  675. }
  676. if (this.explorer.deleteMarkItems.length){
  677. this.explorer.showDeleteAction();
  678. }else{
  679. this.explorer.hideDeleteAction();
  680. }
  681. },
  682. deleteItems: function(){},
  683. _open: function(e){
  684. var _self = this;
  685. var options = {
  686. "onQueryLoad": function(){
  687. this.actions = _self.explorer.actions;
  688. this.category = _self;
  689. this.options.id = _self.data.id;
  690. this.application = _self.explorer.app.options.application;
  691. }
  692. };
  693. this.explorer.app.desktop.openApplication(e, "process.ProcessDesigner", options);
  694. },
  695. _getIcon: function(){
  696. var x = (Math.random()*49).toInt();
  697. return "process_icon_"+x+".png";
  698. },
  699. _getLnkPar: function(){
  700. return {
  701. "icon": this.explorer.path+this.explorer.options.style+"/processIcon/lnk.png",
  702. "title": this.data.name,
  703. "par": "ProcessDesigner#{\"id\": \""+this.data.id+"\"}"
  704. };
  705. },
  706. _isNew: function(){
  707. if (this.data.updateTime){
  708. var createDate = Date.parse(this.data.updateTime);
  709. var currentDate = new Date();
  710. if (createDate.diff(currentDate, "hour")<12) {
  711. this.newNode = new Element("div", {
  712. "styles": this.explorer.options.itemStyle === 'line' ? this.css.itemNewNode_line : this.css.itemNewNode
  713. }).inject(this.node);
  714. this.newNode.addEvent("click", function(e){
  715. this.toggleSelected();
  716. e.stopPropagation();
  717. }.bind(this));
  718. }
  719. }
  720. },
  721. createInforNode: function(callback){
  722. var lp = this.explorer.app.lp;
  723. this.inforNode = new Element("div");
  724. var wrapNode = new Element("div", {
  725. style: 'display: grid; grid-template-columns: 60px auto; line-height:20px;'
  726. }).inject(this.inforNode);
  727. var html = "<div style='grid-column: 1 / -1; font-weight: bold'>"+this.data.name+"</div>";
  728. html += "<div style='font-weight: bold'>"+lp.alias+": </div><div style='margin-left:10px'>"+( this.data.alias || "" )+"</div>";
  729. html += "<div style='font-weight: bold'>"+lp.createTime+": </div><div style='margin-left:10px'>"+(this.data.createTime || "")+"</div>";
  730. html += "<div style='font-weight: bold'>"+lp.updateTime+": </div><div style='float:left; margin-left:10px'>"+(this.data.updateTime||"")+"</div>";
  731. html += "<div style='font-weight: bold'>"+lp.description+": </div><div style='float:left; margin-left:10px'>"+(this.data.description||"")+"</div>";
  732. wrapNode.set("html", html);
  733. this.tooltip = new MWF.xApplication.process.ProcessManager.Explorer.Item.Tooltip(this.explorer.app.content, this.node, this.explorer.app, {}, {
  734. axis : "y",
  735. hiddenDelay : 300,
  736. displayDelay : 200
  737. });
  738. this.tooltip.inforNode = this.inforNode;
  739. },
  740. });
  741. MWF.xDesktop.requireApp("Template", "MTooltips", null, false);
  742. MWF.xApplication.process.ProcessManager.Explorer.Item.Tooltip = new Class({
  743. Extends: MTooltips,
  744. options:{
  745. nodeStyles: {
  746. "font-size" : "12px",
  747. "position" : "absolute",
  748. "max-width" : "500px",
  749. "min-width" : "180px",
  750. "z-index" : "1001",
  751. "background-color" : "#fff",
  752. "padding" : "10px",
  753. "border-radius" : "8px",
  754. "box-shadow": "0 0 12px 0 #999999",
  755. "-webkit-user-select": "text",
  756. "-moz-user-select": "text"
  757. },
  758. isFitToContainer : true,
  759. overflow : "scroll"
  760. },
  761. _loadCustom : function( callback ){
  762. if(callback)callback();
  763. },
  764. _customNode : function( node, contentNode ){
  765. this.inforNode.inject(contentNode);
  766. if( this.inforNode.getSize().y > 300 ){
  767. this.inforNode.setStyle("padding-bottom", "15px");
  768. }
  769. this.fireEvent("customContent", [contentNode, node]);
  770. }
  771. });