Role.js 3.2 KB

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