generate frontend entities
This commit is contained in:
@@ -1,26 +1,41 @@
|
||||
<script setup lang="ts">
|
||||
import Table from "../table/Table.vue";
|
||||
import { onMounted, reactive, ref } from "vue";
|
||||
import { onMounted, reactive } from "vue";
|
||||
import { getDefaultValues } from "../utils/structs/defaults.util";
|
||||
import Service from "./post.service.ts";
|
||||
import type { Scheme } from "../types/scheme.type";
|
||||
import { Post } from "../../bindings/app/internal/services";
|
||||
import { ref } from "vue";
|
||||
import type { Validate } from "../types/validate.type";
|
||||
|
||||
import AuthorService from "../author/author.service.ts";
|
||||
import type { Validate } from "../types/validate.type.ts";
|
||||
const authorService = new AuthorService();
|
||||
|
||||
import PosttypeService from "../posttype/posttype.service.ts";
|
||||
const posttypeService = new PosttypeService();
|
||||
|
||||
import CommentService from "../comment/comment.service.ts";
|
||||
const commentService = new CommentService();
|
||||
|
||||
const service = new Service();
|
||||
|
||||
const items = ref<Post[]>([]);
|
||||
|
||||
const load = async () => {
|
||||
(scheme as any).Author.type!.nested!.values = await authorService.readAll();
|
||||
|
||||
(scheme as any).PostType.type!.nested!.values =
|
||||
await posttypeService.readAll();
|
||||
|
||||
(scheme as any).Comments.type!.nested!.values =
|
||||
await commentService.readAll();
|
||||
|
||||
items.value = await service.readAll();
|
||||
return items.value;
|
||||
};
|
||||
|
||||
const items = ref<Post[]>([]);
|
||||
|
||||
onMounted(async () => {
|
||||
load()
|
||||
load();
|
||||
});
|
||||
|
||||
const scheme: Scheme<Post> = reactive({
|
||||
@@ -72,19 +87,47 @@ const scheme: Scheme<Post> = reactive({
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
PostTypeId: {
|
||||
hidden: true,
|
||||
type: {
|
||||
primitive: "number",
|
||||
},
|
||||
},
|
||||
|
||||
PostType: {
|
||||
russian: "Тип",
|
||||
type: {
|
||||
nested: {
|
||||
values: [],
|
||||
field: ["Name"],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Comments: {
|
||||
russian: "Комментарии",
|
||||
many: true,
|
||||
type: {
|
||||
nested: {
|
||||
values: [],
|
||||
field: ["Text"],
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const getDefaults = () => getDefaultValues(scheme);
|
||||
|
||||
const validate: Validate<Post> = (entity) => {
|
||||
return {
|
||||
status: 'success'
|
||||
}
|
||||
status: "success",
|
||||
};
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main class="w-screen h-screen">
|
||||
<Table :scheme :service :get-defaults :validate :load :items></Table>
|
||||
<Table :scheme :service :get-defaults :load :items :validate></Table>
|
||||
</main>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user