project-booster-vue 9.13.3 → 9.14.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "project-booster-vue",
3
- "version": "9.13.3",
3
+ "version": "9.14.0",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -104,7 +104,7 @@ export const previousContext = {
104
104
  display: true,
105
105
  },
106
106
  },
107
- stepToResume: null,
107
+ stepsToResume: null,
108
108
  },
109
109
  {
110
110
  step: {
@@ -113,7 +113,7 @@ export const previousContext = {
113
113
  component: 'PbQuestion',
114
114
  payload: {
115
115
  viewModel: {
116
- label: 'Question 1',
116
+ label: 'Question 1 (from previous state)',
117
117
  answersComponent: 'PbCard',
118
118
  },
119
119
  answers: {
@@ -198,8 +198,6 @@ export const previousState = {
198
198
  stepIndex: previousContext.stepIndex,
199
199
  steps: previousContext.stepHistory,
200
200
  },
201
- currentStep: previousContext.currentStep,
202
- displayedStep: previousContext.currentStep,
203
201
  };
204
202
 
205
203
  <details>
@@ -491,8 +489,6 @@ export const previousStateForNested = {
491
489
  stepIndex: previousContextForNested.stepIndex,
492
490
  steps: previousContextForNested.stepHistory,
493
491
  },
494
- currentStep: previousContextForNested.currentStep,
495
- displayedStep: previousContextForNested.currentStep,
496
492
  };
497
493
 
498
494
  <details>
@@ -539,8 +535,6 @@ export const previousStateKitchen = {
539
535
  stepIndex: previousContextKitchen.stepIndex,
540
536
  steps: previousContextKitchen.stepHistory,
541
537
  },
542
- currentStep: previousContextKitchen.currentStep,
543
- displayedStep: previousContextKitchen.currentStep,
544
538
  };
545
539
 
546
540
  <details>
@@ -1,9 +1,14 @@
1
1
  import { useStore } from 'vuex';
2
2
  import { nestedAppDecorator } from '../../../.storybook/nested-app-decorator';
3
3
  import { Story, Preview, Meta, Props, ArgsTable, Source, Canvas } from '@storybook/addon-docs';
4
+ import { rest } from 'msw';
4
5
  import PbScenario from './PbScenario';
5
- import estimatesStore from '../../stores/modules/estimatesStore';
6
+ import storeOptions from '../../stores/store';
6
7
  import DEFAULT_PAYLOAD from './default-payload.json';
8
+ import {
9
+ getDocumentsByInhabitantProjectIdResolver,
10
+ uploadDocumentResolver,
11
+ } from '../../services/api/mocks/documentsMock';
7
12
 
8
13
  <Meta
9
14
  title="Project Booster/Scenario/PbScenario 🦠"
@@ -30,19 +35,7 @@ import DEFAULT_PAYLOAD from './default-payload.json';
30
35
  },
31
36
  }}
32
37
  decorators={[
33
- nestedAppDecorator(
34
- {
35
- modules: {
36
- estimates: estimatesStore,
37
- },
38
- actions: {
39
- sendEventToBus({}, payload) {
40
- console.log('Event sent to bus', payload);
41
- },
42
- },
43
- },
44
- [{ path: '/steps/:stepCode/previous/:answers', component: PbScenario }],
45
- ),
38
+ nestedAppDecorator(storeOptions, [{ path: '/steps/:stepCode/previous/:answers', component: PbScenario }]),
46
39
  ]}
47
40
  parameters={{
48
41
  layout: 'fullscreen',
@@ -61,6 +54,8 @@ export const TemplateSandbox = (args, { argTypes }) => {
61
54
  components: { PbScenario },
62
55
  setup() {
63
56
  const store = useStore();
57
+ store.dispatch('documentsPlans/updateContext', { type: 'DOCUMENT', subType: 'PLAN' });
58
+ store.dispatch('documentsPictures/updateContext', { type: 'DOCUMENT', subType: 'PHOTO' });
64
59
  store.dispatch('estimates/setSummary', {
65
60
  cost: {},
66
61
  });
@@ -83,7 +78,13 @@ export const TemplateSandbox = (args, { argTypes }) => {
83
78
  inline={false}
84
79
  height="758px"
85
80
  args={{ scenarios: DEFAULT_PAYLOAD }}
86
- parameters={{ storyshots: { disable: true } }}
81
+ parameters={{
82
+ msw: [
83
+ rest.post('/api/inhabitant-projects/:projectId/documents', uploadDocumentResolver),
84
+ rest.get('/api/inhabitant-projects/:projectId/documents', getDocumentsByInhabitantProjectIdResolver),
85
+ ],
86
+ storyshots: { disable: true },
87
+ }}
87
88
  >
88
89
  {TemplateSandbox.bind({})}
89
90
  </Story>
@@ -70,6 +70,7 @@
70
70
 
71
71
  <script lang="ts">
72
72
  import { v4 as uuidv4 } from 'uuid';
73
+ import cloneDeep from 'lodash.clonedeep';
73
74
  import objectHash from 'object-hash';
74
75
  import {
75
76
  ref,
@@ -384,8 +385,7 @@ export default defineComponent({
384
385
  }
385
386
 
386
387
  state.value.stepsToResume = requestedStep.stepsToResume!;
387
-
388
- state.value.currentStep = requestedStep?.step;
388
+ state.value.currentStep = scenarios.get(requestedStep?.step.code);
389
389
 
390
390
  animateDisplayedStep(stepIndex < state.value.history.stepIndex);
391
391
  state.value.history.stepIndex = stepIndex;
@@ -600,9 +600,6 @@ export default defineComponent({
600
600
  noPointerEvents.value = false;
601
601
  }, 500);
602
602
  };
603
- const currentHeight = () => {
604
- return questionContainer.value?.$el?.clientHeight + 'px' ?? 'auto';
605
- };
606
603
 
607
604
  watch(route, () => {
608
605
  const requestedStepIndex = route.params?.stepCode as string;
@@ -652,6 +649,14 @@ export default defineComponent({
652
649
 
653
650
  if (!props.previousState) {
654
651
  initScenario('__START__');
652
+ } else {
653
+ state.value = cloneDeep(props.previousState);
654
+ if (state.value.answers && !(state.value.answers instanceof Map)) {
655
+ state.value.answers = new Map<string, ScenarioStepAnswer[]>(Object.entries(state.value.answers));
656
+ }
657
+ const newRoute = `/steps/${state.value.history.stepIndex}/previous/${uuidv4()}`;
658
+ forceRefresh.value = true;
659
+ router.replace(newRoute);
655
660
  }
656
661
  onMounted(() => {
657
662
  document.getElementsByTagName('body')[0].style.setProperty('overflow-x', 'hidden');