GroupExplorer.js 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  1. MWF.xDesktop.requireApp("Template", "MTooltips", null, false);
  2. MWF.xDesktop.requireApp("Org", "RoleExplorer", null, false);
  3. MWF.xApplication.Org.GroupExplorer = new Class({
  4. Extends: MWF.xApplication.Org.$Explorer,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "lp": {
  9. },
  10. "creator": false
  11. },
  12. _loadLp: function(){
  13. this.options.lp = {
  14. "elementLoaded": this.app.lp.groupLoaded,
  15. "search": this.app.lp.search,
  16. "searchText": this.app.lp.searchText,
  17. "elementSave": this.app.lp.groupSave,
  18. "deleteElements": this.app.lp.deleteGroups,
  19. "deleteElementsCancel": this.app.lp.deleteElementsCancel,
  20. "deleteElementsTitle": this.app.lp.deleteGroupsTitle,
  21. "deleteElementsConfirm": this.app.lp.deleteGroupsConfirm,
  22. "elementBaseText": this.app.lp.groupBaseText,
  23. "elementName": this.app.lp.groupName,
  24. "noSignature": this.app.lp.noSignature,
  25. "edit": this.app.lp.edit,
  26. "cancel": this.app.lp.cancel,
  27. "save": this.app.lp.save,
  28. "add": this.app.lp.add
  29. }
  30. },
  31. _listElementNext: function(lastid, count, callback){
  32. this.actions.listGroupNext(lastid || "(0)", count, function(json){
  33. if (callback) callback.apply(this, [json]);
  34. }.bind(this));
  35. },
  36. _newElement: function(data, explorer){
  37. return new MWF.xApplication.Org.GroupExplorer.Group(data, explorer, this.isEditor);
  38. },
  39. _listElementByKey: function(callback, failure, key){
  40. this.actions.listGroupByKey(function(json){
  41. if (callback) callback.apply(this, [json]);
  42. }.bind(this), failure, key);
  43. },
  44. _getAddElementData: function(){
  45. return {
  46. "personList": [],
  47. "groupList": [],
  48. "identityList" : [],
  49. "unitList": [],
  50. "description": "",
  51. "unique": "",
  52. "orderNumber": "",
  53. "id": "",
  54. "name": "",
  55. "control": {
  56. "allowEdit": true,
  57. "allowDelete": true
  58. }
  59. };
  60. },
  61. _isActionManager: function() {
  62. return (MWF.AC.isOrganizationManager() || MWF.AC.isGroupManager() && !MWF.AC.isSecurityManager());
  63. }
  64. });
  65. MWF.xApplication.Org.GroupExplorer.Group = new Class({
  66. Extends: MWF.xApplication.Org.$Explorer.Item,
  67. addActions: function(){
  68. if (this.isEditor){
  69. if (this.data.id){
  70. if (this.data.control.allowDelete || MWF.AC.isSecurityManager()){
  71. if (!this.deleteNode){
  72. this.deleteNode = new Element("div.o2icon-delete", {"styles": this.style.actionDeleteNode}).inject(this.actionNode);
  73. this.deleteNode.addEvent("click", function(e){
  74. if (!this.notDelete){
  75. if (!this.deleteSelected){
  76. this.setDelete();
  77. }else{
  78. this.setUndelete();
  79. }
  80. }
  81. e.stopPropagation();
  82. }.bind(this));
  83. if (this.explorer.currentItem===this){
  84. if (this.deleteNode) this.deleteNode.setStyles(this.style.actionDeleteNode_selected);
  85. }
  86. }
  87. }
  88. }
  89. }
  90. },
  91. showItemProperty: function(){
  92. this.content = new MWF.xApplication.Org.GroupExplorer.GroupContent(this);
  93. },
  94. "delete": function(success, failure){
  95. this.explorer.actions.deleteGroup(this.data.id, function(){
  96. this.destroy();
  97. if (success) success();
  98. }.bind(this), function(xhr, text, error){
  99. var errorText = error;
  100. if (xhr) errorText = xhr.responseText;
  101. MWF.xDesktop.notice("error", {x: "right", y:"top"}, "request json error: "+errorText);
  102. if (failure) failure();
  103. });
  104. },
  105. _getIcon: function(){
  106. return "../x_component_Org/$Explorer/default/icon/group.png";
  107. }
  108. });
  109. MWF.xApplication.Org.GroupExplorer.GroupContent = new Class({
  110. Extends: MWF.xApplication.Org.$Explorer.ItemContent,
  111. _getData: function(callback){
  112. if (this.item.data.id){
  113. this.explorer.actions.getGroup(function(json){
  114. this.data = json.data;
  115. this.item.data = json.data;
  116. if (callback) callback();
  117. }.bind(this), null, this.item.data.id);
  118. }else{
  119. this.data = this.item.data;
  120. if (callback) callback();
  121. }
  122. },
  123. _showItemPropertyTitle: function(){
  124. this.titleInfor = new MWF.xApplication.Org.GroupExplorer.GroupContent.TitleInfor(this);
  125. },
  126. _showItemPropertyBottom: function(){
  127. this.bottomInfor = new MWF.xApplication.Org.GroupExplorer.GroupContent.BottomInfor(this);
  128. },
  129. loadItemPropertyTab: function(callback){
  130. this.propertyTabContainerNode = new Element("div", {"styles": this.item.style.tabTitleNode}).inject(this.propertyContentNode, "top");
  131. MWF.require("MWF.widget.Tab", function(){
  132. this.propertyTab = new MWF.widget.Tab(this.propertyContentNode, {"style": "unit", "useMainColor":true});
  133. this.propertyTab.load();
  134. this.propertyTab.tabNodeContainer.inject(this.propertyTabContainerNode);
  135. this.propertyTab.tabNodeContainer.setStyle("width","600px");
  136. if (callback) callback();
  137. }.bind(this));
  138. },
  139. _loadTabs: function(){
  140. this.baseContentNode = new Element("div", {"styles": this.item.style.tabContentNode});
  141. this.basePage = this.propertyTab.addTab(this.baseContentNode, this.explorer.app.lp.groupBaseText);
  142. this.personMemberContentNode = new Element("div", {"styles": this.item.style.tabContentNode});
  143. this.personMemberPage = this.propertyTab.addTab(this.personMemberContentNode, this.explorer.app.lp.groupMemberPersonText);
  144. this.identityMemberContentNode = new Element("div", {"styles": this.item.style.tabContentNode});
  145. this.identityMemberPage = this.propertyTab.addTab(this.identityMemberContentNode, this.explorer.app.lp.groupMemberIdentityText);
  146. this.groupMemberContentNode = new Element("div", {"styles": this.item.style.tabContentNode});
  147. this.groupMemberPage = this.propertyTab.addTab(this.groupMemberContentNode, this.explorer.app.lp.groupMemberGroupText);
  148. this.unitMemberContentNode = new Element("div", {"styles": this.item.style.tabContentNode});
  149. this.unitMemberPage = this.propertyTab.addTab(this.unitMemberContentNode, this.explorer.app.lp.unitMemberGroupText);
  150. },
  151. _loadContent: function(){
  152. debugger;
  153. this._listBaseInfor();
  154. this.loadListCount();
  155. var _self = this;
  156. this.personMemberList = this._listMembers("personList", "woPersonList", this.personMemberContentNode, [{
  157. "getHtml": function(){
  158. var src = _self.explorer.actions.getPersonIcon(this.id);
  159. return "<div style='width:24px; height:24px;''><img style='width:24px; height:24px; border-radius:12px; border: 0' src='"+src+"'/></div>";
  160. },
  161. "set": function(){}
  162. }, "name", "employee", "mobile", "mail", {
  163. "getHtml": function(){
  164. return "<div style='width:24px; height:24px; cursor: pointer; background:url(../x_component_Org/$Explorer/"+
  165. _self.explorer.app.options.style+"/icon/open.png) center center no-repeat'></div>";
  166. },
  167. "events": {
  168. "click": function(){
  169. _self.explorer.openPerson(this.data, this.td);
  170. }
  171. }
  172. }], [
  173. {"style": "width: 30px", "text": ""},
  174. {"style": "width: 20%", "text": this.explorer.app.lp.personName},
  175. {"style": "", "text": this.explorer.app.lp.personEmployee},
  176. {"style": "", "text": this.explorer.app.lp.personMobile},
  177. {"style": "", "text": this.explorer.app.lp.personMail},
  178. {"style": "width: 30px", "text": ""}
  179. ], this.addPersonMember.bind(this), "personCountNode", this.explorer.app.lp.deletePersonMemeberTitle, this.explorer.app.lp.deletePersonMemeber);
  180. this.identityMemberList = this._listMembers("identityList", "woIdentityList", this.identityMemberContentNode, [{
  181. "getHtml": function(){
  182. var src = _self.explorer.actions.getPersonIcon(this.person);
  183. return "<div style='width:24px; height:24px;''><img style='width:24px; height:24px; border-radius:12px; border: 0' src='"+src+"'/></div>";
  184. },
  185. "set": function(){}
  186. }, "name", "unitLevelName", {
  187. "getHtml": function(){
  188. return "<div style='width:24px; height:24px; cursor: pointer; background:url(/x_component_Org/$Explorer/"+
  189. _self.explorer.app.options.style+"/icon/open.png) center center no-repeat'></div>";
  190. },
  191. "events": {
  192. "click": function(){
  193. }
  194. }
  195. }], [
  196. {"style": "width: 30px", "text": ""},
  197. {"style": "width: 20%", "text": this.explorer.app.lp.personName},
  198. {"style": "", "text": this.explorer.app.lp.unitLevelName},
  199. {"style": "width: 30px", "text": ""}
  200. ], this.addIdentityMember.bind(this), "identityCountNode", this.explorer.app.lp.deleteIdentityMemeberTitle, this.explorer.app.lp.deleteIdentityMemeber);
  201. this.groupMemberList = this._listMembers("groupList", "woGroupList", this.groupMemberContentNode, ["name", "distinguishedName", //"description",
  202. {
  203. "getHtml": function(){
  204. return "<div style='width:24px; height:24px; cursor: pointer; background:url(../x_component_Org/$Explorer/"+
  205. _self.explorer.app.options.style+"/icon/open.png) center center no-repeat'></div>";
  206. },
  207. "events": {
  208. "click": function(){
  209. _self.explorer.openGroup(this.data, this.td);
  210. }
  211. }
  212. }
  213. ], [
  214. {"style": "width: 20%", "text": this.explorer.app.lp.groupName},
  215. {"style": "width: 40%", "text": this.explorer.app.lp.groupDn},
  216. //{"style": "", "text": this.explorer.app.lp.groupDescription},
  217. {"style": "width: 30px", "text": ""}
  218. ], this.addGroupMember.bind(this), "groupCountNode", this.explorer.app.lp.deleteGroupMemeberTitle, this.explorer.app.lp.deleteGroupMemeber);
  219. this.unitMemberList = this._listMembers("unitList", "woUnitList", this.unitMemberContentNode, ["name", "levelName", //"typeList",
  220. {
  221. "getHtml": function(){
  222. return "<div style='width:24px; height:24px; cursor: pointer; background:url(../x_component_Org/$Explorer/"+
  223. _self.explorer.app.options.style+"/icon/open.png) center center no-repeat'></div>";
  224. },
  225. "events": {
  226. "click": function(){
  227. _self.explorer.openUnit(this.data, this.td);
  228. }
  229. }
  230. }], [
  231. {"style": "width: 20%", "text": this.explorer.app.lp.unitName},
  232. {"style": "width: 40%", "text": this.explorer.app.lp.unitLevelName},
  233. //{"style": "", "text": this.explorer.app.lp.unitTypeList},
  234. {"style": "width: 30px", "text": ""}
  235. ], this.addUnitMember.bind(this), "unitCountNode", this.explorer.app.lp.deleteUnitMemeberTitle, this.explorer.app.lp.deleteUnitMemeber);
  236. },
  237. loadListCount: function(){
  238. var personCount = this.data.personList.length;
  239. if (personCount){
  240. if (this.personCountNode){
  241. this.personCountNode.set("text", personCount);
  242. }else{
  243. this.personCountNode = new Element("div", {"styles": this.item.style.tabCountNode, "text": personCount}).inject(this.personMemberPage.tabNode);
  244. }
  245. }else{
  246. if (this.personCountNode) this.personCountNode.destroy();
  247. }
  248. var identityCount = this.data.identityList.length;
  249. if (identityCount){
  250. if (this.identityCountNode){
  251. this.identityCountNode.set("text", identityCount);
  252. }else{
  253. this.identityCountNode = new Element("div", {"styles": this.item.style.tabCountNode, "text": identityCount}).inject(this.identityMemberPage.tabNode);
  254. }
  255. }else{
  256. if (this.identityCountNode) this.identityCountNode.destroy();
  257. }
  258. var groupCount = this.data.groupList.length;
  259. if (groupCount){
  260. if (this.groupCountNode){
  261. this.groupCountNode.set("text", groupCount);
  262. }else{
  263. this.groupCountNode = new Element("div", {"styles": this.item.style.tabCountNode, "text": groupCount}).inject(this.groupMemberPage.tabNode);
  264. }
  265. }else{
  266. if (this.groupCountNode) this.groupCountNode.destroy();
  267. }
  268. var unitCount = this.data.unitList.length;
  269. if (unitCount){
  270. if (this.unitCountNode){
  271. this.unitCountNode.set("text", unitCount);
  272. }else{
  273. this.unitCountNode = new Element("div", {"styles": this.item.style.tabCountNode, "text": unitCount}).inject(this.unitMemberPage.tabNode);
  274. }
  275. }else{
  276. if (this.unitCountNode) this.unitCountNode.destroy();
  277. }
  278. },
  279. _listBaseInfor: function(){
  280. this.baseInfor = new MWF.xApplication.Org.GroupExplorer.GroupContent.BaseInfor(this);
  281. },
  282. _listMembers: function(list, woList, node, attr, titles, addItemFun, countNode, deleteTitle, deleteText){
  283. var memberList = new MWF.xApplication.Org.List(node, this, {
  284. "action": this.data.control.allowEdit && !MWF.AC.isSystemManager(),
  285. "canEdit": false,
  286. "deleteItemTitle": deleteTitle,
  287. "deleteItemText": deleteText,
  288. "data": {
  289. "person": this.data.id,
  290. "name": "",
  291. "unique": "",
  292. "orderNumber": "",
  293. "attributeList": []
  294. },
  295. "attr": attr,
  296. "onQueryDelete": function(){
  297. this.saveCloneData = Object.clone(this.data);
  298. }.bind(this),
  299. "onDelete": function(continueDelete){
  300. this.explorer.actions.saveGroup(this.saveCloneData, function(json){
  301. this.data[list] = this.saveCloneData[list];
  302. this.data[woList] = this.saveCloneData[woList];
  303. this.data.id = json.data.id;
  304. this.saveCloneData = null;
  305. delete this.saveCloneData;
  306. }.bind(this), function(xhr, text, error){
  307. continueDelete = false;
  308. this.explorer.app.notice((JSON.decode(xhr.responseText).message.trim() || "request json error"), "error");
  309. }.bind(this), false);
  310. }.bind(this),
  311. "onPostDelete": function(delCount){
  312. if (this[countNode]){
  313. var count = this[countNode].get("text").toInt()-delCount;
  314. this[countNode].set("text", count);
  315. }
  316. }.bind(this)
  317. });
  318. memberList.addItem = addItemFun;
  319. memberList.load(titles);
  320. var _self = this;
  321. if (this.data[woList] && this.data[woList].length){
  322. this.data[woList].each(function(d){
  323. var item = memberList.push(d);
  324. item["delete"] = function(callback){
  325. _self.saveCloneData[list].erase(this.data.id);
  326. _self.saveCloneData[woList] = _self.saveCloneData[woList].filter(function(a){
  327. return (this.data.id !== a.id);
  328. }.bind(this));
  329. if (callback) callback();
  330. };
  331. }.bind(this));
  332. }
  333. return memberList;
  334. },
  335. addListItem: function(memberList, data, list, woList){
  336. var _self = this;
  337. var item = memberList.push(data);
  338. item["delete"] = function(callback){
  339. _self.saveCloneData[list].erase(this.data.id);
  340. _self.saveCloneData[woList] = _self.saveCloneData[woList].filter(function(a){
  341. return (this.data.id !== a.id);
  342. }.bind(this));
  343. if (callback) callback();
  344. };
  345. },
  346. checkSaveBaseInfor: function(callback){
  347. if (!this.data.id){
  348. if (this.baseInfor){
  349. if (this.baseInfor.mode==="edit") this.baseInfor.save(function(){
  350. if (callback) callback();
  351. }.bind(this));
  352. }
  353. }else{
  354. if (callback) callback();
  355. }
  356. },
  357. addPersonMember: function(){
  358. this.checkSaveBaseInfor(function(){
  359. MWF.xDesktop.requireApp("Selector", "Person", function(){
  360. var selector = new MWF.xApplication.Selector.Person(this.explorer.app.content,{
  361. "values": this.data.personList,
  362. "onComplete": function(items){
  363. var ids = [];
  364. var persons = [];
  365. items.each(function(item){
  366. ids.push(item.data.id);
  367. persons.push(item.data);
  368. });
  369. this.data.personList = ids;
  370. this.data.woPersonList = persons;
  371. this._saveElement(this.data, function(){
  372. this.personMemberList.clear();
  373. this.data.woPersonList.each(function(d){
  374. this.addListItem(this.personMemberList, d, "personList", "woPersonList");
  375. }.bind(this));
  376. }.bind(this));
  377. }.bind(this)
  378. });
  379. selector.load();
  380. }.bind(this));
  381. }.bind(this));
  382. },
  383. addIdentityMember: function(){
  384. this.checkSaveBaseInfor(function(){
  385. MWF.xDesktop.requireApp("Selector", "Identity", function(){
  386. var selector = new MWF.xApplication.Selector.Identity(this.explorer.app.content,{
  387. "values": this.data.identityList,
  388. "onComplete": function(items){
  389. var ids = [];
  390. var identitys = [];
  391. items.each(function(item){
  392. ids.push(item.data.id);
  393. identitys.push(item.data);
  394. });
  395. this.data.identityList = ids;
  396. this.data.woIdentityList = identitys;
  397. this._saveElement(this.data, function(){
  398. this.identityMemberList.clear();
  399. this.data.woIdentityList.each(function(d){
  400. this.addListItem(this.identityMemberList, d, "identityList", "woIdentityList");
  401. }.bind(this));
  402. }.bind(this));
  403. }.bind(this)
  404. });
  405. selector.load();
  406. }.bind(this));
  407. }.bind(this));
  408. },
  409. addGroupMember: function(){
  410. this.checkSaveBaseInfor(function(){
  411. MWF.xDesktop.requireApp("Selector", "Group", function(){
  412. var selector = new MWF.xApplication.Selector.Group(this.explorer.app.content,{
  413. "values": this.data.groupList,
  414. "onComplete": function(items){
  415. var ids = [];
  416. var groups = [];
  417. items.each(function(item){
  418. ids.push(item.data.id);
  419. groups.push(item.data);
  420. });
  421. this.data.groupList = ids;
  422. this.data.woGroupList = groups;
  423. this._saveElement(this.data, function(){
  424. this.groupMemberList.clear();
  425. this.data.woGroupList.each(function(d){
  426. this.addListItem(this.groupMemberList, d, "groupList", "woGroupList");
  427. }.bind(this));
  428. }.bind(this));
  429. }.bind(this)
  430. });
  431. selector.load();
  432. }.bind(this));
  433. }.bind(this));
  434. },
  435. addUnitMember: function(){
  436. this.checkSaveBaseInfor(function(){
  437. MWF.xDesktop.requireApp("Selector", "Unit", function(){
  438. var selector = new MWF.xApplication.Selector.Unit(this.explorer.app.content,{
  439. "values": this.data.unitList,
  440. "onComplete": function(items){
  441. var ids = [];
  442. var groups = [];
  443. items.each(function(item){
  444. ids.push(item.data.id);
  445. groups.push(item.data);
  446. });
  447. this.data.unitList = ids;
  448. this.data.woUnitList = groups;
  449. this._saveElement(this.data, function(){
  450. this.unitMemberList.clear();
  451. this.data.woUnitList.each(function(d){
  452. this.addListItem(this.unitMemberList, d, "unitList", "woUnitList");
  453. }.bind(this));
  454. }.bind(this));
  455. }.bind(this)
  456. });
  457. selector.load();
  458. }.bind(this));
  459. }.bind(this));
  460. },
  461. _saveElement: function(data, success, failure){
  462. this.explorer.actions.saveGroup(data, function(json){
  463. Object.merge(this.data, data);
  464. if (this.data.id){
  465. this.data.id = json.data.id;
  466. this.item.refresh();
  467. if (success) success();
  468. }else{
  469. this.explorer.actions.getGroup(function(json){
  470. this.data = json.data;
  471. this.item.refresh();
  472. if (success) success();
  473. }.bind(this), null, json.data.id);
  474. }
  475. }.bind(this), function(xhr, text, error){
  476. if (failure) failure(xhr, text, error);
  477. }.bind(this));
  478. }
  479. });
  480. MWF.xApplication.Org.GroupExplorer.GroupContent.TitleInfor = new Class({
  481. Extends: MWF.xApplication.Org.RoleExplorer.RoleContent.TitleInfor,
  482. _getIcon: function(){
  483. return "../x_component_Org/$Explorer/default/icon/group70.png";
  484. }
  485. });
  486. MWF.xApplication.Org.GroupExplorer.GroupContent.BottomInfor = new Class({
  487. Extends: MWF.xApplication.Org.$Explorer.ItemContent.BottomInfor,
  488. addInforList: function(){
  489. var text = this.explorer.app.lp.groupReadDn.replace(/{dn}/g, (this.data.distinguishedName || " "));
  490. this.addInfor(text);
  491. text = this.explorer.app.lp.groupReadCreate.replace(/{date}/g, (this.data.createTime || " "));
  492. text = text.replace(/{date2}/g, (this.data.updateTime || " "));
  493. this.addInfor(text);
  494. }
  495. });
  496. MWF.xApplication.Org.GroupExplorer.GroupContent.BaseInfor = new Class({
  497. Extends: MWF.xApplication.Org.RoleExplorer.RoleContent.BaseInfor,
  498. getContentHtml: function(){
  499. var html = "<table width='100%' cellpadding='3px' cellspacing='5px'>";
  500. html += "<tr><td class='inforTitle'>"+this.explorer.app.lp.groupName+":</td><td class='inforContent infor_name'></td>" +
  501. "<td class='inforTitle'>"+this.explorer.app.lp.groupUnique+":</td><td class='inforContent infor_unique'></td></tr>";
  502. html += "<tr><td class='inforTitle'>"+this.explorer.app.lp.groupDescription+":</td><td colspan='3' class='inforContent infor_description'></td>";
  503. html += "<tr><td colspan='4' class='inforAction'></td></tr>";
  504. //this.baseInforRightNode.set("html", html);
  505. return html;
  506. },
  507. loadAction: function(){
  508. //this.explorer.app.lp.edit
  509. var actionAreas = this.editContentNode.getElements("td");
  510. var actionArea = actionAreas[actionAreas.length-1];
  511. if (this.data.control.allowEdit && !MWF.AC.isSecurityManager()){
  512. this.baseInforEditActionAreaNode = new Element("div", {"styles": this.style.baseInforEditActionAreaNode}).inject(actionArea);
  513. this.editNode = new Element("div", {"styles": this.style.actionEditNode, "text": this.explorer.app.lp.editGroup}).inject(this.baseInforEditActionAreaNode);
  514. this.saveNode = new Element("div", {"styles": this.style.actionSaveNode, "text": this.explorer.app.lp.saveGroup}).inject(this.baseInforEditActionAreaNode);
  515. this.saveNode.addClass("mainColor_bg");
  516. this.cancelNode = new Element("div", {"styles": this.style.actionCancelNode, "text": this.explorer.app.lp.cancel}).inject(this.baseInforEditActionAreaNode);
  517. this.editNode.setStyle("display", "block");
  518. this.editNode.addEvent("click", this.edit.bind(this));
  519. this.saveNode.addEvent("click", this.save.bind(this));
  520. this.cancelNode.addEvent("click", this.cancel.bind(this));
  521. }else{
  522. }
  523. },
  524. edit: function(){
  525. var tdContents = this.editContentNode.getElements("td.inforContent");
  526. tdContents[0].setStyles(this.style.baseInforContentNode_edit).empty();
  527. this.nameInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[0]);
  528. this.nameInputNode.set("value", (this.data.name));
  529. tdContents[1].setStyles(this.style.baseInforContentNode_edit).empty();
  530. this.uniqueInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[1]);
  531. this.uniqueInputNode.set("value", (this.data.unique));
  532. if( this.data.id ){
  533. this.tooltip = new MWF.xApplication.Org.GroupExplorer.GroupContent.UniqueTooltip(this.explorer.app.content, tdContents[1], this.explorer.app, {}, {
  534. axis : "y",
  535. position : {
  536. x : "right"
  537. },
  538. hiddenDelay : 300,
  539. displayDelay : 300
  540. });
  541. }
  542. tdContents[2].setStyles(this.style.baseInforContentNode_edit).empty();
  543. this.descriptionInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[2]);
  544. this.descriptionInputNode.set("value", (this.data.description));
  545. var _self = this;
  546. this.editContentNode.getElements("input").addEvents({
  547. "focus": function(){if (this.get("type").toLowerCase()==="text"){this.setStyles(_self.style.inputNode_focus);}},
  548. "blur": function(){if (this.get("type").toLowerCase()==="text"){this.setStyles(_self.style.inputNode_blur);}}
  549. });
  550. this.mode = "edit";
  551. this.editNode.setStyle("display", "none");
  552. this.saveNode.setStyle("display", "block");
  553. this.cancelNode.setStyle("display", "block");
  554. },
  555. save: function(){
  556. if (!this.nameInputNode.get("value")){
  557. this.explorer.app.notice(this.explorer.app.lp.inputGroupInfor, "error", this.explorer.propertyContentNode);
  558. return false;
  559. }
  560. //this.data.genderType = gender;
  561. if (!this.uniqueInputNode.get("value")) this.data.unique = this.nameInputNode.get("value");
  562. this.content.propertyContentScrollNode.mask({
  563. "style": {
  564. "opacity": 0.7,
  565. "background-color": "#999"
  566. }
  567. });
  568. this.saveGroup(function(){
  569. this.cancel();
  570. this.content.propertyContentScrollNode.unmask();
  571. }.bind(this), function(xhr, text, error){
  572. this.explorer.app.notice((JSON.decode(xhr.responseText).message.trim() || "request json error"), "error");
  573. this.content.propertyContentScrollNode.unmask();
  574. }.bind(this));
  575. },
  576. saveGroup: function(callback, cancel){
  577. var data = Object.clone(this.data);
  578. data.name = this.nameInputNode.get("value");
  579. data.unique = this.uniqueInputNode.get("value");
  580. data.description = this.descriptionInputNode.get("value");
  581. this.explorer.actions.saveGroup(data, function(json){
  582. Object.merge(this.data, data);
  583. if (this.data.id){
  584. this.data.id = json.data.id;
  585. this.item.refresh();
  586. if (callback) callback();
  587. }else{
  588. this.explorer.actions.getGroup(function(json){
  589. this.data = Object.merge(this.data, json.data);
  590. this.item.data = this.data;
  591. this.item.refresh();
  592. if (callback) callback();
  593. }.bind(this), null, json.data.id);
  594. }
  595. }.bind(this), function(xhr, text, error){
  596. if (cancel) cancel(xhr, text, error);
  597. }.bind(this));
  598. },
  599. destroy: function(){
  600. if( this.tooltip ){
  601. this.tooltip.destroy();
  602. this.tooltip = null;
  603. }
  604. this.node.empty();
  605. this.node.destroy();
  606. MWF.release(this);
  607. }
  608. });
  609. MWF.xApplication.Org.GroupExplorer.GroupContent.UniqueTooltip = new Class({
  610. Extends: MTooltips,
  611. _getHtml : function(){
  612. var html =
  613. "<div item='containr' style='line-height:24px;'><div style='font-size: 14px;color:red;float:left; '>"+ this.lp.groupUniqueModifyNote +"</div></div>";
  614. return html;
  615. }
  616. });