* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip
This commit is contained in:
syuilo
2020-07-11 10:13:11 +09:00
committed by GitHub
parent 5b28d7bf90
commit cf3fc97202
56 changed files with 2695 additions and 907 deletions

View File

@@ -1,6 +1,7 @@
import Vue from 'vue';
import { Form } from '../scripts/form';
export default function <T extends object>(data: {
export default function <T extends Form>(data: {
name: string;
props?: () => T;
}) {
@@ -15,22 +16,22 @@ export default function <T extends object>(data: {
}
},
data() {
return {
bakedOldProps: null
};
},
computed: {
id(): string {
return this.widget.id;
},
props(): T {
props(): Record<string, any> {
return this.widget.data;
}
},
data() {
return {
bakedOldProps: null
};
},
created() {
this.mergeProps();
@@ -45,11 +46,26 @@ export default function <T extends object>(data: {
const defaultProps = data.props();
for (const prop of Object.keys(defaultProps)) {
if (this.props.hasOwnProperty(prop)) continue;
Vue.set(this.props, prop, defaultProps[prop]);
Vue.set(this.props, prop, defaultProps[prop].default);
}
}
},
async setting() {
const form = data.props();
for (const item of Object.keys(form)) {
form[item].default = this.props[item];
}
const { canceled, result } = await this.$root.form(data.name, form);
if (canceled) return;
for (const key of Object.keys(result)) {
Vue.set(this.props, key, result[key]);
}
this.save();
},
save() {
this.$store.commit('deviceUser/updateWidget', this.widget);
}