Main.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. MWF.require("MWF.widget.JsonTemplate", null, false);
  2. MWF.xApplication.Selector.Main = new Class({
  3. Extends: MWF.xApplication.Common.Main,
  4. Implements: [Options, Events],
  5. options: {
  6. "style": "default",
  7. "name": "Selector",
  8. "icon": "icon.png",
  9. "width": "800",
  10. "height": "700",
  11. "isResize": false,
  12. "isMax": false,
  13. "title": MWF.xApplication.Selector.LP.title
  14. },
  15. onQueryLoad: function(){
  16. this.lp = MWF.xApplication.Selector.LP;
  17. },
  18. loadApplication: function(callback){
  19. //this.content
  20. this.node = new Element("div", {"styles": {
  21. "padding": "20px",
  22. "text-align": "center"
  23. }}).inject(this.content);
  24. this.optionsNode = new Element("textarea", {"styles": {
  25. "width": "90%",
  26. "display": "block",
  27. "height": "160px"
  28. }}).inject(this.node);
  29. var buttonArea = new Element("div", {"styles": {
  30. "height": "30px",
  31. "margin-top": "10px",
  32. "text-align": "left"
  33. }}).inject(this.node);
  34. this.buttonNode = new Element("button", {"text": "select", "styles": {
  35. "width": "150px",
  36. "height": "30px"
  37. }}).inject(buttonArea);
  38. this.buttonMobileNode = new Element("button", {"text": "selectMobile", "styles": {
  39. "width": "150px",
  40. "height": "30px"
  41. }}).inject(buttonArea);
  42. this.resaultNode = new Element("div", {"styles": {
  43. "height": "410px",
  44. "overflow": "auto",
  45. "margin-top": "10px",
  46. "background-color": "#ffffff",
  47. "border": "1px solid #666666",
  48. "display": "block"
  49. }}).inject(this.node);
  50. var str = "{\n\t\"count\": 0, \n\t\"type\": \"identity\", \n\t\"title\": \"Select Person\",\n\t\"groups\": [], \n\t\"roles\": [],\n\t\"dutys\" : [], \n\t\"units\": [],\n\t\"unitType\": \"\",\n\t\"values\": []\n}"
  51. this.optionsNode.set("value", str);
  52. this.buttonNode.addEvent("click", function(){
  53. this.select();
  54. }.bind(this));
  55. this.buttonMobileNode.addEvent("click", function(){
  56. this.selectMobile();
  57. }.bind(this));
  58. },
  59. select: function(callback){
  60. var str = this.optionsNode.get("value");
  61. var options = JSON.decode(str);
  62. if (!options.values.length) options.values = this.values || [];
  63. options.onComplete = function(items){
  64. var json = [];
  65. this.values = [];
  66. items.each(function(item){
  67. this.values.push(item.data.distinguishedName || item.data.name);
  68. json.push(item.data);
  69. }.bind(this));
  70. this.resaultNode.empty();
  71. MWF.require("MWF.widget.JsonParse", function(){
  72. var jsonNode = new MWF.widget.JsonParse(json, this.resaultNode, null);
  73. jsonNode.load();
  74. }.bind(this));
  75. if (callback) callback();
  76. }.bind(this);
  77. options.onCancel = function(){
  78. if (callback) callback();
  79. };
  80. MWF.xDesktop.requireApp("Selector", "package", function(){
  81. new MWF.O2Selector(this.content, options)
  82. }.bind(this));
  83. },
  84. selectMobile: function(){
  85. if (!layout.mobile) layout.mobile = true;
  86. this.select(function(){layout.mobile = false;}.bind(this));
  87. }
  88. });