diff --git a/src/components/Pagination.vue b/src/components/Pagination.vue index 0318e51f46dbe54e242cdce4ce57e6eb9cebdaac..1ad308e7970de0242266e52482277e13c83d3832 100644 --- a/src/components/Pagination.vue +++ b/src/components/Pagination.vue @@ -95,10 +95,6 @@ export default { } }, - computed: { - ...mapState('projects', ['currentPage']), - }, - data() { return { // TODO: Refactor by using native scroll to top instead of this @@ -106,6 +102,10 @@ export default { }; }, + computed: { + ...mapState('projects', ['currentPage']), + }, + watch: { currentPage: function(newValue, oldValue) { if (newValue !== oldValue) { diff --git a/src/components/Project/Edition/ProjectAttributeForm.vue b/src/components/Project/Edition/ProjectAttributeForm.vue index 39de284a274e89613ce392c8f1862c1f1ecd05ef..f4d732d9ecb1bf8b731c676feda863351da2f1fe 100644 --- a/src/components/Project/Edition/ProjectAttributeForm.vue +++ b/src/components/Project/Edition/ProjectAttributeForm.vue @@ -51,8 +51,8 @@ export default { value() { // Find the attribute within the project's current attributes array. const projectAttribute = this.formProjectAttributes.find(el => el.attribute_id === this.attribute.id); - // If the attribute is set in this project, return its value, otherwise return the attribute's default value. - return projectAttribute ? projectAttribute.value : this.attribute.default_value; + // If the attribute is set in this project, return its value. + return projectAttribute ? projectAttribute.value : null; }, }, diff --git a/src/components/Projects/DropdownMenuItem.vue b/src/components/Projects/DropdownMenuItem.vue index 358b3c8ac2725cd2c64b82b778135f70db3e79e3..94006a4336a4519791bb43e40bbf45f3c032f65d 100644 --- a/src/components/Projects/DropdownMenuItem.vue +++ b/src/components/Projects/DropdownMenuItem.vue @@ -18,11 +18,21 @@ @remove="remove" @close="close" > - <template v-if="multiple" slot="selection" slot-scope="{ values }"> - <span class="multiselect__single" v-if="values && values.length > 1"> + <template + v-if="multiple" + slot="selection" + slot-scope="{ values }" + > + <span + v-if="values && values.length > 1" + class="multiselect__single" + > {{ values.length }} options sélectionnées </span> - <span class="multiselect__single" v-else>{{ currentSelection || selection.label }}</span> + <span + v-else + class="multiselect__single" + >{{ currentSelection || selection.label }}</span> </template> </Multiselect> </template> diff --git a/src/store/index.js b/src/store/index.js index fba773d7ef43f175e5f5bbdb788fb1f74d654c56..0ec3156209fb8b15e59769e24a0bb07ff23c2f39 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -109,6 +109,11 @@ export default new Vuex.Store({ RESET_CANCELLABLE_SEARCH_REQUEST(state) { state.cancellableSearchRequest = []; }, + REMOVE_LAST_CANCELLABLE_SEARCH_REQUEST(state) { + const updatedCancellableSearchRequest = state.cancellableSearchRequest.slice(0, -1); + state.cancellableSearchRequest = updatedCancellableSearchRequest; + }, + SET_RELOAD_INTERVAL_ID(state, payload) { state.reloadIntervalId = payload; @@ -320,11 +325,12 @@ export default new Vuex.Store({ throw error; }); }, - CANCEL_CURRENT_SEARCH_REQUEST({ state }) { + CANCEL_CURRENT_SEARCH_REQUEST({ state, commit }) { if (state.cancellableSearchRequest.length > 0) { const currentRequestCancelToken = state.cancellableSearchRequest[state.cancellableSearchRequest.length - 1]; currentRequestCancelToken.cancel('Current search request was canceled'); + commit('REMOVE_LAST_CANCELLABLE_SEARCH_REQUEST'); } }, } diff --git a/src/store/modules/projects.store.js b/src/store/modules/projects.store.js index 186caada9766ef464f8a09ed7320362558745102..360e3fc3b7604535c645fa75b43125dd1d40e7c7 100644 --- a/src/store/modules/projects.store.js +++ b/src/store/modules/projects.store.js @@ -8,19 +8,6 @@ const initialFilters = { accessible: null }; - -/** - * Cancels the most recent search request if it exists. - * - * @param {Object} rootState - The root state of the Vuex store to access global states. - */ -function cancelPreviousSearchRequest(rootState) { - if (rootState.cancellableSearchRequest.length > 0) { - const lastRequestToken = rootState.cancellableSearchRequest.pop(); - lastRequestToken.cancel('New search initiated.'); - } -} - /** * Constructs the URL for the search request, appending search text and any active filters. * @@ -172,9 +159,9 @@ const projectsStore = { * @param {Object} context - Destructured to gain access to Vuex state, rootState, and commit function. * @param {String} text - The search text used for filtering projects. */ - async HANDLE_PROJECTS_SEARCH_REQUEST({ state, rootState, commit }, { page, text }) { + async HANDLE_PROJECTS_SEARCH_REQUEST({ state, rootState, commit, dispatch }, { page, text }) { // Cancel any ongoing search request. - cancelPreviousSearchRequest(rootState); + dispatch('CANCEL_CURRENT_SEARCH_REQUEST', null, { root: true }); // Prepare the cancel token for the new request and store it. const cancelToken = axios.CancelToken.source();