PersonSelector.js 8.0 KB

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