32
32
<h3 class =" text-xs-left" >{{ $t("message.activity_data") }} </h3 >
33
33
<v-card >
34
34
<v-form class =" cardContent" >
35
- <v-text-field v-model =" activity.name" label =" Nome" required ></v-text-field >
36
- <v-text-field v-model =" activity.description" v-bind:label =" $t('message.activity_description')" >
35
+ <v-text-field v-model =" activity.name" label =" Nome" required
36
+ @input =" $v.activity.name.$touch"
37
+ v-bind:error-messages =" $v.activity.name.$error == true ? $t('message.validation_alphanum') : null"
38
+ ></v-text-field >
39
+ <v-text-field v-model =" activity.description" v-bind:label =" $t('message.activity_description')"
40
+ @input =" $v.activity.description.$touch"
41
+ v-bind:error-messages =" $v.activity.description.$error == true ? $t('message.validation_alphanum') : null"
42
+ >
37
43
</v-text-field >
38
- <v-select v-model =" defaultView" :items =" viste"
39
- v-bind:label =" $t('message.activity_predefined_view')" required ></v-select >
44
+ <v-select v-model =" activity.defaultView" :items =" viste"
45
+ v-bind:label =" $t('message.activity_predefined_view')" required
46
+ @input =" $v.activity.defaultView.$touch"
47
+ ></v-select >
40
48
</v-form >
41
49
</v-card >
42
50
<br ><br >
65
73
<v-card >
66
74
<div class =" cardContent" >
67
75
<span v-bind:style =" bodyUIstyleObj" >Lorem ipsum dolor sit amet</span >
68
- <v-radio-group v-model =" activity.bodyFont" column >
76
+ <v-radio-group v-model =" activity.bodyFont" column
77
+ v-bind:label =" $t('message.activity_predefined_view')" required
78
+ @change =" $v.activity.bodyFont.$touch"
79
+ >
69
80
<v-radio label =" Roboto" value =" Roboto" ></v-radio >
70
81
<v-radio label =" Open Sans" value =" opensans" ></v-radio >
71
82
<!--
80
91
<v-card >
81
92
<div class =" cardContent" >
82
93
<span v-bind:style =" codeUIstyleObj" >function life() { return 42; }</span >
83
- <v-radio-group v-model =" activity.codeFont" column >
94
+ <v-radio-group v-model =" activity.codeFont" column
95
+ @change =" $v.activity.codeFont.$touch"
96
+ >
84
97
<v-radio label =" Ubuntu Mono" value =" ubuntumono" ></v-radio >
85
98
<v-radio label =" Roboto Mono" value =" robotomono" ></v-radio >
86
99
</v-radio-group >
87
100
</div >
88
101
</v-card >
89
102
<br ><br >
90
- <!--
91
- <h3 class="text-xs-left">Lingua</h3>
103
+ <h3 class =" text-xs-left" >{{ $t("message.activity_locale") }}</h3 >
92
104
<v-card >
93
105
<div class =" cardContent" >
94
- <v-select v-model="uiLang" :items="langs" label="Lingua Interfaccia" required></v-select>
95
- <v-select v-model="blocklyLang" :items="langs" label="Lingua Blocchi" required></v-select>
106
+ <v-select v-model =" activity.uiLang" :items =" langs" v-bind:label =" $t('message.activity_locale')" required
107
+ @change =" $v.activity.uiLang.$touch"
108
+ ></v-select >
96
109
</div >
97
110
</v-card >
98
111
<br ><br >
99
- -->
100
112
<h3 class =" text-xs-left" >{{ $t("message.activity_programing_title") }}</h3 >
101
113
<v-card >
102
114
<div class =" cardContent" >
117
129
-->
118
130
<v-flex >
119
131
<v-checkbox v-model =" activity.autoRecVideo"
120
- v-bind:label =" $t('message.activity_auto_rec_video')" ></v-checkbox >
132
+ v-bind:label =" $t('message.activity_auto_rec_video')"
133
+ @input =" $v.activity.autoRecVideo.$touch"
134
+ ></v-checkbox >
121
135
</v-flex >
122
136
<v-flex >
123
137
<v-text-field v-model =" activity.maxBlocks"
124
- v-bind:label =" $t('message.activity_blocks_max_blocks')" ></v-text-field >
138
+ v-bind:label =" $t('message.activity_blocks_max_blocks')"
139
+ @input =" $v.activity.maxBlocks.$touch"
140
+ v-bind:error-messages =" $v.activity.maxBlocks.$error == true ? $t('message.validation_integer_positive') : null"
141
+ ></v-text-field >
125
142
</v-flex >
126
143
</v-layout >
127
144
</div >
167
184
</template >
168
185
</v-app-bar >
169
186
<br >
170
- <v-switch v-bind:label =" $t('message.activity_lateral_menu_icon')" v-model =" activity.drawerEnabled" >
187
+ <v-switch v-bind:label =" $t('message.activity_lateral_menu_icon')" v-model =" activity.drawerEnabled"
188
+ @change =" $v.activity.drawerEnabled.$touch"
189
+ >
171
190
</v-switch >
172
- <v-switch v-bind:label =" $t('message.activity_name')" v-model =" activity.showName" ></v-switch >
191
+ <v-switch v-bind:label =" $t('message.activity_name')" v-model =" activity.showName"
192
+ @change =" $v.activity.showName.$touch"
193
+ ></v-switch >
173
194
<br >
174
195
<h3 > {{ $t("message.activity_toolbar_buttons") }} </h3 >
175
196
<v-btn @click =" addButton()" outlined color =" green" >
302
323
import Swatches from ' vue-swatches' ;
303
324
import ' vue-swatches/dist/vue-swatches.css' ;
304
325
326
+ import {
327
+ alphaNum , integer ,
328
+ } from ' vuelidate/lib/validators' ;
329
+
305
330
// import wsFactory from '../components/wsFactory';
306
331
import sidebar from ' ../components/Sidebar' ;
307
332
@@ -311,6 +336,14 @@ export default {
311
336
Swatches,
312
337
sidebar /* , wsFactory */
313
338
},
339
+ beforeRouteLeave (to , from , next ) {
340
+ if (this .$v .$anyDirty ) {
341
+ this .router_next = next;
342
+ this .confirm_exit_dialog = true ;
343
+ } else {
344
+ next ();
345
+ }
346
+ },
314
347
computed: {
315
348
prefix () {
316
349
if (this .activity .name != null && this .activity .name != ' ' ) return ' -' ;
@@ -394,6 +427,8 @@ export default {
394
427
snackbarText: ' ' ,
395
428
b: 0 ,
396
429
activity: {
430
+ uiLang: null ,
431
+ defaultView: null ,
397
432
exec: {
398
433
camera: true ,
399
434
log: true ,
@@ -427,6 +462,10 @@ export default {
427
462
},
428
463
],
429
464
actions: [
465
+ {
466
+ text: this .$i18n .t (' message.activity_program_clear' ),
467
+ value: ' clearProgram'
468
+ },
430
469
{
431
470
text: this .$i18n .t (' message.activity_program_run' ),
432
471
value: ' runProgram'
@@ -476,8 +515,6 @@ export default {
476
515
this .$i18n .t (' message.activity_lang_english' ),
477
516
this .$i18n .t (' message.activity_lang_french' ),
478
517
],
479
- uiLang: ' Italiano' ,
480
- blocklyLang: ' Inglese' ,
481
518
editHistory: false ,
482
519
navHistory: false ,
483
520
experimental: true ,
@@ -491,8 +528,6 @@ export default {
491
528
ar: false ,
492
529
// drawer: null,
493
530
source: null ,
494
- msg: ' Welcome to Your Vue.js App' ,
495
- defaultView: ' blocks' ,
496
531
viste: [
497
532
{
498
533
text: this .$i18n .t (' message.activity_views_blocks' ),
@@ -515,6 +550,26 @@ export default {
515
550
unwatch: null
516
551
};
517
552
},
553
+ validations () {
554
+ return {
555
+ activity: {
556
+ uiLang: { },
557
+ defaultView: { },
558
+ drawerEnabled: { },
559
+ showName: { },
560
+ buttons: { },
561
+ fontSize: { },
562
+ capsSwitch: { },
563
+ bodyFont: { },
564
+ codeFont: { },
565
+ viewSource: { },
566
+ autoRecVideo: { },
567
+ name: { required: true , alphaNum },
568
+ description: { alphaNum },
569
+ maxBlocks: { integer, minValue: 0 },
570
+ },
571
+ };
572
+ },
518
573
mounted () {
519
574
if (this .$route .params .name ) {
520
575
const axios = this .$axios ;
@@ -550,12 +605,13 @@ export default {
550
605
axios .post (` ${ CB } /saveActivity` , {
551
606
activity: this .activity ,
552
607
}).then (() => {
553
- this .snackbarText = this .$i18n .t (' activity_saved' );
608
+ this .snackbarText = this .$i18n .t (' message. activity_saved' );
554
609
this .snackbar = true ;
555
610
this .saved = true ;
611
+ this .$v .$reset ();
556
612
});
557
613
} else {
558
- this .snackbarText = this .$i18n .t (' activity_save_error' );
614
+ this .snackbarText = this .$i18n .t (' message. activity_save_error' );
559
615
this .snackbar = true ;
560
616
}
561
617
},
0 commit comments