project-booster-vue 9.10.4 → 9.10.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "project-booster-vue",
3
- "version": "9.10.4",
3
+ "version": "9.10.5",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -71,7 +71,7 @@
71
71
  class="pb-estimates-list__show-more-button"
72
72
  theme="bordered"
73
73
  label="Voir plus"
74
- @click="$store.dispatch('estimates/loadEstimates')"
74
+ @click="$store.dispatch('estimates/loadMoreEstimates')"
75
75
  width="fit"
76
76
  :style="`transition-delay: ${showMoreButtonAnimationDelay}ms;`"
77
77
  />
@@ -207,10 +207,12 @@ export default {
207
207
  },
208
208
  async loadEstimates({ commit, state }: EstimatesContext, projectId: string) {
209
209
  commit('setIsDisplayed', true);
210
+ commit('setEstimates', []);
210
211
  commit('setCurrentProjectId', projectId);
211
212
  commit('setIsLoadingEstimates', true);
212
213
  commit('setEstimatesLoadError', null);
213
214
  commit('setEstimateCreationError', null);
215
+ commit('setCurrentEstimatesPage', 0);
214
216
 
215
217
  try {
216
218
  const estimates = await getAllEstimates(state.currentEstimatesPage, state.estimatesPerPageCount, projectId);
@@ -235,6 +237,39 @@ export default {
235
237
  commit('setIsLoadingEstimates', false);
236
238
  });
237
239
  },
240
+ async loadMoreEstimates({ commit, state }: EstimatesContext) {
241
+ commit('setIsDisplayed', true);
242
+ commit('setIsLoadingEstimates', true);
243
+ commit('setEstimatesLoadError', null);
244
+ commit('setEstimateCreationError', null);
245
+
246
+ try {
247
+ const estimates = await getAllEstimates(
248
+ state.currentEstimatesPage,
249
+ state.estimatesPerPageCount,
250
+ state.currentProjectId!,
251
+ );
252
+
253
+ if (estimates.results) {
254
+ commit('addEstimates', estimates.results);
255
+ }
256
+
257
+ if (state?.estimates?.length >= estimates.total) {
258
+ commit('setHasStillEstimates', false);
259
+ } else {
260
+ commit('setHasStillEstimates', true);
261
+ }
262
+
263
+ commit('setCurrentEstimatesPage', state.currentEstimatesPage + 1);
264
+ } catch (error) {
265
+ console.error('Failure when loading estimates', error);
266
+ commit('setEstimatesLoadError', error);
267
+ }
268
+
269
+ setTimeout(() => {
270
+ commit('setIsLoadingEstimates', false);
271
+ });
272
+ },
238
273
  async saveEstimate({ commit }: EstimatesContext, estimateToCreate: Estimate) {
239
274
  commit('setIsCreatingEstimate', true);
240
275
  commit('setEstimateCreationError', null);