project-booster-vue 9.2.2 → 9.3.0

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.
Files changed (17) hide show
  1. package/package.json +1 -1
  2. package/src/components/configurations/list/__snapshots__/storyshots-puppeteer-test-puppeteer-ts-image-storyshots-project-booster-components-configurations-pb-configurations-list-/360/237/247/254-component-showcase-1-snap.png +0 -0
  3. package/src/components/projects/project-hub/PbProjectHub.vue +40 -40
  4. package/src/components/projects/project-hub/__snapshots__/storyshots-puppeteer-test-puppeteer-ts-image-storyshots-project-booster-components-projects-pb-project-hub-/360/237/246/240-features-documents-media-showcase-with-media-documents-1-snap.png +0 -0
  5. package/src/components/projects/project-hub/__snapshots__/storyshots-puppeteer-test-puppeteer-ts-image-storyshots-project-booster-components-projects-pb-project-hub-/360/237/246/240-features-project-attributes-showcase-empty-state-1-snap.png +0 -0
  6. package/src/components/question/PbQuestion.vue +1 -1
  7. package/src/components/question/__snapshots__/storyshots-puppeteer-test-puppeteer-ts-image-storyshots-project-booster-scenario-questions-pb-question-/360/237/246/240-demo-multiple-multiple-1-snap.png +0 -0
  8. package/src/components/question/__snapshots__/storyshots-puppeteer-test-puppeteer-ts-image-storyshots-project-booster-scenario-questions-pb-question-/360/237/246/240-demo-simple-simple-1-snap.png +0 -0
  9. package/src/components/question/__snapshots__/storyshots-puppeteer-test-puppeteer-ts-image-storyshots-project-booster-scenario-questions-pb-question-/360/237/246/240-features-answers-multiple-skippable-multiselect-question-1-snap.png +0 -0
  10. package/src/components/question/__snapshots__/storyshots-puppeteer-test-puppeteer-ts-image-storyshots-project-booster-scenario-questions-pb-question-/360/237/246/240-features-question-101-101-1-snap.png +0 -0
  11. package/src/components/question/__snapshots__/storyshots-puppeteer-test-puppeteer-ts-image-storyshots-project-booster-scenario-questions-pb-question-/360/237/246/240-features-question-custom-back-button-hide-back-button-1-snap.png +0 -0
  12. package/src/components/question/__snapshots__/storyshots-puppeteer-test-puppeteer-ts-image-storyshots-project-booster-scenario-questions-pb-question-/360/237/246/240-features-question-decorator-stripes-decorator-stripe-1-snap.png +0 -0
  13. package/src/components/question/__snapshots__/storyshots-puppeteer-test-puppeteer-ts-image-storyshots-project-booster-scenario-questions-pb-question-/360/237/246/240-features-question-show-more-show-more-1-snap.png +0 -0
  14. package/src/components/question/__snapshots__/storyshots-puppeteer-test-puppeteer-ts-image-storyshots-project-booster-scenario-questions-pb-question-/360/237/246/240-features-question-skippable-mutiple-skippable-1-snap.png +0 -0
  15. package/src/components/question/__snapshots__/storyshots-puppeteer-test-puppeteer-ts-image-storyshots-project-booster-scenario-questions-pb-question-/360/237/246/240-features-question-skippable-skippable-1-snap.png +0 -0
  16. package/src/components/scenario/PbScenario.vue +45 -29
  17. package/src/types/pb/Scenario.ts +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "project-booster-vue",
3
- "version": "9.2.2",
3
+ "version": "9.3.0",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -137,6 +137,46 @@
137
137
  />
138
138
  </div>
139
139
  </m-flex>
140
+ <m-flex
141
+ v-if="areProjectAttributesDisplayed && projectAttributes && Object.keys(projectAttributes).length > 0"
142
+ class="pb-project-hub__section"
143
+ direction="column"
144
+ full-width
145
+ >
146
+ <div class="pb-project-hub__section-header">
147
+ <div class="pb-project-hub__section-title" ref="pbProjectAttributeList">
148
+ {{ titleProjectAttribute }}
149
+ </div>
150
+ </div>
151
+ <div class="pb-project-hub__section-content">
152
+ <m-flex
153
+ class="pb-project-hub__section-content--loading"
154
+ v-if="isLoadingProjectAttributes && !projectAttributesLoadError"
155
+ direction="column"
156
+ align-items="center"
157
+ justify-content="center"
158
+ align-content="center"
159
+ >
160
+ <pb-animable-loader class="pb-project-hub__section-content--loading-loader" />
161
+ <div class="pb-project-hub__section-content--loading-label">Chargement...</div>
162
+ </m-flex>
163
+ <pb-empty-state
164
+ v-else-if="project && Object.values(projectAttributes).length === 0 && !projectAttributesLoadError"
165
+ subtitle="Aucune information renseignée"
166
+ disabled
167
+ />
168
+ <m-container
169
+ class="pb-project-hub__section-content-cards-container"
170
+ fluid
171
+ v-else-if="project && projectAttributes && !projectAttributesLoadError"
172
+ >
173
+ <pb-project-attributes :project-attributes="projectAttributes" />
174
+ </m-container>
175
+ <m-flex v-else-if="projectAttributesLoadError" direction="column" align-items="center">
176
+ <div>Une erreur est survenue</div>
177
+ </m-flex>
178
+ </div>
179
+ </m-flex>
140
180
  <m-flex
