Group.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. MWF.xDesktop.requireApp("Selector", "Person", null, false);
  2. MWF.xApplication.Selector.Group = new Class({
  3. Extends: MWF.xApplication.Selector.Person,
  4. options: {
  5. "style": "default",
  6. "count": 0,
  7. "title": MWF.xApplication.Selector.LP.selectGroup,
  8. "groups": [],
  9. "roles": [],
  10. "values": [],
  11. "names": []
  12. },
  13. _listItemByKey: function(callback, failure, key){
  14. if (this.options.groups.length || this.options.roles.length) key = {"key": key, "groupList": this.options.groups, "roleList": this.options.roles};
  15. this.orgAction.listGroupByKey(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.getGroup(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.Group.ItemSelected(data, selector, item)
  26. },
  27. _listItemByPinyin: function(callback, failure, key){
  28. if (this.options.groups.length || this.options.roles.length) key = {"key": key, "groupList": this.options.groups, "roleList": this.options.roles};
  29. this.orgAction.listGroupByPinyin(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.Group.Item(data, selector, container);
  35. },
  36. _listItemNext: function(last, count, callback){
  37. this.orgAction.listGroupNext(last, count, function(json){
  38. if (callback) callback.apply(this, [json]);
  39. }.bind(this));
  40. },
  41. _getChildrenItemIds: function(data){
  42. return data.groupList;
  43. }
  44. });
  45. MWF.xApplication.Selector.Group.Item = new Class({
  46. Extends: MWF.xApplication.Selector.Person.Item,
  47. _getShowName: function(){
  48. return this.data.name;
  49. },
  50. _getTtiteText: function(){
  51. return this.data.name;
  52. },
  53. _setIcon: function(){
  54. this.iconNode.setStyle("background-image", "url("+"/x_component_Selector/$Selector/default/icon/groupicon.png)");
  55. },
  56. loadSubItem: function(){
  57. this.selector.orgAction.listPersonNested(this.data.id, function(json){
  58. this.textNode.set("text", this.textNode.get("text")+" ("+json.data.length+")");
  59. var usersText = "";
  60. json.data.each(function(item){
  61. usersText+=item.name+", ";
  62. }.bind(this));
  63. var node = new Element("div", {"styles": {"max-width": "300px"}, "text": usersText});
  64. if (!Browser.Platform.ios){
  65. this.tooltip = new mBox.Tooltip({
  66. content: node,
  67. setStyles: {content: {padding: 15, lineHeight: 20}},
  68. attach: this.node,
  69. transition: 'flyin'
  70. });
  71. }
  72. //this.textNode.set("title", usersText);
  73. }.bind(this));
  74. }
  75. });
  76. MWF.xApplication.Selector.Group.ItemSelected = new Class({
  77. Extends: MWF.xApplication.Selector.Person.ItemSelected,
  78. _getShowName: function(){
  79. return this.data.name;
  80. },
  81. _getTtiteText: function(){
  82. return this.data.name;
  83. },
  84. _setIcon: function(){
  85. this.iconNode.setStyle("background-image", "url("+"/x_component_Selector/$Selector/default/icon/groupicon.png)");
  86. },
  87. loadSubItem: function(){
  88. this.selector.orgAction.listPersonNested(this.data.id, function(json){
  89. this.textNode.set("text", this.textNode.get("text")+" ("+json.data.length+")");
  90. var usersText = "";
  91. json.data.each(function(item){
  92. usersText+=item.name+", ";
  93. }.bind(this));
  94. var node = new Element("div", {"styles": {"max-width": "300px"}, "text": usersText});
  95. if (!Browser.Platform.ios){
  96. this.tooltip = new mBox.Tooltip({
  97. content: node,
  98. setStyles: {content: {padding: 15, lineHeight: 20}},
  99. attach: this.node,
  100. transition: 'flyin'
  101. });
  102. }
  103. //this.textNode.set("title", usersText);
  104. }.bind(this));
  105. }
  106. });
  107. MWF.xApplication.Selector.Group.Filter = new Class({
  108. Implements: [Options, Events],
  109. options: {
  110. "style": "default",
  111. "groups": [],
  112. "roles": [],
  113. },
  114. initialize: function(value, options){
  115. this.setOptions(options);
  116. this.value = value;
  117. this.orgAction = MWF.Actions.get("x_organization_assemble_control");
  118. },
  119. filter: function(value, callback){
  120. this.value = value;
  121. var key = this.value;
  122. if (this.options.groups.length || this.options.roles.length) key = {"key": key, "groupList": this.options.groupList, "roleList": this.options.roleList};
  123. this.orgAction.listGroupByKey(function(json){
  124. data = json.data;
  125. if (callback) callback(data)
  126. }.bind(this), null, key);
  127. }
  128. });