project-booster-vue 9.19.1 → 9.19.4
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 +1 -1
- package/src/components/projects/project-item-save/PbProjectItemSave.vue +9 -10
- package/src/components/question/PbQuestion-Features-Answers-Conditional.stories.mdx +2 -2
- package/src/components/question/PbQuestion-Features-Answers-Decorated.stories.mdx +1 -1
- package/src/components/question/PbQuestion-Features-Answers-Disabled.stories.mdx +2 -2
- package/src/components/question/PbQuestion-Features-Question-Footer.stories.mdx +1 -1
- package/src/components/question/PbQuestion.vue +13 -4
- package/src/components/question/amount-input/PbAmountInput.vue +0 -1
- package/src/components/question/dimensions-input/PbDimensionsInput.stories.mdx +9 -11
- package/src/components/question/dimensions-input/PbDimensionsInput.vue +4 -5
- package/src/components/question/login-redirect/PbLoginRedirect.stories.mdx +1 -1
- package/src/components/question/name-input/PbNameInput.stories.mdx +9 -11
- package/src/components/question/name-input/PbNameInput.vue +2 -3
- package/src/components/question/space-input/PbSpaceInput.stories.mdx +9 -11
- package/src/components/question/space-input/PbSpaceInput.vue +1 -2
- package/src/services/scenarioConditionals.ts +2 -2
- package/src/types/pb/Scenario.ts +10 -1
package/package.json
CHANGED
|
@@ -100,19 +100,18 @@ export const answerGettersMappers: Map<string, (param: any) => void> = new Map<s
|
|
|
100
100
|
}),
|
|
101
101
|
);
|
|
102
102
|
|
|
103
|
-
function adaptAnswers(answers:
|
|
103
|
+
function adaptAnswers(answers: Map<string, ScenarioStepAnswer[]>, scenario: Record<string, any>) {
|
|
104
104
|
let adaptedAnswers: ScenarioAnswer[] = [];
|
|
105
105
|
|
|
106
106
|
if (answers) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}));
|
|
107
|
+
answers.forEach((value: ScenarioStepAnswer[], key: string) => {
|
|
108
|
+
if (!['PbRestitution'].includes(scenario[key]?.component ?? '') && key !== 'SUBPROJECT_FORM_ID') {
|
|
109
|
+
adaptedAnswers.push({
|
|
110
|
+
questionId: key,
|
|
111
|
+
answers: value.map(answerGettersMappers.get(scenario[key]?.component ?? '') ?? (() => undefined)),
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
});
|
|
116
115
|
}
|
|
117
116
|
|
|
118
117
|
return adaptedAnswers;
|
|
@@ -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
|
-
|
|
557
|
-
answer
|
|
558
|
-
|
|
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)) {
|
|
@@ -55,7 +55,6 @@ import { useForm } from 'vee-validate';
|
|
|
55
55
|
import * as yup from 'yup';
|
|
56
56
|
import cloneDeep from 'lodash.clonedeep';
|
|
57
57
|
import merge from 'lodash.merge';
|
|
58
|
-
import objectPath from 'object-path';
|
|
59
58
|
import MFlex from './../../mozaic/flex/MFlex.vue';
|
|
60
59
|
import MButton from './../../mozaic/buttons/MButton.vue';
|
|
61
60
|
import MIcon from './../../mozaic/icon/MIcon.vue';
|
|
@@ -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 =
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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({})}
|
|
@@ -98,7 +98,6 @@ import MTextInput from './../../mozaic/text-input/MTextInput.vue';
|
|
|
98
98
|
import DEFAULT_PAYLOAD from './default-payload.json';
|
|
99
99
|
import MLink from '../../mozaic/link/MLink.vue';
|
|
100
100
|
import MIcon from '../../mozaic/icon/MIcon.vue';
|
|
101
|
-
import objectPath from 'object-path';
|
|
102
101
|
import { ref } from 'vue';
|
|
103
102
|
import { ScenarioStepAnswer } from '@/types/pb/Scenario';
|
|
104
103
|
import { DimensionsInputPayload } from '@/components/question/dimensions-input/DimensionsInput';
|
|
@@ -156,13 +155,13 @@ const computeDefaultValue = (
|
|
|
156
155
|
answers,
|
|
157
156
|
runtimeOptions,
|
|
158
157
|
computedPayload?.value?.value?.length,
|
|
159
|
-
computedPayload?.value?.defaultDecoratorValue,
|
|
158
|
+
computedPayload?.value?.defaultDecoratorValue ?? '',
|
|
160
159
|
);
|
|
161
160
|
width.value = decorate(
|
|
162
161
|
answers,
|
|
163
162
|
runtimeOptions,
|
|
164
163
|
computedPayload?.value?.value?.width,
|
|
165
|
-
computedPayload?.value?.defaultDecoratorValue,
|
|
164
|
+
computedPayload?.value?.defaultDecoratorValue ?? '',
|
|
166
165
|
);
|
|
167
166
|
}
|
|
168
167
|
|
|
@@ -243,8 +242,8 @@ export default defineComponent({
|
|
|
243
242
|
emit(props.completedEventName, {
|
|
244
243
|
answers: [
|
|
245
244
|
{
|
|
246
|
-
|
|
247
|
-
|
|
245
|
+
length: values[elementLengthId],
|
|
246
|
+
width: values[elementWidthId],
|
|
248
247
|
},
|
|
249
248
|
],
|
|
250
249
|
});
|
|
@@ -160,7 +160,7 @@ export const overridenLabelsPayload = {
|
|
|
160
160
|
buttonLabelConnect: 'Se connecter',
|
|
161
161
|
buttonLabelCreateAccount: 'Créer un compte',
|
|
162
162
|
forceRedirect: false,
|
|
163
|
-
link: '/espace-perso/espace-projets.html
|
|
163
|
+
link: '/espace-perso/espace-projets.html',
|
|
164
164
|
},
|
|
165
165
|
};
|
|
166
166
|
|
|
@@ -220,16 +220,14 @@ With optin value :
|
|
|
220
220
|
|
|
221
221
|
`answers` prop to add a previous answer :
|
|
222
222
|
|
|
223
|
-
export const previousAnswersWithOptin =
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
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
|
>
|
|
@@ -52,7 +52,6 @@ import { useForm } from 'vee-validate';
|
|
|
52
52
|
import * as yup from 'yup';
|
|
53
53
|
import cloneDeep from 'lodash.clonedeep';
|
|
54
54
|
import merge from 'lodash.merge';
|
|
55
|
-
import objectPath from 'object-path';
|
|
56
55
|
import MFlex from '../../mozaic/flex/MFlex.vue';
|
|
57
56
|
import MButton from '../../mozaic/buttons/MButton.vue';
|
|
58
57
|
import MLink from '../../mozaic/link/MLink.vue';
|
|
@@ -99,13 +98,13 @@ const computeDefaultValue = (
|
|
|
99
98
|
answers,
|
|
100
99
|
runtimeOptions,
|
|
101
100
|
computedPayload?.value?.value?.projectName,
|
|
102
|
-
computedPayload?.value?.defaultDecoratorValue,
|
|
101
|
+
computedPayload?.value?.defaultDecoratorValue ?? '',
|
|
103
102
|
);
|
|
104
103
|
optin.value = decorate(
|
|
105
104
|
answers,
|
|
106
105
|
runtimeOptions,
|
|
107
106
|
computedPayload?.value?.value?.optin,
|
|
108
|
-
computedPayload?.value?.defaultDecoratorValue,
|
|
107
|
+
computedPayload?.value?.defaultDecoratorValue ?? '',
|
|
109
108
|
);
|
|
110
109
|
}
|
|
111
110
|
|
|
@@ -129,7 +129,7 @@ export const valuePayload = {
|
|
|
129
129
|
<Source language="json" code={JSON.stringify(valuePayload, null, ' ')} />
|
|
130
130
|
|
|
131
131
|
The `getAnswerValue` function allows to retrieve a value from one provided answer. To retrieve a value, the first
|
|
132
|
-
parameter is the answer Id, the second is an
|
|
132
|
+
parameter is the answer Id, the second is an optional path to extract a specific value.
|
|
133
133
|
|
|
134
134
|
A `defaultDecoratorValue` value can be added as a fallback when no previous answer is found. When no default value is provided and no answer
|
|
135
135
|
is found, the component value will be empty :
|
|
@@ -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 =
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
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({})}
|
|
@@ -87,7 +87,6 @@ import { useForm } from 'vee-validate';
|
|
|
87
87
|
import * as yup from 'yup';
|
|
88
88
|
import cloneDeep from 'lodash.clonedeep';
|
|
89
89
|
import merge from 'lodash.merge';
|
|
90
|
-
import objectPath from 'object-path';
|
|
91
90
|
import MFlex from '../../mozaic/flex/MFlex.vue';
|
|
92
91
|
import MButton from '../../mozaic/buttons/MButton.vue';
|
|
93
92
|
import MLink from '../../mozaic/link/MLink.vue';
|
|
@@ -130,7 +129,7 @@ const computeDefaultValue = (
|
|
|
130
129
|
answers,
|
|
131
130
|
runtimeOptions,
|
|
132
131
|
computedPayload?.value?.value?.space,
|
|
133
|
-
computedPayload?.value?.defaultDecoratorValue,
|
|
132
|
+
computedPayload?.value?.defaultDecoratorValue ?? '',
|
|
134
133
|
);
|
|
135
134
|
}
|
|
136
135
|
return space;
|
|
@@ -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 {
|
package/src/types/pb/Scenario.ts
CHANGED
|
@@ -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;
|
|
@@ -62,6 +66,11 @@ export interface ScenarioStepAnswer {
|
|
|
62
66
|
meta?: {
|
|
63
67
|
order: number;
|
|
64
68
|
stringSort: string;
|
|
69
|
+
ProjectTypeLabel?: string;
|
|
70
|
+
domesticSpace?: string;
|
|
71
|
+
projectType?: string;
|
|
72
|
+
ranking?: number;
|
|
73
|
+
projectKind?: string;
|
|
65
74
|
};
|
|
66
75
|
}
|
|
67
76
|
|