@windward/games 0.5.0 → 0.6.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.
@@ -1,119 +1,119 @@
1
1
  <template>
2
2
  <div>
3
- <v-form ref="form" v-model="valid" v-if="!loading">
4
- <v-container class="pa-0">
5
- <v-text-field
6
- ref="title"
7
- v-model="block.metadata.config.title"
8
- outlined
9
- :autofocus="true"
10
- :counter="50"
11
- :label="
12
- $t(
13
- 'windward.games.components.settings.bucket_game.form.title'
14
- )
15
- "
16
- :disabled="render"
17
- ></v-text-field>
18
- <v-textarea
19
- v-model="block.metadata.config.instructions"
20
- outlined
21
- auto-grow
22
- :counter="255"
23
- :label="
24
- $t(
25
- 'windward.games.components.settings.bucket_game.form.instructions'
26
- )
27
- "
28
- :disabled="render"
29
- ></v-textarea>
30
- </v-container>
31
- <v-divider class="my-4 primary"></v-divider>
32
- <v-container class="pa-0">
33
- <p>
3
+ <v-container class="pa-0">
4
+ <v-text-field
5
+ ref="title"
6
+ v-model="block.metadata.config.title"
7
+ outlined
8
+ :autofocus="true"
9
+ :rules="validation.shortInputRules"
10
+ :counter="50"
11
+ :label="
12
+ $t(
13
+ 'windward.games.components.settings.bucket_game.form.title'
14
+ )
15
+ "
16
+ :disabled="render"
17
+ ></v-text-field>
18
+ <v-textarea
19
+ v-model="block.metadata.config.instructions"
20
+ outlined
21
+ auto-grow
22
+ :rules="validation.instructionRule"
23
+ :counter="255"
24
+ :label="
25
+ $t(
26
+ 'windward.games.components.settings.bucket_game.form.instructions'
27
+ )
28
+ "
29
+ :disabled="render"
30
+ ></v-textarea>
31
+ </v-container>
32
+ <v-divider class="my-4 primary"></v-divider>
33
+ <v-container class="pa-0">
34
+ <p>
35
+ {{
36
+ $t(
37
+ 'windward.games.components.settings.sorting_game.sortable_items'
38
+ )
39
+ }}
40
+ </p>
41
+ <SortableExpansionPanel
42
+ v-model="block.metadata.config.answer"
43
+ :disabled="render"
44
+ @click:close="onDelete($event)"
45
+ >
46
+ <template #header="{ item, index }">
34
47
  {{
35
- $t(
36
- 'windward.games.components.settings.sorting_game.sortable_items'
37
- )
48
+ item.value
49
+ ? block.metadata.config.answer[index].value
50
+ : $t(
51
+ 'windward.games.components.settings.bucket_game.form.enter_text'
52
+ )
38
53
  }}
39
- </p>
40
- <SortableExpansionPanel
41
- v-model="block.metadata.config.answer"
54
+ </template>
55
+ <template #body="{ item, index }">
56
+ <v-container>
57
+ <p class="p-label">
58
+ {{
59
+ $t(
60
+ 'windward.games.components.settings.sorting_game.word'
61
+ )
62
+ }}
63
+ </p>
64
+ <v-textarea
65
+ v-model="block.metadata.config.answer[index].value"
66
+ :rules="validation.sortableWordRule"
67
+ :counter="155"
68
+ outlined
69
+ :autofocus="true"
70
+ :disabled="render"
71
+ ></v-textarea>
72
+ </v-container>
73
+ </template>
74
+ </SortableExpansionPanel>
75
+ </v-container>
76
+ <v-container class="pa-0">
77
+ <v-row justify="center" class="my-4">
78
+ <v-btn
79
+ color="primary"
80
+ elevation="0"
42
81
  :disabled="render"
43
- @click:close="onDelete($event)"
82
+ @click="onAddElement"
44
83
  >
