RoleExplorer.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. MWF.xDesktop.requireApp("Org", "PersonExplorer", null, false);
  2. MWF.xApplication.Org.RoleExplorer = new Class({
  3. Extends: MWF.xApplication.Org.PersonExplorer,
  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.roleLoaded,
  14. "search": this.app.lp.search,
  15. "searchText": this.app.lp.searchText,
  16. "elementSave": this.app.lp.roleSave,
  17. "deleteElements": this.app.lp.deleteRoles,
  18. "deleteElementsTitle": this.app.lp.deleteRolesTitle,
  19. "deleteElementsConfirm": this.app.lp.deleteRolesConfirm,
  20. "elementBaseText": this.app.lp.roleBaseText,
  21. "elementName": this.app.lp.roleName,
  22. "edit": this.app.lp.edit,
  23. "cancel": this.app.lp.cancel,
  24. "save": this.app.lp.save,
  25. "add": this.app.lp.add,
  26. "inputElementName": this.app.lp.inputRoleName,
  27. "elementMemberPersonText": this.app.lp.roleMemberPersonText,
  28. "personEmployee": this.app.lp.personEmployee,
  29. "personDisplay": this.app.lp.personDisplay,
  30. "personMail": this.app.lp.personMail,
  31. "personPhone": this.app.lp.personPhone,
  32. "deletePersonMemberTitle": this.app.lp.deletePersonMemberTitle,
  33. "deletePersonMember": this.app.lp.deletePersonMember,
  34. "elementMemberGroupText": this.app.lp.roleMemberGroupText,
  35. "groupDescription": this.app.lp.groupDescription,
  36. "groupName": this.app.lp.groupName,
  37. "deleteGroupMemberTitle": this.app.lp.deleteGroupMemberTitle,
  38. "deleteGroupMember": this.app.lp.deleteGroupMember
  39. }
  40. },
  41. _listElementNext: function(lastid, count, callback){
  42. this.actions.listRoleNext(lastid, count, function(json){
  43. if (callback) callback.apply(this, [json]);
  44. }.bind(this));
  45. },
  46. _newElement: function(data, explorer){
  47. return new MWF.xApplication.Org.RoleExplorer.Role(data, explorer, this.isEditor);
  48. },
  49. _listElementByKey: function(callback, failure, key){
  50. this.actions.listRoleByKey(function(json){
  51. if (callback) callback.apply(this, [json]);
  52. }.bind(this), failure, key);
  53. },
  54. _getAddElementData: function(){
  55. return {
  56. "personList": [],
  57. "groupList": [],
  58. "id": "",
  59. "name": ""
  60. };
  61. },
  62. loadToolbar: function(){
  63. if (MWF.AC.isAdministrator()){
  64. this.isEditor = true;
  65. this.addTopElementNode = new Element("div", {"styles": this.css.addTopGroupNode}).inject(this.toolbarNode);
  66. this.addTopElementNode.addEvent("click", function(){
  67. this.addTopElement();
  68. }.bind(this));
  69. }
  70. this.createSearchNode();
  71. this.loadPingyinArea();
  72. }
  73. });
  74. MWF.xApplication.Org.RoleExplorer.Role = new Class({
  75. Extends: MWF.xApplication.Org.PersonExplorer.Item,
  76. showItemProperty: function(){
  77. this.content = new MWF.xApplication.Org.RoleExplorer.RoleContent(this);
  78. },
  79. "delete": function(success, failure){
  80. this.explorer.actions.deleteRole(this.data.id, function(){
  81. this.destroy();
  82. if (success) success();
  83. }.bind(this), function(xhr, text, error){
  84. var errorText = error;
  85. if (xhr) errorText = xhr.responseText;
  86. MWF.xDesktop.notice("error", {x: "right", y:"top"}, "request json error: "+errorText);
  87. if (failure) failure();
  88. });
  89. },
  90. _getIcon: function(){
  91. return "/x_component_Org/$Explorer/default/icon/role.png";
  92. }
  93. });
  94. MWF.xApplication.Org.RoleExplorer.RoleContent = new Class({
  95. Extends: MWF.xApplication.Org.PersonExplorer.ItemContent
  96. });