Role.js 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. MWF.xDesktop.requireApp("Selector", "Person", null, false);
  2. MWF.xApplication.Selector.Role = new Class({
  3. Extends: MWF.xApplication.Selector.Person,
  4. options: {
  5. "style": "default",
  6. "count": 0,
  7. "title": MWF.xApplication.Selector.LP.selectRole,
  8. "groups": [],
  9. "roles": [],
  10. "values": [],
  11. "names": []
  12. },
  13. _listItemByKey: function(callback, failure, key){
  14. if (this.options.units.length || this.options.roles.length) key = this.getLikeKey(key);
  15. this.orgAction.listRoleByKey(function(json){
  16. if (callback) callback.apply(this, [json]);
  17. }.bind(this), failure, key);
  18. },
  19. _getItem: function(callback, failure, id, async){
  20. this.orgAction.getRole(function(json){
  21. if (callback) callback.apply(this, [json]);
  22. }.bind(this), failure, ((typeOf(id)==="string") ? id : id.distinguishedName), async);
  23. },
  24. _newItemSelected: function(data, selector, item){
  25. return new MWF.xApplication.Selector.Role.ItemSelected(data, selector, item)
  26. },
  27. _listItemByPinyin: function(callback, failure, key){
  28. if (this.options.units.length || this.options.roles.length) key = this.getLikeKey(key);
  29. this.orgAction.listRoleByPinyin(function(json){
  30. if (callback) callback.apply(this, [json]);
  31. }.bind(this), failure, key);
  32. },
  33. _newItem: function(data, selector, container){
  34. return new MWF.xApplication.Selector.Role.Item(data, selector, container);
  35. },
  36. _listItemNext: function(last, count, callback){
  37. this.orgAction.listRoleNext(last, count, function(json){
  38. if (callback) callback.apply(this, [json]);
  39. }.bind(this));
  40. },
  41. _getChildrenItemIds: function(data){
  42. return data.roleList;
  43. },
  44. getLikeKey : function( key ){
  45. var result = key;
  46. if (this.options.groups.length || this.options.roles.length){
  47. var array = [];
  48. this.options.groups.each( function(d){
  49. array.push( typeOf(d)==="object" ? d.distinguishedName : d );
  50. }.bind(this));
  51. var array2 = [];
  52. this.options.roles.each( function(d){
  53. array2.push( typeOf(d)==="object" ? d.distinguishedName : d );
  54. }.bind(this));
  55. result = {"key": key || "", "groupList": array, "roleList": array2};
  56. }
  57. return result;
  58. }
  59. });
  60. MWF.xApplication.Selector.Role.Item = new Class({
  61. Extends: MWF.xApplication.Selector.Person.Item,
  62. _getShowName: function(){
  63. return this.data.name;
  64. },
  65. _setIcon: function(){
  66. this.iconNode.setStyle("background-image", "url("+"/x_component_Selector/$Selector/default/icon/roleicon.png)");
  67. }
  68. });
  69. MWF.xApplication.Selector.Role.ItemSelected = new Class({
  70. Extends: MWF.xApplication.Selector.Person.ItemSelected,
  71. _getShowName: function(){
  72. return this.data.name;
  73. },
  74. _setIcon: function(){
  75. this.iconNode.setStyle("background-image", "url("+"/x_component_Selector/$Selector/default/icon/roleicon.png)");
  76. }
  77. });