141
181
  v-if="isEstimatesDisplayed"
142
182
  class="pb-project-hub__section"
@@ -401,46 +441,6 @@
401
441
  />
402
442
  </div>
403
443
  </m-flex>
404
- <m-flex
405
- v-if="areProjectAttributesDisplayed && projectAttributes && Object.keys(projectAttributes).length > 0"
406
- class="pb-project-hub__section"
407
- direction="column"
408
- full-width
409
- >
410
- <div class="pb-project-hub__section-header">
411
- <div class="pb-project-hub__section-title" ref="pbProjectAttributeList">
412
- {{ titleProjectAttribute }}
413
- </div>
414
- </div>
415
- <div class="pb-project-hub__section-content">
416
- <m-flex
417
- class="pb-project-hub__section-content--loading"
418
- v-if="isLoadingProjectAttributes && !projectAttributesLoadError"
419
- direction="column"
420
- align-items="center"
421
- justify-content="center"
422
- align-content="center"
423
- >
424
- <pb-animable-loader class="pb-project-hub__section-content--loading-loader" />
425
- <div class="pb-project-hub__section-content--loading-label">Chargement...</div>
426
- </m-flex>
427
- <pb-empty-state
428
- v-else-if="project && Object.values(projectAttributes).length === 0 && !projectAttributesLoadError"
429
- subtitle="Aucune information renseignée"
430
- disabled
431
- />
432
- <m-container
433
- class="pb-project-hub__section-content-cards-container"
434
- fluid
435
- v-else-if="project && projectAttributes && !projectAttributesLoadError"
436
- >
437
- <pb-project-attributes :project-attributes="projectAttributes" />
438
- </m-container>
439
- <m-flex v-else-if="projectAttributesLoadError" direction="column" align-items="center">
440
- <div>Une erreur est survenue</div>
441
- </m-flex>
442
- </div>
443
- </m-flex>
444
444
  <m-flex
445
445
  v-if="isPlannerDisplayed"
446
446
  class="pb-project-hub__section pb-project-hub__planner-section"
