GroupExplorer.js 26 KB

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