project-booster-vue 9.19.1 → 9.19.2

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.19.1",
3
+ "version": "9.19.2",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -75,7 +75,7 @@ export const conditionalAnswersPayload = {
75
75
  <Source language="json" code={JSON.stringify(conditionalAnswersPayload, null, ' ')} />
76
76
 
77
77
  Here, the answer `ANSWER-1` will be hidden because no previous answers are provided (same as answers not matching the
78
- condition):
78
+ condition), `ANSWER-2` will be hidden because of the condition on runtime options :
79
79
 
80
80
  <Canvas>
81
81
  <Story
@@ -116,7 +116,7 @@ Runtime options:
116
116
  parameters={{ controls: { disable: true } }}
117
117
  args={{
118
118
  payload: conditionalAnswersPayload,
119
- answers: conditionalAnswersAnswers,
119
+ answers: new Map(Object.entries(conditionalAnswersAnswers)),
120
120
  runtimeOptions: conditionalAnswersRuntimeOptions,
121
121
  minHeight: 'auto',
122
122
  }}
@@ -100,7 +100,7 @@ Runtime options:
100
100
  parameters={{ controls: { disable: true } }}
101
101
  args={{
102
102
  payload: decoratedAnswersPayload,
103
- answers: decoratedAnswersAnswers,
103
+ answers: new Map(Object.entries(decoratedAnswersAnswers)),
104
104
  runtimeOptions: decoratedAnswersRuntimeOptions,
105
105
  minHeight: 'auto',
106
106
  }}
@@ -103,7 +103,7 @@ export const disabledAnswersAnswers = {
103
103
  parameters={{ controls: { disable: true } }}
104
104
  args={{
105
105
  payload: disabledAnswersPayload,
106
- answers: disabledAnswersAnswers,
106
+ answers: new Map(Object.entries(disabledAnswersAnswers)),
107
107
  minHeight: 'auto',
108
108
  }}
109
109
  >
@@ -120,7 +120,7 @@ condition):
120
120
  inline={false}
121
121
  height="862px"
122
122
  parameters={{ controls: { disable: true } }}
123
- args={{ payload: disabledAnswersPayload, minHeight: 'auto' }}
123
+ args={{ payload: disabledAnswersPayload, answers: new Map(), minHeight: 'auto' }}
124
124
  >
125
125
  {TemplateSandbox.bind({})}
126
126
  </Story>
