Skip to content

Commit 2bf5158

Browse files
committed
Do BlockParamEditor a bit
1 parent 61f4586 commit 2bf5158

File tree

4 files changed

+32
-19
lines changed

4 files changed

+32
-19
lines changed

src/nico/src/nico/components/Block.vue

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
11
<template lang="pug">
2-
draggable.dragArea(tag="ul" :list="children" :group="group")
2+
draggable.dragArea(tag="ul" :list="children" :group="group" :clone="onClone")
33
li(v-for="child in children")
44
div(v-if="child.type === 'if'")
55
| if {{ child.condition }}
66
Block.child(:children="child.children")
77
div(v-else-if="child.type === 'callMars'")
8-
| call {{ child.func }}
8+
| {{ child.func }}
9+
BlockParamEditor(
10+
v-for="(param, i) in marsFuncs.find(func => child.func === func.name).parameters"
11+
v-model="child.params[i]"
12+
:type="param"
13+
)
914
</template>
1015

1116
<script>
1217
import draggable from 'vuedraggable'
18+
import BlockParamEditor from "./BlockParamEditor"
19+
import { FUNCTIONS_ONLY } from "../constants"
20+
import _ from "lodash"
1321
1422
export default {
1523
name: 'Block',
1624
components: {
1725
draggable,
26+
BlockParamEditor,
1827
},
1928
props: {
2029
children: {
@@ -32,12 +41,12 @@ export default {
3241
? { name: 'blocks', pull: 'clone', put: false }
3342
: { name: 'blocks' }
3443
},
44+
marsFuncs: () => FUNCTIONS_ONLY
3545
},
3646
methods: {
37-
put (...args) {
38-
console.log(args)
39-
return true
40-
},
47+
onClone (data) {
48+
return _.cloneDeep(data)
49+
}
4150
},
4251
}
4352
</script>

src/nico/src/nico/components/BlockEditor.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
.flex-grow-2
77
h6.font-weight-bold Nico
88
Block(:children="nicoFuncs" :clone="true")
9+
| {{ blocksRoot }}
910
.flex-grow-1.p-3
1011
Block(:children="blocksRoot")
1112
</template>
@@ -31,6 +32,7 @@ export default {
3132
{
3233
type: 'callMars',
3334
func: 'sprite',
35+
params: [],
3436
},
3537
],
3638
}

src/nico/src/nico/components/BlockParamEditor.vue

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
<template lang="pug">
2-
div
3-
div(v-if)
2+
.d-inline
3+
.d-inline(v-if="type.type === 'str'")
4+
input(v-bind:value="value" v-on:input="$emit('input', $event.target.value)")
5+
.d-inline(v-if="type.type === 'num'")
6+
input.w-25(
7+
type="number"
8+
v-bind:value="value"
9+
v-on:input="$emit('input', $event.target.value)"
10+
)
411
</template>
512

613
<script>
714
export default {
815
name: 'BlockParamEditor',
916
props: {
10-
param: {
11-
type: {
12-
name: String,
13-
type: String,
14-
},
17+
value: {
1518
required: true,
1619
},
17-
value: {
20+
type: {
1821
required: true,
1922
}
2023
},

src/nico/src/nico/constants.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,7 @@ export const FUNCTIONS = [
160160
].reverse()
161161
// reverse is because the sections appear in reverse order due to the rotation
162162

163-
export const FUNCTIONS_BARE =
164-
FUNCTIONS |>
165-
_.filter(section => section.name !== 'User') |>
166-
_.flatMap('functions') |>
167-
_.map('name')
163+
export const FUNCTIONS_ONLY =
164+
FUNCTIONS |> _.filter(section => section.name !== 'User') |> _.flatMap('functions')
165+
166+
export const FUNCTIONS_BARE = FUNCTIONS_ONLY |> _.map('name')

0 commit comments

Comments
 (0)