@windward/core 0.0.7 → 0.0.9
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/components/Content/Blocks/ClickableIcons.vue +128 -40
- package/components/Content/Blocks/Image.vue +37 -10
- package/components/Content/Blocks/OpenResponse.vue +32 -10
- package/components/Content/Blocks/OpenResponseCollate.vue +69 -42
- package/components/Content/Blocks/ScenarioChoice.vue +262 -0
- package/components/Content/Blocks/Tab.vue +2 -7
- package/components/Settings/AccordionSettings.vue +97 -74
- package/components/Settings/ClickableIconsSettings.vue +101 -86
- package/components/Settings/ImageSettings.vue +10 -0
- package/components/Settings/OpenResponseCollateSettings.vue +9 -8
- package/components/Settings/ScenarioChoiceSettings.vue +329 -0
- package/components/Settings/TabSettings.vue +75 -61
- package/components/Settings/TextEditorSettings.vue +2 -3
- package/components/utils/FillInBlank/FillInBlankInput.vue +4 -1
- package/components/utils/TinyMCEWrapper.vue +11 -4
- package/components/utils/assets/tinymce/css/content.scss +1 -1
- package/helpers/FillInBlankHelper.ts +0 -2
- package/helpers/tinymce/plugin.ts +1 -1
- package/i18n/en-US/components/content/blocks/index.ts +2 -2
- package/i18n/en-US/components/content/blocks/open_response_collate.ts +1 -0
- package/i18n/en-US/components/content/blocks/scenario_choice.ts +5 -0
- package/i18n/en-US/components/settings/accordion.ts +5 -0
- package/i18n/en-US/components/settings/clickable_icon.ts +8 -0
- package/i18n/en-US/components/settings/image.ts +3 -1
- package/i18n/en-US/components/settings/index.ts +6 -0
- package/i18n/en-US/components/settings/scenario_choice.ts +19 -0
- package/i18n/en-US/components/settings/tab.ts +7 -0
- package/i18n/en-US/components/utils/FillInBlank/FillInBlankInput.ts +1 -1
- package/i18n/en-US/shared/content_blocks.ts +1 -0
- package/i18n/en-US/shared/settings.ts +2 -0
- package/i18n/es-ES/components/content/blocks/feedback.ts +2 -0
- package/i18n/es-ES/components/content/blocks/index.ts +2 -2
- package/i18n/es-ES/components/content/blocks/open_response_collate.ts +1 -0
- package/i18n/es-ES/components/content/blocks/scenario_choice.ts +6 -0
- package/i18n/es-ES/components/navigation/index.ts +2 -0
- package/i18n/es-ES/components/settings/accordion.ts +5 -0
- package/i18n/es-ES/components/settings/clickable_icon.ts +8 -0
- package/i18n/es-ES/components/settings/image.ts +3 -1
- package/i18n/es-ES/components/settings/index.ts +6 -0
- package/i18n/es-ES/components/settings/scenario_choice.ts +19 -0
- package/i18n/es-ES/components/{content/blocks → settings}/tab.ts +3 -0
- package/i18n/es-ES/components/utils/FillInBlank/FillInBlankInput.ts +13 -0
- package/i18n/es-ES/components/utils/FillInBlank/FillInTheBlanksManager.ts +11 -0
- package/i18n/es-ES/components/utils/FillInBlank/index.ts +6 -0
- package/i18n/es-ES/components/utils/index.ts +2 -0
- package/i18n/es-ES/components/utils/tiny_mce_wrapper.ts +1 -0
- package/i18n/es-ES/shared/content_blocks.ts +1 -0
- package/i18n/es-ES/shared/menu.ts +1 -0
- package/i18n/es-ES/shared/settings.ts +2 -0
- package/i18n/index.ts +11 -0
- package/i18n/sv-SE/components/content/blocks/feedback.ts +2 -0
- package/i18n/sv-SE/components/content/blocks/index.ts +2 -2
- package/i18n/sv-SE/components/content/blocks/open_response_collate.ts +1 -0
- package/i18n/sv-SE/components/content/blocks/scenario_choice.ts +5 -0
- package/i18n/sv-SE/components/navigation/index.ts +2 -0
- package/i18n/sv-SE/components/settings/accordion.ts +5 -0
- package/i18n/sv-SE/components/settings/clickable_icon.ts +8 -0
- package/i18n/sv-SE/components/settings/image.ts +3 -1
- package/i18n/sv-SE/components/settings/index.ts +6 -0
- package/i18n/sv-SE/components/settings/scenario_choice.ts +19 -0
- package/i18n/sv-SE/components/{content/blocks → settings}/tab.ts +3 -0
- package/i18n/sv-SE/components/utils/FillInBlank/FillInBlankInput.ts +13 -0
- package/i18n/sv-SE/components/utils/FillInBlank/FillInTheBlanksManager.ts +11 -0
- package/i18n/sv-SE/components/utils/FillInBlank/index.ts +6 -0
- package/i18n/sv-SE/components/utils/index.ts +2 -0
- package/i18n/sv-SE/components/utils/tiny_mce_wrapper.ts +1 -0
- package/i18n/sv-SE/shared/content_blocks.ts +1 -0
- package/i18n/sv-SE/shared/menu.ts +1 -0
- package/i18n/sv-SE/shared/settings.ts +2 -0
- package/package.json +2 -1
- package/plugin.js +24 -5
- package/test/Components/Content/Blocks/ScenarioChoice.spec.js +21 -0
- package/test/Components/Settings/ClickableIconsSettings.spec.js +1 -1
- package/test/Components/Settings/ScenarioChoiceSettings.spec.js +20 -0
- package/test/Feature/LocaleKeys.spec.js +9 -0
- package/test/__mocks__/componentsMock.js +24 -0
- package/test/__mocks__/helpersMock.js +3 -0
- package/test/__mocks__/modelMock.js +4 -0
- package/test/locales.js +95 -0
- package/i18n/en-US/components/content/blocks/tab.ts +0 -4
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
<v-col class="pa-0">
|
|
5
5
|
<v-text-field
|
|
6
6
|
v-model="block.metadata.config.title"
|
|
7
|
+
id="title"
|
|
7
8
|
:label="
|
|
8
9
|
$t(
|
|
9
10
|
'windward.core.components.settings.clickable_icon.title'
|
|
@@ -12,49 +13,91 @@
|
|
|
12
13
|
></v-text-field>
|
|
13
14
|
<v-text-field
|
|
14
15
|
v-model="block.metadata.config.description"
|
|
16
|
+
id="description"
|
|
15
17
|
:label="
|
|
16
18
|
$t(
|
|
17
19
|
'windward.core.components.settings.clickable_icon.description'
|
|
18
20
|
)
|
|
19
21
|
"
|
|
20
22
|
></v-text-field>
|
|
21
|
-
<v-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
<v-switch
|
|
24
|
+
v-model="block.metadata.config.display.show_title"
|
|
25
|
+
:label="
|
|
26
|
+
$t(
|
|
27
|
+
'windward.core.components.settings.clickable_icon.display.show_title'
|
|
28
|
+
)
|
|
29
|
+
"
|
|
30
|
+
></v-switch>
|
|
31
|
+
<v-switch
|
|
32
|
+
v-model="block.metadata.config.display.show_background"
|
|
33
|
+
:label="
|
|
34
|
+
$t(
|
|
35
|
+
'windward.core.components.settings.clickable_icon.display.show_background'
|
|
36
|
+
)
|
|
37
|
+
"
|
|
38
|
+
></v-switch>
|
|
39
|
+
<v-switch
|
|
40
|
+
v-model="block.metadata.config.display.round_icon"
|
|
41
|
+
:label="
|
|
42
|
+
$t(
|
|
43
|
+
'windward.core.components.settings.clickable_icon.display.round_icon'
|
|
44
|
+
)
|
|
45
|
+
"
|
|
46
|
+
></v-switch>
|
|
47
|
+
<v-switch
|
|
48
|
+
v-model="block.metadata.config.display.italic_icon"
|
|
49
|
+
:label="
|
|
50
|
+
$t(
|
|
51
|
+
'windward.core.components.settings.clickable_icon.display.italic_icon'
|
|
52
|
+
)
|
|
53
|
+
"
|
|
54
|
+
></v-switch>
|
|
55
|
+
<v-switch
|
|
56
|
+
v-model="block.metadata.config.display.autocolor"
|
|
57
|
+
:label="
|
|
58
|
+
$t(
|
|
59
|
+
'windward.core.components.settings.clickable_icon.autocolor'
|
|
60
|
+
)
|
|
61
|
+
"
|
|
62
|
+
></v-switch>
|
|
63
|
+
<v-btn color="primary" outlined block @click="onAddElement"
|
|
26
64
|
><v-icon>mdi-plus</v-icon
|
|
27
65
|
>{{ $t('shared.forms.add') }}</v-btn
|
|
28
66
|
>
|
|
29
67
|
</v-col>
|
|
30
|
-
<v-
|
|
31
|
-
<
|
|
32
|
-
v-
|
|
33
|
-
:
|
|
34
|
-
class="elevation-0"
|
|
68
|
+
<v-col>
|
|
69
|
+
<SortableExpansionPanel
|
|
70
|
+
v-model="block.metadata.config.items"
|
|
71
|
+
@click:close="onRemoveElement"
|
|
35
72
|
>
|
|
36
|
-
<
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
<v-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
73
|
+
<template #header="{ item }">
|
|
74
|
+
<v-icon v-if="item.icon && isIcon(item.icon)">{{
|
|
75
|
+
item.icon
|
|
76
|
+
}}</v-icon>
|
|
77
|
+
<span v-else-if="item.icon && !isIcon(item.icon)">{{
|
|
78
|
+
item.icon
|
|
79
|
+
}}</span>
|
|
80
|
+
<span v-else class="font-italic">
|
|
81
|
+
{{
|
|
82
|
+
$t(
|
|
83
|
+
'windward.core.components.settings.clickable_icon.no_icon'
|
|
84
|
+
)
|
|
85
|
+
}}
|
|
86
|
+
</span>
|
|
87
|
+
</template>
|
|
88
|
+
<template #body="{ index }">
|
|
89
|
+
<TextIconPicker
|
|
90
|
+
v-model="block.metadata.config.items[index].icon"
|
|
47
91
|
:label="
|
|
48
92
|
$t(
|
|
49
93
|
'windward.core.components.settings.clickable_icon.item_icon',
|
|
50
|
-
[
|
|
94
|
+
[index + 1]
|
|
51
95
|
)
|
|
52
96
|
"
|
|
53
|
-
></
|
|
97
|
+
></TextIconPicker>
|
|
54
98
|
<v-text-field
|
|
55
|
-
v-model="
|
|
56
|
-
|
|
57
|
-
"
|
|
99
|
+
v-model="block.metadata.config.items[index].title"
|
|
100
|
+
:id="'item-' + index + '-title'"
|
|
58
101
|
:label="
|
|
59
102
|
$t(
|
|
60
103
|
'windward.core.components.settings.clickable_icon.item_title'
|
|
@@ -63,9 +106,8 @@
|
|
|
63
106
|
></v-text-field>
|
|
64
107
|
|
|
65
108
|
<ColorPicker
|
|
66
|
-
v-
|
|
67
|
-
|
|
68
|
-
"
|
|
109
|
+
v-if="!block.metadata.config.display.autocolor"
|
|
110
|
+
v-model="block.metadata.config.items[index].color"
|
|
69
111
|
:label="
|
|
70
112
|
$t(
|
|
71
113
|
'windward.core.components.settings.clickable_icon.item_color'
|
|
@@ -79,40 +121,36 @@
|
|
|
79
121
|
)
|
|
80
122
|
}}</span>
|
|
81
123
|
<TextEditor
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
block.metadata.config.items[itemIndex].body
|
|
85
|
-
"
|
|
124
|
+
v-model="block.metadata.config.items[index].body"
|
|
125
|
+
:height="200"
|
|
86
126
|
></TextEditor>
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
color="primary"
|
|
91
|
-
block
|
|
92
|
-
outlined
|
|
93
|
-
@click="onRemoveElement(itemIndex)"
|
|
94
|
-
><v-icon>mdi-delete-outline</v-icon
|
|
95
|
-
>{{ $t('shared.forms.delete') }}</v-btn
|
|
96
|
-
>
|
|
97
|
-
</v-expansion-panel-content>
|
|
98
|
-
</v-expansion-panel>
|
|
99
|
-
</v-expansion-panels>
|
|
127
|
+
</template>
|
|
128
|
+
</SortableExpansionPanel>
|
|
129
|
+
</v-col>
|
|
100
130
|
</v-container>
|
|
101
131
|
</div>
|
|
102
132
|
</template>
|
|
103
133
|
<script>
|
|
104
134
|
import _ from 'lodash'
|
|
105
|
-
import Crypto from '~/helpers/Crypto'
|
|
106
135
|
import BaseContentSettings from '~/components/Content/Tool/BaseContentSettings.js'
|
|
107
136
|
import TextEditor from '~/components/Text/TextEditor'
|
|
137
|
+
import TextIconPicker from '~/components/TextIconPicker.vue'
|
|
108
138
|
import ColorPicker from '~/components/ColorPicker.vue'
|
|
139
|
+
import SortableExpansionPanel from '~/components/SortableExpansionPanel.vue'
|
|
140
|
+
|
|
109
141
|
export default {
|
|
110
142
|
name: 'ClickableIconsSettings',
|
|
111
143
|
components: {
|
|
144
|
+
SortableExpansionPanel,
|
|
112
145
|
TextEditor,
|
|
146
|
+
TextIconPicker,
|
|
113
147
|
ColorPicker,
|
|
114
148
|
},
|
|
115
149
|
extends: BaseContentSettings,
|
|
150
|
+
|
|
151
|
+
data() {
|
|
152
|
+
return {}
|
|
153
|
+
},
|
|
116
154
|
beforeMount() {
|
|
117
155
|
if (_.isEmpty(this.block)) {
|
|
118
156
|
this.block = {}
|
|
@@ -129,66 +167,43 @@ export default {
|
|
|
129
167
|
if (_.isEmpty(this.block.metadata.config.title)) {
|
|
130
168
|
this.block.metadata.config.title = ''
|
|
131
169
|
}
|
|
170
|
+
if (_.isEmpty(this.block.metadata.config.display)) {
|
|
171
|
+
this.block.metadata.config.display = {
|
|
172
|
+
show_title: false,
|
|
173
|
+
show_background: false,
|
|
174
|
+
round_icon: false,
|
|
175
|
+
italic_icon: false,
|
|
176
|
+
autocolor: true,
|
|
177
|
+
}
|
|
178
|
+
}
|
|
132
179
|
if (_.isEmpty(this.block.metadata.config.items)) {
|
|
133
180
|
this.block.metadata.config.items = []
|
|
134
181
|
}
|
|
135
182
|
},
|
|
136
|
-
data() {
|
|
137
|
-
return {
|
|
138
|
-
valid: true,
|
|
139
|
-
debounce: null,
|
|
140
|
-
loading: false,
|
|
141
|
-
api_key: process.env.TINY_MCE_API_KEY,
|
|
142
|
-
title: '',
|
|
143
|
-
description: '',
|
|
144
|
-
items: [
|
|
145
|
-
{
|
|
146
|
-
icon: '',
|
|
147
|
-
title: '',
|
|
148
|
-
body: '',
|
|
149
|
-
active: false,
|
|
150
|
-
},
|
|
151
|
-
],
|
|
152
|
-
expansionPanelKey: '0',
|
|
153
|
-
}
|
|
154
|
-
},
|
|
155
183
|
mounted() {
|
|
156
184
|
if (this.block.metadata.config.items.length <= 0) {
|
|
157
185
|
this.onAddElement()
|
|
158
186
|
}
|
|
159
187
|
},
|
|
160
|
-
beforeDestroy() {
|
|
161
|
-
if (this.debouncer) {
|
|
162
|
-
clearTimeout(this.debouncer)
|
|
163
|
-
}
|
|
164
|
-
},
|
|
165
|
-
|
|
166
188
|
methods: {
|
|
167
|
-
async onBeforeSave() {
|
|
168
|
-
this.block.metadata.config.items = this.items
|
|
169
|
-
},
|
|
170
189
|
onAddElement() {
|
|
171
190
|
const defaultObject = {
|
|
172
191
|
icon: '',
|
|
173
192
|
title: '',
|
|
174
|
-
body: '',
|
|
175
|
-
color: {
|
|
193
|
+
body: '<p></p>',
|
|
194
|
+
color: {
|
|
195
|
+
class: '',
|
|
196
|
+
},
|
|
176
197
|
active: false,
|
|
177
198
|
}
|
|
178
199
|
this.block.metadata.config.items.push(defaultObject)
|
|
179
200
|
},
|
|
180
201
|
onRemoveElement(index) {
|
|
181
202
|
this.block.metadata.config.items.splice(index, 1)
|
|
182
|
-
|
|
203
|
+
},
|
|
204
|
+
isIcon(str) {
|
|
205
|
+
return str && _.isString(str) && str.indexOf('mdi-') === 0
|
|
183
206
|
},
|
|
184
207
|
},
|
|
185
208
|
}
|
|
186
209
|
</script>
|
|
187
|
-
<style scoped>
|
|
188
|
-
.v-progress-circular {
|
|
189
|
-
margin: 1rem;
|
|
190
|
-
}
|
|
191
|
-
.btn-add {
|
|
192
|
-
width: 100%;
|
|
193
|
-
}
|
|
194
|
-
</style>
|
|
@@ -17,6 +17,13 @@
|
|
|
17
17
|
</template>
|
|
18
18
|
</ContentBlockAsset>
|
|
19
19
|
|
|
20
|
+
<v-switch
|
|
21
|
+
v-model="block.metadata.config.hide_background"
|
|
22
|
+
:label="
|
|
23
|
+
$t('windward.core.components.settings.image.hide_background')
|
|
24
|
+
"
|
|
25
|
+
></v-switch>
|
|
26
|
+
|
|
20
27
|
<v-form>
|
|
21
28
|
<v-text-field
|
|
22
29
|
v-model="block.metadata.config.alt"
|
|
@@ -69,6 +76,9 @@ export default {
|
|
|
69
76
|
if (_.isEmpty(this.block.metadata.config.alt)) {
|
|
70
77
|
this.block.metadata.config.alt = ''
|
|
71
78
|
}
|
|
79
|
+
if (!_.isBoolean(this.block.metadata.config.hide_background)) {
|
|
80
|
+
this.block.metadata.config.hide_background = false
|
|
81
|
+
}
|
|
72
82
|
if (_.isEmpty(this.block.metadata.config.aria_describedby)) {
|
|
73
83
|
this.block.metadata.config.aria_describedby = ''
|
|
74
84
|
}
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
>
|
|
39
39
|
<v-list-item
|
|
40
40
|
v-for="contentBlock in contentBlocks"
|
|
41
|
-
:key="contentBlock.
|
|
42
|
-
:value="contentBlock.
|
|
41
|
+
:key="contentBlock.block_id"
|
|
42
|
+
:value="contentBlock.block_id"
|
|
43
43
|
>
|
|
44
44
|
<template #default="{ active }">
|
|
45
45
|
<v-list-item-icon>
|
|
@@ -133,7 +133,8 @@ export default {
|
|
|
133
133
|
if (_.isEmpty(this.block.metadata.config.filename)) {
|
|
134
134
|
this.block.metadata.config.filename = ''
|
|
135
135
|
}
|
|
136
|
-
|
|
136
|
+
// _.isEmpty(true) returns false. use isBoolean to check if this prop exists
|
|
137
|
+
if (!_.isBoolean(this.block.metadata.config.include_prompts)) {
|
|
137
138
|
this.block.metadata.config.include_prompts = false
|
|
138
139
|
}
|
|
139
140
|
|
|
@@ -151,19 +152,19 @@ export default {
|
|
|
151
152
|
this.setLinkedBlocks()
|
|
152
153
|
},
|
|
153
154
|
setLinkedBlocks() {
|
|
154
|
-
const
|
|
155
|
+
const linkedBlockIds = []
|
|
155
156
|
|
|
156
157
|
// Loop over content blocks since they have the correct order we want to collate
|
|
157
158
|
this.contentBlocks.forEach((contentBlock) => {
|
|
158
159
|
// If the unsorted this.linked includes the block id, add it in the right order
|
|
159
|
-
if (this.linked.includes(contentBlock.
|
|
160
|
-
|
|
160
|
+
if (this.linked.includes(contentBlock.block_id)) {
|
|
161
|
+
linkedBlockIds.push(contentBlock.block_id)
|
|
161
162
|
}
|
|
162
163
|
})
|
|
163
164
|
|
|
164
165
|
// Set the linked and also body for convenience
|
|
165
|
-
this.block.metadata.config.linked =
|
|
166
|
-
this.block.body =
|
|
166
|
+
this.block.metadata.config.linked = linkedBlockIds
|
|
167
|
+
this.block.body = linkedBlockIds.join()
|
|
167
168
|
},
|
|
168
169
|
},
|
|
169
170
|
}
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<v-container>
|
|
4
|
+
<v-col class="pa-0">
|
|
5
|
+
<v-text-field
|
|
6
|
+
v-model="block.metadata.config.title"
|
|
7
|
+
id="title"
|
|
8
|
+
:label="
|
|
9
|
+
$t(
|
|
10
|
+
'windward.core.components.settings.scenario_choice.title'
|
|
11
|
+
)
|
|
12
|
+
"
|
|
13
|
+
></v-text-field>
|
|
14
|
+
<v-text-field
|
|
15
|
+
v-model="block.metadata.config.description"
|
|
16
|
+
id="description"
|
|
17
|
+
:label="
|
|
18
|
+
$t(
|
|
19
|
+
'windward.core.components.settings.scenario_choice.description'
|
|
20
|
+
)
|
|
21
|
+
"
|
|
22
|
+
></v-text-field>
|
|
23
|
+
<v-select
|
|
24
|
+
v-model="block.metadata.config.display_style"
|
|
25
|
+
:items="displayStyles"
|
|
26
|
+
:label="
|
|
27
|
+
$t(
|
|
28
|
+
'windward.core.components.settings.scenario_choice.display_style'
|
|
29
|
+
)
|
|
30
|
+
"
|
|
31
|
+
></v-select>
|
|
32
|
+
<v-switch
|
|
33
|
+
v-model="isLinked"
|
|
34
|
+
:label="
|
|
35
|
+
$t(
|
|
36
|
+
'windward.core.components.settings.scenario_choice.is_linked'
|
|
37
|
+
)
|
|
38
|
+
"
|
|
39
|
+
@click="onClickLinkSwitch"
|
|
40
|
+
></v-switch>
|
|
41
|
+
|
|
42
|
+
<v-switch
|
|
43
|
+
v-model="block.metadata.config.show_reset"
|
|
44
|
+
:label="
|
|
45
|
+
$t(
|
|
46
|
+
'windward.core.components.settings.scenario_choice.show_reset'
|
|
47
|
+
)
|
|
48
|
+
"
|
|
49
|
+
></v-switch>
|
|
50
|
+
|
|
51
|
+
<v-btn
|
|
52
|
+
color="primary"
|
|
53
|
+
outlined
|
|
54
|
+
block
|
|
55
|
+
:disabled="block.metadata.config.items.length > 26"
|
|
56
|
+
@click="onAddElement"
|
|
57
|
+
>
|
|
58
|
+
<v-icon>mdi-plus</v-icon>
|
|
59
|
+
<span v-if="block.metadata.config.items.length <= 26">
|
|
60
|
+
{{ $t('shared.forms.add') }}
|
|
61
|
+
</span>
|
|
62
|
+
<span v-else>
|
|
63
|
+
{{
|
|
64
|
+
$t(
|
|
65
|
+
'windward.core.components.settings.scenario_choice.over_item_limit'
|
|
66
|
+
)
|
|
67
|
+
}}
|
|
68
|
+
</span>
|
|
69
|
+
</v-btn>
|
|
70
|
+
</v-col>
|
|
71
|
+
<v-col>
|
|
72
|
+
<SortableExpansionPanel
|
|
73
|
+
v-model="block.metadata.config.items"
|
|
74
|
+
@click:close="onRemoveElement"
|
|
75
|
+
>
|
|
76
|
+
<template #header="{ item }">
|
|
77
|
+
<span v-if="item.title">{{ item.title }}</span>
|
|
78
|
+
<span v-else>
|
|
79
|
+
{{
|
|
80
|
+
$t(
|
|
81
|
+
'windward.core.components.settings.scenario_choice.no_title'
|
|
82
|
+
)
|
|
83
|
+
}}
|
|
84
|
+
</span>
|
|
85
|
+
</template>
|
|
86
|
+
<template #body="{ index }">
|
|
87
|
+
<v-text-field
|
|
88
|
+
v-model="block.metadata.config.items[index].title"
|
|
89
|
+
:id="'item-' + index + '-title'"
|
|
90
|
+
:label="
|
|
91
|
+
$t(
|
|
92
|
+
'windward.core.components.settings.scenario_choice.item_title'
|
|
93
|
+
)
|
|
94
|
+
"
|
|
95
|
+
></v-text-field>
|
|
96
|
+
|
|
97
|
+
<v-switch
|
|
98
|
+
v-model="block.metadata.config.items[index].correct"
|
|
99
|
+
:label="
|
|
100
|
+
$t(
|
|
101
|
+
'windward.core.components.settings.scenario_choice.correct_choice'
|
|
102
|
+
)
|
|
103
|
+
"
|
|
104
|
+
></v-switch>
|
|
105
|
+
|
|
106
|
+
<span>{{
|
|
107
|
+
$t(
|
|
108
|
+
'windward.core.components.settings.scenario_choice.item_text'
|
|
109
|
+
)
|
|
110
|
+
}}</span>
|
|
111
|
+
<TextEditor
|
|
112
|
+
v-model="block.metadata.config.items[index].body"
|
|
113
|
+
:height="200"
|
|
114
|
+
></TextEditor>
|
|
115
|
+
</template>
|
|
116
|
+
</SortableExpansionPanel>
|
|
117
|
+
</v-col>
|
|
118
|
+
</v-container>
|
|
119
|
+
|
|
120
|
+
<Dialog
|
|
121
|
+
v-model="showLinkDialog"
|
|
122
|
+
:trigger="false"
|
|
123
|
+
action-save
|
|
124
|
+
@click:save="onSetLinkedContent"
|
|
125
|
+
>
|
|
126
|
+
<template #title>{{
|
|
127
|
+
$t(
|
|
128
|
+
'windward.core.components.settings.scenario_choice.link_content'
|
|
129
|
+
)
|
|
130
|
+
}}</template>
|
|
131
|
+
|
|
132
|
+
<template #form="{ on, attrs }">
|
|
133
|
+
<v-form
|
|
134
|
+
v-model="linkDialogFormValid"
|
|
135
|
+
v-bind="attrs"
|
|
136
|
+
v-on="on"
|
|
137
|
+
@submit.prevent
|
|
138
|
+
@input="on['change:valid']($event)"
|
|
139
|
+
>
|
|
140
|
+
<v-text-field
|
|
141
|
+
v-model="block.metadata.config.link_text"
|
|
142
|
+
:rules="validation.existsRules"
|
|
143
|
+
:label="
|
|
144
|
+
$t(
|
|
145
|
+
'windward.core.components.settings.scenario_choice.link_text'
|
|
146
|
+
)
|
|
147
|
+
"
|
|
148
|
+
></v-text-field>
|
|
149
|
+
<v-treeview
|
|
150
|
+
v-model="selectedTreeviewContent"
|
|
151
|
+
selectable
|
|
152
|
+
selected-color="primary"
|
|
153
|
+
selection-type="independent"
|
|
154
|
+
return-object
|
|
155
|
+
open-all
|
|
156
|
+
:items="contentTree"
|
|
157
|
+
@input="onTreeChange(attrs.ref)"
|
|
158
|
+
>
|
|
159
|
+
<template #label="{ item }">
|
|
160
|
+
<span
|
|
161
|
+
:class="
|
|
162
|
+
selectedTreeviewContent.length === 0
|
|
163
|
+
? 'error--text'
|
|
164
|
+
: ''
|
|
165
|
+
"
|
|
166
|
+
>
|
|
167
|
+
{{ item.content.name_prefix }}
|
|
168
|
+
{{ item.content.name }}
|
|
169
|
+
</span>
|
|
170
|
+
</template>
|
|
171
|
+
</v-treeview>
|
|
172
|
+
</v-form>
|
|
173
|
+
</template>
|
|
174
|
+
</Dialog>
|
|
175
|
+
</div>
|
|
176
|
+
</template>
|
|
177
|
+
<script>
|
|
178
|
+
import _ from 'lodash'
|
|
179
|
+
import { mapGetters } from 'vuex'
|
|
180
|
+
import BaseContentSettings from '~/components/Content/Tool/BaseContentSettings.js'
|
|
181
|
+
import TextEditor from '~/components/Text/TextEditor'
|
|
182
|
+
import SortableExpansionPanel from '~/components/SortableExpansionPanel.vue'
|
|
183
|
+
import Dialog from '~/components/Dialog.vue'
|
|
184
|
+
|
|
185
|
+
export default {
|
|
186
|
+
name: 'ScenarioChoiceSettings',
|
|
187
|
+
components: {
|
|
188
|
+
SortableExpansionPanel,
|
|
189
|
+
TextEditor,
|
|
190
|
+
Dialog,
|
|
191
|
+
},
|
|
192
|
+
extends: BaseContentSettings,
|
|
193
|
+
computed: {
|
|
194
|
+
...mapGetters({
|
|
195
|
+
contentTree: 'content/getTree',
|
|
196
|
+
}),
|
|
197
|
+
},
|
|
198
|
+
data() {
|
|
199
|
+
return {
|
|
200
|
+
isLinked: false,
|
|
201
|
+
showLinkDialog: false,
|
|
202
|
+
linkDialogFormValid: false,
|
|
203
|
+
selectedTreeviewContent: [],
|
|
204
|
+
validation: {
|
|
205
|
+
existsRules: [
|
|
206
|
+
(v) =>
|
|
207
|
+
(!!v && !!this.block.metadata.config.link_content_id) ||
|
|
208
|
+
this.$t(
|
|
209
|
+
'windward.core.components.settings.scenario_choice.link_required'
|
|
210
|
+
),
|
|
211
|
+
],
|
|
212
|
+
},
|
|
213
|
+
displayStyles: [
|
|
214
|
+
{
|
|
215
|
+
text: this.$t(
|
|
216
|
+
'windward.core.components.settings.scenario_choice.style.letter'
|
|
217
|
+
),
|
|
218
|
+
value: 'letter',
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
text: this.$t(
|
|
222
|
+
'windward.core.components.settings.scenario_choice.style.number'
|
|
223
|
+
),
|
|
224
|
+
value: 'number',
|
|
225
|
+
},
|
|
226
|
+
],
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
beforeMount() {
|
|
230
|
+
if (_.isEmpty(this.block)) {
|
|
231
|
+
this.block = {}
|
|
232
|
+
}
|
|
233
|
+
if (_.isEmpty(this.block.body)) {
|
|
234
|
+
this.block.body = 'scenario choice'
|
|
235
|
+
}
|
|
236
|
+
if (_.isEmpty(this.block.metadata)) {
|
|
237
|
+
this.block.metadata = {}
|
|
238
|
+
}
|
|
239
|
+
if (_.isEmpty(this.block.metadata.config)) {
|
|
240
|
+
this.block.metadata.config = {}
|
|
241
|
+
}
|
|
242
|
+
if (_.isEmpty(this.block.metadata.config.title)) {
|
|
243
|
+
this.block.metadata.config.title = ''
|
|
244
|
+
}
|
|
245
|
+
if (_.isEmpty(this.block.metadata.config.description)) {
|
|
246
|
+
this.block.metadata.config.description = ''
|
|
247
|
+
}
|
|
248
|
+
if (_.isEmpty(this.block.metadata.config.display_style)) {
|
|
249
|
+
this.block.metadata.config.display_style = 'letter'
|
|
250
|
+
}
|
|
251
|
+
if (_.isEmpty(this.block.metadata.config.link_content_id)) {
|
|
252
|
+
this.block.metadata.config.link_content_id = null
|
|
253
|
+
}
|
|
254
|
+
if (_.isEmpty(this.block.metadata.config.link_text)) {
|
|
255
|
+
this.block.metadata.config.link_text = null
|
|
256
|
+
}
|
|
257
|
+
if (!_.isBoolean(this.block.metadata.config.show_reset)) {
|
|
258
|
+
this.block.metadata.config.show_reset = false
|
|
259
|
+
}
|
|
260
|
+
if (_.isEmpty(this.block.metadata.config.items)) {
|
|
261
|
+
this.block.metadata.config.items = []
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
mounted() {
|
|
265
|
+
if (this.block.metadata.config.items.length <= 0) {
|
|
266
|
+
this.onAddElement()
|
|
267
|
+
}
|
|
268
|
+
this.isLinked =
|
|
269
|
+
!_.isEmpty(this.block.metadata.config.link_content_id) &&
|
|
270
|
+
!_.isEmpty(this.block.metadata.config.link_text)
|
|
271
|
+
},
|
|
272
|
+
methods: {
|
|
273
|
+
onAddElement() {
|
|
274
|
+
const defaultObject = {
|
|
275
|
+
title: '',
|
|
276
|
+
body: '<p></p>',
|
|
277
|
+
correct: false,
|
|
278
|
+
}
|
|
279
|
+
this.block.metadata.config.items.push(defaultObject)
|
|
280
|
+
},
|
|
281
|
+
onRemoveElement(index) {
|
|
282
|
+
this.block.metadata.config.items.splice(index, 1)
|
|
283
|
+
},
|
|
284
|
+
onClickLinkSwitch() {
|
|
285
|
+
// Show the dialog to set the links
|
|
286
|
+
if (this.isLinked) {
|
|
287
|
+
this.showLinkDialog = true
|
|
288
|
+
this.$nextTick(() => {
|
|
289
|
+
this.isLinked = false
|
|
290
|
+
})
|
|
291
|
+
} else {
|
|
292
|
+
// clear the links
|
|
293
|
+
this.block.metadata.config.link_content_id = null
|
|
294
|
+
this.block.metadata.config.link_text = null
|
|
295
|
+
this.selectedTreeviewContent.splice(0)
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
onTreeChange(ref) {
|
|
299
|
+
// Enforce that only 1 item is selected at a time in the treeview
|
|
300
|
+
if (this.selectedTreeviewContent.length > 0) {
|
|
301
|
+
const last = this.selectedTreeviewContent.pop()
|
|
302
|
+
this.selectedTreeviewContent = [last]
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// Set the actual content id for this link
|
|
306
|
+
this.block.metadata.config.link_content_id = _.get(
|
|
307
|
+
this.selectedTreeviewContent,
|
|
308
|
+
'[0].content_id',
|
|
309
|
+
null
|
|
310
|
+
)
|
|
311
|
+
|
|
312
|
+
// Validate the other form forms
|
|
313
|
+
this.$refs[ref].validate()
|
|
314
|
+
|
|
315
|
+
// Overwrite the validation since treeview doesn't implement rules
|
|
316
|
+
if (this.block.metadata.config.link_text) {
|
|
317
|
+
this.$refs[ref].$emit('input', true)
|
|
318
|
+
} else {
|
|
319
|
+
this.$refs[ref].$emit('input', false)
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
onSetLinkedContent() {
|
|
323
|
+
this.isLinked =
|
|
324
|
+
!_.isEmpty(this.block.metadata.config.link_content_id) &&
|
|
325
|
+
!_.isEmpty(this.block.metadata.config.link_text)
|
|
326
|
+
},
|
|
327
|
+
},
|
|
328
|
+
}
|
|
329
|
+
</script>
|