Property.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. MWF.xDesktop.requireApp("query.ViewDesigner", "Property", null, false);
  2. MWF.xApplication.query.ImporterDesigner.Property = new Class({
  3. Extends: MWF.FVProperty,
  4. Implements: [Options, Events],
  5. options: {
  6. "style": "default",
  7. "path": "../x_component_query_FormDesigner/property/property.html"
  8. },
  9. initialize: function (module, propertyNode, designer, options) {
  10. this.setOptions(options);
  11. this.module = module;
  12. this.importer = module.importer || module.view;
  13. this.view = module.importer || module.view;
  14. this.data = module.json;
  15. this.data.vid = this.view.json.id;
  16. this.data.vtype = this.view.json.type;
  17. this.data.pid = this.view.json.id + this.data.id;
  18. this.htmlPath = this.options.path;
  19. this.maplists = {};
  20. this.designer = designer;
  21. this.propertyNode = propertyNode;
  22. },
  23. show: function () {
  24. if (!this.propertyContent) {
  25. this.getHtmlString(function () {
  26. if (this.htmlString) {
  27. this.htmlString = o2.bindJson(this.htmlString, {"lp": MWF.xApplication.query.ImporterDesigner.LP.propertyTemplate});
  28. this.JsonTemplate = new MWF.widget.JsonTemplate(this.data, this.htmlString);
  29. this.propertyContent = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.propertyNode);
  30. this.propertyContent.set("html", this.JsonTemplate.load());
  31. this.setEditNodeEvent();
  32. this.setEditNodeStyles(this.propertyContent);
  33. this.loadPropertyTab();
  34. this.loadPersonInput();
  35. this.loadPersonSelectInput();
  36. this.loadViewFilter();
  37. this.loadScriptArea();
  38. this.loadColumnExportEditor();
  39. this.loadJSONArea();
  40. this.loadEventsEditor();
  41. this.loadMaplist();
  42. this.loadSelectField();
  43. this.loadFormSelect();
  44. }
  45. }.bind(this));
  46. } else {
  47. this.propertyContent.setStyle("display", "block");
  48. }
  49. },
  50. loadSelectField: function(){
  51. var selectFieldNodes = this.propertyContent.getElements(".MWFSelectField");
  52. selectFieldNodes.each(function(node){
  53. node.empty();
  54. var select = new Element("select", {
  55. "style": "width:200px;"
  56. }).inject(node);
  57. select.addEvent("change", function(e){
  58. this.setSelectValue(e.target.getParent("div").get("name"), select);
  59. }.bind(this));
  60. this.setFieldSelectOptions(node, select);
  61. }.bind(this))
  62. },
  63. setFieldSelectOptions: function(node, select){
  64. debugger;
  65. var name = node.get("name");
  66. select.empty();
  67. var option = new Element("option", {"text": "none"}).inject(select);
  68. var d = this.data;
  69. Array.each(name.split("."), function (n) {
  70. if (d) d = d[n];
  71. });
  72. (this.view.json.data.columnList || []).each(function(column){
  73. var option = new Element("option", {
  74. "text": column.displayName + " - "+column.path,
  75. "value": column.path,
  76. "selected": (d===column.path)
  77. }).inject(select);
  78. }.bind(this));
  79. (this.view.json.data.calculateFieldList || []).each(function(column){
  80. var option = new Element("option", {
  81. "text": column.displayName + " - "+column.path,
  82. "value": column.path,
  83. "selected": (d===column.path)
  84. }).inject(select);
  85. }.bind(this));
  86. },
  87. loadFormSelect: function(){
  88. var formNodes = this.propertyContent.getElements(".MWFFormSelect");
  89. if (formNodes.length){
  90. this.getFormList(function(){
  91. formNodes.each(function(node){
  92. node.empty();
  93. var select = new Element("select", {"style": "width:200px;"}).inject(node);
  94. select.addEvent("change", function(e){
  95. this.setValue(e.target.getParent("div").get("name"), e.target.options[e.target.selectedIndex].value);
  96. }.bind(this));
  97. this.setFormSelectOptions(node, select);
  98. var refreshNode = new Element("div", {"styles": this.view.css.propertyRefreshFormNode}).inject(node);
  99. refreshNode.addEvent("click", function(e){
  100. this.getFormList(function(){
  101. this.setFormSelectOptions(node, select);
  102. }.bind(this), true);
  103. }.bind(this));
  104. }.bind(this));
  105. }.bind(this), true);
  106. }
  107. },
  108. setFormSelectOptions: function(node, select){
  109. var name = node.get("name");
  110. select.empty();
  111. var d = this.data;
  112. Array.each(name.split("."), function (n) {
  113. if (d) d = d[n];
  114. });
  115. if(this.forms){
  116. var option = new Element("option", {"text": "none"}).inject(select);
  117. this.forms.each(function(form){
  118. var option = new Element("option", {
  119. "text": form.name,
  120. "value": form.id,
  121. "selected": (d===form.id)
  122. }).inject(select);
  123. }.bind(this));
  124. }else{
  125. new Element("option", {
  126. "text": this.view.designer.lp.propertyTemplate.selectProcess1,
  127. "value": ""
  128. }).inject(select);
  129. }
  130. },
  131. getFormList: function(callback, refresh){
  132. if (this.view.json.data.process && this.view.json.data.process.application && (!this.forms || refresh)){
  133. var action = o2.Actions.load("x_processplatform_assemble_designer");
  134. action.FormAction.listWithApplication(this.view.json.data.process.application, function(json){
  135. this.forms = json.data;
  136. if (callback) callback();
  137. }.bind(this));
  138. }else{
  139. if (callback) callback();
  140. }
  141. },
  142. loadPersonSelectInput: function () {
  143. var personNodes = this.propertyContent.getElements(".MWFSelectPerson");
  144. var identityNodes = this.propertyContent.getElements(".MWFSelectIdentity");
  145. var personUnitNodes = this.propertyContent.getElements(".MWFSelectUnit");
  146. // var cmsapplicationNodes = this.propertyContent.getElements(".MWFSelectCMSApplication");
  147. var cmscategoryNodes = this.propertyContent.getElements(".MWFSelecCMStCategory");
  148. var querytableNodes = this.propertyContent.getElements(".MWFSelecQueryTable");
  149. // var applicationNodes = this.propertyContent.getElements(".MWFSelectApplication");
  150. var processNodes = this.propertyContent.getElements(".MWFSelectProcess");
  151. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function () {
  152. // applicationNodes.each(function (node) {
  153. // new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  154. // "type": "application",
  155. // "names": (this.data.data.where) ? this.data.data.where.applicationList : [],
  156. // "onChange": function (ids) {
  157. // this.savePersonSelectItem(node, ids);
  158. // }.bind(this)
  159. // });
  160. // }.bind(this));
  161. personUnitNodes.each(function (node) {
  162. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  163. "type": "unit",
  164. "names": (this.data.data.where) ? this.data.data.where.creatorUnitList : [],
  165. "onChange": function (ids) {
  166. this.savePersonSelectItem(node, ids);
  167. }.bind(this)
  168. });
  169. }.bind(this));
  170. personNodes.each(function (node) {
  171. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  172. "type": "person",
  173. "names": (this.data.data.where) ? this.data.data.where.creatorPersonList : [],
  174. "onChange": function (ids) {
  175. this.savePersonSelectItem(node, ids);
  176. }.bind(this)
  177. });
  178. }.bind(this));
  179. identityNodes.each(function (node) {
  180. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  181. "type": "identity",
  182. "names": (this.data.data.where) ? this.data.data.where.creatorIdentityList : [],
  183. "onChange": function (ids) {
  184. this.savePersonSelectItem(node, ids);
  185. }.bind(this)
  186. });
  187. }.bind(this));
  188. // cmsapplicationNodes.each(function (node) {
  189. // new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  190. // "type": "CMSApplication",
  191. // "names": (this.data.data.where) ? this.data.data.where.appInfoList : [],
  192. // "onChange": function (ids) {
  193. // this.savePersonSelectItem(node, ids);
  194. // }.bind(this)
  195. // });
  196. // }.bind(this));
  197. cmscategoryNodes.each(function (node) {
  198. var count = node.get("count") ? node.get("count").toInt() : 0;
  199. var name = (this.data.data) ? this.data.data.category : {};
  200. var names = o2.typeOf(name) === "object" ? [name] : name;
  201. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  202. "type": "CMSCategory",
  203. "names": names,
  204. "count" : count,
  205. "onChange": function (ids) {
  206. this.savePersonSelectItem(node, ids, count);
  207. }.bind(this)
  208. });
  209. }.bind(this));
  210. querytableNodes.each(function (node) {
  211. var count = node.get("count") ? node.get("count").toInt() : 0;
  212. var name = (this.data.data) ? this.data.data.dynamicTable : {};
  213. var names = o2.typeOf(name) === "object" ? [name] : name;
  214. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  215. "type": "QueryTable",
  216. "names": names,
  217. "count" : count,
  218. "onChange": function (ids) {
  219. debugger;
  220. this.savePersonSelectItem(node, ids, count);
  221. }.bind(this)
  222. });
  223. }.bind(this));
  224. processNodes.each(function (node) {
  225. var count = node.get("count") ? node.get("count").toInt() : 0;
  226. var name = (this.data.data) ? this.data.data.process : {};
  227. var names = o2.typeOf(name) === "object" ? [name] : name;
  228. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.view.designer, {
  229. "type": "process",
  230. "names": names,
  231. "count" : count,
  232. "onChange": function (ids) {
  233. this.savePersonSelectItem(node, ids, count);
  234. }.bind(this)
  235. });
  236. }.bind(this));
  237. }.bind(this));
  238. },
  239. savePersonSelectItem: function (node, ids, count) {
  240. debugger;
  241. //this.initWhereEntryData();
  242. var values = [];
  243. ids.each(function (id) {
  244. var obj = {"name": (id.data.distinguishedName || id.data.name), "id": id.data.id};
  245. if( id.data.application )obj.application = id.data.application;
  246. if( id.data.applicationName )obj.applicationName = id.data.applicationName;
  247. values.push(obj);
  248. //values.push((id.data.distinguishedName || id.data.id || id.data.name));
  249. }.bind(this));
  250. var name = node.get("name");
  251. var key = name.split(".");
  252. var oldValue = this.data;
  253. for (var idx = 0; idx < key.length; idx++) {
  254. if (!oldValue[key[idx]]) {
  255. oldValue = null;
  256. break;
  257. } else {
  258. oldValue = oldValue[key[idx]];
  259. }
  260. }
  261. var o = this.data;
  262. var len = key.length - 1;
  263. key.each(function (n, i) {
  264. if (!o[n]) o[n] = {};
  265. if (i < len) o = o[n];
  266. }.bind(this));
  267. o[key[len]] = count === 1 ? (values[0] || {}) : values;
  268. this.changeData(name, node, oldValue);
  269. //this.data.data.restrictWhereEntry[node.get("name")] = values;
  270. }
  271. });