mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
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:
parent
c9e3960238
commit
ecda740d81
@ -5,6 +5,7 @@
|
||||
:action="context.action"
|
||||
:buttonText="options.buttonText"
|
||||
:displayBadge="options.displayBadge === 'true'"
|
||||
:parent="options.parent"
|
||||
@saveFormOnTheFly="saveFormOnTheFly">
|
||||
</on-the-fly>
|
||||
</template>
|
||||
|
@ -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':
|
||||
|
@ -17,6 +17,7 @@ const ontheflyMessages = {
|
||||
person: "un nouvel usager",
|
||||
thirdparty: "un nouveau tiers professionnel"
|
||||
},
|
||||
resource_comment_title: "Un commentaire est associé à cet interlocuteur"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
* action string 'show', 'edit', 'create'
|
||||
* buttonText string
|
||||
* displayBadge boolean (default: false) replace button by badge, need to define buttonText for content
|
||||
* parent object (optional) pass parent context of the targetEntity (used for course resource comment)
|
||||
|
||||
#}
|
||||
<span class="onthefly-container"
|
||||
@ -31,6 +32,10 @@
|
||||
data-display-badge="true"
|
||||
{% endif %}
|
||||
|
||||
{% if parent is defined %}
|
||||
data-parent='{{ parent|json_encode }}'
|
||||
{% endif %}
|
||||
|
||||
></span>
|
||||
|
||||
{{ encore_entry_script_tags('vue_onthefly') }}
|
||||
|
@ -22,6 +22,7 @@
|
||||
</li>
|
||||
<li>
|
||||
<on-the-fly
|
||||
:parent="parent"
|
||||
:type="resource.resource.type"
|
||||
:id="resource.resource.id"
|
||||
action="show">
|
||||
@ -29,6 +30,7 @@
|
||||
</li>
|
||||
<li>
|
||||
<on-the-fly
|
||||
:parent="parent"
|
||||
:type="resource.resource.type"
|
||||
:id="resource.resource.id"
|
||||
action="edit"
|
||||
@ -66,6 +68,7 @@
|
||||
</li>
|
||||
<li>
|
||||
<on-the-fly
|
||||
:parent="parent"
|
||||
:type="resource.resource.type"
|
||||
:id="resource.resource.id"
|
||||
action="show">
|
||||
@ -73,6 +76,7 @@
|
||||
</li>
|
||||
<li>
|
||||
<on-the-fly
|
||||
:parent="parent"
|
||||
:type="resource.resource.type"
|
||||
:id="resource.resource.id"
|
||||
action="edit"
|
||||
@ -110,6 +114,17 @@ export default {
|
||||
props: ['resource'],
|
||||
emits: ['remove'],
|
||||
computed: {
|
||||
parent() {
|
||||
return {
|
||||
'type': this.resource.type,
|
||||
'id': this.resource.id,
|
||||
'comment': this.resource.comment,
|
||||
'parent': {
|
||||
'type': this.$store.state.accompanyingCourse.type,
|
||||
'id': this.$store.state.accompanyingCourse.id
|
||||
}
|
||||
}
|
||||
},
|
||||
hasCurrentHouseholdAddress() {
|
||||
if ( this.resource.resource.current_household_address !== null ) {
|
||||
return true;
|
||||
|
@ -4,11 +4,12 @@
|
||||
{{ 'Resume Accompanying Course'|trans }}
|
||||
{% endblock %}
|
||||
|
||||
{% macro insert_onthefly(type, entity) %}
|
||||
{% macro insert_onthefly(type, entity, parent = null) %}
|
||||
{% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with {
|
||||
action: 'show', displayBadge: true,
|
||||
targetEntity: { name: type, id: entity.id },
|
||||
buttonText: entity|chill_entity_render_string
|
||||
buttonText: entity|chill_entity_render_string,
|
||||
parent: parent
|
||||
} %}
|
||||
{% endmacro %}
|
||||
|
||||
@ -106,11 +107,21 @@
|
||||
<div class="mbloc col col-sm-6 col-lg-4">
|
||||
<div class="resources">
|
||||
<h4 class="item-key">{{ 'Resources'|trans }}</h4>
|
||||
|
||||
{% for r in accompanyingCourse.resources %}
|
||||
{% set parent = {
|
||||
'type': 'accompanying_period_resource',
|
||||
'id': r.id,
|
||||
'comment': r.comment,
|
||||
'parent': {
|
||||
'type': 'accompanying_period',
|
||||
'id': accompanyingCourse.id
|
||||
}
|
||||
} %}
|
||||
{% if r.person is not null %}
|
||||
{{ _self.insert_onthefly('person', r.person) }}
|
||||
{{ _self.insert_onthefly('person', r.person, parent) }}
|
||||
{% elseif r.thirdParty is not null %}
|
||||
{{ _self.insert_onthefly('thirdparty', r.thirdParty) }}
|
||||
{{ _self.insert_onthefly('thirdparty', r.thirdParty, parent) }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user