replace all links and buttons involved by OnTheFly component

This commit is contained in:
Mathieu Jaumotte 2021-05-31 15:49:55 +02:00
parent 68059a9938
commit 158b572879
8 changed files with 107 additions and 77 deletions

View File

@ -4,18 +4,21 @@
:class="classAction" :class="classAction"
:title="$t(titleAction)" :title="$t(titleAction)"
@click="openModal"> @click="openModal">
{{ buttonText }}
</a> </a>
<teleport to="body"> <teleport to="body">
<modal v-if="modal.showModal" <modal v-if="modal.showModal"
:modalDialogClass="modal.modalDialogClass" :modalDialogClass="modal.modalDialogClass"
@close="modal.showModal = false"> @close="modal.showModal = false">
<template v-slot:header> <template v-slot:header>
<h3 class="modal-title">{{ $t(modalTitle) }}</h3> <h3 class="modal-title">{{ $t(titleModal) }}</h3>
</template> </template>
<template v-slot:body> <template v-slot:body>
{{ action }}
{{ type }}
{{ id }}
</template> </template>
<template v-slot:footer> <template v-slot:footer>
<button class="sc-button bt-save"> <!-- @click.prevent="$emit('..', ..)" --> <button class="sc-button bt-save"> <!-- @click.prevent="$emit('..', ..)" -->
@ -36,7 +39,7 @@ export default {
components: { components: {
Modal Modal
}, },
props: ['type', 'id', 'action'], props: ['type', 'id', 'action', 'buttonText'],
data() { data() {
return { return {
modal: { modal: {
@ -50,20 +53,30 @@ export default {
switch (this.action) { switch (this.action) {
case 'show': case 'show':
return 'bt-show'; return 'bt-show';
case 'create':
return 'bt-create';
case 'edit': case 'edit':
return 'bt-update'; return 'bt-update';
case 'create':
return 'bt-create';
} }
}, },
titleAction() { titleAction() {
switch (this.action) { switch (this.action) {
case 'show': case 'show':
return 'action.show'; return 'action.show';
case 'create':
return 'action.create';
case 'edit': case 'edit':
return 'action.edit'; return 'action.edit';
case 'create':
return 'action.create';
}
},
titleModal() {
switch (this.action) {
case 'show':
return 'onthefly.show.' + this.type;
case 'edit':
return 'onthefly.edit.' + this.type;
case 'create':
return 'onthefly.create.title';
} }
}, },
}, },

View File

@ -46,6 +46,20 @@ const messages = {
previous: "Précédent", previous: "Précédent",
top: "Haut", top: "Haut",
bottom: "Bas", bottom: "Bas",
},
onthefly: {
show: {
person: "Détails de l'usager",
thirdparty: "Détails du tiers"
},
edit: {
person: "Modifier un usager",
thirdparty: "Modifier un tiers"
},
create: {
button: "Créer \"{q}\"",
title: "Saisir une nouvelle personne à la volée",
},
} }
} }
}; };

View File

@ -14,15 +14,15 @@
<ul class="record_actions"> <ul class="record_actions">
<li> <li>
<on-the-fly <on-the-fly
:type="participation.person.type" v-bind:type="participation.person.type"
:id="participation.person.id" v-bind:id="participation.person.id"
action="show"> action="show">
</on-the-fly> </on-the-fly>
</li> </li>
<li> <li>
<on-the-fly <on-the-fly
:type="participation.person.type" v-bind:type="participation.person.type"
:id="participation.person.id" v-bind:id="participation.person.id"
action="edit"> action="edit">
</on-the-fly> </on-the-fly>
</li> </li>
@ -35,7 +35,7 @@
<li> <li>
<button v-if="!participation.endDate" <button v-if="!participation.endDate"
class="sc-button bt-remove" class="sc-button bt-remove"
:title="$t('action.remove')" v-bind:title="$t('action.remove')"
@click.prevent="$emit('close', participation)"> @click.prevent="$emit('close', participation)">
</button> </button>
<button v-else class="sc-button bt-remove disabled"></button> <button v-else class="sc-button bt-remove disabled"></button>
@ -54,14 +54,6 @@ export default {
OnTheFly OnTheFly
}, },
props: ['participation'], props: ['participation'],
data() { emits: ['remove', 'close'],
return {
url: {
show: '/fr/person/' + this.participation.person.id + '/general',
edit: '/fr/person/' + this.participation.person.id + '/general/edit'
}
}
},
emits: ['remove', 'close']
} }
</script> </script>

