package.js 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. },
  16. initialize: function(container, options){
  17. //MWF.xDesktop.requireApp("Selector", "Actions.RestActions", null, false);
  18. this.setOptions(options);
  19. this.container = container;
  20. var type = this.options.type.capitalize();
  21. if (type){
  22. if ((type.toLowerCase()==="unit") && (this.options.unitType)){
  23. MWF.xDesktop.requireApp("Selector", "UnitWithType", function(){
  24. this.selector = new MWF.xApplication.Selector.UnitWithType(this.container, options);
  25. this.selector.load();
  26. }.bind(this));
  27. }else if ((type.toLowerCase()==="identity") && ((this.options.dutys) && this.options.dutys.length)){
  28. MWF.xDesktop.requireApp("Selector", "IdentityWidthDuty", function(){
  29. this.selector = new MWF.xApplication.Selector.IdentityWidthDuty(this.container, options);
  30. this.selector.load();
  31. }.bind(this));
  32. }else{
  33. debugger;
  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. debugger;
  41. MWF.xDesktop.requireApp("Selector", "MultipleSelector", function() {
  42. this.selector = new MWF.xApplication.Selector.MultipleSelector(this.container, this.options );
  43. this.selector.load();
  44. }.bind(this));
  45. }
  46. }
  47. });
  48. MWF.O2SelectorFilter = new Class({
  49. Implements: [Options],
  50. options: {
  51. "count": 0,
  52. "type": "person",
  53. "title": "Select Person",
  54. "groups": [],
  55. "roles": [],
  56. "units": [],
  57. "unitType": "",
  58. "values": []
  59. },
  60. initialize: function(value, options){
  61. //MWF.xDesktop.requireApp("Selector", "Actions.RestActions", null, false);
  62. this.setOptions(options);
  63. this.value = value;
  64. var type = this.options.type.capitalize();
  65. if (type){
  66. if ((type.toLowerCase()==="unit") && (this.options.unitType)){
  67. MWF.xDesktop.requireApp("Selector", "UnitWithType", function(){
  68. this.selector = new MWF.xApplication.Selector.UnitWithType.Filter(this.container, options);
  69. this.selector.load();
  70. }.bind(this));
  71. }else if ((type.toLowerCase()==="identity") && ((this.options.dutys) && this.options.dutys.length)){
  72. MWF.xDesktop.requireApp("Selector", "IdentityWidthDuty", function(){
  73. this.selectFilter = new MWF.xApplication.Selector.IdentityWidthDuty.Filter(this.value, options);
  74. }.bind(this), false);
  75. }else{
  76. MWF.xDesktop.requireApp("Selector", type, function(){
  77. this.selectFilter = new MWF.xApplication.Selector[type].Filter(this.value, options);
  78. }.bind(this), false);
  79. }
  80. }else{
  81. debugger;
  82. MWF.xDesktop.requireApp("Selector", "MultipleSelector", function() {
  83. this.selectFilter = new MWF.xApplication.Selector.MultipleSelector.Filter(this.container, this.options );
  84. }.bind(this), false);
  85. }
  86. },
  87. filter: function(value, callback){
  88. return this.selectFilter.filter(value, callback);
  89. }
  90. });