45
- <template #header="{ item, index }">
46
- {{
47
- item.value
48
- ? block.metadata.config.answer[index].value
49
- : $t(
50
- 'windward.games.components.settings.bucket_game.form.enter_text'
51
- )
52
- }}
53
- </template>
54
- <template #body="{ item, index }">
55
- <v-container>
56
- <p class="p-label">
57
- {{
58
- $t(
59
- 'windward.games.components.settings.sorting_game.word'
60
- )
61
- }}
62
- </p>
63
- <v-textarea
64
- v-model="
65
- block.metadata.config.answer[index].value
66
- "
67
- outlined
68
- :autofocus="true"
69
- :disabled="render"
70
- ></v-textarea>
71
- </v-container>
72
- </template>
73
- </SortableExpansionPanel>
74
- </v-container>
75
- <v-container class="pa-0">
76
- <v-row justify="center" class="my-4">
77
- <v-btn
78
- color="primary"
79
- elevation="0"
80
- :disabled="render"
81
- @click="onAddElement"
82
- >
83
- <v-icon>mdi-plus</v-icon>
84
- {{
85
- $t(
86
- 'windward.games.components.settings.bucket_game.form.add_answer'
87
- )
88
- }}
89
- </v-btn>
90
- </v-row>
91
- <v-textarea
92
- v-model="block.metadata.config.feedback_correct"
93
- outlined
94
- auto-grow
95
- :counter="255"
96
- :label="
97
- $t(
98
- 'windward.games.components.settings.bucket_game.form.feedback.correct'
99
- )
100
- "
101
- :disabled="render"
102
- ></v-textarea>
103
- <v-textarea
104
- v-model="block.metadata.config.feedback_incorrect"
105
- outlined
106
- auto-grow
107
- :counter="255"
108
- :label="
84
+ <v-icon>mdi-plus</v-icon>
85
+ {{
109
86
  $t(
110
- 'windward.games.components.settings.bucket_game.form.feedback.incorrect'
87
+ 'windward.games.components.settings.bucket_game.form.add_answer'
111
88
  )
112
- "
113
- :disabled="render"
114
- ></v-textarea>
115
- </v-container>
116
- </v-form>
89
+ }}
90
+ </v-btn>
91
+ </v-row>
92
+ <v-textarea
93
+ v-model="block.metadata.config.feedback_correct"
94
+ outlined
95
+ auto-grow
96
+ :counter="255"
97
+ :label="
98
+ $t(
99
+ 'windward.games.components.settings.bucket_game.form.feedback.correct'
100
+ )
101
+ "
102
+ :disabled="render"
103
+ ></v-textarea>
104
+ <v-textarea
105
+ v-model="block.metadata.config.feedback_incorrect"
106
+ outlined
107
+ auto-grow
108
+ :counter="255"
109
+ :label="
110
+ $t(
111
+ 'windward.games.components.settings.bucket_game.form.feedback.incorrect'
112
+ )
113
+ "
114
+ :disabled="render"
115
+ ></v-textarea>
116
+ </v-container>
117
117
  <div v-if="loading" class="text-center">
118
118
  <v-progress-circular
119
119
  :size="70"
@@ -148,6 +148,9 @@ export default {
148
148
  'windward.games.components.settings.sorting_game.sortable_game'
149
149
  )
150
150
  }
151
+ if (_.isEmpty(this.block.metadata.config.instructions)) {
152
+ this.block.metadata.config.instructions = ''
153
+ }
151
154
  if (_.isEmpty(this.block.metadata.config.feedback_correct)) {
152
155
  this.block.metadata.config.feedback_correct = this.$t(
153
156
  'windward.games.components.settings.bucket_game.form.feedback.correct_default'
@@ -182,6 +185,32 @@ export default {
182
185
  },
183
186
  ],
184
187
  cursor: null,
188
+ validation: {
189
+ shortInputRules: [
190
+ (v) =>
191
+ v.length <= 50 ||
192
+ this.$t(
193
+ 'windward.games.shared.settings.errors.input_limitations',
194
+ [50]
195
+ ),
196
+ ],
197
+ instructionRule: [
198
+ (v) =>
199
+ v.length <= 255 ||
200
+ this.$t(
201
+ 'windward.games.shared.settings.errors.input_limitations',
202
+ [255]
203
+ ),
204
+ ],
205
+ sortableWordRule: [
206
+ (v) =>
207
+ v.length <= 155 ||
208
+ this.$t(
209
+ 'windward.games.shared.settings.errors.input_limitations',
210
+ [155]
211
+ ),
212
+ ],
213
+ },
185
214
  }
