$Elinput.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. o2.xDesktop.requireApp("process.Xform", "$ElModule", null, false);
  2. o2.xDesktop.requireApp("process.Xform", "$Input", null, false);
  3. o2.xApplication.process.Xform.$Elinput = o2.APP$Elinput = new Class({
  4. Implements: [Events],
  5. Extends: MWF.APP$ElModule,
  6. });
  7. Object.assign(o2.APP$Elinput.prototype, o2.APP$Input.prototype);
  8. Object.assign(o2.APP$Elinput.prototype, {
  9. isReadonly : function(){
  10. return !!(this.readonly || this.json.isReadonly || this.form.json.isReadonly || this.isSectionMergeRead() );
  11. },
  12. reload: function(){
  13. if (!this.vm) return;
  14. var node = this.vm.$el;
  15. this.vm.$destroy();
  16. node.empty();
  17. this.vm = null;
  18. this.vueApp = null;
  19. this._loadUserInterface();
  20. },
  21. __setValue: function(value){
  22. this.moduleValueAG = null;
  23. this._setBusinessData(value);
  24. this.json[this.json.$id] = value;
  25. this.__setReadonly(value);
  26. this.fieldModuleLoaded = true;
  27. return value;
  28. },
  29. __setData: function(data){
  30. var old = this.getInputData();
  31. this._setBusinessData(data);
  32. this.json[this.json.$id] = data;
  33. this.__setReadonly(data);
  34. if (old!==data) this.fireEvent("change");
  35. this.moduleValueAG = null;
  36. this.validationMode();
  37. },
  38. __setReadonly: function(data){
  39. if (this.isReadonly()) {
  40. this.node.set("text", data);
  41. if( this.json.elProperties ){
  42. this.node.set(this.json.elProperties );
  43. }
  44. if (this.json.elStyles){
  45. this.node.setStyles( this._parseStyles(this.json.elStyles) );
  46. }
  47. this.fireEvent("postLoad");
  48. if( this.moduleSelectAG && typeOf(this.moduleSelectAG.then) === "function" ){
  49. this.moduleSelectAG.then(function () {
  50. this.fireEvent("load");
  51. this.isLoaded = true;
  52. }.bind(this));
  53. }else{
  54. this.fireEvent("load");
  55. this.isLoaded = true;
  56. }
  57. }
  58. },
  59. getInputData: function(){
  60. return this.json[this.json.$id];
  61. },
  62. // _getVueModelBindId: function(){
  63. // if (this.json.id.indexOf("..")!==-1){
  64. // this.json["$id"] ="__"+this.json.id.replace(/\.\./g, "_")
  65. // }else{
  66. // this.json["$id"] = this.json.id;
  67. // }
  68. // },
  69. _loadNodeEdit: function(){
  70. var id = (this.json.id.indexOf("..")!==-1) ? this.json.id.replace(/\.\./g, "_") : this.json.id;
  71. this.json["$id"] = (id.indexOf("-")!==-1) ? id.replace(/-/g, "_") : id;
  72. this.node.appendHTML(this._createElementHtml(), "before");
  73. var input = this.node.getPrevious();
  74. this.node.destroy();
  75. this.node = input;
  76. this.node.set({
  77. "id": this.json.id,
  78. "MWFType": this.json.type
  79. });
  80. this.node.addClass("o2_vue");
  81. this._createVueApp();
  82. },
  83. _loadDomEvents: function(){
  84. Object.each(this.json.events, function(e, key){
  85. if (e.code){
  86. if (this.options.moduleEvents.indexOf(key)===-1 && this.options.elEvents.indexOf(key)===-1){
  87. this.node.addEvent(key, function(event){
  88. return this.form.Macro.fire(e.code, this, event);
  89. }.bind(this));
  90. }
  91. }
  92. }.bind(this));
  93. },
  94. getValue: function(){
  95. if (this.moduleValueAG) return this.moduleValueAG;
  96. var value = this._getBusinessData();
  97. if (value || value===false || value===0){
  98. return value;
  99. }else{
  100. value = this._computeValue();
  101. return (o2.typeOf(value)!=="null") ? value : "";
  102. }
  103. // if (!value) value = this._computeValue();
  104. // return (o2.typeOf(value)!=="null") ? value : "";
  105. //return value || "";
  106. },
  107. _afterLoaded: function(){}
  108. })