refactoring; saving first paragraph contentEditable

This commit is contained in:
Bachir Soussi Chiadmi 2024-03-27 17:10:02 +01:00
parent d1716ce7f6
commit e4104a52ef
6 changed files with 29 additions and 9 deletions

View File

@ -13,6 +13,7 @@ fragment EntiteFields on Entite {
id
}
sources {
id
description
images {
alt

View File

@ -73,7 +73,7 @@ export default {
:data="{
entitytype: 'node',
bundle: 'entite',
nid: this.entite.id,
id: this.entite.id,
field: {field_name: 'field_action', value:'value'}
}"
v-on:updated="reloadEntite" />
@ -89,7 +89,7 @@ export default {
:data="{
entitytype: 'node',
bundle: 'entite',
nid: this.entite.id,
id: this.entite.id,
field: {field_name: 'field_menace_maintien', value:'value'}
}"
v-on:updated="reloadEntite" />

View File

@ -46,7 +46,19 @@ export default {
<!-- <div class="date">{{ source.date.start }}</div> -->
<section v-if="source.description" class="description">
<label v-if="ct_entite"> {{ field_sources_label }}</label>
<div v-html="source.description"/>
<!-- <div v-html="source.description"/> -->
<ContentEditable
tag="div"
:value="source.description"
:contenteditable="entite.can_update"
:html="true"
:data="{
entitytype: 'paragraph',
bundle: 'source',
id: this.source.id,
field: {field_name: 'field_description', value:'value'}
}"
v-on:updated="reloadEntite" />
</section>
<section

View File

@ -247,7 +247,7 @@ export default {
:data="{
entitytype: 'node',
bundle: 'entite',
nid: this.entite.id,
id: this.entite.id,
field: {field_name: 'title', value:'value'}
}" />
@ -296,7 +296,7 @@ export default {
:data="{
entitytype: 'node',
bundle: 'concernement',
nid: this.concernement.id,
id: this.concernement.id,
field: {field_name: 'field_description', value:'value'}
}" />
@ -312,7 +312,7 @@ export default {
:data="{
entitytype: 'node',
bundle: 'concernement',
nid: this.concernement.id,
id: this.concernement.id,
field: {field_name: 'field_caillou', value:'value'}
}" />

View File

@ -49,9 +49,13 @@ export default {
// console.log('save csrf_token', this.csrf_token);
const params = {
type: this.data.bundle,
nid: [{"value":this.data.nid}],
[this.data.field.field_name]: [{[this.data.field.value]: content}]
};
if (this.data.entitytype === 'node') {
params.nid = [{"value":this.data.id}];
} else {
params.id = [{"value":this.data.id}];
}
// we need additional values for image alt for example
// console.log('additional_values', this.data.field.additional_values);
if (this.data.field.additional_values) {
@ -61,10 +65,13 @@ export default {
}
}
}
const configs = {
headers: {'X-CSRF-Token': this.csrf_token}
};
REST.patch(`/${this.data.entitytype}/${this.data.nid}?_format=json`, params, configs)
let url_base = `/${this.data.entitytype === 'node' ? '' : 'entity/'}${this.data.entitytype}`;
REST.patch(`${url_base}/${this.data.id}?_format=json`, params, configs)
.then(({ data }) => {
console.log('user REST post node data', data)
// TODO if success update the data in pinia

View File

@ -76,7 +76,7 @@ export default {
:data="{
entitytype: 'node',
bundle: 'concernement',
nid: this.concernement.id,
id: this.concernement.id,
field: {field_name: 'title', value:'value'}
}" />