@@ -331,7 +331,7 @@ export default defineComponent({
331
331
  */
332
332
  answers: {
333
333
  type: Object as PropType<Map<string, ScenarioStepAnswer[]>>,
334
- default: () => ({}),
334
+ default: () => new Map<string, ScenarioStepAnswer[]>(),
335
335
  },
336
336
  /**
337
337
  * Name for the current step in the scenario
@@ -196,6 +196,8 @@ export default defineComponent({
196
196
  });
197
197
  const reverseAnimation = ref(false);
198
198
  const noPointerEvents = ref(false);
199
+ const stepAnimationTimeoutId = ref<ReturnType<typeof setTimeout>>();
200
+ const progressUpdateTimeoutId = ref<ReturnType<typeof setTimeout>>();
199
201
 
200
202
  const initScenario = (currentScenarioCode: string, stepToResume: ScenarioStep | undefined = undefined) => {
201
203
  if (currentScenarioCode === '__START__') {
@@ -312,6 +314,7 @@ export default defineComponent({
312
314
  currentStep: state.value.currentStep,
313
315
  stepIndex: state.value.history.stepIndex,
314
316
  stepHistory: state.value.history.steps,
317
+ stepsToResume: state.value.stepsToResume,
315
318
  },
316
319
  });
317
320
  };
@@ -368,7 +371,7 @@ export default defineComponent({
368
371
 
369
372
  state.value.stepsToResume = requestedStep.stepsToResume!;
370
373
 
371
- state.value.currentStep = scenarios.get(requestedStep?.step.code)!;
374
+ state.value.currentStep = requestedStep?.step;
372
375
 
373
376
  animateDisplayedStep(stepIndex < state.value.history.stepIndex);
374
377
  state.value.history.stepIndex = stepIndex;
@@ -395,41 +398,47 @@ export default defineComponent({
395
398
  }
396
399
  };
397
400
  const updateProgressInScenario = () => {
398
- if (state.value.stepsToResume.slice(-1)[0]?.trackProgress) {
399
- // Use current step props
400
- setTimeout(() => {
401
- progress.value = {
402
- ...progress.value,
403
- ...trackProgress(state.value.history.stepIndex - 1, state.value.history.steps!),
404
- };
405
-
406
- progress.value.progress =
407
- (100 * (progress.value.currentPosition - 1)) /
408
- (progress.value.currentPosition + progress.value.remainingSteps);
409
- }, 450);
410
- } else if (state.value.stepsToResume.slice(-2, -1)[0]?.trackProgress) {
411
- // Use current last progress tracked scenario step props for first step of nested scenario
412
- setTimeout(() => {
413
- const currentProgress = trackProgress(state.value.history.stepIndex - 1, state.value.history.steps!);
414
-
415
- if (currentProgress.currentPosition === 1) {
416
- const previousProgress = trackProgress(state.value.history.stepIndex - 3, state.value.history.steps!);
417
- previousProgress.currentPosition++;
418
- previousProgress.remainingSteps--;
401
+ if (state.value.stepsToResume) {
402
+ if (progressUpdateTimeoutId.value) {
403
+ clearTimeout(progressUpdateTimeoutId.value);
404
+ }
405
+
406
+ if (state.value.stepsToResume.slice(-1)[0]?.trackProgress) {
407
+ // Use current step props
408
+ progressUpdateTimeoutId.value = setTimeout(() => {
419
409
  progress.value = {
420
410
  ...progress.value,
421
- ...previousProgress,
411
+ ...trackProgress(state.value.history.stepIndex - 1, state.value.history.steps!),
422
412
  };
413
+
423
414
  progress.value.progress =
424
415
  (100 * (progress.value.currentPosition - 1)) /
425
416
  (progress.value.currentPosition + progress.value.remainingSteps);
426
- }
427
- }, 450);
417
+ }, 450);
418
+ } else if (state.value.stepsToResume.slice(-2, -1)[0]?.trackProgress) {
419
+ // Use current last progress tracked scenario step props for first step of nested scenario
420
+ progressUpdateTimeoutId.value = setTimeout(() => {
421
+ const currentProgress = trackProgress(state.value.history.stepIndex - 1, state.value.history.steps!);
422
+
423
+ if (currentProgress.currentPosition === 1) {
424
+ const previousProgress = trackProgress(state.value.history.stepIndex - 3, state.value.history.steps!);
425
+ previousProgress.currentPosition++;
426
+ previousProgress.remainingSteps--;
427
+ progress.value = {
428
+ ...progress.value,
429
+ ...previousProgress,
430
+ };
431
+ progress.value.progress =
432
+ (100 * (progress.value.currentPosition - 1)) /
433
+ (progress.value.currentPosition + progress.value.remainingSteps);
434
+ }
435
+ }, 450);
436
+ }
428
437
  }
429
438
  };
430
439
  const trackProgress = (originIndex: number, steps: ScenarioHistoryItem[]) => {
431
440
  let currentPosition = 1;
432
- for (let index = originIndex; index--; index >= 0) {
441
+ for (let index = Math.max(originIndex, 0); index >= 0; index--) {
433
442
  if (steps[index]?.step?.type === 'SCENARIO') {
434
443
  break;
435
444
  }
@@ -469,7 +478,11 @@ export default defineComponent({
469
478
  const animateDisplayedStep = (reversed = false) => {
470
479
  reverseAnimation.value = reversed;
471
480
 
472
- setTimeout(() => {
481
+ if (stepAnimationTimeoutId.value) {
482
+ clearTimeout(stepAnimationTimeoutId.value);
483
+ }
484
+
485
+ stepAnimationTimeoutId.value = setTimeout(() => {
473
486
  nextTick(() => {
474
487
  state.value.displayedStep = state.value.currentStep;
475
488
  setTimeout(() => {
@@ -609,7 +622,8 @@ export default defineComponent({
609
622
  if (state.value.answers && !(state.value.answers instanceof Map)) {
610
623
  state.value.answers = new Map<string, ScenarioStepAnswer[]>(Object.entries(state.value.answers));
611
624
  }
612
- goToStep(state.value.history.stepIndex);
625
+ const newRoute = `/steps/${state.value.history.stepIndex}/previous/${uuidv4()}`;
626
+ router.replace(newRoute);
613
627
  }
614
628
  },
615
629
  );
@@ -620,7 +634,9 @@ export default defineComponent({
620
634
  },
621
635
  );
622
636
 
623
- initScenario('__START__');
637
+ if (!props.previousState) {
638
+ initScenario('__START__');
639
+ }
624
640
  onMounted(() => {
625
641
  document.getElementsByTagName('body')[0].style.setProperty('overflow-x', 'hidden');
626
642
  });
@@ -147,7 +147,6 @@ export interface ScenarioState {
147
147
  currentStep: ScenarioStep | undefined;
148
148
  displayedStep: ScenarioStep | undefined;
149
149
  history: ScenarioHistory;
150
- refreshSteps: boolean;
151
150
  }
152
151
 
153
152
  export interface ScenarioStepAnswerData {