26
26
</v-list-item-content >
27
27
<v-list-item-icon >
28
28
<v-icon @click =" editCategory(i)" >edit</v-icon >
29
- <v-icon @click =" upCategory(i)" >sort </v-icon >
30
- <v-icon @click =" downCategory(i)" >stop </v-icon >
29
+ <v-icon @click =" upCategory(i)" >mdi-arrow-up </v-icon >
30
+ <v-icon @click =" downCategory(i)" >mdi-arrow-down </v-icon >
31
31
<v-icon @click =" deleteCategory(i)" >delete</v-icon >
32
32
</v-list-item-icon >
33
33
</v-list-item >
71
71
<script >
72
72
import * as Blockly from ' blockly/core' ;
73
73
import ' blockly/blocks' ;
74
+ import ' blockly/python' ;
75
+
74
76
import * as blockly_it from ' blockly/msg/it' ;
75
77
import * as blockly_en from ' blockly/msg/en' ;
76
78
import * as blockly_fr from ' blockly/msg/fr' ;
77
- /*
79
+
78
80
import ' ../assets/js/blockly/blocks' ;
79
81
import * as bot_it from ' ../assets/js/blockly/bot_it.json' ;
80
82
import * as bot_en from ' ../assets/js/blockly/bot_en.json' ;
81
83
import * as bot_fr from ' ../assets/js/blockly/bot_fr.json' ;
82
- */
84
+
83
85
import i18n from ' ../i18n/index' ;
84
86
85
87
const locale = i18n .locale .substring (0 , 2 );
86
- /*
88
+
87
89
const coderbot_locales = {
88
90
it: bot_it .default ,
89
91
en: bot_en .default ,
90
92
fr: bot_fr .default
91
93
};
92
94
Blockly .Msg = { ... Blockly .Msg , ... coderbot_locales[locale] };
93
- */
95
+
94
96
const blockly_locales = {
95
97
it: blockly_it,
96
98
en: blockly_en,
97
99
fr: blockly_fr
98
100
};
99
101
Blockly .setLocale (blockly_locales[locale]);
100
102
101
- // Blockly.Blocks.CoderBotSettings.instrumentlist = [];
102
- // Blockly.Blocks.CoderBotSettings.animalist = [];
103
+ Blockly .Blocks .CoderBotSettings .instrumentlist = [];
104
+ Blockly .Blocks .CoderBotSettings .animalist = [];
103
105
104
106
export default {
105
- components: {
106
- },
107
+ props: [' toolbox_in' ],
107
108
data : () => ({
108
109
CB : process .env .CB_ENDPOINT + process .env .APIv2 ,
109
110
CBv1: process .env .CB_ENDPOINT ,
110
111
workspace_toolbox_editor: null ,
111
112
workspace_toolbox_test: null ,
113
+ in_changing_category: true ,
112
114
toolbox: {
113
115
kind: ' categoryToolbox' ,
114
116
contents: []
@@ -122,10 +124,11 @@ export default {
122
124
category_index: null
123
125
}),
124
126
125
- computed: {
126
- },
127
-
128
127
mounted () {
128
+ if (this .toolbox_in ) {
129
+ this .toolbox = this .toolbox_in ;
130
+ }
131
+
129
132
this .loadMusicPackages ();
130
133
131
134
const axios = this .$axios ;
@@ -136,6 +139,9 @@ export default {
136
139
const settings = response .data ;
137
140
this .settings = settings;
138
141
this .initBlockly (settings);
142
+ if (this .toolbox .contents .length ) {
143
+ this .onChangeCategory ();
144
+ }
139
145
});
140
146
},
141
147
beforeRouteLeave (to , from , next ) {
@@ -165,22 +171,20 @@ export default {
165
171
},
166
172
167
173
onChangeCategory () {
168
- this .workspace_toolbox_editor .clear ();
169
- this .in_changing_category = true ;
170
- this .toolbox .contents [this .category_index ].contents .forEach ((block ) => {
171
- const parentBlock = this .workspace_toolbox_editor .newBlock (block .type );
172
- parentBlock .initSvg ();
173
- parentBlock .render ();
174
- parentBlock .bumpNeighbours ();
175
- });
176
- /* const blocks = this.workspace_toolbox_editor.getTopBlocks();
177
- let y = 0;
178
- for (let i = 0; i < blocks.length; i++) {
179
- blocks[i].moveTo(0, y);
180
- y += blocks[i].getHeightWidth().height;
181
- y += 10; // buffer
182
- } */
183
- this .in_changing_category = false ;
174
+ if (this .category_index != null
175
+ && this .workspace_toolbox_editor != null ) {
176
+ this .in_changing_category = true ;
177
+ this .workspace_toolbox_editor .clear ();
178
+ let y = 0 ;
179
+ this .toolbox .contents [this .category_index ].contents .forEach ((block ) => {
180
+ const parentBlock = this .workspace_toolbox_editor .newBlock (block .type );
181
+ parentBlock .initSvg ();
182
+ parentBlock .render ();
183
+ parentBlock .moveTo (new Blockly.utils.Coordinate (5 , y));
184
+ y += parentBlock .getHeightWidth ().height + 10 ;
185
+ });
186
+ this .in_changing_category = false ;
187
+ }
184
188
},
185
189
186
190
addCategory () {
@@ -201,6 +205,7 @@ export default {
201
205
this .category_index = i;
202
206
this .category = this .toolbox .contents [i];
203
207
this .category_edit = true ;
208
+ this .category_dialog = true ;
204
209
},
205
210
206
211
saveCategory () {
@@ -236,7 +241,7 @@ export default {
236
241
// Extend the default blocks set
237
242
this .blocksExtensions ();
238
243
239
- const toolbox_full = require (' ../assets/toolbox_less .xml' );
244
+ const toolbox_full = require (' ../assets/toolbox_adv .xml' );
240
245
241
246
// Clean the base64 encoding of the resource, removing meta infos
242
247
const b64Toolbox = toolbox_full .substring (toolbox_full .indexOf (' ,' ) + 1 ).toString ();
@@ -264,6 +269,7 @@ export default {
264
269
},
265
270
},
266
271
);
272
+
267
273
// Initialise Blockly Instance Toolbox Editor
268
274
this .workspace_toolbox_test = Blockly .inject (
269
275
// Blockly container
@@ -289,9 +295,10 @@ export default {
289
295
const toolbox = this .toolbox ;
290
296
const state = this ;
291
297
function onToolboxEditorChange (event ) {
292
- if (event .type == Blockly .Events .BLOCK_CREATE
293
- || (event .type == Blockly .Events .BLOCK_DELETE && state .in_changing_category == false )) {
294
- // || event.type == Blockly.Events.BLOCK_MOVE) {
298
+ if ((event .type == Blockly .Events .BLOCK_CREATE
299
+ || event .type == Blockly .Events .BLOCK_DELETE
300
+ || event .type == Blockly .Events .BLOCK_MOVE )
301
+ && state .in_changing_category == false ) {
295
302
toolbox .contents [state .category_index ].contents = [];
296
303
workspace_toolbox_editor .getTopBlocks (true ).forEach ((ablock ) => {
297
304
toolbox .contents [state .category_index ].contents .push ({
0 commit comments