186
215
  },
187
216
  methods: {
@@ -1,137 +1,139 @@
1
1
  <template>
2
2
  <div>
3
- <v-form ref="form" v-model="valid" v-if="!loading">
4
- <v-container class="pa-0">
5
- <v-text-field
6
- ref="title"
7
- v-model="block.metadata.config.title"
8
- :counter="50"
9
- outlined
10
- :autofocus="true"
11
- :label="
12
- $t(
13
- 'windward.games.components.settings.word_jumble.title_input'
14
- )
15
- "
16
- :disabled="render"
17
- ></v-text-field>
18
- <v-textarea
19
- v-model="block.metadata.config.instructions"
20
- outlined
21
- auto-grow
22
- :label="
23
- $t(
24
- 'windward.games.components.settings.word_jumble.instructions'
25
- )
26
- "
27
- :disabled="render"
28
- ></v-textarea>
29
- </v-container>
30
- <v-divider class="my-4 primary"></v-divider>
31
- <v-container class="pa-0">
32
- <p>
3
+ <v-container class="pa-0">
4
+ <v-text-field
5
+ ref="title"
6
+ v-model="block.metadata.config.title"
7
+ :counter="50"
8
+ :rules="validation.shortInputRules"
9
+ outlined
10
+ :autofocus="true"
11
+ :label="
12
+ $t(
13
+ 'windward.games.components.settings.word_jumble.title_input'
14
+ )
15
+ "
16
+ :disabled="render"
17
+ ></v-text-field>
18
+ <v-textarea
19
+ v-model="block.metadata.config.instructions"
20
+ :rules="validation.instructionRule"
21
+ :counter="255"
22
+ outlined
23
+ auto-grow
24
+ :label="
25
+ $t(
26
+ 'windward.games.components.settings.word_jumble.instructions'
27
+ )
28
+ "
29
+ :disabled="render"
30
+ ></v-textarea>
31
+ </v-container>
32
+ <v-divider class="my-4 primary"></v-divider>
33
+ <v-container class="pa-0">
34
+ <p>
35
+ {{
36
+ $t(
37
+ 'windward.games.components.settings.word_jumble.word_jumble'
38
+ )
39
+ }}
40
+ </p>
41
+ <SortableExpansionPanel
42
+ v-model="block.metadata.config.words"
43
+ v-bind:currentPanel.sync="block.metadata.config.currentWord"
44
+ :disabled="render"
45
+ @click:close="onDelete($event)"
46
+ >
47
+ <template #header="{ item, index }">
33
48
  {{
34
- $t(
35
- 'windward.games.components.settings.word_jumble.word_jumble'
36
- )
49
+ item.value
50
+ ? item.value
51
+ : $t(
52
+ 'windward.games.components.settings.word_jumble.click'
53
+ )
37
54
  }}
38
- </p>
39
- <SortableExpansionPanel
40
- v-model="block.metadata.config.words"
41
- v-bind:currentPanel.sync="block.metadata.config.currentWord"
55
+ </template>
56
+ <template #body="{ item, index }">
57
+ <v-container>
58
+ <v-flex xs12>
59
+ <p class="p-label">
60
+ {{
61
+ $t(
62
+ 'windward.games.components.settings.word_jumble.word_jumble'
63
+ )
64
+ }}
65
+ </p>
66
+ <v-text-field
67
+ v-model="
68
+ block.metadata.config.words[index].value
69
+ "
70
+ :rules="validation.shortInputRules"
71
+ :counter="50"
72
+ outlined
73
+ :disabled="render"
74
+ ></v-text-field>
75
+ </v-flex>
76
+ <v-flex xs12>
77
+ <p class="p-label">
78
+ {{
79
+ $t(
80
+ 'windward.games.components.settings.word_jumble.hint'
81
+ )
82
+ }}
83
+ </p>
84
+ <v-textarea
85
+ v-model="
86
+ block.metadata.config.words[index].hint
87
+ "
88
+ :rules="validation.hintRule"
89
+ :counter="155"
90
+ outlined
91
+ :disabled="render"
92
+ ></v-textarea>
93
+ </v-flex>
94
+ </v-container>
95
+ </template>
96
+ </SortableExpansionPanel>
97
+ </v-container>
98
+ <v-container class="pa-0">
99
+ <v-row justify="center" class="my-4">
100
+ <v-btn
101
+ color="primary"
102
+ elevation="0"
42
103
  :disabled="render"
43
- @click:close="onDelete($event)"
104
+ @click="onAddWord"
44
105
  >
45
- <template #header="{ item, index }">
46
- {{
47
- item.value
48
- ? item.value
49
- : $t(
50
- 'windward.games.components.settings.word_jumble.click'
51
- )
52
- }}
53
- </template>
54
- <template #body="{ item, index }">
55
- <v-container>
56
- <v-flex xs12>
57
- <p class="p-label">
58
- {{
59
- $t(
60
- 'windward.games.components.settings.word_jumble.word_jumble'
61
- )
62
- }}
63
- </p>
64
- <v-textarea
65
- v-model="
66
- block.metadata.config.words[index].value
67
- "
68
- outlined
69
- :autofocus="true"
70
- :disabled="render"
71
- ></v-textarea>
72
- </v-flex>
73
- <v-flex xs12>
74
- <p class="p-label">
75
- {{
76
- $t(
77
- 'windward.games.components.settings.word_jumble.hint'
78
- )
79
- }}
80
- </p>
81
- <v-textarea
82
- v-model="
83
- block.metadata.config.words[index].hint
84
- "
85
- outlined
86
- :disabled="render"
87
- ></v-textarea>
88
- </v-flex>
89
- </v-container>
90
- </template>
91
- </SortableExpansionPanel>
92
- </v-container>
93
- <v-container class="pa-0">
94
- <v-row justify="center" class="my-4">
95
- <v-btn
96
- color="primary"
97
- elevation="0"
98
- :disabled="render"
99
- @click="onAddWord"
100
- >
101
- <v-icon>mdi-plus</v-icon>
102
- {{
103
- $t(
104
- 'windward.games.components.settings.word_jumble.add'
105
- )
106
- }}
107
- </v-btn>
108
- </v-row>
109
- <v-textarea
110
- ref="title"
111
- v-model="block.metadata.config.feedback_correct"
112
- outlined
113
- auto-grow
114
- :counter="50"
115
- :label="
116
- $t(
117
- 'windward.games.components.settings.word_jumble.feedback_correct'
118
- )
119
- "
120
- :disabled="render"
121
- ></v-textarea>
122
- <v-textarea
123
- v-model="block.metadata.config.feedback_incorrect"
124
- outlined
125
- auto-grow
126
- :label="
127
- $t(
128
- 'windward.games.components.settings.word_jumble.feedback_incorrect'
129
- )
130
- "
131
- :disabled="render"
132
- ></v-textarea>
133
- </v-container>
134
- </v-form>
106
+ <v-icon>mdi-plus</v-icon>
107
+ {{
108
+ $t('windward.games.components.settings.word_jumble.add')
109
+ }}
110
+ </v-btn>
111
+ </v-row>
112
+ <v-textarea
113
+ ref="title"
114
+ v-model="block.metadata.config.feedback_correct"
115
+ outlined
116
+ auto-grow
117
+ :counter="50"
118
+ :label="
119
+ $t(
120
+ 'windward.games.components.settings.word_jumble.feedback_correct'
121
+ )
122
+ "
123
+ :disabled="render"
124
+ ></v-textarea>
125
+ <v-textarea
126
+ v-model="block.metadata.config.feedback_incorrect"
127
+ outlined
128
+ auto-grow
129
+ :label="
130
+ $t(
131
+ 'windward.games.components.settings.word_jumble.feedback_incorrect'
132
+ )
133
+ "
134
+ :disabled="render"
135
+ ></v-textarea>
136
+ </v-container>
135
137
  <div v-if="loading" class="text-center">
136
138
  <v-progress-circular
137
139
  :size="70"
@@ -193,6 +195,32 @@ export default {
193
195
  return {
194
196
  valid: true,
195
197
  loading: false,
198
+ validation: {
199
+ shortInputRules: [
200
+ (v) =>
201
+ v.length <= 50 ||
202
+ this.$t(
203
+ 'windward.games.shared.settings.errors.input_limitations',
204
+ [50]
205
+ ),
206
+ ],
207
+ instructionRule: [
208
+ (v) =>
209
+ v.length <= 255 ||
210
+ this.$t(
211
+ 'windward.games.shared.settings.errors.input_limitations',
212
+ [255]
213
+ ),
214
+ ],
215
+ hintRule: [
216
+ (v) =>
217
+ v.length <= 155 ||
218
+ this.$t(
219
+ 'windward.games.shared.settings.errors.input_limitations',
220
+ [155]
221
+ ),
222
+ ],
223
+ },
196
224
  }
197
225
  },
198
226
  methods: {
@@ -202,25 +230,27 @@ export default {
202
230
  })
203
231
  },