View File

@ -41,7 +41,18 @@
<ul class="record_actions"> <ul class="record_actions">
<li> <li>
<a class="sc-button bt-show" :title="$t('action.show')" target="_blank" :href="url.show"></a> <on-the-fly
v-bind:type="accompanyingCourse.requestor.type"
v-bind:id="accompanyingCourse.requestor.id"
action="show">
</on-the-fly>
</li>
<li>
<on-the-fly
v-bind:type="accompanyingCourse.requestor.type"
v-bind:id="accompanyingCourse.requestor.id"
action="edit">
</on-the-fly>
</li> </li>
</ul> </ul>
</div> </div>
@ -76,12 +87,14 @@
</template> </template>
<script> <script>
import AddPersons from 'ChillPersonAssets/vuejs/_components/AddPersons.vue' import AddPersons from 'ChillPersonAssets/vuejs/_components/AddPersons.vue';
import OnTheFly from 'ChillMainAssets/vuejs/_components/OnTheFly.vue';
export default { export default {
name: 'Requestor', name: 'Requestor',
components: { components: {
AddPersons, AddPersons,
OnTheFly
}, },
data() { data() {
return { return {
@ -107,13 +120,6 @@ export default {
get() { get() {
return this.$store.state.accompanyingCourse.requestorAnonymous; return this.$store.state.accompanyingCourse.requestorAnonymous;
} }
},
url() {
return (this.accompanyingCourse.requestor.type === 'person') ? {
show: `/fr/person/${this.accompanyingCourse.requestor.id}/general`,
} : {
show: `/fr/thirdparty/thirdparty/${this.accompanyingCourse.requestor.id}/show`,
}
} }
}, },
methods: { methods: {

View File

@ -21,24 +21,25 @@
<td> <td>
<ul class="record_actions"> <ul class="record_actions">
<li> <li>
<a class="sc-button bt-show" target="_blank" <on-the-fly
:href="url.show" v-bind:type="resource.resource.type"
:title="$t('action.show')"> v-bind:id="resource.resource.id"
</a> action="show">
</on-the-fly>
</li> </li>
<li> <li>
<a class="sc-button bt-update" target="_blank" <on-the-fly
:href="url.edit" v-bind:type="resource.resource.type"
:title="$t('action.edit')"> v-bind:id="resource.resource.id"
</a> action="edit">
</on-the-fly>
</li> </li>
<li> <li>
<button <button
class="sc-button bt-remove" class="sc-button bt-remove"
:title="$t('action.remove')" v-bind:title="$t('action.remove')"
@click.prevent="$emit('remove', resource)"> @click.prevent="$emit('remove', resource)">
</button> </button>
</li> </li>
</ul> </ul>
</td> </td>
@ -46,23 +47,14 @@
</template> </template>
<script> <script>
import OnTheFly from 'ChillMainAssets/vuejs/_components/OnTheFly.vue';
export default { export default {
name: 'ResourceItem', name: 'ResourceItem',
components: {
OnTheFly
},
props: ['resource'], props: ['resource'],
emits: ['remove'], emits: ['remove']
computed: {
type() {
return this.resource.resource.type;
},
url() {
return (this.type === 'person') ? {
show: `/fr/person/${this.resource.resource.id}/general`,
edit: `/fr/person/${this.resource.resource.id}/general/edit`
} : {
show: `/fr/thirdparty/thirdparty/${this.resource.resource.id}/show`,
edit: `/fr/thirdparty/thirdparty/${this.resource.resource.id}/update`
}
}
}
} }
</script> </script>

View File

@ -65,9 +65,14 @@
@updateSelected="updateSelected"> @updateSelected="updateSelected">
</person-suggestion> </person-suggestion>
<button v-if="query.length >= 3" class="sc-button bt-create ml-5 mt-2" name="createPerson"> <div class="create-button">
{{ $t('action.create') }} "{{ query }}" <on-the-fly
</button> v-if="query.length >= 3"
v-bind:buttonText="$t('onthefly.create.button', {q: query})"
action="create">
</on-the-fly>
</div>
</div> </div>
</template> </template>
@ -84,6 +89,7 @@
<script> <script>
import Modal from 'ChillMainAssets/vuejs/_components/Modal'; import Modal from 'ChillMainAssets/vuejs/_components/Modal';
import OnTheFly from 'ChillMainAssets/vuejs/_components/OnTheFly.vue';
import PersonSuggestion from './AddPersons/PersonSuggestion'; import PersonSuggestion from './AddPersons/PersonSuggestion';
import { searchPersons, searchPersons_2 } from 'ChillPersonAssets/vuejs/_api/AddPersons'; import { searchPersons, searchPersons_2 } from 'ChillPersonAssets/vuejs/_api/AddPersons';
@ -92,6 +98,7 @@ export default {
components: { components: {
Modal, Modal,
PersonSuggestion, PersonSuggestion,
OnTheFly
}, },
props: [ props: [
'buttonTitle', 'buttonTitle',
@ -251,4 +258,8 @@ export default {
} }
} }
} }
.create-button > a {
margin-top: 0.5em;
margin-left: 2.6em;
}
</style> </style>

View File

@ -14,22 +14,23 @@
<span class="badge badge-pill badge-secondary" :title="item.key"> <span class="badge badge-pill badge-secondary" :title="item.key">
{{ $t('item.type_person') }} {{ $t('item.type_person') }}
</span> </span>
<a class="sc-button bt-show" target="_blank" :title="item.key" :href="url.show"></a> <on-the-fly
type="person"
v-bind:id="item.result.id"
action="show">
</on-the-fly>
</div> </div>
</template> </template>
<script> <script>
import OnTheFly from 'ChillMainAssets/vuejs/_components/OnTheFly.vue';
export default { export default {
name: 'SuggestionPerson', name: 'SuggestionPerson',
props: ['item'], components: {
data() { OnTheFly
return {
url: {
show: '/fr/person/' + this.item.result.person_id + '/general',
edit: '/fr/person/' + this.item.result.person_id + '/general/edit'
},
}
}, },
props: ['item']
} }
</script> </script>

View File

@ -15,22 +15,23 @@
<span class="badge badge-pill badge-secondary" :title="item.key"> <span class="badge badge-pill badge-secondary" :title="item.key">
{{ $t('item.type_thirdparty') }} {{ $t('item.type_thirdparty') }}
</span> </span>
<a class="sc-button bt-show" target="_blank" :title="item.key" :href="url.show"></a> <on-the-fly
type="thirdparty"
v-bind:id="item.result.id"
action="show">
</on-the-fly>
</div> </div>
</template> </template>
<script> <script>
import OnTheFly from 'ChillMainAssets/vuejs/_components/OnTheFly.vue';
export default { export default {
name: 'SuggestionThirdParty', name: 'SuggestionThirdParty',
props: ['item'], components: {
data() { OnTheFly
return {
url: {
show: '/fr/thirdparty/thirdparty/' + this.item.result.thirdparty_id + '/show',
edit: '/fr/thirdparty/thirdparty/' + this.item.result.thirdparty_id + '/edit'
},
}
}, },
props: ['item']
} }
</script> </script>