From b9f5a25932882dcce6047a39cb5c71c3bdda7680 Mon Sep 17 00:00:00 2001 From: andrey Date: Wed, 18 Feb 2026 15:36:22 +0300 Subject: [PATCH 1/9] Update vt template and fix path form --- .../all/src/pages/Entity/Category/Form.vue | 103 +++++--- .../all/src/pages/Entity/Category/List.vue | 106 +++++--- .../Category/components/MultiListFilters.vue | 53 ++-- .../all/src/pages/Entity/News/Form.vue | 159 ++++++----- .../all/src/pages/Entity/News/List.vue | 114 +++++--- .../News/components/MultiListFilters.vue | 67 +++-- .../all/src/pages/Entity/Tag/Form.vue | 95 +++++-- .../all/src/pages/Entity/Tag/List.vue | 104 +++++--- .../Tag/components/MultiListFilters.vue | 51 +++- .../src/pages/Entity/Category/Form.vue | 103 +++++--- .../src/pages/Entity/Category/List.vue | 106 +++++--- .../Category/components/MultiListFilters.vue | 53 ++-- .../entities/src/pages/Entity/Tag/Form.vue | 95 +++++-- .../entities/src/pages/Entity/Tag/List.vue | 104 +++++--- .../Tag/components/MultiListFilters.vue | 51 +++- generators/vt-template/generator.go | 2 +- generators/vt-template/template.go | 248 ++++++++++++------ 17 files changed, 1083 insertions(+), 531 deletions(-) diff --git a/generators/testdata/expected/vt-template/all/src/pages/Entity/Category/Form.vue b/generators/testdata/expected/vt-template/all/src/pages/Entity/Category/Form.vue index 49ec139..41f5809 100644 --- a/generators/testdata/expected/vt-template/all/src/pages/Entity/Category/Form.vue +++ b/generators/testdata/expected/vt-template/all/src/pages/Entity/Category/Form.vue @@ -15,7 +15,7 @@ >

- {{ store.model.title || "..." }} + {{ model.title || "..." }}

@@ -23,7 +23,7 @@ - + done - {{ $t("common.form.saveAndCloseButtonLabel") }} + {{ t("common.form.saveAndCloseButtonLabel") }} - {{ $t("common.form.saveButtonLabel") }} + {{ t("common.form.saveButtonLabel") }} @@ -150,17 +150,58 @@ diff --git a/generators/testdata/expected/vt-template/all/src/pages/Entity/Category/List.vue b/generators/testdata/expected/vt-template/all/src/pages/Entity/Category/List.vue index f2e6d2a..1c63952 100644 --- a/generators/testdata/expected/vt-template/all/src/pages/Entity/Category/List.vue +++ b/generators/testdata/expected/vt-template/all/src/pages/Entity/Category/List.vue @@ -18,27 +18,26 @@

- {{ $t("category.list.title") }} + {{ t("category.list.title") }}

- {{ store.pagination.totalItems }} + {{ pagination.totalItems }}
- - add - - {{ $t("common.list.addNewLabel") }} + add + {{ t("common.list.addNewLabel") }} @@ -64,9 +63,9 @@ mr-sm-2 > @@ -100,9 +100,9 @@ @@ -164,48 +164,76 @@ diff --git a/generators/testdata/expected/vt-template/all/src/pages/Entity/Category/components/MultiListFilters.vue b/generators/testdata/expected/vt-template/all/src/pages/Entity/Category/components/MultiListFilters.vue index fc765eb..a6fedaf 100644 --- a/generators/testdata/expected/vt-template/all/src/pages/Entity/Category/components/MultiListFilters.vue +++ b/generators/testdata/expected/vt-template/all/src/pages/Entity/Category/components/MultiListFilters.vue @@ -1,26 +1,43 @@ diff --git a/generators/testdata/expected/vt-template/all/src/pages/Entity/News/Form.vue b/generators/testdata/expected/vt-template/all/src/pages/Entity/News/Form.vue index 3892583..ac58a62 100644 --- a/generators/testdata/expected/vt-template/all/src/pages/Entity/News/Form.vue +++ b/generators/testdata/expected/vt-template/all/src/pages/Entity/News/Form.vue @@ -15,7 +15,7 @@ >

- {{ store.model.title || "..." }} + {{ model.title || "..." }}

@@ -23,7 +23,7 @@ - + done - {{ $t("common.form.saveAndCloseButtonLabel") }} + {{ t("common.form.saveAndCloseButtonLabel") }} - {{ $t("common.form.saveButtonLabel") }} + {{ t("common.form.saveButtonLabel") }} @@ -225,17 +225,58 @@ diff --git a/generators/testdata/expected/vt-template/all/src/pages/Entity/News/List.vue b/generators/testdata/expected/vt-template/all/src/pages/Entity/News/List.vue index 8cc4aa6..e86ccd6 100644 --- a/generators/testdata/expected/vt-template/all/src/pages/Entity/News/List.vue +++ b/generators/testdata/expected/vt-template/all/src/pages/Entity/News/List.vue @@ -18,27 +18,26 @@

- {{ $t("news.list.title") }} + {{ t("news.list.title") }}

- {{ store.pagination.totalItems }} + {{ pagination.totalItems }}
- - add - - {{ $t("common.list.addNewLabel") }} + add + {{ t("common.list.addNewLabel") }} @@ -64,9 +63,9 @@ mr-sm-2 > @@ -100,9 +100,9 @@ @@ -176,67 +176,95 @@ diff --git a/generators/testdata/expected/vt-template/all/src/pages/Entity/News/components/MultiListFilters.vue b/generators/testdata/expected/vt-template/all/src/pages/Entity/News/components/MultiListFilters.vue index 83bb31e..7f1ec20 100644 --- a/generators/testdata/expected/vt-template/all/src/pages/Entity/News/components/MultiListFilters.vue +++ b/generators/testdata/expected/vt-template/all/src/pages/Entity/News/components/MultiListFilters.vue @@ -1,26 +1,43 @@ diff --git a/generators/testdata/expected/vt-template/all/src/pages/Entity/Tag/Form.vue b/generators/testdata/expected/vt-template/all/src/pages/Entity/Tag/Form.vue index e46587a..0391899 100644 --- a/generators/testdata/expected/vt-template/all/src/pages/Entity/Tag/Form.vue +++ b/generators/testdata/expected/vt-template/all/src/pages/Entity/Tag/Form.vue @@ -15,7 +15,7 @@ >

- {{ store.model.title || "..." }} + {{ model.title || "..." }}

@@ -23,7 +23,7 @@ - + done - {{ $t("common.form.saveAndCloseButtonLabel") }} + {{ t("common.form.saveAndCloseButtonLabel") }} - {{ $t("common.form.saveButtonLabel") }} + {{ t("common.form.saveButtonLabel") }} @@ -142,17 +142,58 @@ diff --git a/generators/testdata/expected/vt-template/all/src/pages/Entity/Tag/List.vue b/generators/testdata/expected/vt-template/all/src/pages/Entity/Tag/List.vue index 59f5d65..eb520c5 100644 --- a/generators/testdata/expected/vt-template/all/src/pages/Entity/Tag/List.vue +++ b/generators/testdata/expected/vt-template/all/src/pages/Entity/Tag/List.vue @@ -18,27 +18,26 @@

- {{ $t("tag.list.title") }} + {{ t("tag.list.title") }}

- {{ store.pagination.totalItems }} + {{ pagination.totalItems }}
- - add - - {{ $t("common.list.addNewLabel") }} + add + {{ t("common.list.addNewLabel") }} @@ -64,9 +63,9 @@ mr-sm-2 > @@ -100,9 +100,9 @@ @@ -161,44 +161,72 @@ diff --git a/generators/testdata/expected/vt-template/all/src/pages/Entity/Tag/components/MultiListFilters.vue b/generators/testdata/expected/vt-template/all/src/pages/Entity/Tag/components/MultiListFilters.vue index 4e5ae81..523e594 100644 --- a/generators/testdata/expected/vt-template/all/src/pages/Entity/Tag/components/MultiListFilters.vue +++ b/generators/testdata/expected/vt-template/all/src/pages/Entity/Tag/components/MultiListFilters.vue @@ -1,26 +1,43 @@ diff --git a/generators/testdata/expected/vt-template/entities/src/pages/Entity/Category/Form.vue b/generators/testdata/expected/vt-template/entities/src/pages/Entity/Category/Form.vue index 49ec139..41f5809 100644 --- a/generators/testdata/expected/vt-template/entities/src/pages/Entity/Category/Form.vue +++ b/generators/testdata/expected/vt-template/entities/src/pages/Entity/Category/Form.vue @@ -15,7 +15,7 @@ >

- {{ store.model.title || "..." }} + {{ model.title || "..." }}

@@ -23,7 +23,7 @@ - + done - {{ $t("common.form.saveAndCloseButtonLabel") }} + {{ t("common.form.saveAndCloseButtonLabel") }} - {{ $t("common.form.saveButtonLabel") }} + {{ t("common.form.saveButtonLabel") }} @@ -150,17 +150,58 @@ diff --git a/generators/testdata/expected/vt-template/entities/src/pages/Entity/Category/List.vue b/generators/testdata/expected/vt-template/entities/src/pages/Entity/Category/List.vue index f2e6d2a..1c63952 100644 --- a/generators/testdata/expected/vt-template/entities/src/pages/Entity/Category/List.vue +++ b/generators/testdata/expected/vt-template/entities/src/pages/Entity/Category/List.vue @@ -18,27 +18,26 @@

- {{ $t("category.list.title") }} + {{ t("category.list.title") }}

