(self.webpackChunkncpasswords=self.webpackChunkncpasswords||[]).push([[930,1637],{80018(t,e,a){"use strict";a.r(e),a.d(e,{default:()=>s});const s={}},35206(t,e,a){"use strict";a.d(e,{default:()=>u});var s=function(){var t=this,e=t._self._c;return t.modal?e("nc-modal",{attrs:{name:t.localizedTitle,size:t.size},on:{close:t.cancel}},[e("form",{ref:"form",staticClass:"passwords-form",class:{"with-actions":this.hasActions},attrs:{id:t.id,"data-form":t.name},on:{submit:function(e){return t.submit(e)}}},[t.message?e("translate",{staticClass:"message",attrs:{tag:"div",say:t.message}}):e("br"),t._v(" "),t._l(t.fields,function(a){return e("div",{staticClass:"field"},[e("translate",{attrs:{tag:"label",for:a.attributes.id,say:a.label}}),t._v(" "),"checkbox"===a.attributes.type?e("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.models[a.name],expression:"models[field.name]"}],attrs:{type:"checkbox"},domProps:{checked:Array.isArray(t.models[a.name])?t._i(t.models[a.name],null)>-1:t.models[a.name]},on:{change:function(e){var s=t.models[a.name],l=e.target,i=!!l.checked;if(Array.isArray(s)){var n=t._i(s,null);l.checked?n<0&&t.$set(t.models,a.name,s.concat([null])):n>-1&&t.$set(t.models,a.name,s.slice(0,n).concat(s.slice(n+1)))}else t.$set(t.models,a.name,i)}}},"input",a.attributes,!1)):"radio"===a.attributes.type?e("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.models[a.name],expression:"models[field.name]"}],attrs:{type:"radio"},domProps:{checked:t._q(t.models[a.name],null)},on:{change:function(e){return t.$set(t.models,a.name,null)}}},"input",a.attributes,!1)):e("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.models[a.name],expression:"models[field.name]"}],attrs:{type:a.attributes.type},domProps:{value:t.models[a.name]},on:{input:function(e){e.target.composing||t.$set(t.models,a.name,e.target.value)}}},"input",a.attributes,!1)),t._v(" "),a.button?e("translate",{staticClass:"button",attrs:{tag:"a",icon:a.button.icon,title:a.button.title},on:{click:function(e){return t.executeButtonAction(a,e)}}}):t._e()],1)}),t._v(" "),e("div",{staticClass:"actions"},[e("nc-button",{attrs:{type:"primary",nativeType:"button",size:"large"},on:{click:t.submit}},[t._v("\n                "+t._s(t.t("Save"))+"\n            ")])],1)],2)]):t._e()};s._withStripped=!0;var l=a(53024),i=a(80444),n=a(74095),o=a(94493);const r={components:{NcButton:n.default,Translate:l.A,NcModal:o.A},props:{id:{type:String},title:{type:String},name:{type:String},message:{type:String|Array},form:{type:Object},size:{type:String,default:"normal"}},data:()=>({modal:!0,hasActions:!1,models:{}}),computed:{fields(){let t=[];for(let e in this.form){if(!this.form.hasOwnProperty(e))continue;let a=this.form[e],s=a.value?a.value:"",l=a.type?a.type:"text",n=this.resolveFieldButton(a),o=`password-field-${e}`,r=a.label?a.label:e.capitalize(),u=i.A.translateArray(a.title?a.title:a.label),m=!!a.required,c=!!a.checked,d=a.minlength?a.minlength:null,p=a.maxlength?a.maxlength:null,f=a.pattern?a.pattern:null,h=i.A.translateArray(a.placeholder?a.placeholder:a.label);"checkbox"!==l||a.hasOwnProperty("value")||(s=c),this.models[e]=s,d&&!f&&(f=`.{${d},}`),t.push({name:e,label:r,button:n,attributes:{name:e,value:s,type:l,id:o,title:u,placeholder:h,required:m,checked:c,maxlength:p,pattern:f}})}return t},localizedTitle(){return i.A.translateArray(this.title)}},methods:{submit(t){let e=this.$refs.form.querySelectorAll(`#${this.id} input`),a=!1;for(let t of e){let e=t.name;if(e)if(t.setCustomValidity(""),t.checkValidity()){if(this.form[e].validator&&!this.form[e].validator(this.models[e],this.models,t)){let s="Please correct your input";this.form[e].title&&(s=this.form[e].title),t.setCustomValidity(i.A.translate(s)),t.reportValidity(),a=!0}}else a=!0,t.reportValidity()}if(a)return!1;t.preventDefault(),this.$emit("submit",this.models),this.modal=!1},cancel(){this.$emit("cancel")},executeButtonAction(t,e){let a=document.getElementById(t.attributes.id),s=t.button.action(t,a,e);void 0!==s&&(a.value=s,this.fields[t.name]=s)},resolveFieldButton(t){if(t.button){if(this.hasActions=!0,"string"!=typeof t.button)return t.button;if("toggle"===t.button)return{icon:"eye",title:"Show value",action:this.toggleButtonAction}}return null},toggleButtonAction(t,e,a){let s="I"===a.target.tagName?a.target:a.target.getElementsByTagName("i")[0];s.classList.toggle("fa-eye-slash"),s.classList.toggle("fa-eye"),e.type="text"===e.type?"password":"text"}}};a(48949);const u=(0,a(14486).A)(r,s,[],!1,null,null,null).exports},48949(t,e,a){var s=a(80018);s.__esModule&&(s=s.default),"string"==typeof s&&(s=[[t.id,s,""]]),s.locals&&(t.exports=s.locals),(0,a(70534).A)("9ecba06a",s,!1,{})},74095(t,e,a){"use strict";a.r(e),a.d(e,{default:()=>s.N});var s=a(90080)}}]);