1
0

settings-declarative-settings-forms.js 11 KB

12
  1. (()=>{"use strict";var e,a,i,r={27565:(e,a,i)=>{var r=i(85471),l=i(38613),o=i(53334),n=i(26287),d=i(63814),s=i(85168),c=i(17334),p=i.n(c),u=i(88837),f=i(44492),v=i(67607),m=i(32073),h=i(96763);const A={name:"DeclarativeSection",components:{NcSettingsSection:u.A,NcInputField:f.A,NcSelect:v.A,NcCheckboxRadioSwitch:m.A},props:{form:{type:Object,required:!0}},data:()=>({formFieldsData:{}}),beforeMount(){this.initFormFieldsData()},computed:{formApp(){return this.form.app||""},formFields(){return this.form.fields||[]}},methods:{initFormFieldsData(){this.form.fields.forEach((e=>{"checkbox"===e.type&&this.$set(e,"value",+e.value),"multi-checkbox"===e.type&&(""===e.value?(this.$set(e,"value",{}),e.options.forEach((t=>{this.$set(e.value,t.value,!1)}))):(this.$set(e,"value",JSON.parse(e.value)),e.options.forEach((t=>{e.value.hasOwnProperty(t.value)||this.$set(e.value,t.value,!1)})),Object.keys(e.value).forEach((t=>{e.options.find((e=>e.value===t))||delete e.value[t]})))),"multi-select"===e.type&&(""===e.value?this.$set(e,"value",[]):this.$set(e,"value",JSON.parse(e.value))),this.$set(this.formFieldsData,e.id,{value:e.value})}))},updateFormFieldDataValue(e,t){let a=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.formFieldsData[t.id].value=e,a&&this.updateDeclarativeSettingsValue(t)},updateDeclarativeSettingsValue(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;try{return n.A.post((0,d.KT)("settings/api/declarative/value"),{app:this.formApp,formId:this.form.id.replace(this.formApp+"_",""),fieldId:e.id,value:null===a?this.formFieldsData[e.id].value:a})}catch(e){h.debug(e),(0,s.Qg)(t("settings","Failed to save setting"))}},onChangeDebounced:p()((function(e){this.updateDeclarativeSettingsValue(e)}),1e3),isTextFormField:e=>["text","password","email","tel","url","number"].includes(e.type)}};var b=i(85072),_=i.n(b),g=i(97825),C=i.n(g),y=i(77659),x=i.n(y),k=i(55056),D=i.n(k),F=i(10540),w=i.n(F),S=i(41113),O=i.n(S),N=i(46613),E={};E.styleTagTransform=O(),E.setAttributes=D(),E.insert=x().bind(null,"head"),E.domAPI=C(),E.insertStyleElement=w(),_()(N.A,E),N.A&&N.A.locals&&N.A.locals;const T=(0,i(14486).A)(A,(function(){var e=this,t=e._self._c;return t("NcSettingsSection",{staticClass:"declarative-settings-section",attrs:{name:e.t(e.formApp,e.form.title),description:e.t(e.formApp,e.form.description),"doc-url":e.form.doc_url||""}},e._l(e.formFields,(function(a){return t("div",{key:a.id,staticClass:"declarative-form-field",class:{"declarative-form-field-text":e.isTextFormField(a),"declarative-form-field-select":"select"===a.type,"declarative-form-field-multi-select":"multi-select"===a.type,"declarative-form-field-checkbox":"checkbox"===a.type,"declarative-form-field-multi_checkbox":"multi-checkbox"===a.type,"declarative-form-field-radio":"radio"===a.type},attrs:{"aria-label":e.t("settings","{app}'s declarative setting field: {name}",{app:e.formApp,name:e.t(e.formApp,a.title)})}},[e.isTextFormField(a)?[t("div",{staticClass:"input-wrapper"},[t("NcInputField",{attrs:{type:a.type,label:e.t(e.formApp,a.title),value:e.formFieldsData[a.id].value,placeholder:e.t(e.formApp,a.placeholder)},on:{"update:value":[function(t){return e.$set(e.formFieldsData[a.id],"value",t)},function(t){return e.onChangeDebounced(a)}],submit:function(t){return e.updateDeclarativeSettingsValue(a)}}})],1),e._v(" "),t("span",{staticClass:"hint"},[e._v(e._s(e.t(e.formApp,a.description)))])]:e._e(),e._v(" "),"select"===a.type?[t("label",{attrs:{for:a.id+"_field"}},[e._v(e._s(e.t(e.formApp,a.title)))]),e._v(" "),t("div",{staticClass:"input-wrapper"},[t("NcSelect",{attrs:{id:a.id+"_field",options:a.options,placeholder:e.t(e.formApp,a.placeholder),"label-outside":!0,value:e.formFieldsData[a.id].value},on:{input:t=>e.updateFormFieldDataValue(t,a,!0)}})],1),e._v(" "),t("span",{staticClass:"hint"},[e._v(e._s(e.t(e.formApp,a.description)))])]:e._e(),e._v(" "),"multi-select"===a.type?[t("label",{attrs:{for:a.id+"_field"}},[e._v(e._s(e.t(e.formApp,a.title)))]),e._v(" "),t("div",{staticClass:"input-wrapper"},[t("NcSelect",{attrs:{id:a.id+"_field",options:a.options,placeholder:e.t(e.formApp,a.placeholder),multiple:!0,"label-outside":!0,value:e.formFieldsData[a.id].value},on:{input:t=>{e.formFieldsData[a.id].value=t,e.updateDeclarativeSettingsValue(a,JSON.stringify(e.formFieldsData[a.id].value))}}})],1),e._v(" "),t("span",{staticClass:"hint"},[e._v(e._s(e.t(e.formApp,a.description)))])]:e._e(),e._v(" "),"checkbox"===a.type?[t("label",{attrs:{for:a.id+"_field"}},[e._v(e._s(e.t(e.formApp,a.title)))]),e._v(" "),t("NcCheckboxRadioSwitch",{attrs:{id:a.id+"_field",checked:Boolean(e.formFieldsData[a.id].value)},on:{"update:checked":t=>{a.value=t,e.updateFormFieldDataValue(+t,a,!0)}}},[e._v("\n\t\t\t\t"+e._s(e.t(e.formApp,a.label))+"\n\t\t\t")]),e._v(" "),t("span",{staticClass:"hint"},[e._v(e._s(e.t(e.formApp,a.description)))])]:e._e(),e._v(" "),"multi-checkbox"===a.type?[t("label",{attrs:{for:a.id+"_field"}},[e._v(e._s(e.t(e.formApp,a.title)))]),e._v(" "),e._l(a.options,(function(i){return t("NcCheckboxRadioSwitch",{key:i.value,attrs:{id:a.id+"_field_"+i.value,checked:e.formFieldsData[a.id].value[i.value]},on:{"update:checked":t=>{e.formFieldsData[a.id].value[i.value]=t,e.updateDeclarativeSettingsValue(a,JSON.stringify(e.formFieldsData[a.id].value))}}},[e._v("\n\t\t\t\t"+e._s(e.t(e.formApp,i.name))+"\n\t\t\t")])})),e._v(" "),t("span",{staticClass:"hint"},[e._v(e._s(e.t(e.formApp,a.description)))])]:e._e(),e._v(" "),"radio"===a.type?[t("label",{attrs:{for:a.id+"_field"}},[e._v(e._s(e.t(e.formApp,a.title)))]),e._v(" "),e._l(a.options,(function(i){return t("NcCheckboxRadioSwitch",{key:i.value,attrs:{value:i.value,type:"radio",checked:e.formFieldsData[a.id].value},on:{"update:checked":t=>e.updateFormFieldDataValue(t,a,!0)}},[e._v("\n\t\t\t\t"+e._s(e.t(e.formApp,i.name))+"\n\t\t\t")])})),e._v(" "),t("span",{staticClass:"hint"},[e._v(e._s(e.t(e.formApp,a.description)))])]:e._e()],2)})),0)}),[],!1,null,"49d8d244",null).exports;var j=i(96763);const $=(0,l.C)("settings","declarative-settings-forms",[]);j.debug("Loaded declarative forms:",$),document.addEventListener("DOMContentLoaded",(()=>{!function(e){r.Ay.mixin({methods:{t:o.Tl,n:o.zw}});const t=r.Ay.extend(T);for(const a of e)new t({el:"#".concat(a.app,"_").concat(a.id),propsData:{form:a}})}($)}))},46613:(e,t,a)=>{a.d(t,{A:()=>n});var i=a(71354),r=a.n(i),l=a(76314),o=a.n(l)()(r());o.push([e.id,".declarative-form-field[data-v-49d8d244]{margin:20px 0;padding:10px 0}.declarative-form-field .input-wrapper[data-v-49d8d244]{width:100%;max-width:400px}.declarative-form-field[data-v-49d8d244]:last-child{border-bottom:none}.declarative-form-field .hint[data-v-49d8d244]{display:inline-block;color:var(--color-text-maxcontrast);margin-left:8px;padding-top:5px}.declarative-form-field-radio[data-v-49d8d244],.declarative-form-field-multi_checkbox[data-v-49d8d244]{max-height:250px;overflow-y:auto}.declarative-form-field-multi-select[data-v-49d8d244],.declarative-form-field-select[data-v-49d8d244]{display:flex;flex-direction:column}.declarative-form-field-multi-select label[data-v-49d8d244],.declarative-form-field-select label[data-v-49d8d244]{margin-bottom:5px}","",{version:3,sources:["webpack://./apps/settings/src/components/DeclarativeSettings/DeclarativeSection.vue"],names:[],mappings:"AACA,yCACC,aAAA,CACA,cAAA,CAEA,wDACC,UAAA,CACA,eAAA,CAGD,oDACC,kBAAA,CAGD,+CACC,oBAAA,CACA,mCAAA,CACA,eAAA,CACA,eAAA,CAGD,uGACC,gBAAA,CACA,eAAA,CAGD,sGACC,YAAA,CACA,qBAAA,CAEA,kHACC,iBAAA",sourcesContent:["\n.declarative-form-field {\n\tmargin: 20px 0;\n\tpadding: 10px 0;\n\n\t.input-wrapper {\n\t\twidth: 100%;\n\t\tmax-width: 400px;\n\t}\n\n\t&:last-child {\n\t\tborder-bottom: none;\n\t}\n\n\t.hint {\n\t\tdisplay: inline-block;\n\t\tcolor: var(--color-text-maxcontrast);\n\t\tmargin-left: 8px;\n\t\tpadding-top: 5px;\n\t}\n\n\t&-radio, &-multi_checkbox {\n\t\tmax-height: 250px;\n\t\toverflow-y: auto;\n\t}\n\n\t&-multi-select, &-select {\n\t\tdisplay: flex;\n\t\tflex-direction: column;\n\n\t\tlabel {\n\t\t\tmargin-bottom: 5px;\n\t\t}\n\t}\n}\n"],sourceRoot:""}]);const n=o}},l={};function o(e){var t=l[e];if(void 0!==t)return t.exports;var a=l[e]={id:e,loaded:!1,exports:{}};return r[e].call(a.exports,a,a.exports,o),a.loaded=!0,a.exports}o.m=r,e=[],o.O=(t,a,i,r)=>{if(!a){var l=1/0;for(c=0;c<e.length;c++){a=e[c][0],i=e[c][1],r=e[c][2];for(var n=!0,d=0;d<a.length;d++)(!1&r||l>=r)&&Object.keys(o.O).every((e=>o.O[e](a[d])))?a.splice(d--,1):(n=!1,r<l&&(l=r));if(n){e.splice(c--,1);var s=i();void 0!==s&&(t=s)}}return t}r=r||0;for(var c=e.length;c>0&&e[c-1][2]>r;c--)e[c]=e[c-1];e[c]=[a,i,r]},o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var a in t)o.o(t,a)&&!o.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},o.f={},o.e=e=>Promise.all(Object.keys(o.f).reduce(((t,a)=>(o.f[a](e,t),t)),[])),o.u=e=>e+"-"+e+".js?v="+{1110:"a5d6e6f59aa058840a1e",5455:"8915a218db5b7bc90f34"}[e],o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a={},i="nextcloud:",o.l=(e,t,r,l)=>{if(a[e])a[e].push(t);else{var n,d;if(void 0!==r)for(var s=document.getElementsByTagName("script"),c=0;c<s.length;c++){var p=s[c];if(p.getAttribute("src")==e||p.getAttribute("data-webpack")==i+r){n=p;break}}n||(d=!0,(n=document.createElement("script")).charset="utf-8",n.timeout=120,o.nc&&n.setAttribute("nonce",o.nc),n.setAttribute("data-webpack",i+r),n.src=e),a[e]=[t];var u=(t,i)=>{n.onerror=n.onload=null,clearTimeout(f);var r=a[e];if(delete a[e],n.parentNode&&n.parentNode.removeChild(n),r&&r.forEach((e=>e(i))),t)return t(i)},f=setTimeout(u.bind(null,void 0,{type:"timeout",target:n}),12e4);n.onerror=u.bind(null,n.onerror),n.onload=u.bind(null,n.onload),d&&document.head.appendChild(n)}},o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),o.j=6085,(()=>{var e;o.g.importScripts&&(e=o.g.location+"");var t=o.g.document;if(!e&&t&&(t.currentScript&&(e=t.currentScript.src),!e)){var a=t.getElementsByTagName("script");if(a.length)for(var i=a.length-1;i>-1&&(!e||!/^http(s?):/.test(e));)e=a[i--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=e})(),(()=>{o.b=document.baseURI||self.location.href;var e={6085:0};o.f.j=(t,a)=>{var i=o.o(e,t)?e[t]:void 0;if(0!==i)if(i)a.push(i[2]);else{var r=new Promise(((a,r)=>i=e[t]=[a,r]));a.push(i[2]=r);var l=o.p+o.u(t),n=new Error;o.l(l,(a=>{if(o.o(e,t)&&(0!==(i=e[t])&&(e[t]=void 0),i)){var r=a&&("load"===a.type?"missing":a.type),l=a&&a.target&&a.target.src;n.message="Loading chunk "+t+" failed.\n("+r+": "+l+")",n.name="ChunkLoadError",n.type=r,n.request=l,i[1](n)}}),"chunk-"+t,t)}},o.O.j=t=>0===e[t];var t=(t,a)=>{var i,r,l=a[0],n=a[1],d=a[2],s=0;if(l.some((t=>0!==e[t]))){for(i in n)o.o(n,i)&&(o.m[i]=n[i]);if(d)var c=d(o)}for(t&&t(a);s<l.length;s++)r=l[s],o.o(e,r)&&e[r]&&e[r][0](),e[r]=0;return o.O(c)},a=self.webpackChunknextcloud=self.webpackChunknextcloud||[];a.forEach(t.bind(null,0)),a.push=t.bind(null,a.push.bind(a))})(),o.nc=void 0;var n=o.O(void 0,[4208],(()=>o(27565)));n=o.O(n)})();
  2. //# sourceMappingURL=settings-declarative-settings-forms.js.map?v=8c99420e425d8e0e2162