- {{ store.pagination.totalItems }} + {{ pagination.totalItems }}
- - add - - {{ $t("common.list.addNewLabel") }} + add + {{ t("common.list.addNewLabel") }} @@ -64,9 +63,9 @@ mr-sm-2 > @@ -100,9 +100,9 @@ @@ -164,48 +164,76 @@ diff --git a/generators/testdata/expected/vt-template/entities/src/pages/Entity/Category/components/MultiListFilters.vue b/generators/testdata/expected/vt-template/entities/src/pages/Entity/Category/components/MultiListFilters.vue index fc765eb..a6fedaf 100644 --- a/generators/testdata/expected/vt-template/entities/src/pages/Entity/Category/components/MultiListFilters.vue +++ b/generators/testdata/expected/vt-template/entities/src/pages/Entity/Category/components/MultiListFilters.vue @@ -1,26 +1,43 @@ diff --git a/generators/testdata/expected/vt-template/entities/src/pages/Entity/Tag/Form.vue b/generators/testdata/expected/vt-template/entities/src/pages/Entity/Tag/Form.vue index e46587a..0391899 100644 --- a/generators/testdata/expected/vt-template/entities/src/pages/Entity/Tag/Form.vue +++ b/generators/testdata/expected/vt-template/entities/src/pages/Entity/Tag/Form.vue @@ -15,7 +15,7 @@ >

- {{ store.model.title || "..." }} + {{ model.title || "..." }}

@@ -23,7 +23,7 @@ - + done - {{ $t("common.form.saveAndCloseButtonLabel") }} + {{ t("common.form.saveAndCloseButtonLabel") }} - {{ $t("common.form.saveButtonLabel") }} + {{ t("common.form.saveButtonLabel") }} @@ -142,17 +142,58 @@ diff --git a/generators/testdata/expected/vt-template/entities/src/pages/Entity/Tag/List.vue b/generators/testdata/expected/vt-template/entities/src/pages/Entity/Tag/List.vue index 59f5d65..eb520c5 100644 --- a/generators/testdata/expected/vt-template/entities/src/pages/Entity/Tag/List.vue +++ b/generators/testdata/expected/vt-template/entities/src/pages/Entity/Tag/List.vue @@ -18,27 +18,26 @@

- {{ $t("tag.list.title") }} + {{ t("tag.list.title") }}