@@ -93,7 +93,7 @@ export const questionFooterAnswers = {
93
93
  parameters={{ controls: { disable: true } }}
94
94
  args={{
95
95
  payload: questionFooterPayload,
96
- answers: questionFooterAnswers,
96
+ answers: new Map(Object.entries(questionFooterAnswers)),
97
97
  minHeight: 'auto',
98
98
  }}
99
99
  >
@@ -318,6 +318,7 @@ import {
318
318
  ScenarioStepPayload,
319
319
  ScenarioStepSkippableOptions,
320
320
  ScenarioStepViewModel,
321
+ ScenarioCondition,
321
322
  } from '@/types/pb/Scenario';
322
323
 
323
324
  const BACK_ICON =
@@ -553,10 +554,18 @@ export default defineComponent({
553
554
  return viewModel.footer && areConditionsValid(viewModel.footer.conditions!, this.answers, this.runtimeOptions);
554
555
  },
555
556
  isAnswerDisabled(answer: ScenarioStepAnswer) {
556
- return (
557
- answer?.viewModel?.disabled &&
558
- areConditionsValid(answer.viewModel.conditions!, this.answers, this.runtimeOptions)
559
- );
557
+ if (answer.viewModel?.disabled instanceof Boolean) {
558
+ return answer.viewModel.disabled;
559
+ } else {
560
+ return (
561
+ answer?.viewModel?.disabled &&
562
+ areConditionsValid(
563
+ (<ScenarioCondition>answer.viewModel.disabled).conditions,
564
+ this.answers,
565
+ this.runtimeOptions,
566
+ )
567
+ );
568
+ }
560
569
  },
561
570
  selectAnswer(stepCode: string, answer: ScenarioStepAnswer) {
562
571
  if (this.isAnswerDisabled(answer)) {
@@ -153,16 +153,14 @@ parameter is the answer's id, the second is an optional path to extract a specif
153
153
  It will try to find a value in a previous answer for a question with id `LMFR_PREVIOUS_QUESTION`,
154
154
  provided thanks to the `answers` prop. If no value is found, it will use the `defaultDecoratorValue` as a fallback.
155
155
 
156
- export const previousAnswers = new Map(
157
- Object.entries({
158
- LMFR_PREVIOUS_QUESTION: [
159
- {
160
- pathForLength: '4.56',
161
- pathForWidth: '7.89',
162
- },
163
- ],
164
- }),
165
- );
156
+ export const previousAnswers = {
157
+ LMFR_PREVIOUS_QUESTION: [
158
+ {
159
+ pathForLength: '4.56',
160
+ pathForWidth: '7.89',
161
+ },
162
+ ],
163
+ };
166
164
 
167
165
  <Source language="json" code={JSON.stringify(previousAnswers, null, ' ')} />
168
166
 
@@ -172,7 +170,7 @@ export const previousAnswers = new Map(
172
170
  parameters={{ controls: { disable: true } }}
173
171
  args={{
174
172
  payload: valuePayload,
175
- answers: previousAnswers,
173
+ answers: new Map(Object.entries(previousAnswers)),
176
174
  }}
177
175
  >
178
176
  {TemplateSandbox.bind({})}
@@ -220,16 +220,14 @@ With optin value :
220
220
 
221
221
  `answers` prop to add a previous answer :
222
222
 
223
- export const previousAnswersWithOptin = new Map(
224
- Object.entries({
225
- LMFR_PREVIOUS_QUESTION: [
226
- {
227
- pathForProjectName: 'Rénover la cuisine',
228
- pathForOptin: true,
229
- },
230
- ],
231
- }),
232
- );
223
+ export const previousAnswersWithOptin = {
224
+ LMFR_PREVIOUS_QUESTION: [
225
+ {
226
+ pathForProjectName: 'Rénover la cuisine',
227
+ pathForOptin: true,
228
+ },
229
+ ],
230
+ };
233
231
 
234
232
  <Source language="json" code={JSON.stringify(previousAnswersWithOptin, null, ' ')} />
235
233
 
@@ -239,7 +237,7 @@ export const previousAnswersWithOptin = new Map(
239
237
  parameters={{ controls: { disable: true } }}
240
238
  args={{
241
239
  payload: valuePayload,
242
- answers: previousAnswersWithOptin,
240
+ answers: new Map(Object.entries(previousAnswersWithOptin)),
243
241
  runtimeOptions: runtimeOptions,
244
242
  }}
245
243
  >
@@ -148,15 +148,13 @@ export const valueWithFallbackPayload = {
148
148
  It will try to find a value in a previous answer for a question with id `LMFR_PREVIOUS_QUESTION`,
149
149
  provided thanks to the `answers` prop. If no value is found, it will use the `defaultDecoratorValue` as a fallback.
150
150
 
151
- export const previousAnswers = new Map(
152
- Object.entries({
153
- LMFR_PREVIOUS_QUESTION: [
154
- {
155
- pathForSpace: '456',
156
- },
157
- ],
158
- }),
159
- );
151
+ export const previousAnswers = {
152
+ LMFR_PREVIOUS_QUESTION: [
153
+ {
154
+ pathForSpace: '456',
155
+ },
156
+ ],
157
+ };
160
158
 
161
159
  <Source language="json" code={JSON.stringify(previousAnswers, null, ' ')} />
162
160
 
@@ -166,7 +164,7 @@ export const previousAnswers = new Map(
166
164
  parameters={{ controls: { disable: true } }}
167
165
  args={{
168
166
  payload: valuePayload,
169
- answers: previousAnswers,
167
+ answers: new Map(Object.entries(previousAnswers)),
170
168
  }}
171
169
  >
172
170
  {TemplateSandbox.bind({})}
@@ -33,13 +33,13 @@ const Condition = (
33
33
  };
34
34
 
35
35
  export const areConditionsValid = (
36
- conditions: string[],
36
+ conditions: boolean | string[],
37
37
  answers: Map<string, ScenarioStepAnswer[]>,
38
38
  runtimeOptions: Record<string, any>,
39
39
  ) => {
40
40
  let valid = true;
41
41
 
42
- if (conditions) {
42
+ if (conditions && conditions instanceof Array) {
43
43
  valid = false;
44
44
  for (const condition of conditions) {
45
45
  try {
@@ -37,6 +37,10 @@ export interface ScenarioStepAnswerDialog {
37
37
  imageUrl?: string;
38
38
  }
39
39
 
40
+ export interface ScenarioCondition {
41
+ conditions: string[];
42
+ }
43
+
40
44
  export interface ScenarioStepAnswerViewModel {
41
45
  title?: string;
42
46
  flagLabel?: string;
@@ -47,7 +51,7 @@ export interface ScenarioStepAnswerViewModel {
47
51
  alignVertical?: string;
48
52
  alignHorizontal?: string;
49
53
  alignText?: string;
50
- disabled?: boolean;
54
+ disabled?: boolean | ScenarioCondition;
51
55
  footer?: ScenarioStepFooterOptions;
52
56
  conditions?: string[];
53
57
  dialog?: ScenarioStepAnswerDialog;