"use strict";(("undefined"!==typeof self?self:this)["webpackChunkEditEntity"]=("undefined"!==typeof self?self:this)["webpackChunkEditEntity"]||[]).push([[252],{2252:function(t,e,i){i.r(e),i.d(e,{default:function(){return _}});var s=function(){var t=this,e=t._self._c;return e("ValidationProvider",{attrs:{name:t.fullname,rules:t.getRules()},scopedSlots:t._u([{key:"default",fn:function(i){return[e("b-form-group",{attrs:{label:t.field.label,description:t.field.description}},[e("div",{staticClass:"autocomplete"},[e("multiselect",{attrs:{options:t.options,"custom-label":t.nameWithLang,taggable:t.auto_create,placeholder:"",label:"text","track-by":"text","show-no-results":!0,"show-labels":!1,loading:t.isLoading,multiple:t.cardinality,"allow-empty":!0},on:{"search-change":t.asyncFind,tag:t.createElement},model:{value:t.value_computed,callback:function(e){t.value_computed=e},expression:"value_computed"}},[e("template",{slot:"noResult"},[e("span",{staticClass:"option__title"},[t._v(" Aucun contenu ne correspond à votre recherche ")])]),e("template",{slot:"placeholder"},[e("span",{staticClass:"option__title"},[t._v(" Aucun contenu ... ")])]),e("template",{slot:"noOptions"},[e("span",{staticClass:"option__title"},[t._v(" Saisir un ou plusieurs caractères ... ")])])],2),e("div",{staticClass:"text-danger"},t._l(i.errors,(function(i,s){return e("small",{key:s,staticClass:"d-block"},[t._v(" "+t._s(i)+" ")])})),0)],1)])]}}])})},a=[],n=(i(3518),i(8111),i(7588),i(3923)),l=i(8807),o=i.n(l),r=i(1549),u=i(7458),d={name:"MultiSelectTaxo",components:{ValidationProvider:n.LW,Multiselect:o()},props:{field:{type:Object,required:!0},model:{type:[Object,Array],required:!0},namespaceStore:{type:String,required:!0},parentName:{type:String,required:!0}},data(){return{isLoading:!1,options:[],value_select:null}},computed:{fullname(){return this.parentName+this.field.name},cardinality(){return-1===this.field.cardinality},auto_create(){return this.field.definition_settings.handler_settings.auto_create},value_computed:{get(){return this.value_select},set(t){this.updateValue(t)}}},mounted(){this.loadDefaults(),this.asyncFind("",!0)},methods:{getTermByTid(t){this.isLoading=!0;let e=this.getFistVocab();const i=new r.A(e);i.getValueByTid(t).then((()=>{const t=i.getOptions();this.options=t,this.cardinality?this.value_select.push(t[0]):t[0]&&(this.value_select=t[0]),this.isLoading=!1})).catch((()=>{this.isLoading=!1}))},loadDefaults(){this.value_select=[],this.model[this.field.name].forEach((t=>{this.getTermByTid(t.target_id)}))},getFistVocab(){if(this.field.definition_settings.handler_settings.target_bundles){const t=Object.keys(this.field.definition_settings.handler_settings.target_bundles);return this.field.definition_settings.handler_settings.target_bundles[t[0]]}return this.field.definition_settings.target_type?this.field.definition_settings.target_type:null},createElement(t){const e={value:{name:t,vid:this.field.definition_settings.bundle_entity_type_id},entity_type_id:this.field.definition_settings.target_type},i=this.namespaceStore?this.namespaceStore+"/saveEntity":"saveEntity";this.$store.dispatch(i,e).then((e=>{this.value_select.push({text:t,value:e.data.id}),this.updateValue(this.value_select)})).catch((t=>console.log("error: ",t)))},asyncFind(t,e=!1){if(t.length>=2||e){let e=this.getFistVocab();const i=new r.A(e);this.isLoading=!0,i.getSearch(t).then((()=>{this.options=i.getOptions(),this.isLoading=!1}))}},nameWithLang({text:t}){return`${t}`},setValue(t){this.namespaceStore?this.$store.dispatch(this.namespaceStore+"/setValue",{value:t,fieldName:this.fullname}):this.$store.dispatch("setValue",{value:t,fieldName:this.fullname})},getRules(){return u.A.getRules(this.field)},updateValue(t){if(this.value_select=t,this.cardinality){const e=[];t&&t.length&&t.forEach((t=>{e.push({target_id:t.value})})),this.setValue(e)}else{const e=[];t&&t.value&&e.push({target_id:t.value}),this.setValue(e)}}}},c=d,h=i(1656),p=(0,h.A)(c,s,a,!1,null,null,null),_=p.exports}}]);
//# sourceMappingURL=EditEntity.umd.min.252.js.map