GroupExplorer.js 26 KB

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