add options on button for AddPersons component: size, type and display

* size: add bootstrap class : btn-sm, btn-lg..
* type: override chill button class : btn-update, btn-chill-beige
* display: override default : true
This commit is contained in:
Mathieu Jaumotte 2021-08-09 17:03:21 +02:00 committed by Marc Ducobu
parent 3156706c2b
commit d67483fd9a
2 changed files with 33 additions and 22 deletions

View File

@ -140,9 +140,7 @@
<ul class="record_actions"> <ul class="record_actions">
<li> <li>
<button class="btn btn-delete" @click="removeHandlingThirdParty"> <button class="btn btn-remove" @click="removeHandlingThirdParty" :title="$t('remove_handling_thirdparty')"></button>
{{ $t('remove_handling_thirdparty') }}
</button>
</li> </li>
</ul> </ul>
</div> </div>
@ -163,7 +161,7 @@
<show-address :address="t.address"></show-address> <show-address :address="t.address"></show-address>
<ul class="record_actions"> <ul class="record_actions">
<button class="btn btn-delete" @click="removeThirdParty(t)"></button> <button class="btn btn-remove" @click="removeThirdParty(t)" :title="$t('remove_thirdparty')"></button>
</ul> </ul>
</li> </li>
</ul> </ul>
@ -302,11 +300,12 @@
} }
div.objective-title { div.objective-title {
font-weight: bold;
/*
margin-top: 1rem; margin-top: 1rem;
font-size: 1.5rem; font-size: 1.5rem;
font-weight: bold;
text-align: center; text-align: center;
*/
i.fa { i.fa {
padding: 0.25rem; padding: 0.25rem;
@ -399,7 +398,8 @@ const i18n = {
no_handling_thirdparty: "Aucun tiers traitant", no_handling_thirdparty: "Aucun tiers traitant",
precise_handling_thirdparty: "Indiquer un tiers traitant", precise_handling_thirdparty: "Indiquer un tiers traitant",
choose_a_thirdparty: "Choisir un tiers", choose_a_thirdparty: "Choisir un tiers",
remove_handling_thirdparty: "Supprimer le tiers traitant", remove_thirdparty: "Enlever le tiers",
remove_handling_thirdparty: "Enlever le tiers traitant",
thirdparty_intervener: "Tiers intervenants", thirdparty_intervener: "Tiers intervenants",
no_thirdparty_intervener: "Aucun tiers intervenant", no_thirdparty_intervener: "Aucun tiers intervenant",
add_thirdparties: "Ajouter des tiers", add_thirdparties: "Ajouter des tiers",
@ -430,7 +430,10 @@ export default {
options: { options: {
type: [ 'thirdparty' ], type: [ 'thirdparty' ],
priority: null, priority: null,
uniq: true uniq: true,
button: {
display: false
}
}, },
}, },
thirdPartyPicker: { thirdPartyPicker: {
@ -439,6 +442,9 @@ export default {
type: [ 'thirdparty' ], type: [ 'thirdparty' ],
priority: null, priority: null,
uniq: false, uniq: false,
button: {
display: false
}
}, },
} }
}; };

View File

@ -1,9 +1,8 @@
<template> <template>
<ul class="record_actions"> <ul class="record_actions">
<li class="add-persons"> <li class="add-persons">
<a class="btn btn-create" @click="openModal"> <a class="btn" :class="getClassButton" :title="$t(buttonTitle)"
{{ $t(buttonTitle) }} @click="openModal"><span v-if="displayTextButton">{{ $t(buttonTitle) }}</span></a>
</a>
</li> </li>
</ul> </ul>
@ -19,7 +18,7 @@
<template v-slot:body-head> <template v-slot:body-head>
<div class="modal-body"> <div class="modal-body">
<div class="search"> <div class="search">
<label class="col-form-label" style="float: right;"> <label class="col-form-label" style="float: right;">
{{ $tc('add_persons.suggested_counter', suggestedCounter) }} {{ $tc('add_persons.suggested_counter', suggestedCounter) }}
</label> </label>
@ -66,17 +65,17 @@
<div class="create-button"> <div class="create-button">
<on-the-fly <on-the-fly
v-if="query.length >= 3" v-if="query.length >= 3"
v-bind:buttonText="$t('onthefly.create.button', {q: query})" v-bind:buttonText="$t('onthefly.create.button', {q: query})"
action="create"><!-- TODO first close this modal --> action="create"><!-- TODO first close this modal -->
</on-the-fly> </on-the-fly>
</div> </div>
</div> </div>
</template> </template>
<template v-slot:footer> <template v-slot:footer>
<button class="btn btn-create" <button class="btn btn-create"
@click.prevent="$emit('addNewPersons', { selected, modal })"> @click.prevent="$emit('addNewPersons', { selected, modal })">
{{ $t('action.add')}} {{ $t('action.add')}}
</button> </button>
@ -150,13 +149,19 @@ export default {
]; ];
let union = [...new Set([ let union = [...new Set([
...this.suggested.slice().reverse(), ...this.suggested.slice().reverse(),
...this.selected.slice().reverse(), ...this.selected.slice().reverse(),
])]; ])];
return uniqBy(union, k => k.key); return uniqBy(union, k => k.key);
}, },
//options() { getClassButton() {
// return this.options; let size = (typeof this.options.button !== 'undefined' && typeof this.options.button.size !== 'undefined') ? this.options.button.size : '';
//}, let type = (typeof this.options.button !== 'undefined' && typeof this.options.button.type !== 'undefined') ? this.options.button.type : 'btn-create';
return size ? size + ' ' + type : type;
},
displayTextButton() {
return (typeof this.options.button !== 'undefined' && typeof this.options.button.display !== 'undefined') ?
this.options.button.display : true;
},
checkUniq() { checkUniq() {
if (this.options.uniq === true) { if (this.options.uniq === true) {
return 'radio'; return 'radio';
@ -184,7 +189,7 @@ export default {
this.loadSuggestions([]); this.loadSuggestions([]);
} }
}, },
loadSuggestions(suggested) { loadSuggestions(suggested) {
//console.log('suggested', suggested); //console.log('suggested', suggested);
this.search.suggested = suggested; this.search.suggested = suggested;
this.search.suggested.forEach(function(item) { this.search.suggested.forEach(function(item) {
@ -230,7 +235,7 @@ export default {
margin: auto 4em; margin: auto 4em;
div.search { div.search {
position: relative; position: relative;
input { input {
width: 100%; width: 100%;
padding: 1.2em 1.5em 1.2em 2.5em; padding: 1.2em 1.5em 1.2em 2.5em;
//margin: 1em 0; //margin: 1em 0;
@ -239,7 +244,7 @@ export default {
position: absolute; position: absolute;
opacity: 0.5; opacity: 0.5;
padding: 0.65em 0; padding: 0.65em 0;
top: 50%; top: 50%;
} }
i.fa-search { i.fa-search {
left: 0.5em; left: 0.5em;