Skip to content

Commit e89c86a

Browse files
committed
wip: Create a style manager #1072
wip: Create a style editor #1073
1 parent 09ab01b commit e89c86a

11 files changed

+538
-232
lines changed

core/client/components/collection/KCard.vue

-4
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,6 @@ export default {
132132
type: [Object, Array],
133133
default: () => null
134134
},
135-
avatar: {
136-
type: Boolean,
137-
default: true
138-
},
139135
shadow: {
140136
type: Number,
141137
default: 0,
+69-34
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,78 @@
11
<template>
2-
<KModalEditor
3-
id="layer-editor"
4-
:ref="onEditorCreated"
5-
service="catalog"
6-
:objectId="layerId"
7-
@applied="onLayerEdited"
2+
<KForm
3+
ref="formRef"
4+
:values="layer"
5+
:schema="getFormSchema()"
86
/>
97
</template>
8+
<script setup>
9+
import { ref } from 'vue'
1010
11-
<script>
12-
import config from 'config'
13-
import { KModalEditor } from '../../../core/client/components'
11+
// Props
12+
const props = defineProps({
13+
layer: {
14+
type: Object,
15+
default: () => null
16+
}
17+
})
1418
15-
export default {
16-
name: 'k-layer-editor',
17-
inject: ['kActivity'],
18-
components: {
19-
KModalEditor
20-
},
21-
props: {
22-
layerId: {
23-
type: String,
24-
required: true
25-
}
26-
},
27-
methods: {
28-
onEditorCreated (ref) {
29-
this.editor = ref
30-
},
31-
onLayerEdited (updatedLayer) {
32-
// Actual layer update should be triggerred by real-time event
33-
// but as we might not always use sockets we should perform it explicitely in this case
34-
if (config.transport !== 'websocket') {
35-
if (this.layer.name !== updatedLayer.name) {
36-
this.kActivity.renameLayer(this.layer.name, updatedLayer.name)
37-
Object.assign(this.layer, updatedLayer)
19+
// Data
20+
const formRef = ref(null)
21+
22+
// Functions
23+
function getFormSchema () {
24+
return {
25+
$schema: "http://json-schema.org/draft-07/schema#",
26+
$id: "http://www.kalisio.xyz/schemas/catalog.update.json#",
27+
title: "schemas.OBJECT_NAME",
28+
description: "Layer edition schema",
29+
type: "object",
30+
properties: {
31+
name: {
32+
type: "string",
33+
maxLength: 128,
34+
minLength: 3,
35+
field: {
36+
component: "form/KTextField",
37+
label: "schemas.CATALOG_NAME_FIELD_LABEL"
38+
}
39+
},
40+
description: {
41+
type: "string",
42+
maxLength: 256,
43+
field: {
44+
component: "form/KTextField",
45+
label: "schemas.CATALOG_DESCRIPTION_FIELD_LABEL"
46+
}
47+
},
48+
featureId: {
49+
type: "string",
50+
maxLength: 256,
51+
field: {
52+
component: "form/KTextField",
53+
label: "schemas.CATALOG_FEATURE_ID_FIELD_LABEL"
54+
}
55+
},
56+
featureLabel: {
57+
type: "string",
58+
maxLength: 256,
59+
field: {
60+
component: "form/KTextField",
61+
label: "schemas.CATALOG_FEATURE_LABEL_FIELD_LABEL"
3862
}
3963
}
40-
}
64+
},
65+
required: ["name"]
4166
}
4267
}
43-
</script>
68+
function apply () {
69+
const { isValid, values } = formRef.value.validate()
70+
if (!isValid) return false
71+
// Do stuff
72+
}
73+
74+
// Expose
75+
defineExpose({
76+
apply
77+
})
78+
</script>

0 commit comments

Comments
 (0)