UX: [vue] Change single button notification by dropdown button (edit workAction)

This commit is contained in:
Mathieu Jaumotte 2023-05-23 16:32:08 +02:00
parent 5931b2f709
commit ef6a5e0b6b
2 changed files with 77 additions and 36 deletions

View File

@ -296,13 +296,26 @@
@go-to-generate-workflow="goToGenerateWorkflow" @go-to-generate-workflow="goToGenerateWorkflow"
></list-workflow-modal> ></list-workflow-modal>
</li> </li>
<li> <li>
<!--
{% if accompanyingCourse.hasUser and accompanyingCourse.user is not same as(app.user) %}
{{ work.accompanyingPeriod.user }}
-->
<button <button
v-if="false"
class="btn btn-notify" class="btn btn-notify"
@click="goToGenerateNotification" @click="goToGenerateNotification(false)"
> ></button>
</button> <template v-else>
<button id="btnGroupNotifyButtons" type="button" class="btn btn-notify dropdown-toggle" :title="$t('notification_send')" data-bs-toggle="dropdown" aria-expanded="false">&nbsp;</button>
<ul class="dropdown-menu" aria-labelledby="btnGroupNotifyButtons">
<li><a class="dropdown-item" @click="goToGenerateNotification(true)">{{ $t('notification_notify_referrer') }}</a></li>
<li><a class="dropdown-item" @click="goToGenerateNotification(false)">{{ $t('notification_notify_any') }}</a></li>
</ul>
</template>
</li> </li>
<li v-if="!isPosting"> <li v-if="!isPosting">
<button class="btn btn-save" @click="submit"> <button class="btn btn-save" @click="submit">
{{ $t('action.save') }} {{ $t('action.save') }}
@ -372,7 +385,10 @@ const i18n = {
no_referrers: "Aucun agent traitant", no_referrers: "Aucun agent traitant",
choose_referrers: "Choisir des agents traitants", choose_referrers: "Choisir des agents traitants",
remove_referrer: "Enlever l'agent", remove_referrer: "Enlever l'agent",
private_comment: "Commentaire privé" private_comment: "Commentaire privé",
notification_notify_referrer: "Notifier le référent",
notification_notify_any: "Notifier d'autres utilisateurs",
notification_send: "Envoyer une notification",
} }
} }
}; };
@ -554,10 +570,14 @@ export default {
return this.$store.dispatch('submit', callback) return this.$store.dispatch('submit', callback)
.catch(e => { console.log(e); throw e; }); .catch(e => { console.log(e); throw e; });
}, },
goToGenerateNotification() { goToGenerateNotification(tos) {
console.log('save before leave to notification'); console.log('save before leave to notification');
const callback = (data) => { const callback = (data) => {
window.location.assign(`/fr/notification/create?entityClass=Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWork&entityId=${this.work.id}&returnPath=/fr/person/accompanying-period/${this.work.accompanyingPeriod.id}/work`); if (tos === true) {
window.location.assign(`/fr/notification/create?entityClass=Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWork&entityId=${this.work.id}&tos[0]=${this.work.accompanyingPeriod.user.id}&returnPath=/fr/person/accompanying-period/${this.work.accompanyingPeriod.id}/work`);
} else {
window.location.assign(`/fr/notification/create?entityClass=Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWork&entityId=${this.work.id}&returnPath=/fr/person/accompanying-period/${this.work.accompanyingPeriod.id}/work`);
}
} }
return this.$store.dispatch('submit', callback) return this.$store.dispatch('submit', callback)

View File

@ -102,32 +102,36 @@
</div> </div>
<div class="item-row"> <div class="item-row">
<div class="item-col"> <div class="item-col">
<ul class="record_actions" > <ul class="record_actions">
<li v-if="d.workflows_availables.length > 0">
<li> <list-workflow-modal
<button class="btn btn-notify" @click="goToGenerateDocumentNotification(d)"> :workflows="d.workflows"
</button> :allowCreate="true"
</li> relatedEntityClass="Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument"
<li v-if="d.workflows_availables.length > 0"> :relatedEntityId="d.id"
<list-workflow-modal :workflowsAvailables="d.workflows_availables"
:workflows="d.workflows" :preventDefaultMoveToGenerate="true"
:allowCreate="true" :goToGenerateWorkflowPayload="{doc: d}"
relatedEntityClass="Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument" @go-to-generate-workflow="goToGenerateWorkflowEvaluationDocument"
:relatedEntityId="d.id" ></list-workflow-modal>
:workflowsAvailables="d.workflows_availables" </li>
:preventDefaultMoveToGenerate="true"
:goToGenerateWorkflowPayload="{doc: d}"
@go-to-generate-workflow="goToGenerateWorkflowEvaluationDocument"
></list-workflow-modal>
</li>
<li> <li>
<add-async-upload <!--
:buttonTitle="$t('replace')" {% if accompanyingCourse.hasUser and accompanyingCourse.user is not same as(app.user) %}
:options="asyncUploadOptions" {{ work.accompanyingPeriod.user }}
:btnClasses="{'btn': true, 'btn-edit': true}" -->
@addDocument="(arg) => replaceDocument(d, arg)" <button
> v-if="false"
</add-async-upload> class="btn btn-notify"
@click="goToGenerateDocumentNotification(d, false)">
</button>
<template v-else>
<button id="btnGroupNotifyButtons" type="button" class="btn btn-notify dropdown-toggle" :title="$t('notification_send')" data-bs-toggle="dropdown" aria-expanded="false">&nbsp;</button>
<ul class="dropdown-menu" aria-labelledby="btnGroupNotifyButtons">
<li><a class="dropdown-item" @click="goToGenerateDocumentNotification(d, true)">{{ $t('notification_notify_referrer') }}</a></li>
<li><a class="dropdown-item" @click="goToGenerateDocumentNotification(d, false)">{{ $t('notification_notify_any') }}</a></li>
</ul>
</template>
</li> </li>
<li> <li>
<document-action-buttons-group <document-action-buttons-group
@ -138,6 +142,15 @@
@on-stored-object-status-change="onStatusDocumentChanged" @on-stored-object-status-change="onStatusDocumentChanged"
></document-action-buttons-group> ></document-action-buttons-group>
</li> </li>
<li>
<add-async-upload
:buttonTitle="$t('replace')"
:options="asyncUploadOptions"
:btnClasses="{'btn': true, 'btn-edit': true}"
@addDocument="(arg) => replaceDocument(d, arg)"
>
</add-async-upload>
</li>
<li v-if="d.workflows.length === 0"> <li v-if="d.workflows.length === 0">
<a class="btn btn-delete" @click="removeDocument(d)"> <a class="btn btn-delete" @click="removeDocument(d)">
</a> </a>
@ -219,7 +232,10 @@ const i18n = {
template_title: "Nom du template", template_title: "Nom du template",
browse: "Ajouter un document", browse: "Ajouter un document",
replace: "Remplacer", replace: "Remplacer",
download: "Télécharger le fichier existant" download: "Télécharger le fichier existant",
notification_notify_referrer: "Notifier le référent",
notification_notify_any: "Notifier d'autres utilisateurs",
notification_send: "Envoyer une notification",
} }
} }
}; };
@ -265,7 +281,8 @@ export default {
}, },
computed: { computed: {
...mapState([ ...mapState([
'isPosting' 'isPosting',
'work'
]), ]),
getTemplatesAvailables() { getTemplatesAvailables() {
return this.$store.getters.getTemplatesAvailablesForEvaluation(this.evaluation.evaluation); return this.$store.getters.getTemplatesAvailablesForEvaluation(this.evaluation.evaluation);
@ -395,10 +412,14 @@ export default {
return this.$store.dispatch('submit', callback) return this.$store.dispatch('submit', callback)
.catch(e => { console.log(e); throw e; }); .catch(e => { console.log(e); throw e; });
}, },
goToGenerateDocumentNotification(document){ goToGenerateDocumentNotification(document, tos){
const callback = (data) => { const callback = (data) => {
let evaluation = data.accompanyingPeriodWorkEvaluations.find(e => e.key === this.evaluation.key); let evaluation = data.accompanyingPeriodWorkEvaluations.find(e => e.key === this.evaluation.key);
window.location.assign(`/fr/notification/create?entityClass=Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument&entityId=${document.id}&returnPath=/fr/person/accompanying-period/work/${evaluation.id}/edit`) if (tos === true) {
window.location.assign(`/fr/notification/create?entityClass=Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument&entityId=${document.id}&tos[0]=${this.$store.state.work.accompanyingPeriod.user.id}&returnPath=/fr/person/accompanying-period/work/${evaluation.id}/edit`)
} else {
window.location.assign(`/fr/notification/create?entityClass=Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument&entityId=${document.id}&returnPath=/fr/person/accompanying-period/work/${evaluation.id}/edit`)
}
}; };
return this.$store.dispatch('submit', callback) return this.$store.dispatch('submit', callback)
.catch(e => {console.log(e); throw e}); .catch(e => {console.log(e); throw e});