- {{ store.pagination.totalItems }} + {{ pagination.totalItems }}
- - add - - {{ $t("common.list.addNewLabel") }} + add + {{ t("common.list.addNewLabel") }} @@ -64,9 +63,9 @@ mr-sm-2 > @@ -100,9 +100,9 @@ @@ -161,44 +161,72 @@ diff --git a/generators/testdata/expected/vt-template/entities/src/pages/Entity/Tag/components/MultiListFilters.vue b/generators/testdata/expected/vt-template/entities/src/pages/Entity/Tag/components/MultiListFilters.vue index 4e5ae81..523e594 100644 --- a/generators/testdata/expected/vt-template/entities/src/pages/Entity/Tag/components/MultiListFilters.vue +++ b/generators/testdata/expected/vt-template/entities/src/pages/Entity/Tag/components/MultiListFilters.vue @@ -1,26 +1,43 @@ diff --git a/generators/vt-template/generator.go b/generators/vt-template/generator.go index 7375f6f..004ac00 100644 --- a/generators/vt-template/generator.go +++ b/generators/vt-template/generator.go @@ -93,7 +93,7 @@ func (g *Generator) ReadFlags(command *cobra.Command) error { if g.options.FiltersTemplatePath, err = flags.GetString(filterTemplateFlag); err != nil { return err } - if g.options.FiltersTemplatePath, err = flags.GetString(formTemplateFlag); err != nil { + if g.options.FormTemplatePath, err = flags.GetString(formTemplateFlag); err != nil { return err } diff --git a/generators/vt-template/template.go b/generators/vt-template/template.go index 10912aa..e3c059f 100644 --- a/generators/vt-template/template.go +++ b/generators/vt-template/template.go @@ -54,27 +54,26 @@ const listDefaultTemplate = ` diff --git a/generators/testdata/expected/vt-template/all/src/pages/Entity/Tag/List.vue b/generators/testdata/expected/vt-template/all/src/pages/Entity/Tag/List.vue index 71dec4b..59f5d65 100644 --- a/generators/testdata/expected/vt-template/all/src/pages/Entity/Tag/List.vue +++ b/generators/testdata/expected/vt-template/all/src/pages/Entity/Tag/List.vue @@ -18,26 +18,27 @@

- {{ t("tag.list.title") }} + {{ $t("tag.list.title") }}

- {{ pagination.totalItems }} + {{ store.pagination.totalItems }}
- add - {{ t("common.list.addNewLabel") }} + + add + + {{ $t("common.list.addNewLabel") }} @@ -63,9 +64,9 @@ mr-sm-2 > @@ -100,9 +100,9 @@ @@ -161,72 +161,44 @@ diff --git a/generators/testdata/expected/vt-template/all/src/pages/Entity/Tag/components/MultiListFilters.vue b/generators/testdata/expected/vt-template/all/src/pages/Entity/Tag/components/MultiListFilters.vue index 523e594..4e5ae81 100644 --- a/generators/testdata/expected/vt-template/all/src/pages/Entity/Tag/components/MultiListFilters.vue +++ b/generators/testdata/expected/vt-template/all/src/pages/Entity/Tag/components/MultiListFilters.vue @@ -1,43 +1,26 @@ diff --git a/generators/testdata/expected/vt-template/all/src/pages/Entity/routes.ts b/generators/testdata/expected/vt-template/all/src/pages/Entity/routes.ts index 198b28f..7c69d18 100644 --- a/generators/testdata/expected/vt-template/all/src/pages/Entity/routes.ts +++ b/generators/testdata/expected/vt-template/all/src/pages/Entity/routes.ts @@ -1,344 +1,311 @@ /* eslint-disable */ export default [ - /* Category */ - { - name: "categoryList", - path: "/categories", - component: () => - import("@/pages/Entity/Category/List.vue"), - meta: { - title: "CategoryList", - breadcrumbs: ["dashboard", "categoryList"] - } - }, - { - name: "categoryEdit", - path: "/categories/:id/edit", - component: () => - import("@/pages/Entity/Category/Form.vue"), - meta: { - title: "CategoryEdit", - breadcrumbs: ["dashboard", "categoryList", "categoryEdit"] - } - }, - { - name: "categoryAdd", - path: "/categories/add", - component: () => - import("@/pages/Entity/Category/Form.vue"), - meta: { - title: "CategoryAdd", - breadcrumbs: ["dashboard", "categoryList", "categoryAdd"] - } - }, - /* News */ - { - name: "newsList", - path: "/news", - component: () => - import("@/pages/Entity/News/List.vue"), - meta: { - title: "NewsList", - breadcrumbs: ["dashboard", "newsList"] - } - }, - { - name: "newsEdit", - path: "/news/:id/edit", - component: () => - import("@/pages/Entity/News/Form.vue"), - meta: { - title: "NewsEdit", - breadcrumbs: ["dashboard", "newsList", "newsEdit"] - } - }, - { - name: "newsAdd", - path: "/news/add", - component: () => - import("@/pages/Entity/News/Form.vue"), - meta: { - title: "NewsAdd", - breadcrumbs: ["dashboard", "newsList", "newsAdd"] - } - }, - /* Tag */ - { - name: "tagList", - path: "/tags", - component: () => - import("@/pages/Entity/Tag/List.vue"), - meta: { - title: "TagList", - breadcrumbs: ["dashboard", "tagList"] - } - }, - { - name: "tagEdit", - path: "/tags/:id/edit", - component: () => - import("@/pages/Entity/Tag/Form.vue"), - meta: { - title: "TagEdit", - breadcrumbs: ["dashboard", "tagList", "tagEdit"] - } - }, - { - name: "tagAdd", - path: "/tags/add", - component: () => - import("@/pages/Entity/Tag/Form.vue"), - meta: { - title: "TagAdd", - breadcrumbs: ["dashboard", "tagList", "tagAdd"] - } - }, - /* City */ - { - name: "cityList", - path: "/cities", - component: () => - import("@/pages/Entity/City/List.vue"), - meta: { - title: "CityList", - breadcrumbs: ["dashboard", "cityList"] - } - }, - { - name: "cityEdit", - path: "/cities/:id/edit", - component: () => - import("@/pages/Entity/City/Form.vue"), - meta: { - title: "CityEdit", - breadcrumbs: ["dashboard", "cityList", "cityEdit"] - } - }, - { - name: "cityAdd", - path: "/cities/add", - component: () => - import("@/pages/Entity/City/Form.vue"), - meta: { - title: "CityAdd", - breadcrumbs: ["dashboard", "cityList", "cityAdd"] - } - }, - /* Country */ - { - name: "countryList", - path: "/countries", - component: () => - import("@/pages/Entity/Country/List.vue"), - meta: { - title: "CountryList", - breadcrumbs: ["dashboard", "countryList"] - } - }, - { - name: "countryEdit", - path: "/countries/:id/edit", - component: () => - import("@/pages/Entity/Country/Form.vue"), - meta: { - title: "CountryEdit", - breadcrumbs: ["dashboard", "countryList", "countryEdit"] - } - }, - { - name: "countryAdd", - path: "/countries/add", - component: () => - import("@/pages/Entity/Country/Form.vue"), - meta: { - title: "CountryAdd", - breadcrumbs: ["dashboard", "countryList", "countryAdd"] - } - }, - /* Region */ - { - name: "regionList", - path: "/regions", - component: () => - import("@/pages/Entity/Region/List.vue"), - meta: { - title: "RegionList", - breadcrumbs: ["dashboard", "regionList"] - } - }, - { - name: "regionEdit", - path: "/regions/:id/edit", - component: () => - import("@/pages/Entity/Region/Form.vue"), - meta: { - title: "RegionEdit", - breadcrumbs: ["dashboard", "regionList", "regionEdit"] - } - }, - { - name: "regionAdd", - path: "/regions/add", - component: () => - import("@/pages/Entity/Region/Form.vue"), - meta: { - title: "RegionAdd", - breadcrumbs: ["dashboard", "regionList", "regionAdd"] - } - }, - /* EncryptionKey */ - { - name: "encryptionKeyList", - path: "/encryption-keys", - component: () => - import("@/pages/Entity/EncryptionKey/List.vue"), - meta: { - title: "EncryptionKeyList", - breadcrumbs: ["dashboard", "encryptionKeyList"] - } - }, - { - name: "encryptionKeyEdit", - path: "/encryption-keys/:id/edit", - component: () => - import("@/pages/Entity/EncryptionKey/Form.vue"), - meta: { - title: "EncryptionKeyEdit", - breadcrumbs: ["dashboard", "encryptionKeyList", "encryptionKeyEdit"] - } - }, - { - name: "encryptionKeyAdd", - path: "/encryption-keys/add", - component: () => - import("@/pages/Entity/EncryptionKey/Form.vue"), - meta: { - title: "EncryptionKeyAdd", - breadcrumbs: ["dashboard", "encryptionKeyList", "encryptionKeyAdd"] - } - }, - /* LoginCode */ - { - name: "loginCodeList", - path: "/login-codes", - component: () => - import("@/pages/Entity/LoginCode/List.vue"), - meta: { - title: "LoginCodeList", - breadcrumbs: ["dashboard", "loginCodeList"] - } - }, - { - name: "loginCodeEdit", - path: "/login-codes/:id/edit", - component: () => - import("@/pages/Entity/LoginCode/Form.vue"), - meta: { - title: "LoginCodeEdit", - breadcrumbs: ["dashboard", "loginCodeList", "loginCodeEdit"] - } - }, - { - name: "loginCodeAdd", - path: "/login-codes/add", - component: () => - import("@/pages/Entity/LoginCode/Form.vue"), - meta: { - title: "LoginCodeAdd", - breadcrumbs: ["dashboard", "loginCodeList", "loginCodeAdd"] - } - }, - /* SiteUser */ - { - name: "siteUserList", - path: "/site-users", - component: () => - import("@/pages/Entity/SiteUser/List.vue"), - meta: { - title: "SiteUserList", - breadcrumbs: ["dashboard", "siteUserList"] - } - }, - { - name: "siteUserEdit", - path: "/site-users/:id/edit", - component: () => - import("@/pages/Entity/SiteUser/Form.vue"), - meta: { - title: "SiteUserEdit", - breadcrumbs: ["dashboard", "siteUserList", "siteUserEdit"] - } - }, - { - name: "siteUserAdd", - path: "/site-users/add", - component: () => - import("@/pages/Entity/SiteUser/Form.vue"), - meta: { - title: "SiteUserAdd", - breadcrumbs: ["dashboard", "siteUserList", "siteUserAdd"] - } - }, - /* VfsFile */ - { - name: "vfsFileList", - path: "/vfs-files", - component: () => - import("@/pages/Entity/VfsFile/List.vue"), - meta: { - title: "VfsFileList", - breadcrumbs: ["dashboard", "vfsFileList"] - } - }, - { - name: "vfsFileEdit", - path: "/vfs-files/:id/edit", - component: () => - import("@/pages/Entity/VfsFile/Form.vue"), - meta: { - title: "VfsFileEdit", - breadcrumbs: ["dashboard", "vfsFileList", "vfsFileEdit"] - } - }, - { - name: "vfsFileAdd", - path: "/vfs-files/add", - component: () => - import("@/pages/Entity/VfsFile/Form.vue"), - meta: { - title: "VfsFileAdd", - breadcrumbs: ["dashboard", "vfsFileList", "vfsFileAdd"] - } - }, - /* VfsFolder */ - { - name: "vfsFolderList", - path: "/vfs-folders", - component: () => - import("@/pages/Entity/VfsFolder/List.vue"), - meta: { - title: "VfsFolderList", - breadcrumbs: ["dashboard", "vfsFolderList"] - } - }, - { - name: "vfsFolderEdit", - path: "/vfs-folders/:id/edit", - component: () => - import("@/pages/Entity/VfsFolder/Form.vue"), - meta: { - title: "VfsFolderEdit", - breadcrumbs: ["dashboard", "vfsFolderList", "vfsFolderEdit"] - } - }, - { - name: "vfsFolderAdd", - path: "/vfs-folders/add", - component: () => - import("@/pages/Entity/VfsFolder/Form.vue"), - meta: { - title: "VfsFolderAdd", - breadcrumbs: ["dashboard", "vfsFolderList", "vfsFolderAdd"] - } - }, + /* Category */ + { + name: "categoryList", + path: "/categories", + component: () => + import("@/pages/Entity/Category/List.vue"), + meta: { + breadcrumbs: ["dashboard", "categoryList"] + } + }, + { + name: "categoryEdit", + path: "/categories/:id/edit", + component: () => + import("@/pages/Entity/Category/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "categoryList", "categoryEdit"] + } + }, + { + name: "categoryAdd", + path: "/categories/add", + component: () => + import("@/pages/Entity/Category/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "categoryList", "categoryAdd"] + } + }, + /* News */ + { + name: "newsList", + path: "/news", + component: () => + import("@/pages/Entity/News/List.vue"), + meta: { + breadcrumbs: ["dashboard", "newsList"] + } + }, + { + name: "newsEdit", + path: "/news/:id/edit", + component: () => + import("@/pages/Entity/News/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "newsList", "newsEdit"] + } + }, + { + name: "newsAdd", + path: "/news/add", + component: () => + import("@/pages/Entity/News/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "newsList", "newsAdd"] + } + }, + /* Tag */ + { + name: "tagList", + path: "/tags", + component: () => + import("@/pages/Entity/Tag/List.vue"), + meta: { + breadcrumbs: ["dashboard", "tagList"] + } + }, + { + name: "tagEdit", + path: "/tags/:id/edit", + component: () => + import("@/pages/Entity/Tag/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "tagList", "tagEdit"] + } + }, + { + name: "tagAdd", + path: "/tags/add", + component: () => + import("@/pages/Entity/Tag/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "tagList", "tagAdd"] + } + }, + /* City */ + { + name: "cityList", + path: "/cities", + component: () => + import("@/pages/Entity/City/List.vue"), + meta: { + breadcrumbs: ["dashboard", "cityList"] + } + }, + { + name: "cityEdit", + path: "/cities/:id/edit", + component: () => + import("@/pages/Entity/City/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "cityList", "cityEdit"] + } + }, + { + name: "cityAdd", + path: "/cities/add", + component: () => + import("@/pages/Entity/City/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "cityList", "cityAdd"] + } + }, + /* Country */ + { + name: "countryList", + path: "/countries", + component: () => + import("@/pages/Entity/Country/List.vue"), + meta: { + breadcrumbs: ["dashboard", "countryList"] + } + }, + { + name: "countryEdit", + path: "/countries/:id/edit", + component: () => + import("@/pages/Entity/Country/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "countryList", "countryEdit"] + } + }, + { + name: "countryAdd", + path: "/countries/add", + component: () => + import("@/pages/Entity/Country/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "countryList", "countryAdd"] + } + }, + /* Region */ + { + name: "regionList", + path: "/regions", + component: () => + import("@/pages/Entity/Region/List.vue"), + meta: { + breadcrumbs: ["dashboard", "regionList"] + } + }, + { + name: "regionEdit", + path: "/regions/:id/edit", + component: () => + import("@/pages/Entity/Region/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "regionList", "regionEdit"] + } + }, + { + name: "regionAdd", + path: "/regions/add", + component: () => + import("@/pages/Entity/Region/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "regionList", "regionAdd"] + } + }, + /* EncryptionKey */ + { + name: "encryptionKeyList", + path: "/encryption-keys", + component: () => + import("@/pages/Entity/EncryptionKey/List.vue"), + meta: { + breadcrumbs: ["dashboard", "encryptionKeyList"] + } + }, + { + name: "encryptionKeyEdit", + path: "/encryption-keys/:id/edit", + component: () => + import("@/pages/Entity/EncryptionKey/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "encryptionKeyList", "encryptionKeyEdit"] + } + }, + { + name: "encryptionKeyAdd", + path: "/encryption-keys/add", + component: () => + import("@/pages/Entity/EncryptionKey/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "encryptionKeyList", "encryptionKeyAdd"] + } + }, + /* LoginCode */ + { + name: "loginCodeList", + path: "/login-codes", + component: () => + import("@/pages/Entity/LoginCode/List.vue"), + meta: { + breadcrumbs: ["dashboard", "loginCodeList"] + } + }, + { + name: "loginCodeEdit", + path: "/login-codes/:id/edit", + component: () => + import("@/pages/Entity/LoginCode/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "loginCodeList", "loginCodeEdit"] + } + }, + { + name: "loginCodeAdd", + path: "/login-codes/add", + component: () => + import("@/pages/Entity/LoginCode/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "loginCodeList", "loginCodeAdd"] + } + }, + /* SiteUser */ + { + name: "siteUserList", + path: "/site-users", + component: () => + import("@/pages/Entity/SiteUser/List.vue"), + meta: { + breadcrumbs: ["dashboard", "siteUserList"] + } + }, + { + name: "siteUserEdit", + path: "/site-users/:id/edit", + component: () => + import("@/pages/Entity/SiteUser/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "siteUserList", "siteUserEdit"] + } + }, + { + name: "siteUserAdd", + path: "/site-users/add", + component: () => + import("@/pages/Entity/SiteUser/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "siteUserList", "siteUserAdd"] + } + }, + /* VfsFile */ + { + name: "vfsFileList", + path: "/vfs-files", + component: () => + import("@/pages/Entity/VfsFile/List.vue"), + meta: { + breadcrumbs: ["dashboard", "vfsFileList"] + } + }, + { + name: "vfsFileEdit", + path: "/vfs-files/:id/edit", + component: () => + import("@/pages/Entity/VfsFile/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "vfsFileList", "vfsFileEdit"] + } + }, + { + name: "vfsFileAdd", + path: "/vfs-files/add", + component: () => + import("@/pages/Entity/VfsFile/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "vfsFileList", "vfsFileAdd"] + } + }, + /* VfsFolder */ + { + name: "vfsFolderList", + path: "/vfs-folders", + component: () => + import("@/pages/Entity/VfsFolder/List.vue"), + meta: { + breadcrumbs: ["dashboard", "vfsFolderList"] + } + }, + { + name: "vfsFolderEdit", + path: "/vfs-folders/:id/edit", + component: () => + import("@/pages/Entity/VfsFolder/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "vfsFolderList", "vfsFolderEdit"] + } + }, + { + name: "vfsFolderAdd", + path: "/vfs-folders/add", + component: () => + import("@/pages/Entity/VfsFolder/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "vfsFolderList", "vfsFolderAdd"] + } + }, ]; diff --git a/generators/testdata/expected/vt-template/composition/src/pages/Entity/Category/Form.vue b/generators/testdata/expected/vt-template/composition/src/pages/Entity/Category/Form.vue new file mode 100644 index 0000000..ab8d2d8 --- /dev/null +++ b/generators/testdata/expected/vt-template/composition/src/pages/Entity/Category/Form.vue @@ -0,0 +1,207 @@ + + + + + diff --git a/generators/testdata/expected/vt-template/composition/src/pages/Entity/Category/List.vue b/generators/testdata/expected/vt-template/composition/src/pages/Entity/Category/List.vue new file mode 100644 index 0000000..261806a --- /dev/null +++ b/generators/testdata/expected/vt-template/composition/src/pages/Entity/Category/List.vue @@ -0,0 +1,239 @@ + + + + + diff --git a/generators/testdata/expected/vt-template/composition/src/pages/Entity/Category/components/MultiListFilters.vue b/generators/testdata/expected/vt-template/composition/src/pages/Entity/Category/components/MultiListFilters.vue new file mode 100644 index 0000000..a6fedaf --- /dev/null +++ b/generators/testdata/expected/vt-template/composition/src/pages/Entity/Category/components/MultiListFilters.vue @@ -0,0 +1,97 @@ + + + diff --git a/generators/testdata/expected/vt-template/composition/src/pages/Entity/Category/en.json b/generators/testdata/expected/vt-template/composition/src/pages/Entity/Category/en.json new file mode 100644 index 0000000..33b0135 --- /dev/null +++ b/generators/testdata/expected/vt-template/composition/src/pages/Entity/Category/en.json @@ -0,0 +1,30 @@ +{ + "breadcrumbs": { + "categoryAdd": "Add", + "categoryEdit": "Edit", + "categoryList": "Categories" + }, + "category": { + "form": { + "orderNumberLabel": "Order Number", + "statusIdLabel": "Status", + "titleLabel": "Title" + }, + "list": { + "title": "Categories", + "filter": { + "ids": "Ids", + "orderNumber": "Order Number", + "quickFilterPlaceholder": "", + "statusId": "Status", + "title": "Title" + }, + "headers": { + "actions": "Actions", + "orderNumber": "Order Number", + "status": "Status", + "title": "Title" + } + } + } +} \ No newline at end of file diff --git a/generators/testdata/expected/vt-template/composition/src/pages/Entity/News/Form.vue b/generators/testdata/expected/vt-template/composition/src/pages/Entity/News/Form.vue new file mode 100644 index 0000000..ff0c74e --- /dev/null +++ b/generators/testdata/expected/vt-template/composition/src/pages/Entity/News/Form.vue @@ -0,0 +1,282 @@ + + + + + diff --git a/generators/testdata/expected/vt-template/composition/src/pages/Entity/News/List.vue b/generators/testdata/expected/vt-template/composition/src/pages/Entity/News/List.vue new file mode 100644 index 0000000..c9dc873 --- /dev/null +++ b/generators/testdata/expected/vt-template/composition/src/pages/Entity/News/List.vue @@ -0,0 +1,270 @@ + + + + + diff --git a/generators/testdata/expected/vt-template/composition/src/pages/Entity/News/components/MultiListFilters.vue b/generators/testdata/expected/vt-template/composition/src/pages/Entity/News/components/MultiListFilters.vue new file mode 100644 index 0000000..7f1ec20 --- /dev/null +++ b/generators/testdata/expected/vt-template/composition/src/pages/Entity/News/components/MultiListFilters.vue @@ -0,0 +1,187 @@ + + + diff --git a/generators/testdata/expected/vt-template/composition/src/pages/Entity/News/en.json b/generators/testdata/expected/vt-template/composition/src/pages/Entity/News/en.json new file mode 100644 index 0000000..3ee7e56 --- /dev/null +++ b/generators/testdata/expected/vt-template/composition/src/pages/Entity/News/en.json @@ -0,0 +1,48 @@ +{ + "breadcrumbs": { + "newsAdd": "Add", + "newsEdit": "Edit", + "newsList": "News" + }, + "news": { + "form": { + "categoryIdLabel": "Category", + "cityIdLabel": "City", + "contentLabel": "Content", + "countryIdLabel": "Country", + "previewLabel": "Preview", + "publishedAtLabel": "Published At", + "regionIdLabel": "Region", + "statusIdLabel": "Status", + "tagIdsLabel": "Tags", + "titleLabel": "Title" + }, + "list": { + "title": "News", + "filter": { + "categoryId": "Category", + "cityId": "City", + "content": "Content", + "countryId": "Country", + "createdAt": "Created at", + "ids": "Ids", + "preview": "Preview", + "publishedAt": "Published At", + "quickFilterPlaceholder": "", + "regionId": "Region", + "statusId": "Status", + "title": "Title" + }, + "headers": { + "actions": "Actions", + "category": "Category", + "content": "Content", + "country": "Country", + "preview": "Preview", + "region": "Region", + "status": "Status", + "title": "Title" + } + } + } +} \ No newline at end of file diff --git a/generators/testdata/expected/vt-template/composition/src/pages/Entity/Tag/Form.vue b/generators/testdata/expected/vt-template/composition/src/pages/Entity/Tag/Form.vue new file mode 100644 index 0000000..6630576 --- /dev/null +++ b/generators/testdata/expected/vt-template/composition/src/pages/Entity/Tag/Form.vue @@ -0,0 +1,199 @@ + + + + + diff --git a/generators/testdata/expected/vt-template/composition/src/pages/Entity/Tag/List.vue b/generators/testdata/expected/vt-template/composition/src/pages/Entity/Tag/List.vue new file mode 100644 index 0000000..71dec4b --- /dev/null +++ b/generators/testdata/expected/vt-template/composition/src/pages/Entity/Tag/List.vue @@ -0,0 +1,232 @@ + + + + + diff --git a/generators/testdata/expected/vt-template/composition/src/pages/Entity/Tag/components/MultiListFilters.vue b/generators/testdata/expected/vt-template/composition/src/pages/Entity/Tag/components/MultiListFilters.vue new file mode 100644 index 0000000..523e594 --- /dev/null +++ b/generators/testdata/expected/vt-template/composition/src/pages/Entity/Tag/components/MultiListFilters.vue @@ -0,0 +1,85 @@ + + + diff --git a/generators/testdata/expected/vt-template/composition/src/pages/Entity/Tag/en.json b/generators/testdata/expected/vt-template/composition/src/pages/Entity/Tag/en.json new file mode 100644 index 0000000..d408aad --- /dev/null +++ b/generators/testdata/expected/vt-template/composition/src/pages/Entity/Tag/en.json @@ -0,0 +1,27 @@ +{ + "breadcrumbs": { + "tagAdd": "Add", + "tagEdit": "Edit", + "tagList": "Tags" + }, + "tag": { + "form": { + "statusIdLabel": "Status", + "titleLabel": "Title" + }, + "list": { + "title": "Tags", + "filter": { + "ids": "Ids", + "quickFilterPlaceholder": "", + "statusId": "Status", + "title": "Title" + }, + "headers": { + "actions": "Actions", + "status": "Status", + "title": "Title" + } + } + } +} \ No newline at end of file diff --git a/generators/testdata/expected/vt-template/composition/src/pages/Entity/routes.ts b/generators/testdata/expected/vt-template/composition/src/pages/Entity/routes.ts new file mode 100644 index 0000000..198b28f --- /dev/null +++ b/generators/testdata/expected/vt-template/composition/src/pages/Entity/routes.ts @@ -0,0 +1,344 @@ +/* eslint-disable */ +export default [ + /* Category */ + { + name: "categoryList", + path: "/categories", + component: () => + import("@/pages/Entity/Category/List.vue"), + meta: { + title: "CategoryList", + breadcrumbs: ["dashboard", "categoryList"] + } + }, + { + name: "categoryEdit", + path: "/categories/:id/edit", + component: () => + import("@/pages/Entity/Category/Form.vue"), + meta: { + title: "CategoryEdit", + breadcrumbs: ["dashboard", "categoryList", "categoryEdit"] + } + }, + { + name: "categoryAdd", + path: "/categories/add", + component: () => + import("@/pages/Entity/Category/Form.vue"), + meta: { + title: "CategoryAdd", + breadcrumbs: ["dashboard", "categoryList", "categoryAdd"] + } + }, + /* News */ + { + name: "newsList", + path: "/news", + component: () => + import("@/pages/Entity/News/List.vue"), + meta: { + title: "NewsList", + breadcrumbs: ["dashboard", "newsList"] + } + }, + { + name: "newsEdit", + path: "/news/:id/edit", + component: () => + import("@/pages/Entity/News/Form.vue"), + meta: { + title: "NewsEdit", + breadcrumbs: ["dashboard", "newsList", "newsEdit"] + } + }, + { + name: "newsAdd", + path: "/news/add", + component: () => + import("@/pages/Entity/News/Form.vue"), + meta: { + title: "NewsAdd", + breadcrumbs: ["dashboard", "newsList", "newsAdd"] + } + }, + /* Tag */ + { + name: "tagList", + path: "/tags", + component: () => + import("@/pages/Entity/Tag/List.vue"), + meta: { + title: "TagList", + breadcrumbs: ["dashboard", "tagList"] + } + }, + { + name: "tagEdit", + path: "/tags/:id/edit", + component: () => + import("@/pages/Entity/Tag/Form.vue"), + meta: { + title: "TagEdit", + breadcrumbs: ["dashboard", "tagList", "tagEdit"] + } + }, + { + name: "tagAdd", + path: "/tags/add", + component: () => + import("@/pages/Entity/Tag/Form.vue"), + meta: { + title: "TagAdd", + breadcrumbs: ["dashboard", "tagList", "tagAdd"] + } + }, + /* City */ + { + name: "cityList", + path: "/cities", + component: () => + import("@/pages/Entity/City/List.vue"), + meta: { + title: "CityList", + breadcrumbs: ["dashboard", "cityList"] + } + }, + { + name: "cityEdit", + path: "/cities/:id/edit", + component: () => + import("@/pages/Entity/City/Form.vue"), + meta: { + title: "CityEdit", + breadcrumbs: ["dashboard", "cityList", "cityEdit"] + } + }, + { + name: "cityAdd", + path: "/cities/add", + component: () => + import("@/pages/Entity/City/Form.vue"), + meta: { + title: "CityAdd", + breadcrumbs: ["dashboard", "cityList", "cityAdd"] + } + }, + /* Country */ + { + name: "countryList", + path: "/countries", + component: () => + import("@/pages/Entity/Country/List.vue"), + meta: { + title: "CountryList", + breadcrumbs: ["dashboard", "countryList"] + } + }, + { + name: "countryEdit", + path: "/countries/:id/edit", + component: () => + import("@/pages/Entity/Country/Form.vue"), + meta: { + title: "CountryEdit", + breadcrumbs: ["dashboard", "countryList", "countryEdit"] + } + }, + { + name: "countryAdd", + path: "/countries/add", + component: () => + import("@/pages/Entity/Country/Form.vue"), + meta: { + title: "CountryAdd", + breadcrumbs: ["dashboard", "countryList", "countryAdd"] + } + }, + /* Region */ + { + name: "regionList", + path: "/regions", + component: () => + import("@/pages/Entity/Region/List.vue"), + meta: { + title: "RegionList", + breadcrumbs: ["dashboard", "regionList"] + } + }, + { + name: "regionEdit", + path: "/regions/:id/edit", + component: () => + import("@/pages/Entity/Region/Form.vue"), + meta: { + title: "RegionEdit", + breadcrumbs: ["dashboard", "regionList", "regionEdit"] + } + }, + { + name: "regionAdd", + path: "/regions/add", + component: () => + import("@/pages/Entity/Region/Form.vue"), + meta: { + title: "RegionAdd", + breadcrumbs: ["dashboard", "regionList", "regionAdd"] + } + }, + /* EncryptionKey */ + { + name: "encryptionKeyList", + path: "/encryption-keys", + component: () => + import("@/pages/Entity/EncryptionKey/List.vue"), + meta: { + title: "EncryptionKeyList", + breadcrumbs: ["dashboard", "encryptionKeyList"] + } + }, + { + name: "encryptionKeyEdit", + path: "/encryption-keys/:id/edit", + component: () => + import("@/pages/Entity/EncryptionKey/Form.vue"), + meta: { + title: "EncryptionKeyEdit", + breadcrumbs: ["dashboard", "encryptionKeyList", "encryptionKeyEdit"] + } + }, + { + name: "encryptionKeyAdd", + path: "/encryption-keys/add", + component: () => + import("@/pages/Entity/EncryptionKey/Form.vue"), + meta: { + title: "EncryptionKeyAdd", + breadcrumbs: ["dashboard", "encryptionKeyList", "encryptionKeyAdd"] + } + }, + /* LoginCode */ + { + name: "loginCodeList", + path: "/login-codes", + component: () => + import("@/pages/Entity/LoginCode/List.vue"), + meta: { + title: "LoginCodeList", + breadcrumbs: ["dashboard", "loginCodeList"] + } + }, + { + name: "loginCodeEdit", + path: "/login-codes/:id/edit", + component: () => + import("@/pages/Entity/LoginCode/Form.vue"), + meta: { + title: "LoginCodeEdit", + breadcrumbs: ["dashboard", "loginCodeList", "loginCodeEdit"] + } + }, + { + name: "loginCodeAdd", + path: "/login-codes/add", + component: () => + import("@/pages/Entity/LoginCode/Form.vue"), + meta: { + title: "LoginCodeAdd", + breadcrumbs: ["dashboard", "loginCodeList", "loginCodeAdd"] + } + }, + /* SiteUser */ + { + name: "siteUserList", + path: "/site-users", + component: () => + import("@/pages/Entity/SiteUser/List.vue"), + meta: { + title: "SiteUserList", + breadcrumbs: ["dashboard", "siteUserList"] + } + }, + { + name: "siteUserEdit", + path: "/site-users/:id/edit", + component: () => + import("@/pages/Entity/SiteUser/Form.vue"), + meta: { + title: "SiteUserEdit", + breadcrumbs: ["dashboard", "siteUserList", "siteUserEdit"] + } + }, + { + name: "siteUserAdd", + path: "/site-users/add", + component: () => + import("@/pages/Entity/SiteUser/Form.vue"), + meta: { + title: "SiteUserAdd", + breadcrumbs: ["dashboard", "siteUserList", "siteUserAdd"] + } + }, + /* VfsFile */ + { + name: "vfsFileList", + path: "/vfs-files", + component: () => + import("@/pages/Entity/VfsFile/List.vue"), + meta: { + title: "VfsFileList", + breadcrumbs: ["dashboard", "vfsFileList"] + } + }, + { + name: "vfsFileEdit", + path: "/vfs-files/:id/edit", + component: () => + import("@/pages/Entity/VfsFile/Form.vue"), + meta: { + title: "VfsFileEdit", + breadcrumbs: ["dashboard", "vfsFileList", "vfsFileEdit"] + } + }, + { + name: "vfsFileAdd", + path: "/vfs-files/add", + component: () => + import("@/pages/Entity/VfsFile/Form.vue"), + meta: { + title: "VfsFileAdd", + breadcrumbs: ["dashboard", "vfsFileList", "vfsFileAdd"] + } + }, + /* VfsFolder */ + { + name: "vfsFolderList", + path: "/vfs-folders", + component: () => + import("@/pages/Entity/VfsFolder/List.vue"), + meta: { + title: "VfsFolderList", + breadcrumbs: ["dashboard", "vfsFolderList"] + } + }, + { + name: "vfsFolderEdit", + path: "/vfs-folders/:id/edit", + component: () => + import("@/pages/Entity/VfsFolder/Form.vue"), + meta: { + title: "VfsFolderEdit", + breadcrumbs: ["dashboard", "vfsFolderList", "vfsFolderEdit"] + } + }, + { + name: "vfsFolderAdd", + path: "/vfs-folders/add", + component: () => + import("@/pages/Entity/VfsFolder/Form.vue"), + meta: { + title: "VfsFolderAdd", + breadcrumbs: ["dashboard", "vfsFolderList", "vfsFolderAdd"] + } + }, +]; diff --git a/generators/testdata/expected/vt-template/entities/src/pages/Entity/Category/Form.vue b/generators/testdata/expected/vt-template/entities/src/pages/Entity/Category/Form.vue index ab8d2d8..49ec139 100644 --- a/generators/testdata/expected/vt-template/entities/src/pages/Entity/Category/Form.vue +++ b/generators/testdata/expected/vt-template/entities/src/pages/Entity/Category/Form.vue @@ -15,7 +15,7 @@ >

- {{ model.title || "..." }} + {{ store.model.title || "..." }}

@@ -23,7 +23,7 @@ - + done - {{ t("common.form.saveAndCloseButtonLabel") }} + {{ $t("common.form.saveAndCloseButtonLabel") }} - {{ t("common.form.saveButtonLabel") }} + {{ $t("common.form.saveButtonLabel") }} @@ -150,58 +150,17 @@ diff --git a/generators/testdata/expected/vt-template/entities/src/pages/Entity/Category/List.vue b/generators/testdata/expected/vt-template/entities/src/pages/Entity/Category/List.vue index 261806a..f2e6d2a 100644 --- a/generators/testdata/expected/vt-template/entities/src/pages/Entity/Category/List.vue +++ b/generators/testdata/expected/vt-template/entities/src/pages/Entity/Category/List.vue @@ -18,26 +18,27 @@

- {{ t("category.list.title") }} + {{ $t("category.list.title") }}

- {{ pagination.totalItems }} + {{ store.pagination.totalItems }}
- add - {{ t("common.list.addNewLabel") }} + + add + + {{ $t("common.list.addNewLabel") }} @@ -63,9 +64,9 @@ mr-sm-2 > @@ -100,9 +100,9 @@ @@ -164,76 +164,48 @@ diff --git a/generators/testdata/expected/vt-template/entities/src/pages/Entity/Category/components/MultiListFilters.vue b/generators/testdata/expected/vt-template/entities/src/pages/Entity/Category/components/MultiListFilters.vue index a6fedaf..fc765eb 100644 --- a/generators/testdata/expected/vt-template/entities/src/pages/Entity/Category/components/MultiListFilters.vue +++ b/generators/testdata/expected/vt-template/entities/src/pages/Entity/Category/components/MultiListFilters.vue @@ -1,43 +1,26 @@ diff --git a/generators/testdata/expected/vt-template/entities/src/pages/Entity/Tag/Form.vue b/generators/testdata/expected/vt-template/entities/src/pages/Entity/Tag/Form.vue index 6630576..e46587a 100644 --- a/generators/testdata/expected/vt-template/entities/src/pages/Entity/Tag/Form.vue +++ b/generators/testdata/expected/vt-template/entities/src/pages/Entity/Tag/Form.vue @@ -15,7 +15,7 @@ >

- {{ model.title || "..." }} + {{ store.model.title || "..." }}

@@ -23,7 +23,7 @@ - + done - {{ t("common.form.saveAndCloseButtonLabel") }} + {{ $t("common.form.saveAndCloseButtonLabel") }} - {{ t("common.form.saveButtonLabel") }} + {{ $t("common.form.saveButtonLabel") }} @@ -142,58 +142,17 @@ diff --git a/generators/testdata/expected/vt-template/entities/src/pages/Entity/Tag/List.vue b/generators/testdata/expected/vt-template/entities/src/pages/Entity/Tag/List.vue index 71dec4b..59f5d65 100644 --- a/generators/testdata/expected/vt-template/entities/src/pages/Entity/Tag/List.vue +++ b/generators/testdata/expected/vt-template/entities/src/pages/Entity/Tag/List.vue @@ -18,26 +18,27 @@

- {{ t("tag.list.title") }} + {{ $t("tag.list.title") }}

- {{ pagination.totalItems }} + {{ store.pagination.totalItems }}
- add - {{ t("common.list.addNewLabel") }} + + add + + {{ $t("common.list.addNewLabel") }} @@ -63,9 +64,9 @@ mr-sm-2 > @@ -100,9 +100,9 @@ @@ -161,72 +161,44 @@ diff --git a/generators/testdata/expected/vt-template/entities/src/pages/Entity/Tag/components/MultiListFilters.vue b/generators/testdata/expected/vt-template/entities/src/pages/Entity/Tag/components/MultiListFilters.vue index 523e594..4e5ae81 100644 --- a/generators/testdata/expected/vt-template/entities/src/pages/Entity/Tag/components/MultiListFilters.vue +++ b/generators/testdata/expected/vt-template/entities/src/pages/Entity/Tag/components/MultiListFilters.vue @@ -1,43 +1,26 @@ diff --git a/generators/testdata/expected/vt-template/entities/src/pages/Entity/routes.ts b/generators/testdata/expected/vt-template/entities/src/pages/Entity/routes.ts index 198b28f..7c69d18 100644 --- a/generators/testdata/expected/vt-template/entities/src/pages/Entity/routes.ts +++ b/generators/testdata/expected/vt-template/entities/src/pages/Entity/routes.ts @@ -1,344 +1,311 @@ /* eslint-disable */ export default [ - /* Category */ - { - name: "categoryList", - path: "/categories", - component: () => - import("@/pages/Entity/Category/List.vue"), - meta: { - title: "CategoryList", - breadcrumbs: ["dashboard", "categoryList"] - } - }, - { - name: "categoryEdit", - path: "/categories/:id/edit", - component: () => - import("@/pages/Entity/Category/Form.vue"), - meta: { - title: "CategoryEdit", - breadcrumbs: ["dashboard", "categoryList", "categoryEdit"] - } - }, - { - name: "categoryAdd", - path: "/categories/add", - component: () => - import("@/pages/Entity/Category/Form.vue"), - meta: { - title: "CategoryAdd", - breadcrumbs: ["dashboard", "categoryList", "categoryAdd"] - } - }, - /* News */ - { - name: "newsList", - path: "/news", - component: () => - import("@/pages/Entity/News/List.vue"), - meta: { - title: "NewsList", - breadcrumbs: ["dashboard", "newsList"] - } - }, - { - name: "newsEdit", - path: "/news/:id/edit", - component: () => - import("@/pages/Entity/News/Form.vue"), - meta: { - title: "NewsEdit", - breadcrumbs: ["dashboard", "newsList", "newsEdit"] - } - }, - { - name: "newsAdd", - path: "/news/add", - component: () => - import("@/pages/Entity/News/Form.vue"), - meta: { - title: "NewsAdd", - breadcrumbs: ["dashboard", "newsList", "newsAdd"] - } - }, - /* Tag */ - { - name: "tagList", - path: "/tags", - component: () => - import("@/pages/Entity/Tag/List.vue"), - meta: { - title: "TagList", - breadcrumbs: ["dashboard", "tagList"] - } - }, - { - name: "tagEdit", - path: "/tags/:id/edit", - component: () => - import("@/pages/Entity/Tag/Form.vue"), - meta: { - title: "TagEdit", - breadcrumbs: ["dashboard", "tagList", "tagEdit"] - } - }, - { - name: "tagAdd", - path: "/tags/add", - component: () => - import("@/pages/Entity/Tag/Form.vue"), - meta: { - title: "TagAdd", - breadcrumbs: ["dashboard", "tagList", "tagAdd"] - } - }, - /* City */ - { - name: "cityList", - path: "/cities", - component: () => - import("@/pages/Entity/City/List.vue"), - meta: { - title: "CityList", - breadcrumbs: ["dashboard", "cityList"] - } - }, - { - name: "cityEdit", - path: "/cities/:id/edit", - component: () => - import("@/pages/Entity/City/Form.vue"), - meta: { - title: "CityEdit", - breadcrumbs: ["dashboard", "cityList", "cityEdit"] - } - }, - { - name: "cityAdd", - path: "/cities/add", - component: () => - import("@/pages/Entity/City/Form.vue"), - meta: { - title: "CityAdd", - breadcrumbs: ["dashboard", "cityList", "cityAdd"] - } - }, - /* Country */ - { - name: "countryList", - path: "/countries", - component: () => - import("@/pages/Entity/Country/List.vue"), - meta: { - title: "CountryList", - breadcrumbs: ["dashboard", "countryList"] - } - }, - { - name: "countryEdit", - path: "/countries/:id/edit", - component: () => - import("@/pages/Entity/Country/Form.vue"), - meta: { - title: "CountryEdit", - breadcrumbs: ["dashboard", "countryList", "countryEdit"] - } - }, - { - name: "countryAdd", - path: "/countries/add", - component: () => - import("@/pages/Entity/Country/Form.vue"), - meta: { - title: "CountryAdd", - breadcrumbs: ["dashboard", "countryList", "countryAdd"] - } - }, - /* Region */ - { - name: "regionList", - path: "/regions", - component: () => - import("@/pages/Entity/Region/List.vue"), - meta: { - title: "RegionList", - breadcrumbs: ["dashboard", "regionList"] - } - }, - { - name: "regionEdit", - path: "/regions/:id/edit", - component: () => - import("@/pages/Entity/Region/Form.vue"), - meta: { - title: "RegionEdit", - breadcrumbs: ["dashboard", "regionList", "regionEdit"] - } - }, - { - name: "regionAdd", - path: "/regions/add", - component: () => - import("@/pages/Entity/Region/Form.vue"), - meta: { - title: "RegionAdd", - breadcrumbs: ["dashboard", "regionList", "regionAdd"] - } - }, - /* EncryptionKey */ - { - name: "encryptionKeyList", - path: "/encryption-keys", - component: () => - import("@/pages/Entity/EncryptionKey/List.vue"), - meta: { - title: "EncryptionKeyList", - breadcrumbs: ["dashboard", "encryptionKeyList"] - } - }, - { - name: "encryptionKeyEdit", - path: "/encryption-keys/:id/edit", - component: () => - import("@/pages/Entity/EncryptionKey/Form.vue"), - meta: { - title: "EncryptionKeyEdit", - breadcrumbs: ["dashboard", "encryptionKeyList", "encryptionKeyEdit"] - } - }, - { - name: "encryptionKeyAdd", - path: "/encryption-keys/add", - component: () => - import("@/pages/Entity/EncryptionKey/Form.vue"), - meta: { - title: "EncryptionKeyAdd", - breadcrumbs: ["dashboard", "encryptionKeyList", "encryptionKeyAdd"] - } - }, - /* LoginCode */ - { - name: "loginCodeList", - path: "/login-codes", - component: () => - import("@/pages/Entity/LoginCode/List.vue"), - meta: { - title: "LoginCodeList", - breadcrumbs: ["dashboard", "loginCodeList"] - } - }, - { - name: "loginCodeEdit", - path: "/login-codes/:id/edit", - component: () => - import("@/pages/Entity/LoginCode/Form.vue"), - meta: { - title: "LoginCodeEdit", - breadcrumbs: ["dashboard", "loginCodeList", "loginCodeEdit"] - } - }, - { - name: "loginCodeAdd", - path: "/login-codes/add", - component: () => - import("@/pages/Entity/LoginCode/Form.vue"), - meta: { - title: "LoginCodeAdd", - breadcrumbs: ["dashboard", "loginCodeList", "loginCodeAdd"] - } - }, - /* SiteUser */ - { - name: "siteUserList", - path: "/site-users", - component: () => - import("@/pages/Entity/SiteUser/List.vue"), - meta: { - title: "SiteUserList", - breadcrumbs: ["dashboard", "siteUserList"] - } - }, - { - name: "siteUserEdit", - path: "/site-users/:id/edit", - component: () => - import("@/pages/Entity/SiteUser/Form.vue"), - meta: { - title: "SiteUserEdit", - breadcrumbs: ["dashboard", "siteUserList", "siteUserEdit"] - } - }, - { - name: "siteUserAdd", - path: "/site-users/add", - component: () => - import("@/pages/Entity/SiteUser/Form.vue"), - meta: { - title: "SiteUserAdd", - breadcrumbs: ["dashboard", "siteUserList", "siteUserAdd"] - } - }, - /* VfsFile */ - { - name: "vfsFileList", - path: "/vfs-files", - component: () => - import("@/pages/Entity/VfsFile/List.vue"), - meta: { - title: "VfsFileList", - breadcrumbs: ["dashboard", "vfsFileList"] - } - }, - { - name: "vfsFileEdit", - path: "/vfs-files/:id/edit", - component: () => - import("@/pages/Entity/VfsFile/Form.vue"), - meta: { - title: "VfsFileEdit", - breadcrumbs: ["dashboard", "vfsFileList", "vfsFileEdit"] - } - }, - { - name: "vfsFileAdd", - path: "/vfs-files/add", - component: () => - import("@/pages/Entity/VfsFile/Form.vue"), - meta: { - title: "VfsFileAdd", - breadcrumbs: ["dashboard", "vfsFileList", "vfsFileAdd"] - } - }, - /* VfsFolder */ - { - name: "vfsFolderList", - path: "/vfs-folders", - component: () => - import("@/pages/Entity/VfsFolder/List.vue"), - meta: { - title: "VfsFolderList", - breadcrumbs: ["dashboard", "vfsFolderList"] - } - }, - { - name: "vfsFolderEdit", - path: "/vfs-folders/:id/edit", - component: () => - import("@/pages/Entity/VfsFolder/Form.vue"), - meta: { - title: "VfsFolderEdit", - breadcrumbs: ["dashboard", "vfsFolderList", "vfsFolderEdit"] - } - }, - { - name: "vfsFolderAdd", - path: "/vfs-folders/add", - component: () => - import("@/pages/Entity/VfsFolder/Form.vue"), - meta: { - title: "VfsFolderAdd", - breadcrumbs: ["dashboard", "vfsFolderList", "vfsFolderAdd"] - } - }, + /* Category */ + { + name: "categoryList", + path: "/categories", + component: () => + import("@/pages/Entity/Category/List.vue"), + meta: { + breadcrumbs: ["dashboard", "categoryList"] + } + }, + { + name: "categoryEdit", + path: "/categories/:id/edit", + component: () => + import("@/pages/Entity/Category/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "categoryList", "categoryEdit"] + } + }, + { + name: "categoryAdd", + path: "/categories/add", + component: () => + import("@/pages/Entity/Category/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "categoryList", "categoryAdd"] + } + }, + /* News */ + { + name: "newsList", + path: "/news", + component: () => + import("@/pages/Entity/News/List.vue"), + meta: { + breadcrumbs: ["dashboard", "newsList"] + } + }, + { + name: "newsEdit", + path: "/news/:id/edit", + component: () => + import("@/pages/Entity/News/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "newsList", "newsEdit"] + } + }, + { + name: "newsAdd", + path: "/news/add", + component: () => + import("@/pages/Entity/News/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "newsList", "newsAdd"] + } + }, + /* Tag */ + { + name: "tagList", + path: "/tags", + component: () => + import("@/pages/Entity/Tag/List.vue"), + meta: { + breadcrumbs: ["dashboard", "tagList"] + } + }, + { + name: "tagEdit", + path: "/tags/:id/edit", + component: () => + import("@/pages/Entity/Tag/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "tagList", "tagEdit"] + } + }, + { + name: "tagAdd", + path: "/tags/add", + component: () => + import("@/pages/Entity/Tag/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "tagList", "tagAdd"] + } + }, + /* City */ + { + name: "cityList", + path: "/cities", + component: () => + import("@/pages/Entity/City/List.vue"), + meta: { + breadcrumbs: ["dashboard", "cityList"] + } + }, + { + name: "cityEdit", + path: "/cities/:id/edit", + component: () => + import("@/pages/Entity/City/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "cityList", "cityEdit"] + } + }, + { + name: "cityAdd", + path: "/cities/add", + component: () => + import("@/pages/Entity/City/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "cityList", "cityAdd"] + } + }, + /* Country */ + { + name: "countryList", + path: "/countries", + component: () => + import("@/pages/Entity/Country/List.vue"), + meta: { + breadcrumbs: ["dashboard", "countryList"] + } + }, + { + name: "countryEdit", + path: "/countries/:id/edit", + component: () => + import("@/pages/Entity/Country/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "countryList", "countryEdit"] + } + }, + { + name: "countryAdd", + path: "/countries/add", + component: () => + import("@/pages/Entity/Country/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "countryList", "countryAdd"] + } + }, + /* Region */ + { + name: "regionList", + path: "/regions", + component: () => + import("@/pages/Entity/Region/List.vue"), + meta: { + breadcrumbs: ["dashboard", "regionList"] + } + }, + { + name: "regionEdit", + path: "/regions/:id/edit", + component: () => + import("@/pages/Entity/Region/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "regionList", "regionEdit"] + } + }, + { + name: "regionAdd", + path: "/regions/add", + component: () => + import("@/pages/Entity/Region/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "regionList", "regionAdd"] + } + }, + /* EncryptionKey */ + { + name: "encryptionKeyList", + path: "/encryption-keys", + component: () => + import("@/pages/Entity/EncryptionKey/List.vue"), + meta: { + breadcrumbs: ["dashboard", "encryptionKeyList"] + } + }, + { + name: "encryptionKeyEdit", + path: "/encryption-keys/:id/edit", + component: () => + import("@/pages/Entity/EncryptionKey/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "encryptionKeyList", "encryptionKeyEdit"] + } + }, + { + name: "encryptionKeyAdd", + path: "/encryption-keys/add", + component: () => + import("@/pages/Entity/EncryptionKey/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "encryptionKeyList", "encryptionKeyAdd"] + } + }, + /* LoginCode */ + { + name: "loginCodeList", + path: "/login-codes", + component: () => + import("@/pages/Entity/LoginCode/List.vue"), + meta: { + breadcrumbs: ["dashboard", "loginCodeList"] + } + }, + { + name: "loginCodeEdit", + path: "/login-codes/:id/edit", + component: () => + import("@/pages/Entity/LoginCode/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "loginCodeList", "loginCodeEdit"] + } + }, + { + name: "loginCodeAdd", + path: "/login-codes/add", + component: () => + import("@/pages/Entity/LoginCode/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "loginCodeList", "loginCodeAdd"] + } + }, + /* SiteUser */ + { + name: "siteUserList", + path: "/site-users", + component: () => + import("@/pages/Entity/SiteUser/List.vue"), + meta: { + breadcrumbs: ["dashboard", "siteUserList"] + } + }, + { + name: "siteUserEdit", + path: "/site-users/:id/edit", + component: () => + import("@/pages/Entity/SiteUser/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "siteUserList", "siteUserEdit"] + } + }, + { + name: "siteUserAdd", + path: "/site-users/add", + component: () => + import("@/pages/Entity/SiteUser/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "siteUserList", "siteUserAdd"] + } + }, + /* VfsFile */ + { + name: "vfsFileList", + path: "/vfs-files", + component: () => + import("@/pages/Entity/VfsFile/List.vue"), + meta: { + breadcrumbs: ["dashboard", "vfsFileList"] + } + }, + { + name: "vfsFileEdit", + path: "/vfs-files/:id/edit", + component: () => + import("@/pages/Entity/VfsFile/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "vfsFileList", "vfsFileEdit"] + } + }, + { + name: "vfsFileAdd", + path: "/vfs-files/add", + component: () => + import("@/pages/Entity/VfsFile/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "vfsFileList", "vfsFileAdd"] + } + }, + /* VfsFolder */ + { + name: "vfsFolderList", + path: "/vfs-folders", + component: () => + import("@/pages/Entity/VfsFolder/List.vue"), + meta: { + breadcrumbs: ["dashboard", "vfsFolderList"] + } + }, + { + name: "vfsFolderEdit", + path: "/vfs-folders/:id/edit", + component: () => + import("@/pages/Entity/VfsFolder/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "vfsFolderList", "vfsFolderEdit"] + } + }, + { + name: "vfsFolderAdd", + path: "/vfs-folders/add", + component: () => + import("@/pages/Entity/VfsFolder/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "vfsFolderList", "vfsFolderAdd"] + } + }, ]; diff --git a/generators/vt-template/README.md b/generators/vt-template/README.md index e0d7255..230b670 100644 --- a/generators/vt-template/README.md +++ b/generators/vt-template/README.md @@ -25,10 +25,19 @@ Flags: -o, --output string output dir path -m, --mfd string mfd file path -n, --namespaces strings namespaces to generate. separate by comma + -e, --entities strings entities to generate, must be in vt.xml file. separate by comma -h, --help help for template ``` +#### Шаблоны + +Встроенные шаблоны существуют в двух вариантах: +- **default** (по умолчанию) — class-based компоненты на `vue-property-decorator` + `mobx-vue`. +- **Composition API** — генерирует компоненты через `defineComponent`/`setup` и подключает composables (`useEntityList`, `useEntityForm`, `useI18n`), которые должны существовать во фронтенд-проекте (`@/composables/...`); в `routes.ts` добавляется поле `meta.title`. + +Выбор варианта задаётся на уровне проекта в mfd-файле . В корневом `` добавьте элемент `true` — при его наличии используются Composition API шаблоны. Если элемент отсутствует или `false`, используются default class-based шаблоны. + #### MODE Значение Mode vt-сущности в vt.xml определяет какие файлы будут сгенерированы. @@ -36,6 +45,12 @@ Flags: - "ReadOnlyWithTemplates" - все файлы в read-only режиме, Form.vue генерироваться не будет - "None" - файлы генерироваться не будут +#### Частичная генерация + +Флаги `-n --namespaces` и `-e --entities` ограничивают набор сущностей, для которых генерируются файлы. Если ни один из них не указан, обрабатываются все неймспейсы и сущности. + +При частичной генерации `routes.ts` обновляется точечно: перезаписываются только блоки указанных сущностей (по маркеру `/* EntityName */`), остальная часть файла сохраняется. Если целевой сущности в файле ещё нет — её блок дописывается в конец. При полной генерации (без `-n`/`-e`) `routes.ts` перезаписывается целиком. + #### Особенности работы с существующими моделями -Все файлы будут перезаписаны при каждой генерации. +Файлы сущностей (`List.vue`, `Form.vue`, `MultiListFilters.vue`, переводы) перезаписываются при каждой генерации. Исключение — `routes.ts` при частичной генерации (см. выше). diff --git a/generators/vt-template/generator.go b/generators/vt-template/generator.go index 9239f76..80200ad 100644 --- a/generators/vt-template/generator.go +++ b/generators/vt-template/generator.go @@ -121,23 +121,27 @@ func (g *Generator) Generate() error { g.options.Namespaces = project.NamespaceNames } + // selecting built-in templates set based on the project-level setting: + // composition (VTComposition=true) or default class-based templates + defRoutes, defList, defFilter, defForm := g.defaultTemplates(project.VTComposition) + // loading templates - routesTemplate, err := mfd.LoadTemplate(g.options.RoutesTemplatePath, routesDefaultTemplate) + routesTemplate, err := mfd.LoadTemplate(g.options.RoutesTemplatePath, defRoutes) if err != nil { return fmt.Errorf("load routes template, err=%w", err) } - listTemplate, err := mfd.LoadTemplate(g.options.ListTemplatePath, listDefaultTemplate) + listTemplate, err := mfd.LoadTemplate(g.options.ListTemplatePath, defList) if err != nil { return fmt.Errorf("load list template, err=%w", err) } - filterTemplate, err := mfd.LoadTemplate(g.options.FiltersTemplatePath, filterDefaultTemplate) + filterTemplate, err := mfd.LoadTemplate(g.options.FiltersTemplatePath, defFilter) if err != nil { return fmt.Errorf("load filter template, err=%w", err) } - formTemplate, err := mfd.LoadTemplate(g.options.ListTemplatePath, formDefaultTemplate) + formTemplate, err := mfd.LoadTemplate(g.options.FormTemplatePath, defForm) if err != nil { return fmt.Errorf("load form template, err=%w", err) } @@ -201,6 +205,18 @@ func (g *Generator) Generate() error { return mfd.SaveMFD(g.options.MFDPath, project) } +// defaultTemplates returns the built-in templates set used as fallback when no +// custom template path is provided. When composition is true (driven by the +// project-level VTComposition setting) it returns the Vue Composition API +// templates, otherwise the default class-based ones. +func (g *Generator) defaultTemplates(composition bool) (routes, list, filter, form string) { + if composition { + return routesCompositionTemplate, listCompositionTemplate, filterCompositionTemplate, formCompositionTemplate + } + + return routesDefaultTemplate, listDefaultTemplate, filterDefaultTemplate, formDefaultTemplate +} + func (g *Generator) getTargetEntities(project *mfd.Project) []string { var targetEntities []string nsList := g.options.Namespaces diff --git a/generators/vt-template/generator_test.go b/generators/vt-template/generator_test.go index bf7727b..d7984ba 100644 --- a/generators/vt-template/generator_test.go +++ b/generators/vt-template/generator_test.go @@ -8,17 +8,24 @@ import ( "testing" "github.com/vmkteam/mfd-generator/generators/testdata" + "github.com/vmkteam/mfd-generator/mfd" . "github.com/smartystreets/goconvey/convey" ) func TestGenerator_Generate(t *testing.T) { + // clean up leftover output from previous runs so partial routes injection starts fresh + _ = os.RemoveAll(testdata.PathActualVTTemplateAll) + _ = os.RemoveAll(testdata.PathActualVTTemplateEntity) + Convey("TestGenerator_Generate", t, func() { generator := New() generator.options.Output = testdata.PathActualVTTemplateAll generator.options.MFDPath = testdata.PathExpectedMFD generator.options.Namespaces = []string{"portal"} + // expected testdata is generated with default class-based templates + // (project mfd has no VTComposition setting) Convey("Check correct generate", func() { t.Log("Generate vt-template") @@ -105,6 +112,68 @@ func TestGenerator_Generate(t *testing.T) { }) } +func TestGenerator_GenerateComposition(t *testing.T) { + // clean up leftover output from previous runs so partial routes injection starts fresh + _ = os.RemoveAll(testdata.PathActualVTTemplateComposition) + + // build a temp mfd with the project-level VTComposition setting enabled, + // placed next to the translation files so they still resolve + project, err := mfd.LoadProject(testdata.PathExpectedMFD, false, 0) + if err != nil { + t.Fatal(err) + } + project.VTComposition = true + compositionMFD := filepath.Join(filepath.Dir(testdata.PathExpectedMFD), "newsportal.composition.mfd") + if err := mfd.SaveMFD(compositionMFD, project); err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = os.Remove(compositionMFD) }) + + Convey("TestGenerator_GenerateComposition", t, func() { + generator := New() + + generator.options.Output = testdata.PathActualVTTemplateComposition + // composition templates are selected via the project-level VTComposition setting + generator.options.MFDPath = compositionMFD + generator.options.Namespaces = []string{"portal"} + + Convey("Check correct generate with composition templates", func() { + t.Log("Generate vt-template with composition templates") + So(generator.Generate(), ShouldBeNil) + }) + + filePrefix := filepath.Join("src", "pages", "Entity") + + Convey("Check generated composition files", func() { + expectedFilenames := map[string]struct{}{ + filepath.Join("Category", "List.vue"): {}, + filepath.Join("Category", "Form.vue"): {}, + filepath.Join("Category", "en.json"): {}, + filepath.Join("Category", "components", "MultiListFilters.vue"): {}, + filepath.Join("News", "List.vue"): {}, + filepath.Join("News", "Form.vue"): {}, + filepath.Join("News", "en.json"): {}, + filepath.Join("News", "components", "MultiListFilters.vue"): {}, + filepath.Join("Tag", "List.vue"): {}, + filepath.Join("Tag", "Form.vue"): {}, + filepath.Join("Tag", "en.json"): {}, + filepath.Join("Tag", "components", "MultiListFilters.vue"): {}, + "routes.ts": {}, + } + + for f := range expectedFilenames { + filenameWithFullPath := filepath.Join(testdata.PathActualVTTemplateComposition, filePrefix, f) + t.Logf("Check %s file", filenameWithFullPath) + content, err := os.ReadFile(filenameWithFullPath) + So(err, ShouldBeNil) + expectedContent, err := os.ReadFile(filepath.Join(testdata.PathExpectedVTTemplateComposition, filePrefix, f)) + So(err, ShouldBeNil) + So(string(content), ShouldResemble, string(expectedContent)) + } + }) + }) +} + func fullFilesPaths(path string) ([]string, error) { files, err := os.ReadDir(path) if err != nil { diff --git a/generators/vt-template/template.go b/generators/vt-template/template.go index 1d89d0b..10912aa 100644 --- a/generators/vt-template/template.go +++ b/generators/vt-template/template.go @@ -2,37 +2,34 @@ package vttmpl const routesDefaultTemplate = `/* eslint-disable */ export default [{{range $model := .Entities}} - /* {{.Name}} */ - { - name: "{{.JSName}}List", - path: "/{{.TerminalPath}}", - component: () => - import("@/pages/Entity/{{.Name}}/List.vue"), - meta: { - title: "{{.Name}}List", - breadcrumbs: ["dashboard", "{{.JSName}}List"] - } - }, - {{if not .ReadOnly}}{ - name: "{{.JSName}}Edit", - path: "/{{.TerminalPath}}/:id/edit", - component: () => - import("@/pages/Entity/{{.Name}}/Form.vue"), - meta: { - title: "{{.Name}}Edit", - breadcrumbs: ["dashboard", "{{.JSName}}List", "{{.JSName}}Edit"] - } - }, - { - name: "{{.JSName}}Add", - path: "/{{.TerminalPath}}/add", - component: () => - import("@/pages/Entity/{{.Name}}/Form.vue"), - meta: { - title: "{{.Name}}Add", - breadcrumbs: ["dashboard", "{{.JSName}}List", "{{.JSName}}Add"] - } - },{{end}}{{end}} + /* {{.Name}} */ + { + name: "{{.JSName}}List", + path: "/{{.TerminalPath}}", + component: () => + import("@/pages/Entity/{{.Name}}/List.vue"), + meta: { + breadcrumbs: ["dashboard", "{{.JSName}}List"] + } + }, + {{if not .ReadOnly}}{ + name: "{{.JSName}}Edit", + path: "/{{.TerminalPath}}/:id/edit", + component: () => + import("@/pages/Entity/{{.Name}}/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "{{.JSName}}List", "{{.JSName}}Edit"] + } + }, + { + name: "{{.JSName}}Add", + path: "/{{.TerminalPath}}/add", + component: () => + import("@/pages/Entity/{{.Name}}/Form.vue"), + meta: { + breadcrumbs: ["dashboard", "{{.JSName}}List", "{{.JSName}}Add"] + } + },{{end}}{{end}} ]; ` @@ -57,26 +54,27 @@ const listDefaultTemplate = `