on-the-fly: add a 'parent' option to pass parent context. So we could now display resource.comment below the renderbox.

This commit is contained in:
2022-01-12 20:26:54 +01:00
parent c9e3960238
commit ecda740d81
7 changed files with 63 additions and 8 deletions

View File

@@ -5,6 +5,7 @@
:action="context.action"
:buttonText="options.buttonText"
:displayBadge="options.displayBadge === 'true'"
:parent="options.parent"
@saveFormOnTheFly="saveFormOnTheFly">
</on-the-fly>
</template>

View File

@@ -28,6 +28,12 @@
v-bind:action="action"
ref="castPerson">
</on-the-fly-person>
<div v-if="hasResourceComment">
<h3>{{ $t('onthefly.resource_comment_title') }}</h3>
<blockquote class="chill-user-quote">
{{ parent.comment }}
</blockquote>
</div>
</template>
<template v-slot:body v-else-if="type === 'thirdparty'">
@@ -37,6 +43,12 @@
v-bind:action="action"
ref="castThirdparty">
</on-the-fly-thirdparty>
<div v-if="hasResourceComment">
<h3>{{ $t('onthefly.resource_comment_title') }}</h3>
<blockquote class="chill-user-quote">
{{ parent.comment }}
</blockquote>
</div>
</template>
<template v-slot:body v-else>
@@ -78,18 +90,27 @@ export default {
OnTheFlyThirdparty,
OnTheFlyCreate
},
props: ['type', 'id', 'action', 'buttonText', 'displayBadge'],
props: ['type', 'id', 'action', 'buttonText', 'displayBadge', 'parent'],
emits: ['saveFormOnTheFly'],
data() {
return {
modal: {
showModal: false,
modalDialogClass: "modal-dialog-scrollable modal-xl"
},
//action: this.action
}
}
},
computed: {
hasResourceComment() {
//console.log('hasResourceComment', this.parent);
if (typeof this.parent === 'undefined' || this.parent === null) {
return false;
}
return this.action === 'show'
&& this.parent.type === 'accompanying_period_resource'
&& (this.parent.comment !== null || this.parent.comment !== '')
;
},
classAction() {
switch (this.action) {
case 'show':

View File

@@ -17,6 +17,7 @@ const ontheflyMessages = {
person: "un nouvel usager",
thirdparty: "un nouveau tiers professionnel"
},
resource_comment_title: "Un commentaire est associé à cet interlocuteur"
}
}
}

View File

@@ -21,7 +21,8 @@ containers.forEach((container) => {
},
options: {
buttonText: container.dataset.buttonText || null,
displayBadge: container.dataset.displayBadge || false
displayBadge: container.dataset.displayBadge || false,
parent: JSON.parse(container.dataset.parent) || null,
}
}
}