"use strict";(("undefined"!==typeof self?self:this)["webpackChunkEditEntity"]=("undefined"!==typeof self?self:this)["webpackChunkEditEntity"]||[]).push([[302],{1302:function(t,e,i){i.r(e),i.d(e,{default:function(){return o}});var s=function(){var t=this,e=t._self._c;return e("div",[e("b-form-group",{attrs:{label:t.field.label}},["options_select"==t.field.type?e("b-form-select",{attrs:{options:t.options,name:t.field.name},on:{change:t.input},model:{value:t.selected,callback:function(e){t.selected=e},expression:"selected"}}):e("b-form-radio-group",{attrs:{options:t.options,name:t.field.name},on:{change:t.input},model:{value:t.selected,callback:function(e){t.selected=e},expression:"selected"}})],1)],1)},n=[],r=(i(3518),i(8175)),a=i(7458),l={name:"OptionsEntities",components:{},props:{field:{type:Object,required:!0},model:{type:[Object,Array],required:!0},namespaceStore:{type:String,required:!0}},data(){return{options:[],selected:null}},mounted(){this.loadTerms(),this.selected=this.getValue()},methods:{loadTerms(){let t=this.getFistVocab();if(t&&a.A.config){const e=new r.A(t,t,a.A.config);e.get().then((()=>{this.options=e.getOptions()}))}},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},input(t){const e=[];e.push({target_id:t}),this.$emit("setValue",e)},getValue(){return this.model[this.field.name]&&this.model[this.field.name][0]?this.model[this.field.name][0].value?this.model[this.field.name][0].value:this.model[this.field.name][0].target_id:null}}},d=l,u=i(1656),h=(0,u.A)(d,s,n,!1,null,null,null),o=h.exports},8175:function(t,e,i){i(3491);var s=i(4802),n=i(7899),r=i(5606);class a{constructor(t,e=null,i=null){this.entity_type_id=t,this.bundle=e,e||(this.bundle=t),this.url=n.A.baseURl+"/"+this.entity_type_id+"/"+e,this.items=[],this.newConfig=i,i&&i.TestDomain&&(s.A.TestDomain=i.TestDomain),this.filterQuery="",this.fields=[]}get(){return new Promise(((t,e)=>{this.filterQuery&&(this.filterQuery=this.url.includes("?")?"&"+this.filterQuery:"?"+this.filterQuery),s.A.dGet(this.url+this.filterQuery+this.addFieldsToQuery(),n.A.headers).then((e=>{this.items=e.data,t(e.data)})).catch((t=>{e(t)}))}))}getColumnName(){switch(this.entity_type_id){case"webform":return"title";default:return"name"}}getSearch(t){const e=new r.A;return e.addFilter(this.getColumnName(),"CONTAINS",t),new Promise(((t,i)=>{s.A.dGet(this.url+"?"+e.query,n.A.headers).then((e=>{this.items=e.data,t(e.data)})).catch((t=>{i(t)}))}))}getValue(t){const e=new r.A;return e.addFilter(this.getColumnName(),"=",t),new Promise(((t,i)=>{s.A.dGet(this.url+"?"+e.query,n.A.headers).then((e=>{this.items=e.data,t(e.data)})).catch((t=>{i(t)}))}))}getValueByTid(t){const e=new r.A;return e.addFilter("tid","=",t),new Promise(((t,i)=>{s.A.dGet(this.url+"?"+e.query,n.A.headers).then((e=>{this.items=e.data,t(e.data)})).catch((t=>{i(t)}))}))}getValueById(t){const e=new r.A;let i="drupal_internal__id";switch(this.entity_type_id){case"user":i="uid";break;case"node":i="drupal_internal__nid";break;case"taxonomy_term":i="tid";break}return e.addFilter(i,"=",t),new Promise((t=>{s.A.dGet(this.url+"?"+e.query,n.A.headers).then((e=>{this.items=e.data,t(e.data)}))}))}filter(t,e,i){const s=new r.A;s.addFilter(t,e,i),s.query&&(this.filterQuery?this.filterQuery+="&"+s.query:this.filterQuery+=s.query)}pagination(t){t.limit&&(this.filterQuery?this.filterQuery+="&page[limit]="+t.limit:this.filterQuery+="page[limit]="+t.limit,t.offset&&(this.filterQuery+="&page[offset]="+t.offset))}addIncludesEntities(t=[]){}getOptions(){const t=[];for(const e in this.items.data){const i=this.items.data[e];"user"==this.entity_type_id?i.attributes.drupal_internal__uid&&t.push({text:i.attributes.name?i.attributes.name:i.attributes.display_name,value:i.attributes.drupal_internal__uid}):i.attributes.title?t.push({text:i.attributes.title,value:i.attributes.drupal_internal__id}):i.attributes.name?t.push({text:i.attributes.name,value:i.attributes.drupal_internal__id}):i.attributes.label&&t.push({text:i.attributes.label,value:i.attributes.drupal_internal__id})}return t}addFieldsToQuery(){var t="";return this.fields.length>0&&(t+="&fields["+this.entity_type_id+"--"+this.bundle+"]",t+="="+this.fields.toString()),t}setFields(t){this.fields=t}remplaceConfig(){for(const t in this.newConfig)s.A[t]=this.newConfig[t]}}e.A=a}}]);
//# sourceMappingURL=EditEntity.umd.min.302.js.map