204
232
  shuffle(str) {
205
- var a = str
206
- var newArr = []
207
- var neww = ''
208
- var text = a.replace(/[\r\n]/g, '').split(' ')
233
+ if (str) {
234
+ var a = str
235
+ var newArr = []
236
+ var neww = ''
237
+ var text = a.replace(/[\r\n]/g, '').split(' ')
209
238
 
210
- text.map(function (v) {
211
- v.split('').map(function () {
212
- var hash = Math.floor(Math.random() * v.length)
213
- neww += v[hash]
214
- v = v.replace(v.charAt(hash), '')
239
+ text.map(function (v) {
240
+ v.split('').map(function () {
241
+ var hash = Math.floor(Math.random() * v.length)
242
+ neww += v[hash]
243
+ v = v.replace(v.charAt(hash), '')
244
+ })
245
+ newArr.push(neww)
246
+ neww = ''
215
247
  })
216
- newArr.push(neww)
217
- neww = ''
218
- })
219
- var x = newArr.map((v) => v.split('').join(' ')).join('\n')
220
- str = x
221
- .split('')
222
- .map((v) => v.toUpperCase())
223
- .join('')
248
+ var x = newArr.map((v) => v.split('').join(' ')).join('\n')
249
+ str = x
250
+ .split('')
251
+ .map((v) => v.toUpperCase())
252
+ .join('')
253
+ }
224
254
  return str
225
255
  },
226
256
  onAddWord() {
@@ -11,4 +11,7 @@ export default {
11
11
  seven_strikes_manager: 'Seven Strikes Manager',
12
12
  crossword_puzzle_manager: 'Crossword Puzzle Manager',
13
13
  },
14
+ errors: {
15
+ input_limitations: 'Must be less than {0} characters.'
16
+ },
14
17
  }
@@ -11,4 +11,7 @@ export default {
11
11
  seven_strikes_manager: 'Gerente de los Siete Golpes',
12
12
  crossword_puzzle_manager: 'Administrador de crucigramas',
13
13
  },
14
+ errors: {
15
+ input_limitations: 'Måste vara mindre än {0} tecken.',
16
+ },
14
17
  }
@@ -11,4 +11,7 @@ export default {
11
11
  seven_strikes_manager: 'Seven Strikes Manager',
12
12
  crossword_puzzle_manager: 'Crossword Puzzle Manager',
13
13
  },
14
+ errors: {
15
+ input_limitations: 'Debe tener menos de {0} caracteres.'
16
+ },
14
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@windward/games",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Windward UI Plugin Games",
5
5
  "main": "plugin.js",
6
6
  "scripts": {