refactoring; saving first paragraph contentEditable
This commit is contained in:
parent
d1716ce7f6
commit
e4104a52ef
@ -13,6 +13,7 @@ fragment EntiteFields on Entite {
|
|||||||
id
|
id
|
||||||
}
|
}
|
||||||
sources {
|
sources {
|
||||||
|
id
|
||||||
description
|
description
|
||||||
images {
|
images {
|
||||||
alt
|
alt
|
||||||
|
@ -73,7 +73,7 @@ export default {
|
|||||||
:data="{
|
:data="{
|
||||||
entitytype: 'node',
|
entitytype: 'node',
|
||||||
bundle: 'entite',
|
bundle: 'entite',
|
||||||
nid: this.entite.id,
|
id: this.entite.id,
|
||||||
field: {field_name: 'field_action', value:'value'}
|
field: {field_name: 'field_action', value:'value'}
|
||||||
}"
|
}"
|
||||||
v-on:updated="reloadEntite" />
|
v-on:updated="reloadEntite" />
|
||||||
@ -89,7 +89,7 @@ export default {
|
|||||||
:data="{
|
:data="{
|
||||||
entitytype: 'node',
|
entitytype: 'node',
|
||||||
bundle: 'entite',
|
bundle: 'entite',
|
||||||
nid: this.entite.id,
|
id: this.entite.id,
|
||||||
field: {field_name: 'field_menace_maintien', value:'value'}
|
field: {field_name: 'field_menace_maintien', value:'value'}
|
||||||
}"
|
}"
|
||||||
v-on:updated="reloadEntite" />
|
v-on:updated="reloadEntite" />
|
||||||
|
@ -46,7 +46,19 @@ export default {
|
|||||||
<!-- <div class="date">{{ source.date.start }}</div> -->
|
<!-- <div class="date">{{ source.date.start }}</div> -->
|
||||||
<section v-if="source.description" class="description">
|
<section v-if="source.description" class="description">
|
||||||
<label v-if="ct_entite"> {{ field_sources_label }}</label>
|
<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>
|
||||||
|
|
||||||
<section
|
<section
|
||||||
|
@ -247,7 +247,7 @@ export default {
|
|||||||
:data="{
|
:data="{
|
||||||
entitytype: 'node',
|
entitytype: 'node',
|
||||||
bundle: 'entite',
|
bundle: 'entite',
|
||||||
nid: this.entite.id,
|
id: this.entite.id,
|
||||||
field: {field_name: 'title', value:'value'}
|
field: {field_name: 'title', value:'value'}
|
||||||
}" />
|
}" />
|
||||||
|
|
||||||
@ -296,7 +296,7 @@ export default {
|
|||||||
:data="{
|
:data="{
|
||||||
entitytype: 'node',
|
entitytype: 'node',
|
||||||
bundle: 'concernement',
|
bundle: 'concernement',
|
||||||
nid: this.concernement.id,
|
id: this.concernement.id,
|
||||||
field: {field_name: 'field_description', value:'value'}
|
field: {field_name: 'field_description', value:'value'}
|
||||||
}" />
|
}" />
|
||||||
|
|
||||||
@ -312,7 +312,7 @@ export default {
|
|||||||
:data="{
|
:data="{
|
||||||
entitytype: 'node',
|
entitytype: 'node',
|
||||||
bundle: 'concernement',
|
bundle: 'concernement',
|
||||||
nid: this.concernement.id,
|
id: this.concernement.id,
|
||||||
field: {field_name: 'field_caillou', value:'value'}
|
field: {field_name: 'field_caillou', value:'value'}
|
||||||
}" />
|
}" />
|
||||||
|
|
||||||
|
@ -49,9 +49,13 @@ export default {
|
|||||||
// console.log('save csrf_token', this.csrf_token);
|
// console.log('save csrf_token', this.csrf_token);
|
||||||
const params = {
|
const params = {
|
||||||
type: this.data.bundle,
|
type: this.data.bundle,
|
||||||
nid: [{"value":this.data.nid}],
|
|
||||||
[this.data.field.field_name]: [{[this.data.field.value]: content}]
|
[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
|
// we need additional values for image alt for example
|
||||||
// console.log('additional_values', this.data.field.additional_values);
|
// console.log('additional_values', this.data.field.additional_values);
|
||||||
if (this.data.field.additional_values) {
|
if (this.data.field.additional_values) {
|
||||||
@ -61,10 +65,13 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const configs = {
|
const configs = {
|
||||||
headers: {'X-CSRF-Token': this.csrf_token}
|
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 }) => {
|
.then(({ data }) => {
|
||||||
console.log('user REST post node data', data)
|
console.log('user REST post node data', data)
|
||||||
// TODO if success update the data in pinia
|
// TODO if success update the data in pinia
|
||||||
|
@ -76,7 +76,7 @@ export default {
|
|||||||
:data="{
|
:data="{
|
||||||
entitytype: 'node',
|
entitytype: 'node',
|
||||||
bundle: 'concernement',
|
bundle: 'concernement',
|
||||||
nid: this.concernement.id,
|
id: this.concernement.id,
|
||||||
field: {field_name: 'title', value:'value'}
|
field: {field_name: 'title', value:'value'}
|
||||||
}" />
|
}" />
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user