From 82dd65fb1dae18676bd8b02f0e75918c9a7e8744 Mon Sep 17 00:00:00 2001 From: luisthieme Date: Tue, 25 Jun 2024 15:10:43 +0200 Subject: [PATCH] fix getting data --- resources/dynamic-form.umd.js | 5 ++--- resources/dynamic-form.umd.js.map | 1 - ui/components/DynamicForm.vue | 19 ++++++------------- 3 files changed, 8 insertions(+), 17 deletions(-) delete mode 100644 resources/dynamic-form.umd.js.map diff --git a/resources/dynamic-form.umd.js b/resources/dynamic-form.umd.js index 3a1b14d..81c1929 100644 --- a/resources/dynamic-form.umd.js +++ b/resources/dynamic-form.umd.js @@ -1,3 +1,2 @@ -(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".dynamic-form-wrapper[data-v-19b58e9c]{padding:10px;margin:10px;border:1px solid black}.dynamic-form-class[data-v-19b58e9c]{color:green;font-weight:700}h1[data-v-19b58e9c]{margin-bottom:10px}h2[data-v-19b58e9c]{margin-top:1.5rem;margin-bottom:.75rem}h3[data-v-19b58e9c]{margin-top:1rem}p[data-v-19b58e9c]{margin-bottom:5px}ul li[data-v-19b58e9c]{list-style-type:circle;list-style-position:inside;margin-left:15px}pre[data-v-19b58e9c]{padding:12px;margin:12px;background-color:#eee}code[data-v-19b58e9c]{font-size:.825rem;color:#ae0000}")),document.head.appendChild(e)}}catch(a){console.error("vite-plugin-css-injected-by-js",a)}})(); -(function(i,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("vuex")):typeof define=="function"&&define.amd?define(["exports","vue","vuex"],e):(i=typeof globalThis<"u"?globalThis:i||self,e(i["dynamic-form"]={},i.Vue,i.vuex))})(this,function(i,e,p){"use strict";const u=(t,o)=>{const s=t.__vccOpts||t;for(const[a,r]of o)s[a]=r;return s},f={name:"DynamicForm",inject:["$socket"],props:{id:{type:String,required:!0},props:{type:Object,default:()=>({})},state:{type:Object,default:()=>({enabled:!1,visible:!1})}},setup(t){console.info("DynamicForm setup with:",t),console.debug("Vue function loaded correctly",e.markRaw)},data(){return{actions:[],form:{},formData:{}}},computed:{...p.mapState("data",["messages"]),waiting_title(){return this.props.waiting_title||"Warten auf den Usertask..."},waiting_info(){return this.props.waiting_info||"Der Usertask wird automatisch angezeigt, wenn ein entsprechender Task vorhanden ist."}},mounted(){this.$socket.on("widget-load:"+this.id,t=>{this.init(),this.$store.commit("data/bind",{widgetId:this.id,msg:t})}),this.$socket.on("msg-input:"+this.id,t=>{if(this.init(),t.payload.formFields){const o=t.payload.formFields.reduce((s,a)=>(s[a.id]=a.defaultValue||"",s),{});this.formData=o}else console.debug("No formFields in msg.payload",t.payload.formFields);this.$store.commit("data/bind",{widgetId:this.id,msg:t})}),this.$socket.emit("widget-load",this.id)},unmounted(){var t,o;(t=this.$socket)==null||t.off("widget-load"+this.id),(o=this.$socket)==null||o.off("msg-input:"+this.id)},methods:{hasUserTask(){return this.messages&&this.messages[this.id]&&this.messages[this.id].payload.userTask},userTask(){return this.hasUserTask()?this.messages[this.id].payload.userTask:{}},fields(){return(this.hasUserTask()?this.userTask().userTaskConfig.formFields:[]).map(s=>({...s,component:k(s.type),items:h(s.type,s)}))},hasFields(){return console.info("luisss"),this.messages&&this.messages[this.id]&&this.messages[this.id].payload.userTask!==void 0},send(t,o){const s=[];s[o]=t,console.info(s),this.$socket.emit("widget-action",this.id,s)},init(){this.actions=this.props.options},actionFn(t){this.send({payload:{formData:this.formData,userTask:this.userTask()}},this.actions.findIndex(o=>o.label===t))}}};function h(t,o){return t==="enum"?o.enumValues.map(s=>({title:s.name,value:s.id})):null}function k(t){switch(t){case"string":return"v-text-field";case"long":case"date":return"v-text-field";case"enum":return"v-select";case"boolean":return"v-checkbox";case"text":return"v-text-field";case"select":return"v-select";case"checkbox":return"v-checkbox";case"radio":return"v-radio";case"switch":return"v-switch";case"slider":return"v-slider";case"time":return"v-time-picker";case"datetime":return"v-datetime-picker";case"color":return"v-color-picker";case"file":return"v-file-input";case"textarea":return"v-textarea";case"password":return"v-text-field";case"number":return"v-text-field";case"email":return"v-text-field";case"tel":return"v-text-field";case"url":return"v-text-field";default:return"v-text-field"}}const _={className:"dynamic-form-wrapper"},y={key:0},g={key:1};function x(t,o,s,a,r,l){const b=e.resolveComponent("v-col"),d=e.resolveComponent("v-row"),F=e.resolveComponent("v-btn"),B=e.resolveComponent("v-form"),T=e.resolveComponent("v-alert");return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createCommentVNode(" Component must be wrapped in a block so props such as className and style can be passed in from parent "),e.createElementVNode("div",_,[l.hasFields()?(e.openBlock(),e.createElementBlock("p",y,[e.createVNode(B,{ref:"form",modelValue:r.form,"onUpdate:modelValue":o[0]||(o[0]=n=>r.form=n)},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.fields(),(n,c)=>(e.openBlock(),e.createBlock(d,{key:c},{default:e.withCtx(()=>[e.createVNode(b,{cols:"12"},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n.component),{id:n.id,modelValue:r.formData[n.id],"onUpdate:modelValue":m=>r.formData[n.id]=m,required:n.required,items:n.items,label:n.label},null,8,["id","modelValue","onUpdate:modelValue","required","items","label"]))]),_:2},1024)]),_:2},1024))),128)),e.createVNode(d,{style:{display:"flex",gap:"8px",padding:"12px"}},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.actions,(n,c)=>(e.openBlock(),e.createElementBlock("div",{key:c,style:{"flex-grow":"1"}},[(e.openBlock(),e.createBlock(F,{key:c,style:{width:"100%"},onClick:m=>l.actionFn(n.label)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(n.label),1)]),_:2},1032,["onClick"]))]))),128))]),_:1})]),_:1},8,["modelValue"])])):(e.openBlock(),e.createElementBlock("p",g,[e.createVNode(T,{text:l.waiting_info,title:l.waiting_title},null,8,["text","title"])]))])],2112)}const w=u(f,[["render",x],["__scopeId","data-v-19b58e9c"],["__file","/Users/guestuser/5minds/Solutions/node-red/dashboard2/repos/node-red-dashboard-2-processcube-dynamic-form/ui/components/DynamicForm.vue"]]);i.DynamicForm=w,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}); -//# sourceMappingURL=dynamic-form.umd.js.map +(function(){"use strict";try{if(typeof document<"u"){var a=document.createElement("style");a.appendChild(document.createTextNode(".dynamic-form-wrapper[data-v-5ca4b3d4]{padding:10px;margin:10px;border:1px solid black}.dynamic-form-class[data-v-5ca4b3d4]{color:green;font-weight:700}h1[data-v-5ca4b3d4]{margin-bottom:10px}h2[data-v-5ca4b3d4]{margin-top:1.5rem;margin-bottom:.75rem}h3[data-v-5ca4b3d4]{margin-top:1rem}p[data-v-5ca4b3d4]{margin-bottom:5px}ul li[data-v-5ca4b3d4]{list-style-type:circle;list-style-position:inside;margin-left:15px}pre[data-v-5ca4b3d4]{padding:12px;margin:12px;background-color:#eee}code[data-v-5ca4b3d4]{font-size:.825rem;color:#ae0000}")),document.head.appendChild(a)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})(); +(function(n,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("vuex")):typeof define=="function"&&define.amd?define(["exports","vue","vuex"],e):(n=typeof globalThis<"u"?globalThis:n||self,e(n["dynamic-form"]={},n.Vue,n.vuex))})(this,function(n,e,p){"use strict";const u=(t,o)=>{const s=t.__vccOpts||t;for(const[l,r]of o)s[l]=r;return s},f={name:"DynamicForm",inject:["$socket"],props:{id:{type:String,required:!0},props:{type:Object,default:()=>({})},state:{type:Object,default:()=>({enabled:!1,visible:!1})}},setup(t){console.info("DynamicForm setup with:",t),console.debug("Vue function loaded correctly",e.markRaw)},data(){return{actions:[],form:{},formData:{}}},computed:{...p.mapState("data",["messages"]),waiting_title(){return this.props.waiting_title||"Warten auf den Usertask..."},waiting_info(){return this.props.waiting_info||"Der Usertask wird automatisch angezeigt, wenn ein entsprechender Task vorhanden ist."}},mounted(){this.$socket.on("widget-load:"+this.id,t=>{this.init(),this.$store.commit("data/bind",{widgetId:this.id,msg:t})}),this.$socket.on("msg-input:"+this.id,t=>{this.init(),t.payload&&t.payload.userTask&&t.payload.userTask.startToken&&t.payload.userTask.startToken.formData&&(this.formData={...t.payload.userTask.startToken.formData},console.info(this.formData)),this.$store.commit("data/bind",{widgetId:this.id,msg:t})}),this.$socket.emit("widget-load",this.id)},unmounted(){var t,o;(t=this.$socket)==null||t.off("widget-load"+this.id),(o=this.$socket)==null||o.off("msg-input:"+this.id)},methods:{hasUserTask(){return this.messages&&this.messages[this.id]&&this.messages[this.id].payload.userTask},userTask(){return this.hasUserTask()?this.messages[this.id].payload.userTask:{}},fields(){return(this.hasUserTask()?this.userTask().userTaskConfig.formFields:[]).map(s=>({...s,component:k(s.type),items:h(s.type,s)}))},hasFields(){return this.messages&&this.messages[this.id]&&this.messages[this.id].payload.userTask!==void 0},send(t,o){const s=[];s[o]=t,console.info(s),this.$socket.emit("widget-action",this.id,s)},init(){this.actions=this.props.options},actionFn(t){this.send({payload:{formData:this.formData,userTask:this.userTask()}},this.actions.findIndex(o=>o.label===t))}}};function h(t,o){return t==="enum"?o.enumValues.map(s=>({title:s.name,value:s.id})):null}function k(t){switch(t){case"string":return"v-text-field";case"long":case"date":return"v-text-field";case"enum":return"v-select";case"boolean":return"v-checkbox";case"text":return"v-text-field";case"select":return"v-select";case"checkbox":return"v-checkbox";case"radio":return"v-radio";case"switch":return"v-switch";case"slider":return"v-slider";case"time":return"v-time-picker";case"datetime":return"v-datetime-picker";case"color":return"v-color-picker";case"file":return"v-file-input";case"textarea":return"v-textarea";case"password":return"v-text-field";case"number":return"v-text-field";case"email":return"v-text-field";case"tel":return"v-text-field";case"url":return"v-text-field";default:return"v-text-field"}}const _={className:"dynamic-form-wrapper"},y={key:0},x={key:1};function g(t,o,s,l,r,a){const T=e.resolveComponent("v-col"),d=e.resolveComponent("v-row"),b=e.resolveComponent("v-btn"),B=e.resolveComponent("v-form"),D=e.resolveComponent("v-alert");return e.openBlock(),e.createElementBlock("div",_,[a.hasFields()?(e.openBlock(),e.createElementBlock("p",y,[e.createVNode(B,{ref:"form",modelValue:r.form,"onUpdate:modelValue":o[0]||(o[0]=i=>r.form=i)},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.fields(),(i,c)=>(e.openBlock(),e.createBlock(d,{key:c},{default:e.withCtx(()=>[e.createVNode(T,{cols:"12"},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(i.component),{id:i.id,modelValue:r.formData[i.id],"onUpdate:modelValue":m=>r.formData[i.id]=m,required:i.required,items:i.items,label:i.label},null,8,["id","modelValue","onUpdate:modelValue","required","items","label"]))]),_:2},1024)]),_:2},1024))),128)),e.createVNode(d,{style:{display:"flex",gap:"8px",padding:"12px"}},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.actions,(i,c)=>(e.openBlock(),e.createElementBlock("div",{key:c,style:{"flex-grow":"1"}},[(e.openBlock(),e.createBlock(b,{key:c,style:{width:"100%"},onClick:m=>a.actionFn(i.label)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(i.label),1)]),_:2},1032,["onClick"]))]))),128))]),_:1})]),_:1},8,["modelValue"])])):(e.openBlock(),e.createElementBlock("p",x,[e.createVNode(D,{text:a.waiting_info,title:a.waiting_title},null,8,["text","title"])]))])}const w=u(f,[["render",g],["__scopeId","data-v-5ca4b3d4"]]);n.DynamicForm=w,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})}); diff --git a/resources/dynamic-form.umd.js.map b/resources/dynamic-form.umd.js.map deleted file mode 100644 index 27648c2..0000000 --- a/resources/dynamic-form.umd.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"dynamic-form.umd.js","sources":["../ui/components/DynamicForm.vue"],"sourcesContent":["\n\n\n\n\n"],"names":["_sfc_main","props","markRaw","mapState","msg","formData","acc","field","_a","_b","mapFieldTypes","mapItems","index","msgArr","action","element","type","enumValue","fieldType","_hoisted_1","_openBlock","_createElementBlock","_Fragment","_createCommentVNode","_createElementVNode","$options","_hoisted_2","_createVNode","_component_v_form","$data","_cache","$event","_withCtx","_renderList","_createBlock","_component_v_row","_component_v_col","_resolveDynamicComponent","_component_v_btn","_createTextVNode","_toDisplayString","_hoisted_3","_component_v_alert"],"mappings":"+WA0CKA,EAAU,CACb,KAAM,cACN,OAAQ,CAAC,SAAS,EAClB,MAAO,CAEL,GAAI,CAAE,KAAM,OAAQ,SAAU,EAAM,EACpC,MAAO,CAAE,KAAM,OAAQ,QAAS,KAAO,CAAE,EAAG,EAC5C,MAAO,CACL,KAAM,OACN,QAAS,KAAO,CAAE,QAAS,GAAO,QAAS,EAAI,EAChD,CACF,EACD,MAAMC,EAAO,CACX,QAAQ,KAAK,0BAA2BA,CAAK,EAC7C,QAAQ,MAAM,gCAAiCC,EAAAA,OAAO,CACvD,EACD,MAAO,CACL,MAAO,CACL,QAAS,CAAE,EACX,KAAM,CAAE,EACR,SAAU,CAAE,EAEf,EACD,SAAU,CACR,GAAGC,WAAS,OAAQ,CAAC,UAAU,CAAC,EAChC,eAAgB,CACd,OAAO,KAAK,MAAM,eAAiB,4BACpC,EACD,cAAe,CACb,OACE,KAAK,MAAM,cACX,sFAEH,CACF,EACD,SAAU,CACR,KAAK,QAAQ,GAAG,eAAiB,KAAK,GAAKC,GAAQ,CACjD,KAAK,KAAI,EACT,KAAK,OAAO,OAAO,YAAa,CAC9B,SAAU,KAAK,GACf,IAAAA,CACF,CAAC,CACH,CAAC,EACD,KAAK,QAAQ,GAAG,aAAe,KAAK,GAAKA,GAAQ,CAI/C,GAFA,KAAK,KAAI,EAELA,EAAI,QAAQ,WAAY,CAC1B,MAAMC,EAAWD,EAAI,QAAQ,WAAW,OAAO,CAACE,EAAKC,KAEnDD,EAAIC,EAAM,EAAE,EAAIA,EAAM,cAAgB,GAC/BD,GACN,CAAE,CAAA,EAEL,KAAK,SAAWD,OAEhB,QAAQ,MAAM,+BAAg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7D,QAAAoB,EAAA,QAMU,IAQQ,CARRL,EAAAA,YAQQS,EAAA,CARD,KAAK,IAAI,EAAA,CAN1B,QAAAJ,EAAA,QAOY,IAMyB,EANzBZ,EAAAA,UAAA,EAAAc,EAAA,YAMyBG,EAbrC,wBAQmB9B,EAAM,SAAS,EAAA,CACnB,GAAIA,EAAM,GATzB,WAUuBsB,EAAQ,SAACtB,EAAM,EAAE,EAVxC,sBAAAwB,GAUuBF,EAAQ,SAACtB,EAAM,EAAE,EAAAwB,EACzB,SAAUxB,EAAM,SAChB,MAAOA,EAAM,MACb,MAAOA,EAAM,uFAb5B,EAAA,WAAA,EAAA,iBAiBQoB,EAAAA,YAYQQ,EAAA,CAZD,MAAA,CAA8C,QAAA,OAAA,IAAA,MAAA,QAAA,MAAA,CAAA,EAAA,CAjB7D,QAAAH,EAAA,QAmBY,IAAkC,EADpCZ,EAAAA,UAAA,EAAA,EAAAC,EAAA,mBAUMC,gBA5BhBW,EAmBsC,WAAAJ,EAAA,QAnBtC,CAmBoBf,EAAQF,mBADlBS,EAUM,mBAAA,MAAA,CARH,IAAKT,EACN,MAAA,CAAoB,YAAA,GAAA,mBACpBsB,EAKQ,YAAAI,EAAA,CAJL,IAAK1B,EACN,MAAA,CAAmB,MAAA,MAAA,EAClB,QAAOmB,GAAAN,EAAA,SAASX,EAAO,KAAK,IAzB3C,QAAAkB,EAAA,QA0Bc,IAAkB,CA1BhCO,EAAAA,gBA0BiBC,EAAAA,gBAAA1B,EAAO,KAAK,EAAA,CAAA,IA1B7B,EAAA,kCAAA,EAAA,MAAA,EAAA,yBAgCIM,EAAAA,YAAAC,EAAAA,mBAEI,IAlCRoB,EAAA,CAiCMd,EAAAA,YAAuDe,EAAA,CAA7C,KAAMjB,EAAY,aAAG,MAAOA,EAAa"} \ No newline at end of file diff --git a/ui/components/DynamicForm.vue b/ui/components/DynamicForm.vue index e8ad09b..b63f65c 100644 --- a/ui/components/DynamicForm.vue +++ b/ui/components/DynamicForm.vue @@ -77,7 +77,8 @@ export default { }, mounted() { this.$socket.on("widget-load:" + this.id, (msg) => { - this.init(); + this.init() + this.$store.commit("data/bind", { widgetId: this.id, msg, @@ -85,18 +86,11 @@ export default { }); this.$socket.on("msg-input:" + this.id, (msg) => { // store the latest message in our client-side vuex store when we receive a new message - this.init(); - - if (msg.payload.formFields) { - const formData = msg.payload.formFields.reduce((acc, field) => { - // acc[field.id] = field.value || field.defaultValue || '' - acc[field.id] = field.defaultValue || ""; - return acc; - }, {}); + this.init() - this.formData = formData; - } else { - console.debug("No formFields in msg.payload", msg.payload.formFields); + if (msg.payload && msg.payload.userTask && msg.payload.userTask.startToken && msg.payload.userTask.startToken.formData) { + this.formData = { ...msg.payload.userTask.startToken.formData }; + console.info(this.formData) } this.$store.commit("data/bind", { @@ -137,7 +131,6 @@ export default { return fieldMap; }, hasFields() { - console.info("luisss"); return ( this.messages && this.messages[this.id] &&