PersonSelector.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. MWF.xApplication.process = MWF.xApplication.process || {};
  2. MWF.xApplication.cms.FormDesigner = MWF.xApplication.cms.FormDesigner || {};
  3. MWF.xApplication.cms.FormDesigner.widget = MWF.xApplication.cms.FormDesigner.widget || {};
  4. MWF.xDesktop.requireApp("Selector", "package", null, false);
  5. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", null, false);
  6. MWF.require("MWF.widget.O2Identity", null, false);
  7. // MWF.widget.O2CMSApplication = new Class({
  8. // Extends: MWF.widget.O2Application,
  9. // getPersonData: function(){
  10. // if (!this.data.distinguishedName){
  11. // this.action = new MWF.xDesktop.Actions.RestActions("", "x_cms_assemble_control", "");
  12. // this.action.actions = {"getCMSApplication": {"uri": "/jaxrs/appinfo/{id}"}};
  13. // this.action.invoke({"name": "getCMSApplication", "async": false, "parameter": {"id": (this.data.id || this.data.name)}, "success": function(json){
  14. // this.data = json.data;
  15. // this.data.name = this.data.appName;
  16. // }.bind(this)});
  17. // }
  18. // }
  19. // });
  20. //
  21. // MWF.widget.O2CMSCategory = new Class({
  22. // Extends: MWF.widget.O2CMSApplication,
  23. // getPersonData: function(){
  24. // if (!this.data.distinguishedName){
  25. // this.action = new MWF.xDesktop.Actions.RestActions("", "x_cms_assemble_control", "");
  26. // this.action.actions = {"getCMSCategory": {"uri": "/jaxrs/categoryinfo/{id}"}};
  27. // this.action.invoke({"name": "getCMSCategory", "async": false, "parameter": {"id": (this.data.id || this.data.name)}, "success": function(json){
  28. // this.data = json.data;
  29. // this.data.name = this.data.categoryName;
  30. // }.bind(this)});
  31. // }
  32. // }
  33. // });
  34. MWF.xApplication.cms.FormDesigner.widget.PersonSelector = new Class({
  35. Implements: [Options, Events],
  36. Extends: MWF.xApplication.process.ProcessDesigner.widget.PersonSelector,
  37. options: {
  38. "style": "default",
  39. "type": "identity",
  40. "names": []
  41. },
  42. loadIdentitys: function(){
  43. var explorer = {
  44. "actions": this.restActions,
  45. "app": {
  46. "lp": this.app.lp
  47. }
  48. };
  49. if (this.options.names){
  50. if (this.options.type.toLowerCase()=="duty"){
  51. var dutys = JSON.decode(this.options.names);
  52. dutys.each(function(d){
  53. var dutyItem = new MWF.widget.Duty(d, this.node, explorer, true, function(e){
  54. var _self = this;
  55. var text = this.selector.app.lp.deleteDutyText.replace(/{duty}/g, this.data.name);
  56. this.selector.app.confirm("warm", e, this.selector.app.lp.deleteDutyTitle, text, 300, 120, function(){
  57. _self.selector.fireEvent("removeDuty", [_self]);
  58. this.close();
  59. }, function(){
  60. this.close();
  61. });
  62. e.stopPropagation();
  63. });
  64. dutyItem.selector = this;
  65. dutyItem.explorer = explorer;
  66. this.identitys.push(dutyItem);
  67. }.bind(this));
  68. }else{
  69. this.options.names.each(function(name){
  70. MWF.require("MWF.widget.O2Identity", function(){
  71. if (this.options.type.toLowerCase()=="identity") this.identitys.push(new MWF.widget.O2Identity({"name": name.name, "id": name.id}, this.node, {}));
  72. if (this.options.type.toLowerCase()=="unit") this.identitys.push(new MWF.widget.O2Unit({"name": name.name, "id": name.id}, this.node, {}));
  73. if (this.options.type.toLowerCase()=="person") this.identitys.push(new MWF.widget.O2Person({"name": name.name, "id": name.id}, this.node, {}));
  74. if (this.options.type.toLowerCase()=="application") this.identitys.push(new MWF.widget.O2CMSApplication({"name": name.name, "id": name.id}, this.node, {}));
  75. if (this.options.type.toLowerCase()=="category") this.identitys.push(new MWF.widget.O2CMSCategory({"name": name.name, "id": name.id}, this.node, {}));
  76. if (this.options.type.toLowerCase()=="formfield") this.identitys.push(new MWF.widget.O2FormField({"name": name, "id": name}, this.node, {}));
  77. if (this.options.type.toLowerCase()==="view") this.identitys.push(new MWF.widget.O2View(data, this.node));
  78. if (this.options.type.toLowerCase()==="cmsview") this.identitys.push(new MWF.widget.O2CMSView(data, this.node));
  79. }.bind(this));
  80. }.bind(this));
  81. }
  82. }
  83. },
  84. createAddNode: function(){
  85. this.addNode = new Element("div", {"styles": this.css.addPersonNode}).inject(this.node, "before");
  86. this.addNode.addEvent("click", function(e){
  87. var selecteds = [];
  88. this.identitys.each(function(id){selecteds.push(id.data.id)});
  89. var explorer = {
  90. "actions": this.restActions,
  91. "app": {
  92. "lp": this.app.lp
  93. }
  94. };
  95. var type = this.options.type;
  96. if( type == "application" ){
  97. type = "CMSApplication";
  98. }else if( type == "category" ){
  99. type = "CMSCategory";
  100. }else if( type == "formField" ){
  101. type = "CMSFormField";
  102. }
  103. var options = {
  104. "type": type,
  105. "application": this.options.application,
  106. "fieldType": this.options.fieldType,
  107. "count": (this.options.type.toLowerCase()=="duty")? 1: 0,
  108. "values": selecteds,
  109. "zIndex": 20000,
  110. "form" : this.options.form,
  111. "onComplete": function(items){
  112. this.identitys = [];
  113. if (this.options.type.toLowerCase()!="duty") this.node.empty();
  114. MWF.require("MWF.widget.O2Identity", function(){
  115. items.each(function(item){
  116. if (this.options.type.toLowerCase()=="identity") this.identitys.push(new MWF.widget.O2Identity(item.data, this.node, {}));
  117. if (this.options.type.toLowerCase()=="unit") this.identitys.push(new MWF.widget.O2Unit(item.data, this.node, {}));
  118. if (this.options.type.toLowerCase()=="person") this.identitys.push(new MWF.widget.O2Person(item.data, this.node, {}));
  119. if (this.options.type.toLowerCase()=="application") this.identitys.push(new MWF.widget.O2CMSApplication(item.data, this.node, {}));
  120. if (this.options.type.toLowerCase()=="category") this.identitys.push(new MWF.widget.O2CMSCategory(item.data, this.node, {}));
  121. if (this.options.type.toLowerCase()=="formfield") this.identitys.push(new MWF.widget.O2FormField(item.data, this.node, {}));
  122. if (this.options.type.toLowerCase()==="view") this.identitys.push(new MWF.widget.O2View(data, this.node));
  123. if (this.options.type.toLowerCase()==="cmsview") this.identitys.push(new MWF.widget.O2CMSView(data, this.node));
  124. }.bind(this));
  125. if (this.options.type.toLowerCase()=="duty") {
  126. items.each(function(item){
  127. new MWF.xApplication.cms.FormDesigner.widget.PersonSelector.DutyInput(this, item.data, this.node, explorer, 20000);
  128. }.bind(this));
  129. }
  130. this.fireEvent("change", [this.identitys]);
  131. }.bind(this));
  132. }.bind(this)
  133. };
  134. var selector = new MWF.O2Selector(this.app.content, options);
  135. }.bind(this));
  136. }
  137. });
  138. MWF.xApplication.cms.FormDesigner.widget.PersonSelector.DutyInput = Class({
  139. Extends : MWF.xApplication.process.ProcessDesigner.widget.PersonSelector.DutyInput
  140. });