field confidentialite SelectEditable
This commit is contained in:
parent
4b215617f1
commit
67c2008d1f
@ -23,6 +23,7 @@ import { mdiChevronDown } from '@mdi/js';
|
||||
|
||||
import ContentEditable from '@components/editable/ContentEditable.vue';
|
||||
import CheckboxEditable from '@components/editable/CheckboxEditable.vue';
|
||||
import SelectEditable from '@components/editable/SelectEditable.vue';
|
||||
|
||||
export default {
|
||||
props: ['cid', 'eid'],
|
||||
@ -223,7 +224,8 @@ export default {
|
||||
VueSlider,
|
||||
SvgIcon,
|
||||
ContentEditable,
|
||||
CheckboxEditable
|
||||
CheckboxEditable,
|
||||
SelectEditable
|
||||
}
|
||||
}
|
||||
|
||||
@ -260,6 +262,22 @@ export default {
|
||||
field: 'field_entite_agissante'
|
||||
}" />
|
||||
|
||||
<SelectEditable
|
||||
v-if="entite && entite.can_update"
|
||||
label="Confidentialité"
|
||||
:value="0"
|
||||
:options="{
|
||||
'confidentialite_prive': 'privé',
|
||||
'confidentialite_interne': 'interne',
|
||||
'confidentialite_public': 'public'
|
||||
}"
|
||||
:data="{
|
||||
entitytype: 'node',
|
||||
bundle: 'entite',
|
||||
nid: this.entite.id,
|
||||
field: 'field_confidentialite'
|
||||
}" />
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
76
src/components/editable/SelectEditable.vue
Normal file
76
src/components/editable/SelectEditable.vue
Normal file
@ -0,0 +1,76 @@
|
||||
<script>
|
||||
|
||||
import REST from '@api/rest-axios'
|
||||
|
||||
import { mapActions, mapState } from 'pinia'
|
||||
import { ConcernementsStore } from '@stores/concernements'
|
||||
import { UserStore } from '@stores/user'
|
||||
|
||||
|
||||
export default {
|
||||
props: {
|
||||
value: Number,
|
||||
options: Object,
|
||||
label: String,
|
||||
data: Object
|
||||
},
|
||||
emits: ['updated'],
|
||||
data(){
|
||||
return {
|
||||
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState(UserStore,['csrf_token']),
|
||||
},
|
||||
created () {
|
||||
console.log('SelectEditable created');
|
||||
},
|
||||
mounted () {
|
||||
|
||||
},
|
||||
methods: {
|
||||
...mapActions(ConcernementsStore, ['reloadConcernements']),
|
||||
onInput(e){
|
||||
console.log('onInput select e', e);
|
||||
// let checked = e.target.checked;
|
||||
let value = e.target.value;
|
||||
// console.log('onInput checkbox checked', checked);
|
||||
this.save(value)
|
||||
},
|
||||
save(value){
|
||||
// console.log('save csrf_token', this.csrf_token);
|
||||
const params = {
|
||||
type: this.data.bundle,
|
||||
nid: [{"value":this.data.nid}],
|
||||
[this.data.field]: {value: value}
|
||||
};
|
||||
const configs = {
|
||||
headers: {'X-CSRF-Token': this.csrf_token}
|
||||
};
|
||||
REST.patch(`/node/${this.data.nid}?_format=json`, params, configs)
|
||||
.then(({ data }) => {
|
||||
console.log('user REST post node data', data)
|
||||
// TODO if success update the data in pinia
|
||||
// this.reloadConcernements();
|
||||
this.$emit('updated');
|
||||
})
|
||||
.catch(error => {
|
||||
console.warn(`Issue with patch node ${this.data.bundle}`, error)
|
||||
Promise.reject(error)
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="editable">
|
||||
<label>{{ label }}</label>
|
||||
<select :value="value" @input="onInput">
|
||||
<template v-for="(name,value,index) in options" :key="index">
|
||||
<option :value="value">{{name}}</option>
|
||||
</template>
|
||||
</select>
|
||||
</section>
|
||||
</template>
|
Loading…
x
Reference in New Issue
Block a user