Role.js 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. "selectType" : "role"
  13. },
  14. _init : function(){
  15. this.selectType = "role";
  16. this.className = "Role";
  17. },
  18. _listItemByKey: function(callback, failure, key){
  19. if (this.options.units.length || this.options.roles.length) key = this.getLikeKey(key);
  20. this.orgAction.listRoleByKey(function(json){
  21. if (callback) callback.apply(this, [json]);
  22. }.bind(this), failure, key);
  23. },
  24. _getItem: function(callback, failure, id, async){
  25. this.orgAction.getRole(function(json){
  26. if (callback) callback.apply(this, [json]);
  27. }.bind(this), failure, ((typeOf(id)==="string") ? id : id.distinguishedName), async);
  28. },
  29. _newItemSelected: function(data, selector, item, selectedNode){
  30. return new MWF.xApplication.Selector.Role.ItemSelected(data, selector, item, selectedNode)
  31. },
  32. _listItemByPinyin: function(callback, failure, key){
  33. if (this.options.units.length || this.options.roles.length) key = this.getLikeKey(key);
  34. this.orgAction.listRoleByPinyin(function(json){
  35. if (callback) callback.apply(this, [json]);
  36. }.bind(this), failure, key);
  37. },
  38. _newItem: function(data, selector, container){
  39. return new MWF.xApplication.Selector.Role.Item(data, selector, container);
  40. },
  41. _listItemNext: function(last, count, callback){
  42. this.orgAction.listRoleNext(last, count, function(json){
  43. if (callback) callback.apply(this, [json]);
  44. }.bind(this));
  45. },
  46. _getChildrenItemIds: function(data){
  47. return data.roleList;
  48. },
  49. getLikeKey : function( key ){
  50. var result = key;
  51. if (this.options.groups.length || this.options.roles.length){
  52. var array = [];
  53. this.options.groups.each( function(d){
  54. array.push( typeOf(d)==="object" ? d.distinguishedName : d );
  55. }.bind(this));
  56. var array2 = [];
  57. this.options.roles.each( function(d){
  58. array2.push( typeOf(d)==="object" ? d.distinguishedName : d );
  59. }.bind(this));
  60. result = {"key": key || "", "groupList": array, "roleList": array2};
  61. }
  62. return result;
  63. }
  64. });
  65. MWF.xApplication.Selector.Role.Item = new Class({
  66. Extends: MWF.xApplication.Selector.Person.Item,
  67. _getShowName: function(){
  68. return this.data.name;
  69. },
  70. _setIcon: function(){
  71. var style = this.selector.options.style;
  72. this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/"+style+"/icon/roleicon.png)");
  73. }
  74. });
  75. MWF.xApplication.Selector.Role.ItemSelected = new Class({
  76. Extends: MWF.xApplication.Selector.Person.ItemSelected,
  77. _getShowName: function(){
  78. return this.data.name;
  79. },
  80. _setIcon: function(){
  81. var style = this.selector.options.style;
  82. this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/"+style+"/icon/roleicon.png)");
  83. }
  84. });