package.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. MWF.xApplication.Selector = MWF.xApplication.Selector || {};
  2. MWF.xDesktop.requireApp("Selector", "lp."+MWF.language, null, false);
  3. //MWF.xDesktop.requireApp("Selector", "Actions.RestActions", null, false);
  4. MWF.O2Selector = new Class({
  5. Implements: [Options],
  6. options: {
  7. "count": 0,
  8. "type": "person",
  9. "title": "Select Person",
  10. "groups": [],
  11. "roles": [],
  12. "units": [],
  13. "unitType": "",
  14. "values": [],
  15. "exclude" : []
  16. },
  17. initialize: function(container, options){
  18. //MWF.xDesktop.requireApp("Selector", "Actions.RestActions", null, false);
  19. this.setOptions(options);
  20. this.container = container;
  21. var type = this.options.type.capitalize();
  22. if (type){
  23. if ((type.toLowerCase()==="unit") && (this.options.unitType)){
  24. MWF.xDesktop.requireApp("Selector", "UnitWithType", function(){
  25. this.selector = new MWF.xApplication.Selector.UnitWithType(this.container, options);
  26. this.selector.load();
  27. }.bind(this));
  28. }else if ((type.toLowerCase()==="identity") && ((this.options.dutys) && this.options.dutys.length)){
  29. MWF.xDesktop.requireApp("Selector", "IdentityWidthDuty", function(){
  30. this.selector = new MWF.xApplication.Selector.IdentityWidthDuty(this.container, options);
  31. this.selector.load();
  32. }.bind(this));
  33. }else{
  34. MWF.xDesktop.requireApp("Selector", type, function(){
  35. this.selector = new MWF.xApplication.Selector[type](this.container, options);
  36. this.selector.load();
  37. }.bind(this));
  38. }
  39. }else{
  40. MWF.xDesktop.requireApp("Selector", "MultipleSelector", function() {
  41. this.selector = new MWF.xApplication.Selector.MultipleSelector(this.container, this.options );
  42. this.selector.load();
  43. }.bind(this));
  44. }
  45. }
  46. });
  47. MWF.O2SelectorFilter = new Class({
  48. Implements: [Options],
  49. options: {
  50. "count": 0,
  51. "type": "person",
  52. "title": "Select Person",
  53. "groups": [],
  54. "roles": [],
  55. "units": [],
  56. "unitType": "",
  57. "values": []
  58. },
  59. initialize: function(value, options){
  60. //MWF.xDesktop.requireApp("Selector", "Actions.RestActions", null, false);
  61. this.setOptions(options);
  62. this.value = value;
  63. var type = this.options.type.capitalize();
  64. if (type){
  65. if ((type.toLowerCase()==="unit") && (this.options.unitType)){
  66. MWF.xDesktop.requireApp("Selector", "UnitWithType", function(){
  67. this.selector = new MWF.xApplication.Selector.UnitWithType.Filter(this.container, options);
  68. this.selector.load();
  69. }.bind(this));
  70. }else if ((type.toLowerCase()==="identity") && ((this.options.dutys) && this.options.dutys.length)){
  71. MWF.xDesktop.requireApp("Selector", "IdentityWidthDuty", function(){
  72. this.selectFilter = new MWF.xApplication.Selector.IdentityWidthDuty.Filter(this.value, options);
  73. }.bind(this), false);
  74. }else{
  75. MWF.xDesktop.requireApp("Selector", type, function(){
  76. this.selectFilter = new MWF.xApplication.Selector[type].Filter(this.value, options);
  77. }.bind(this), false);
  78. }
  79. }else{
  80. MWF.xDesktop.requireApp("Selector", "MultipleSelector", function() {
  81. this.selectFilter = new MWF.xApplication.Selector.MultipleSelector.Filter(this.container, this.options );
  82. }.bind(this), false);
  83. }
  84. },
  85. filter: function(value, callback){
  86. return this.selectFilter.filter(value, callback);
  87. }
  88. });