mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
save checkboxes state in store
This commit is contained in:
parent
a1bb9ea352
commit
d393e74896
@ -96,11 +96,20 @@ div.vue-component {
|
|||||||
|
|
||||||
//// AddPersons modal
|
//// AddPersons modal
|
||||||
div.results {
|
div.results {
|
||||||
padding: 0 1.3em;
|
|
||||||
div.list-item {
|
div.list-item {
|
||||||
line-height: 26pt;
|
line-height: 26pt;
|
||||||
|
padding: 0.3em 0.8em;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
&.checked {
|
||||||
|
background-color: #ececec;
|
||||||
|
border-bottom: 1px dotted #d9d9d9;
|
||||||
|
}
|
||||||
|
div.container {
|
||||||
|
& > input {
|
||||||
|
margin-right: 0.8em;
|
||||||
|
}
|
||||||
|
}
|
||||||
div.right_actions {
|
div.right_actions {
|
||||||
margin: 0 0 0 auto;
|
margin: 0 0 0 auto;
|
||||||
& > * {
|
& > * {
|
||||||
@ -110,14 +119,12 @@ div.results {
|
|||||||
border: 1px solid lightgrey;
|
border: 1px solid lightgrey;
|
||||||
font-size: 70%;
|
font-size: 70%;
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
}
|
|
||||||
span {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
a.discret {
|
.discret {
|
||||||
color: grey;
|
color: grey;
|
||||||
margin-right: 1em;
|
margin-right: 1em;
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,14 @@ const datetimeFormats = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
//const pluralizationRules = {
|
||||||
|
// 'fr': (choice, choicesLength) => {
|
||||||
|
// if (choice === 0) {
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
|
// return (choicesLength < 4) ? 2 : 3;
|
||||||
|
// }
|
||||||
|
//};
|
||||||
const messages = {
|
const messages = {
|
||||||
fr: {
|
fr: {
|
||||||
action: {
|
action: {
|
||||||
@ -43,10 +51,11 @@ const messages = {
|
|||||||
const _createI18n = (appMessages) => {
|
const _createI18n = (appMessages) => {
|
||||||
Object.assign(messages.fr, appMessages.fr);
|
Object.assign(messages.fr, appMessages.fr);
|
||||||
return createI18n({
|
return createI18n({
|
||||||
|
locale: 'fr',
|
||||||
|
fallbackLocale: 'fr',
|
||||||
datetimeFormats,
|
datetimeFormats,
|
||||||
messages,
|
messages,
|
||||||
locale: 'fr',
|
//pluralizationRules
|
||||||
fallbackLocale: 'fr'
|
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -16,7 +16,8 @@ let getDataPromise = getAccompanyingCourse(id)
|
|||||||
accompanying_course: accompanying_course,
|
accompanying_course: accompanying_course,
|
||||||
add_persons: {
|
add_persons: {
|
||||||
query: "",
|
query: "",
|
||||||
suggested: []
|
suggested: [],
|
||||||
|
selected: []
|
||||||
},
|
},
|
||||||
errorMsg: []
|
errorMsg: []
|
||||||
},
|
},
|
||||||
@ -24,21 +25,25 @@ let getDataPromise = getAccompanyingCourse(id)
|
|||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
removeParticipation(state, item) {
|
removeParticipation(state, item) {
|
||||||
console.log('remove item', item.id);
|
//console.log('remove item', item.id);
|
||||||
state.accompanying_course.participations = state.accompanying_course.participations.filter(
|
state.accompanying_course.participations = state.accompanying_course.participations.filter(
|
||||||
participation => participation !== item
|
participation => participation !== item
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
addParticipation(state, item) {
|
addParticipation(state, item) {
|
||||||
console.log('add new item');
|
//console.log('add new item');
|
||||||
state.accompanying_course.participations.push(item);
|
state.accompanying_course.participations.push(item);
|
||||||
},
|
},
|
||||||
setQuery(state, query) {
|
setQuery(state, query) {
|
||||||
console.log('q=', query);
|
//console.log('q=', query);
|
||||||
state.add_persons = Object.assign({}, state.add_persons, query);
|
state.add_persons = Object.assign({}, state.add_persons, query);
|
||||||
},
|
},
|
||||||
loadSuggestions(state, suggestions) {
|
loadSuggestions(state, suggestions) {
|
||||||
state.add_persons.suggested = suggestions;
|
state.add_persons.suggested = suggestions;
|
||||||
|
},
|
||||||
|
updateSelected(state, value) {
|
||||||
|
console.log('update value', value);
|
||||||
|
state.add_persons.selected = value;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
@ -49,8 +54,8 @@ let getDataPromise = getAccompanyingCourse(id)
|
|||||||
commit('addParticipation', payload);
|
commit('addParticipation', payload);
|
||||||
postParticipation(id, payload.id).catch((error) => {
|
postParticipation(id, payload.id).catch((error) => {
|
||||||
commit('removeParticipation', payload);
|
commit('removeParticipation', payload);
|
||||||
state.errorMsg.push(error.message);
|
state.errorMsg.push(error.message); // result action ??
|
||||||
}) // result action ??
|
});
|
||||||
},
|
},
|
||||||
setQuery({ commit }, payload) {
|
setQuery({ commit }, payload) {
|
||||||
commit('setQuery', payload);
|
commit('setQuery', payload);
|
||||||
@ -63,6 +68,9 @@ let getDataPromise = getAccompanyingCourse(id)
|
|||||||
} else {
|
} else {
|
||||||
commit('loadSuggestions', []);
|
commit('loadSuggestions', []);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
updateSelected({ commit }, payload) {
|
||||||
|
commit('updateSelected', payload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -13,15 +13,27 @@
|
|||||||
</template>
|
</template>
|
||||||
<template v-slot:body-fixed>
|
<template v-slot:body-fixed>
|
||||||
|
|
||||||
<label style="float: right;">{{ $tc('add_persons.counter', counter) }}</label>
|
<label style="float: right;">
|
||||||
<input class="my-4" v-model="query" name="query" ref="search"
|
{{ $tc('add_persons.suggested_counter', suggestedCounter) }}
|
||||||
|
<span v-if="selectedCounter > 0">
|
||||||
|
{{ $tc('add_persons.selected_counter', selectedCounter) }}
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<input class="my-4"
|
||||||
|
name="query"
|
||||||
|
ref="search"
|
||||||
|
v-model="query"
|
||||||
:placeholder="$t('add_persons.search_some_persons')" />
|
:placeholder="$t('add_persons.search_some_persons')" />
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:body>
|
<template v-slot:body>
|
||||||
|
|
||||||
|
<!--span class="discret">Selection: {{ selected }}</span-->
|
||||||
|
|
||||||
<div class="results">
|
<div class="results">
|
||||||
<person-suggestion v-for="item in suggested.results"
|
<person-suggestion
|
||||||
|
v-for="item in suggested.results"
|
||||||
v-bind:item="item"
|
v-bind:item="item"
|
||||||
v-bind:key="item.id">
|
v-bind:key="item.id">
|
||||||
</person-suggestion>
|
</person-suggestion>
|
||||||
@ -29,7 +41,7 @@
|
|||||||
|
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:footer>
|
<template v-slot:footer>
|
||||||
<button class="sc-button green" @click="AddPersons">
|
<button class="sc-button green" @click="addPersons">
|
||||||
<i class="fa fa-plus fa-fw"></i>{{ $t('action.add')}}</button>
|
<i class="fa fa-plus fa-fw"></i>{{ $t('action.add')}}</button>
|
||||||
</template>
|
</template>
|
||||||
</modal>
|
</modal>
|
||||||
@ -76,12 +88,21 @@ export default {
|
|||||||
suggested() {
|
suggested() {
|
||||||
return this.add_persons.suggested;
|
return this.add_persons.suggested;
|
||||||
},
|
},
|
||||||
counter() {
|
suggestedCounter() {
|
||||||
if (! this.add_persons.suggested.results) { return 0; }
|
if (! this.add_persons.suggested.results) { return 0; }
|
||||||
return this.add_persons.suggested.results.length;
|
return this.add_persons.suggested.results.length;
|
||||||
|
},
|
||||||
|
selected() {
|
||||||
|
return this.add_persons.selected;
|
||||||
|
},
|
||||||
|
selectedCounter() {
|
||||||
|
if (! this.add_persons.selected) { return 0; }
|
||||||
|
return this.add_persons.selected.length;
|
||||||
},
|
},
|
||||||
AddPersons() {
|
addPersons() {
|
||||||
console.log('add persons');
|
console.log('add persons');
|
||||||
|
// code here
|
||||||
|
this.modal.showModal = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,30 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="list-item">
|
<div class="list-item" :class="{ checked: isChecked }">
|
||||||
<div>
|
<div class="container">
|
||||||
<a class="discret" target="_blank" :href="url.show">{{ item.id }}</a>
|
|
||||||
|
<!--a class="discret" target="_blank" :href="url.show">{{ item.id }}</a-->
|
||||||
|
<input class=""
|
||||||
|
type="checkbox"
|
||||||
|
v-model="selected"
|
||||||
|
:value="item" />
|
||||||
|
|
||||||
{{ item.text }}
|
{{ item.text }}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="right_actions">
|
<div class="right_actions">
|
||||||
|
|
||||||
<span class="badge badge-pill badge-secondary" :title="item.id">
|
<span class="badge badge-pill badge-secondary" :title="item.id">
|
||||||
{{ $t('item.type_person') }}
|
{{ $t('item.type_person') }}
|
||||||
</span>
|
</span>
|
||||||
<a class="sc-button bt-show" target="_blank" :title="item.id" :href="url.show"></a>
|
<a class="sc-button bt-show" target="_blank" :title="item.id" :href="url.show"></a>
|
||||||
<input class="" type="checkbox" name="" value="" />
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { mapState } from 'vuex';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'PersonSuggestion',
|
name: 'PersonSuggestion',
|
||||||
props: ['item'],
|
props: ['item'],
|
||||||
@ -26,5 +36,18 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
selected: {
|
||||||
|
set(value) {
|
||||||
|
this.$store.dispatch('updateSelected', value);
|
||||||
|
},
|
||||||
|
get() {
|
||||||
|
return this.$store.state.add_persons.selected;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
isChecked() {
|
||||||
|
return (this.selected.indexOf(this.item) === -1) ? false : true;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -3,7 +3,8 @@ const personMessages = {
|
|||||||
add_persons: {
|
add_persons: {
|
||||||
search_add_others_persons: "Rechercher et ajouter d'autres usagers",
|
search_add_others_persons: "Rechercher et ajouter d'autres usagers",
|
||||||
title: "Ajouter des usagers",
|
title: "Ajouter des usagers",
|
||||||
counter: "Pas de résultats | 1 résultat | {count} résultats",
|
suggested_counter: "Pas de résultats | 1 résultat | {count} résultats",
|
||||||
|
selected_counter: " / 1 sélectionné | / {count} sélectionnés",
|
||||||
search_some_persons: "Rechercher des personnes..",
|
search_some_persons: "Rechercher des personnes..",
|
||||||
},
|
},
|
||||||
item: {
|
item: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user