project-booster-vue 9.26.0 → 9.27.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 +1 -1
- package/src/components/cards/PbCard.vue +14 -2
- package/src/components/question/PbQuestion-Features-Answers-Conditional.stories.mdx +2 -1
- package/src/components/question/PbQuestion-Features-Answers-Modal.stories.mdx +122 -0
- package/src/components/question/PbQuestion.vue +99 -1
- package/src/components/question/__snapshots__/storyshots-puppeteer-test-puppeteer-ts-image-storyshots-project-booster-scenario-questions-pb-question-/360/237/246/240-features-answers-conditional-with-modal-1-snap.png +0 -0
- package/src/components/question/space-input/__snapshots__/storyshots-puppeteer-test-puppeteer-ts-image-storyshots-project-booster-scenario-questions-pb-space-input-/360/237/246/240-showcase-feature-with-modal-1-snap.png +0 -0
- package/src/types/pb/Scenario.ts +7 -0
package/package.json
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
disabled ? 'pb-card--disabled' : ''
|
|
6
6
|
}${flattened ? 'pb-card--no-pointer-events' : ''} ${
|
|
7
7
|
cardMinRatio && cardMinRatio !== 'auto' ? 'm-ratio-container--' + cardMinRatio : ''
|
|
8
|
-
}`"
|
|
8
|
+
}${borderTop ? 'pb-card--border-top' : ''}`"
|
|
9
9
|
:role="!buttonLabel ? 'button' : 'article'"
|
|
10
|
-
:style="`min-height: ${cardMinHeight}`"
|
|
10
|
+
:style="`min-height: ${cardMinHeight}; border-color:${borderTop ? borderTop : null}`"
|
|
11
11
|
@click="handleCardClick"
|
|
12
12
|
>
|
|
13
13
|
<m-flex
|
|
@@ -309,6 +309,13 @@ export default defineComponent({
|
|
|
309
309
|
type: [Boolean, String],
|
|
310
310
|
default: false,
|
|
311
311
|
},
|
|
312
|
+
/**
|
|
313
|
+
* Definies if the card has a border top
|
|
314
|
+
*/
|
|
315
|
+
borderTop: {
|
|
316
|
+
type: String,
|
|
317
|
+
default: null,
|
|
318
|
+
},
|
|
312
319
|
},
|
|
313
320
|
|
|
314
321
|
computed: {
|
|
@@ -361,6 +368,11 @@ $responsive-breakpoint: 's';
|
|
|
361
368
|
overflow: hidden;
|
|
362
369
|
position: relative;
|
|
363
370
|
|
|
371
|
+
&--border-top {
|
|
372
|
+
border-top-style: solid !important;
|
|
373
|
+
border-top-width: 4px !important;
|
|
374
|
+
}
|
|
375
|
+
|
|
364
376
|
&__items-container:empty ~ &__image-container {
|
|
365
377
|
height: 100%;
|
|
366
378
|
|
|
@@ -36,7 +36,8 @@ It is possible to condition the display of certain answers according to previous
|
|
|
36
36
|
|
|
37
37
|
export const conditionalAnswersPayload = {
|
|
38
38
|
viewModel: {
|
|
39
|
-
label: '
|
|
39
|
+
label: 'Quel est votre revenu fiscal de référence annuel de votre foyer fiscal ?',
|
|
40
|
+
subtitle: 'Le revenu fiscal de référence du foyer concerne la somme des revenus des conjoints.',
|
|
40
41
|
answersComponent: 'PbCard',
|
|
41
42
|
},
|
|
42
43
|
answers: {
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { nestedAppDecorator } from '../../../.storybook/nested-app-decorator';
|
|
2
|
+
import { Story, Preview, Meta, Props, ArgsTable, Source, Canvas } from '@storybook/addon-docs';
|
|
3
|
+
import PbQuestion from './PbQuestion';
|
|
4
|
+
import { TemplateSandbox } from './PbQuestion.stories.mdx';
|
|
5
|
+
|
|
6
|
+
<Meta
|
|
7
|
+
title="Project Booster/Scenario/Questions/PbQuestion 🦠/Features/Answers/Conditional"
|
|
8
|
+
component={PbQuestion}
|
|
9
|
+
argTypes={{
|
|
10
|
+
onStepCompleted: {
|
|
11
|
+
action: 'Step completed',
|
|
12
|
+
table: { disable: true },
|
|
13
|
+
},
|
|
14
|
+
}}
|
|
15
|
+
decorators={[
|
|
16
|
+
nestedAppDecorator(
|
|
17
|
+
{
|
|
18
|
+
actions: {
|
|
19
|
+
sendEventToBus({}, payload) {
|
|
20
|
+
console.log('Event sent to bus', payload);
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
[],
|
|
25
|
+
),
|
|
26
|
+
]}
|
|
27
|
+
parameters={{
|
|
28
|
+
layout: 'fullscreen',
|
|
29
|
+
}}
|
|
30
|
+
/>
|
|
31
|
+
|
|
32
|
+
# `PbQuestion` - With Modal
|
|
33
|
+
|
|
34
|
+
export const conditionalAnswersPayload = {
|
|
35
|
+
viewModel: {
|
|
36
|
+
label: 'Quel est votre revenu fiscal de référence annuel de votre foyer fiscal ?',
|
|
37
|
+
subtitle: 'Le revenu fiscal de référence du foyer concerne la somme des revenus des conjoints.',
|
|
38
|
+
answersComponent: 'PbCard',
|
|
39
|
+
},
|
|
40
|
+
answers: {
|
|
41
|
+
'ANSWER-1': {
|
|
42
|
+
code: 'ANSWER-1',
|
|
43
|
+
conditions: [
|
|
44
|
+
"isAnswerMatching('QUESTION_1', 'QUESTION_1--ANSWER_1')",
|
|
45
|
+
"isAnswerMatching('QUESTION_2', 'QUESTION_2--ANSWER_1')",
|
|
46
|
+
],
|
|
47
|
+
viewModel: {
|
|
48
|
+
title: '15000 - 20000 €',
|
|
49
|
+
borderColor: 'orange',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
'ANSWER-2': {
|
|
53
|
+
code: 'ANSWER-2',
|
|
54
|
+
conditions: ['runtimeOptions.isElligible'],
|
|
55
|
+
viewModel: {
|
|
56
|
+
title: '20000 - 30000 €',
|
|
57
|
+
borderColor: 'red',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
'ANSWER-3': {
|
|
61
|
+
code: 'ANSWER-3',
|
|
62
|
+
viewModel: {
|
|
63
|
+
title: '30000 - 40000 €',
|
|
64
|
+
borderColor: 'purple',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
'ANSWER-4': {
|
|
68
|
+
code: 'ANSWER-4',
|
|
69
|
+
viewModel: {
|
|
70
|
+
title: 'Plus de 50000 €',
|
|
71
|
+
borderColor: 'yellow',
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
helpArea: [
|
|
76
|
+
{
|
|
77
|
+
type: 'text',
|
|
78
|
+
label: 'Besoin d’aide pour trouver votre revenu fiscal de référence ?',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
type: 'link',
|
|
82
|
+
label: 'Voir l’aide pour trouver votre revenu fiscal',
|
|
83
|
+
action: {
|
|
84
|
+
type: 'MODAL',
|
|
85
|
+
viewModelDialog: {
|
|
86
|
+
headerTitle: 'Ou trouver votre revenu fiscal de référence ?',
|
|
87
|
+
subTitle: 'Sur votre dernier avis d’imposition disponible dans votre espace impots-gouv.fr',
|
|
88
|
+
imgUrl:
|
|
89
|
+
'https://www.lerevenu.com/sites/site/files/styles/img_lg/public/field/image/impots_7.jpg?itok=A2rlQzx3',
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
<Source language="json" code={JSON.stringify(conditionalAnswersPayload, null, ' ')} />
|
|
97
|
+
|
|
98
|
+
export const conditionalAnswersAnswers = {
|
|
99
|
+
QUESTION_1: [{ code: 'QUESTION_1--ANSWER_1' }],
|
|
100
|
+
QUESTION_2: [{ code: 'QUESTION_2--ANSWER_1' }],
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const conditionalAnswersRuntimeOptions = {
|
|
104
|
+
isElligible: true,
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
<Canvas>
|
|
108
|
+
<Story
|
|
109
|
+
name="With Modal"
|
|
110
|
+
inline={false}
|
|
111
|
+
height="862px"
|
|
112
|
+
parameters={{ controls: { disable: true } }}
|
|
113
|
+
args={{
|
|
114
|
+
payload: conditionalAnswersPayload,
|
|
115
|
+
answers: new Map(Object.entries(conditionalAnswersAnswers)),
|
|
116
|
+
runtimeOptions: conditionalAnswersRuntimeOptions,
|
|
117
|
+
minHeight: 'auto',
|
|
118
|
+
}}
|
|
119
|
+
>
|
|
120
|
+
{TemplateSandbox.bind({})}
|
|
121
|
+
</Story>
|
|
122
|
+
</Canvas>
|
|
@@ -72,6 +72,7 @@
|
|
|
72
72
|
:is="payload.viewModel.answersComponent"
|
|
73
73
|
v-if="payload.viewModel.answersComponent !== 'MButton'"
|
|
74
74
|
class="pb-question__answer__component"
|
|
75
|
+
:border-top="answer.viewModel.borderColor || null"
|
|
75
76
|
:image="decorate(answers, runtimeOptions, answer.viewModel.image, payload.defaultDecoratorValue)"
|
|
76
77
|
:image-title="
|
|
77
78
|
decorate(answers, runtimeOptions, answer.viewModel.imageTitle, payload.defaultDecoratorValue)
|
|
@@ -252,7 +253,59 @@
|
|
|
252
253
|
</m-flexy-col>
|
|
253
254
|
</m-flexy>
|
|
254
255
|
</m-container>
|
|
255
|
-
<div class="pb-question__padding-bottom" />
|
|
256
|
+
<div class="pb-question__padding-bottom" v-if="!payload.helpArea" />
|
|
257
|
+
<m-flex
|
|
258
|
+
class="pb-question__help"
|
|
259
|
+
v-if="payload.helpArea"
|
|
260
|
+
direction="column"
|
|
261
|
+
align-items="center"
|
|
262
|
+
justify-content="center"
|
|
263
|
+
>
|
|
264
|
+
<div v-for="helpItem in payload.helpArea" :key="helpItem.type">
|
|
265
|
+
<div v-if="helpItem.type === 'text'">
|
|
266
|
+
<p class="pb-question__help__text">{{ helpItem.label }}</p>
|
|
267
|
+
</div>
|
|
268
|
+
<div v-if="helpItem.type === 'link'">
|
|
269
|
+
<m-link
|
|
270
|
+
class="pb-question__help__link"
|
|
271
|
+
:label="helpItem.label"
|
|
272
|
+
width="full"
|
|
273
|
+
size="l"
|
|
274
|
+
theme="primary"
|
|
275
|
+
@click="handleHelpClick(helpItem.action)"
|
|
276
|
+
/>
|
|
277
|
+
</div>
|
|
278
|
+
</div>
|
|
279
|
+
</m-flex>
|
|
280
|
+
|
|
281
|
+
<m-dialog
|
|
282
|
+
class="pb-question__dialog-help"
|
|
283
|
+
v-model:show-dialog="displayDialogHelp"
|
|
284
|
+
width="771px"
|
|
285
|
+
height="492px"
|
|
286
|
+
maxHeight="100vh"
|
|
287
|
+
>
|
|
288
|
+
<template #header v-if="helpDialog">
|
|
289
|
+
<div class="pb-question__dialog-help__title">
|
|
290
|
+
<h2>{{ helpDialog.viewModelDialog.headerTitle }}</h2>
|
|
291
|
+
<p>{{ helpDialog.viewModelDialog.subTitle }}</p>
|
|
292
|
+
</div>
|
|
293
|
+
</template>
|
|
294
|
+
<template #body>
|
|
295
|
+
<div class="pb-question__dialog-help__body" v-if="helpDialog">
|
|
296
|
+
<div
|
|
297
|
+
:style="`background-image: url(${helpDialog.viewModelDialog.imgUrl});`"
|
|
298
|
+
class="pb-question__dialog-help__body__image"
|
|
299
|
+
/>
|
|
300
|
+
</div>
|
|
301
|
+
</template>
|
|
302
|
+
<template v-slot:footer>
|
|
303
|
+
<m-flex class="pb-question__dialog-help__footer" align-items="center" justify-content="center">
|
|
304
|
+
<m-button label="Fermer" theme="bordered-neutral" @click.prevent="displayDialogHelp = false"></m-button>
|
|
305
|
+
</m-flex>
|
|
306
|
+
</template>
|
|
307
|
+
</m-dialog>
|
|
308
|
+
|
|
256
309
|
<m-dialog class="pb-question__dialog" v-model:show-dialog="displayDialog">
|
|
257
310
|
<template #header v-if="!displayVideo">
|
|
258
311
|
<span>{{ dialog.headerTitle }}</span>
|
|
@@ -322,6 +375,7 @@ import {
|
|
|
322
375
|
ScenarioStepSkippableOptions,
|
|
323
376
|
ScenarioStepViewModel,
|
|
324
377
|
ScenarioCondition,
|
|
378
|
+
ScenarioStepDialog,
|
|
325
379
|
} from '@/types/pb/Scenario';
|
|
326
380
|
|
|
327
381
|
const BACK_ICON =
|
|
@@ -460,7 +514,9 @@ export default defineComponent({
|
|
|
460
514
|
BACK_ICON,
|
|
461
515
|
INFO_ICON,
|
|
462
516
|
displayDialog: false,
|
|
517
|
+
displayDialogHelp: false,
|
|
463
518
|
dialog: undefined as undefined | ScenarioStepAnswerDialog,
|
|
519
|
+
helpDialog: undefined as undefined | ScenarioStepDialog,
|
|
464
520
|
displayVideo: false,
|
|
465
521
|
pbQuestionActionsButtonsMaxHeight: 0,
|
|
466
522
|
decorate,
|
|
@@ -761,6 +817,19 @@ export default defineComponent({
|
|
|
761
817
|
},
|
|
762
818
|
});
|
|
763
819
|
},
|
|
820
|
+
handleHelpClick(answer: ScenarioStepDialog) {
|
|
821
|
+
this.displayDialogHelp = !this.displayDialogHelp;
|
|
822
|
+
this.helpDialog = answer ?? undefined;
|
|
823
|
+
this.$store.dispatch('sendEventToBus', {
|
|
824
|
+
code: 'LINK-CLICKED',
|
|
825
|
+
payload: {
|
|
826
|
+
context: {
|
|
827
|
+
answer: answer,
|
|
828
|
+
questionId: this.stepName,
|
|
829
|
+
},
|
|
830
|
+
},
|
|
831
|
+
});
|
|
832
|
+
},
|
|
764
833
|
},
|
|
765
834
|
});
|
|
766
835
|
</script>
|
|
@@ -1229,8 +1298,37 @@ $answers-apparition-duration: '0.5s';
|
|
|
1229
1298
|
}
|
|
1230
1299
|
}
|
|
1231
1300
|
|
|
1301
|
+
&__dialog-help {
|
|
1302
|
+
&__title {
|
|
1303
|
+
padding: $mu250 $mu250 0 $mu250;
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
&__body {
|
|
1307
|
+
padding: 0 $mu250;
|
|
1308
|
+
@include set-font-scale('05', 'l');
|
|
1309
|
+
&__image {
|
|
1310
|
+
background-size: cover;
|
|
1311
|
+
padding: 120px 0;
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1315
|
+
&__footer {
|
|
1316
|
+
padding: $mu100 $mu250 $mu250 $mu250;
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1232
1320
|
&__padding-bottom {
|
|
1233
1321
|
height: $mu800;
|
|
1234
1322
|
}
|
|
1323
|
+
|
|
1324
|
+
&__help {
|
|
1325
|
+
margin-bottom: $mu250;
|
|
1326
|
+
&__link,
|
|
1327
|
+
&__text {
|
|
1328
|
+
margin: 0;
|
|
1329
|
+
@include set-font-scale('05', 'l');
|
|
1330
|
+
@include set-font-face('regular');
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1235
1333
|
}
|
|
1236
1334
|
</style>
|
package/src/types/pb/Scenario.ts
CHANGED
|
@@ -74,6 +74,13 @@ export interface ScenarioStepAnswer {
|
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
export interface ScenarioStepDialog {
|
|
78
|
+
viewModelDialog: {
|
|
79
|
+
headerTitle: string;
|
|
80
|
+
imageUrl?: string;
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
77
84
|
export interface ScenarioStepAnswers {
|
|
78
85
|
answers: ScenarioStepAnswer[];
|
|
79
86
|
nextStep?: ScenarioStepNextStep;
|