@tager/admin-blog 0.3.41 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants/paths.d.ts +6 -14
- package/dist/constants/routes.d.ts +5 -5
- package/dist/dev/App.vue.d.ts +5 -0
- package/dist/dev/config.d.ts +2 -0
- package/dist/dev/env.d.ts +1 -0
- package/dist/dev/main.d.ts +3 -0
- package/dist/hooks/index.d.ts +4 -4
- package/dist/hooks/useFetchCategories.d.ts +3 -6
- package/dist/hooks/useFetchCategory.d.ts +7 -8
- package/dist/hooks/useFetchModuleConfig.d.ts +3 -6
- package/dist/hooks/useFetchPosts.d.ts +3 -6
- package/dist/index.mjs +2363 -0
- package/dist/locales/apply.d.ts +1 -0
- package/dist/locales/en.d.ts +87 -80
- package/dist/locales/ru.d.ts +3 -3
- package/dist/main.d.ts +3 -4
- package/dist/services/requests.d.ts +59 -57
- package/dist/style.css +1 -0
- package/dist/typings/common.d.ts +1 -1
- package/dist/typings/model.d.ts +106 -104
- package/dist/utils/common.d.ts +2 -2
- package/dist/utils/paths.d.ts +8 -0
- package/dist/views/Categories/CategoryForm/CategoryForm.helpers.d.ts +7 -7
- package/dist/views/Categories/CategoryForm/CategoryForm.vue.d.ts +53 -116
- package/dist/views/Categories/CategoryForm/index.d.ts +1 -1
- package/dist/views/Categories/CategoryList/CategoryList.helpers.d.ts +7 -7
- package/dist/views/Categories/CategoryList/CategoryList.vue.d.ts +26 -57
- package/dist/views/Categories/CategoryList/hooks/index.d.ts +1 -1
- package/dist/views/Categories/CategoryList/hooks/useAdvancedSearch.d.ts +19 -16
- package/dist/views/Categories/CategoryList/index.d.ts +1 -1
- package/dist/views/Posts/PostForm/PostForm.helpers.d.ts +32 -30
- package/dist/views/Posts/PostForm/PostForm.vue.d.ts +2768 -9394
- package/dist/views/Posts/PostForm/components/TabList/TabList.types.d.ts +5 -5
- package/dist/views/Posts/PostForm/components/TabList/TabList.vue.d.ts +23 -0
- package/dist/views/Posts/PostForm/components/TabList/index.d.ts +2 -2
- package/dist/views/Posts/PostForm/index.d.ts +1 -1
- package/dist/views/Posts/PostList/PostList.helpers.d.ts +7 -7
- package/dist/views/Posts/PostList/PostList.vue.d.ts +38 -71
- package/dist/views/Posts/PostList/hooks/index.d.ts +1 -1
- package/dist/views/Posts/PostList/hooks/useAdvancedSearch.d.ts +27 -24
- package/dist/views/Posts/PostList/index.d.ts +1 -1
- package/package.json +51 -49
- package/src/constants/paths.ts +0 -22
- package/src/constants/routes.ts +9 -9
- package/src/dev/App.vue +56 -0
- package/src/dev/config.ts +23 -0
- package/src/dev/env.ts +17 -0
- package/src/dev/main.ts +49 -0
- package/src/hooks/useFetchCategories.ts +2 -7
- package/src/hooks/useFetchCategory.ts +3 -6
- package/src/hooks/useFetchModuleConfig.ts +2 -7
- package/src/hooks/useFetchPosts.ts +2 -5
- package/src/locales/apply.ts +9 -0
- package/src/locales/en.ts +10 -3
- package/src/locales/ru.ts +11 -2
- package/src/main.ts +3 -8
- package/src/services/requests.ts +2 -0
- package/src/typings/model.ts +2 -0
- package/src/utils/paths.ts +23 -0
- package/src/views/Categories/CategoryForm/CategoryForm.vue +81 -61
- package/src/views/Categories/CategoryList/CategoryList.helpers.ts +1 -1
- package/src/views/Categories/CategoryList/CategoryList.vue +86 -58
- package/src/views/Categories/CategoryList/hooks/useAdvancedSearch.ts +9 -12
- package/src/views/Posts/PostForm/PostForm.helpers.ts +15 -7
- package/src/views/Posts/PostForm/PostForm.vue +191 -112
- package/src/views/Posts/PostForm/components/TabList/TabList.vue +2 -2
- package/src/views/Posts/PostList/PostList.helpers.ts +9 -10
- package/src/views/Posts/PostList/PostList.vue +138 -105
- package/src/views/Posts/PostList/hooks/useAdvancedSearch.ts +22 -30
- package/CHANGELOG.md +0 -13
- package/dist/constants/menu.d.ts +0 -5
- package/dist/dev.d.ts +0 -1
- package/dist/index.esm.js +0 -5144
- package/dist/index.umd.js +0 -5171
- package/dist/router/index.d.ts +0 -4
- package/src/constants/menu.ts +0 -31
- package/src/dev.ts +0 -34
- package/src/router/index.ts +0 -40
- package/src/typings/sfc.d.ts +0 -12
- package/src/typings/shims-tsx.d.ts +0 -13
- package/src/typings/shims-vue.d.ts +0 -11
- package/src/typings/translate.d.ts +0 -10
- package/src/views/App.vue +0 -22
- package/src/views/Home.vue +0 -31
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { onMounted, Ref,
|
|
1
|
+
import { onMounted, Ref, watch } from 'vue';
|
|
2
2
|
|
|
3
3
|
import { Nullable, ResourceRef, useResource } from '@tager/admin-services';
|
|
4
4
|
|
|
@@ -6,23 +6,20 @@ import { Category } from '../typings/model';
|
|
|
6
6
|
import { getCategory } from '../services/requests';
|
|
7
7
|
|
|
8
8
|
export function useFetchCategory({
|
|
9
|
-
context,
|
|
10
9
|
categoryId,
|
|
11
10
|
isCreation,
|
|
12
11
|
}: {
|
|
13
|
-
context: SetupContext;
|
|
14
12
|
categoryId: Ref<string>;
|
|
15
13
|
isCreation: Ref<boolean>;
|
|
16
14
|
}): ResourceRef<Nullable<Category>> {
|
|
17
15
|
const [fetchCategory, resource] = useResource<Nullable<Category>>({
|
|
18
16
|
fetchResource: () => getCategory(categoryId.value),
|
|
19
17
|
initialValue: null,
|
|
20
|
-
context,
|
|
21
18
|
resourceName: 'Blog category',
|
|
22
19
|
});
|
|
23
20
|
|
|
24
21
|
onMounted(() => {
|
|
25
|
-
if (isCreation.value) {
|
|
22
|
+
if (isCreation.value || !categoryId.value) {
|
|
26
23
|
return;
|
|
27
24
|
}
|
|
28
25
|
|
|
@@ -30,7 +27,7 @@ export function useFetchCategory({
|
|
|
30
27
|
});
|
|
31
28
|
|
|
32
29
|
watch(categoryId, () => {
|
|
33
|
-
if (isCreation.value) {
|
|
30
|
+
if (isCreation.value || !categoryId.value) {
|
|
34
31
|
return;
|
|
35
32
|
}
|
|
36
33
|
|
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
import { onMounted
|
|
1
|
+
import { onMounted } from 'vue';
|
|
2
2
|
|
|
3
3
|
import { Nullable, ResourceRef, useResource } from '@tager/admin-services';
|
|
4
4
|
|
|
5
5
|
import { ModuleConfig } from '../typings/model';
|
|
6
6
|
import { getModuleConfig } from '../services/requests';
|
|
7
7
|
|
|
8
|
-
export function useFetchModuleConfig({
|
|
9
|
-
context,
|
|
10
|
-
}: {
|
|
11
|
-
context: SetupContext;
|
|
12
|
-
}): ResourceRef<Nullable<ModuleConfig>> {
|
|
8
|
+
export function useFetchModuleConfig(): ResourceRef<Nullable<ModuleConfig>> {
|
|
13
9
|
const [fetchModuleConfig, resource] = useResource<Nullable<ModuleConfig>>({
|
|
14
10
|
fetchResource: getModuleConfig,
|
|
15
11
|
initialValue: null,
|
|
16
|
-
context: context,
|
|
17
12
|
resourceName: 'Module configuration',
|
|
18
13
|
});
|
|
19
14
|
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import { onMounted
|
|
1
|
+
import { onMounted } from 'vue';
|
|
2
2
|
|
|
3
3
|
import { ResourceRef, useResource } from '@tager/admin-services';
|
|
4
4
|
|
|
5
5
|
import { PostShort } from '../typings/model';
|
|
6
6
|
import { getPosts } from '../services/requests';
|
|
7
7
|
|
|
8
|
-
export function useFetchPosts(
|
|
9
|
-
context: SetupContext;
|
|
10
|
-
}): ResourceRef<PostShort[]> {
|
|
8
|
+
export function useFetchPosts(): ResourceRef<PostShort[]> {
|
|
11
9
|
const [fetchPosts, resource] = useResource<PostShort[]>({
|
|
12
10
|
fetchResource: () => getPosts({ pageNumber: 1, pageSize: 99999 }),
|
|
13
11
|
initialValue: [],
|
|
14
|
-
context: params.context,
|
|
15
12
|
resourceName: 'Blog posts',
|
|
16
13
|
});
|
|
17
14
|
|
package/src/locales/en.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const EN = {
|
|
1
|
+
export const EN = {
|
|
2
2
|
yes: 'Yes',
|
|
3
3
|
no: 'no',
|
|
4
4
|
blog: 'Blog',
|
|
@@ -23,6 +23,8 @@ const EN = {
|
|
|
23
23
|
languages: 'Languages',
|
|
24
24
|
date: 'Date',
|
|
25
25
|
dateOfPublication: 'Date of publication',
|
|
26
|
+
dateOfPublicationFrom: 'Date of publication - From',
|
|
27
|
+
dateOfPublicationTo: 'Date of publication - To',
|
|
26
28
|
from: 'from',
|
|
27
29
|
to: 'to',
|
|
28
30
|
From: 'From',
|
|
@@ -80,6 +82,11 @@ const EN = {
|
|
|
80
82
|
statusPublished: 'Published',
|
|
81
83
|
statusDraft: 'Draft',
|
|
82
84
|
statusArchived: 'Archived',
|
|
83
|
-
};
|
|
84
85
|
|
|
85
|
-
|
|
86
|
+
scheduleArchive: 'Schedule archive',
|
|
87
|
+
schedulePublish: 'Schedule publish',
|
|
88
|
+
archiveAt: 'Archive at',
|
|
89
|
+
publishAt: 'Publish at',
|
|
90
|
+
archiveAtLabel: 'Archive at',
|
|
91
|
+
publishAtLabel: 'Publish at',
|
|
92
|
+
};
|
package/src/locales/ru.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import EN from './en';
|
|
1
|
+
import { EN } from './en';
|
|
2
2
|
|
|
3
|
-
const RU: typeof EN = {
|
|
3
|
+
export const RU: typeof EN = {
|
|
4
4
|
yes: 'Да',
|
|
5
5
|
no: 'Нет',
|
|
6
6
|
blog: 'Блог',
|
|
@@ -25,6 +25,8 @@ const RU: typeof EN = {
|
|
|
25
25
|
languages: 'Языки',
|
|
26
26
|
date: 'Дата',
|
|
27
27
|
dateOfPublication: 'Дата публикации',
|
|
28
|
+
dateOfPublicationFrom: 'Дата публикации - От',
|
|
29
|
+
dateOfPublicationTo: 'Дата публикации - До',
|
|
28
30
|
from: 'от',
|
|
29
31
|
to: 'до',
|
|
30
32
|
From: 'От',
|
|
@@ -82,6 +84,13 @@ const RU: typeof EN = {
|
|
|
82
84
|
statusPublished: 'Опубликован',
|
|
83
85
|
statusDraft: 'Черновик',
|
|
84
86
|
statusArchived: 'В архиве',
|
|
87
|
+
|
|
88
|
+
scheduleArchive: 'Запланировать перенос в архив',
|
|
89
|
+
schedulePublish: 'Запланировать публикацию',
|
|
90
|
+
archiveAt: 'Перенести в архив в',
|
|
91
|
+
publishAt: 'Опубликовать в',
|
|
92
|
+
archiveAtLabel: 'Перенос в архив',
|
|
93
|
+
publishAtLabel: 'Публикация',
|
|
85
94
|
};
|
|
86
95
|
|
|
87
96
|
export default RU;
|
package/src/main.ts
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { applyTranslations } from './locales/apply';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
import RU from './locales/ru';
|
|
5
|
-
|
|
6
|
-
i18n.addTranslations('en', 'blog', EN);
|
|
7
|
-
i18n.addTranslations('ru', 'blog', RU);
|
|
3
|
+
applyTranslations();
|
|
8
4
|
|
|
9
5
|
export * from './constants/routes';
|
|
10
|
-
export * from './
|
|
11
|
-
export * from './constants/paths';
|
|
6
|
+
export * from './utils/paths';
|
|
12
7
|
export * from './services/requests';
|
package/src/services/requests.ts
CHANGED
package/src/typings/model.ts
CHANGED
|
@@ -62,6 +62,8 @@ export interface PostFull extends SeoInfo {
|
|
|
62
62
|
readonly relatedPosts: Pick<PostShort, 'id' | 'title'>[];
|
|
63
63
|
readonly tags: string[];
|
|
64
64
|
readonly additionalFields: FieldShortType<IncomingValueUnion>[];
|
|
65
|
+
readonly archiveAt: Nullable<string>;
|
|
66
|
+
readonly publishAt: Nullable<string>;
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
export interface Language {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { compile } from 'path-to-regexp';
|
|
2
|
+
|
|
3
|
+
import { BLOG_ROUTE_PATHS } from '../constants/paths';
|
|
4
|
+
|
|
5
|
+
export function getBlogPostListUrl() {
|
|
6
|
+
return BLOG_ROUTE_PATHS.POST_LIST;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function getBlogPostFormUrl(params: { postId: number | string }) {
|
|
10
|
+
return compile(BLOG_ROUTE_PATHS.POST_FORM)({ postId: params.postId });
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function getBlogCategoryListUrl() {
|
|
14
|
+
return BLOG_ROUTE_PATHS.CATEGORY_LIST;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function getBlogCategoryFormUrl(params: {
|
|
18
|
+
categoryId: number | string;
|
|
19
|
+
}) {
|
|
20
|
+
return compile(BLOG_ROUTE_PATHS.CATEGORY_FORM)({
|
|
21
|
+
categoryId: params.categoryId,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
@@ -1,44 +1,46 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<Page
|
|
3
3
|
:title="
|
|
4
|
-
isCreation
|
|
4
|
+
isCreation
|
|
5
|
+
? $i18n.t('blog:createBlogCategory')
|
|
6
|
+
: $i18n.t('blog:updateBlogCategory')
|
|
5
7
|
"
|
|
6
8
|
:is-content-loading="isContentLoading"
|
|
7
9
|
>
|
|
8
|
-
<template
|
|
10
|
+
<template #content>
|
|
9
11
|
<form novalidate @submit.prevent="submitForm">
|
|
10
12
|
<template v-if="isCreation">
|
|
11
|
-
<
|
|
13
|
+
<FormFieldSelect
|
|
12
14
|
v-if="isLangSpecific"
|
|
13
|
-
v-model="values.language"
|
|
15
|
+
v-model:value="values.language"
|
|
14
16
|
name="language"
|
|
15
|
-
:label="$t('blog:language')"
|
|
17
|
+
:label="$i18n.t('blog:language')"
|
|
16
18
|
:options="languageOptionList"
|
|
17
19
|
:error="errors.language"
|
|
18
20
|
/>
|
|
19
21
|
|
|
20
|
-
<
|
|
21
|
-
v-model="values.name"
|
|
22
|
+
<FormField
|
|
23
|
+
v-model:value="values.name"
|
|
22
24
|
name="name"
|
|
23
|
-
:label="$t('blog:name')"
|
|
25
|
+
:label="$i18n.t('blog:name')"
|
|
24
26
|
:error="errors.name"
|
|
25
27
|
@input="handleNameChange"
|
|
26
28
|
/>
|
|
27
29
|
|
|
28
|
-
<
|
|
30
|
+
<FormFieldSelect
|
|
29
31
|
v-if="!isLangSpecific || values.language"
|
|
30
|
-
v-model="values.parent"
|
|
32
|
+
v-model:value="values.parent"
|
|
31
33
|
name="parentCategory"
|
|
32
|
-
:label="$t('blog:parentCategory')"
|
|
34
|
+
:label="$i18n.t('blog:parentCategory')"
|
|
33
35
|
:options="parentCategoryOptionList"
|
|
34
36
|
:error="errors.parent"
|
|
35
37
|
/>
|
|
36
38
|
|
|
37
|
-
<
|
|
39
|
+
<FormFieldUrlAliasInput
|
|
38
40
|
id="urlAlias"
|
|
39
|
-
v-model="values.urlAlias"
|
|
41
|
+
v-model:value="values.urlAlias"
|
|
40
42
|
name="urlAlias"
|
|
41
|
-
:label="$t('blog:link')"
|
|
43
|
+
:label="$i18n.t('blog:link')"
|
|
42
44
|
:url-template="pagePath"
|
|
43
45
|
:error="errors.urlAlias"
|
|
44
46
|
@change="handleAliasChange"
|
|
@@ -46,57 +48,57 @@
|
|
|
46
48
|
</template>
|
|
47
49
|
|
|
48
50
|
<template v-else>
|
|
49
|
-
<
|
|
51
|
+
<TabList
|
|
50
52
|
:tab-list="tabList"
|
|
51
53
|
:selected-tab-id="selectedTabId"
|
|
52
54
|
@tab:update="selectedTabId = $event.tabId"
|
|
53
55
|
/>
|
|
54
56
|
|
|
55
57
|
<template v-if="selectedTabId === 'common'">
|
|
56
|
-
<
|
|
58
|
+
<FormFieldSelect
|
|
57
59
|
v-if="isLangSpecific"
|
|
58
|
-
v-model="values.language"
|
|
60
|
+
v-model:value="values.language"
|
|
59
61
|
name="language"
|
|
60
|
-
:label="$t('blog:language')"
|
|
62
|
+
:label="$i18n.t('blog:language')"
|
|
61
63
|
:options="languageOptionList"
|
|
62
64
|
:error="errors.language"
|
|
63
65
|
/>
|
|
64
66
|
|
|
65
|
-
<
|
|
66
|
-
v-model="values.isDefault"
|
|
67
|
+
<FormFieldCheckbox
|
|
68
|
+
v-model:checked="values.isDefault"
|
|
67
69
|
name="isDefault"
|
|
68
|
-
:label="$t('blog:defaultCategory')"
|
|
70
|
+
:label="$i18n.t('blog:defaultCategory')"
|
|
69
71
|
:error="errors.isDefault"
|
|
70
72
|
/>
|
|
71
73
|
|
|
72
|
-
<
|
|
73
|
-
v-model="values.name"
|
|
74
|
+
<FormField
|
|
75
|
+
v-model:value="values.name"
|
|
74
76
|
name="name"
|
|
75
|
-
:label="$t('blog:name')"
|
|
77
|
+
:label="$i18n.t('blog:name')"
|
|
76
78
|
:error="errors.name"
|
|
77
79
|
/>
|
|
78
80
|
|
|
79
|
-
<
|
|
81
|
+
<FormFieldSelect
|
|
80
82
|
v-if="!isLangSpecific || values.language"
|
|
81
|
-
v-model="values.parent"
|
|
83
|
+
v-model:value="values.parent"
|
|
82
84
|
name="parentCategory"
|
|
83
|
-
:label="$t('blog:parentCategory')"
|
|
85
|
+
:label="$i18n.t('blog:parentCategory')"
|
|
84
86
|
:options="parentCategoryOptionList"
|
|
85
87
|
:error="errors.parent"
|
|
86
88
|
/>
|
|
87
89
|
|
|
88
|
-
<
|
|
90
|
+
<FormFieldUrlAliasInput
|
|
89
91
|
id="urlAlias"
|
|
90
|
-
v-model="values.urlAlias"
|
|
92
|
+
v-model:value="values.urlAlias"
|
|
91
93
|
name="urlAlias"
|
|
92
|
-
:label="$t('blog:link')"
|
|
94
|
+
:label="$i18n.t('blog:link')"
|
|
93
95
|
:url-template="pagePath"
|
|
94
96
|
:error="errors.urlAlias"
|
|
95
97
|
/>
|
|
96
98
|
</template>
|
|
97
99
|
|
|
98
100
|
<template v-if="selectedTabId === 'seo'">
|
|
99
|
-
<
|
|
101
|
+
<SeoFieldGroup
|
|
100
102
|
:title="values.pageTitle"
|
|
101
103
|
:title-error-message="errors.pageTitle"
|
|
102
104
|
:description="values.pageDescription"
|
|
@@ -114,26 +116,30 @@
|
|
|
114
116
|
</form>
|
|
115
117
|
</template>
|
|
116
118
|
|
|
117
|
-
<template
|
|
119
|
+
<template #footer>
|
|
118
120
|
<FormFooter
|
|
119
121
|
:back-href="categoryListUrl"
|
|
120
|
-
:on-submit="submitForm"
|
|
121
122
|
:is-submitting="isSubmitting"
|
|
122
123
|
:is-creation="isCreation"
|
|
123
124
|
:can-create-another="isCreation"
|
|
125
|
+
@submit="submitForm"
|
|
124
126
|
/>
|
|
125
127
|
</template>
|
|
126
|
-
</
|
|
128
|
+
</Page>
|
|
127
129
|
</template>
|
|
128
130
|
|
|
129
131
|
<script lang="ts">
|
|
130
|
-
import { computed, defineComponent, ref, watch } from '
|
|
132
|
+
import { computed, defineComponent, ref, watch } from 'vue';
|
|
133
|
+
import { useRoute, useRouter } from 'vue-router';
|
|
131
134
|
|
|
132
135
|
import {
|
|
133
136
|
convertRequestErrorToMap,
|
|
134
137
|
getWebsiteOrigin,
|
|
138
|
+
navigateBack,
|
|
135
139
|
Nullable,
|
|
136
140
|
urlTranslit,
|
|
141
|
+
useI18n,
|
|
142
|
+
useToast,
|
|
137
143
|
} from '@tager/admin-services';
|
|
138
144
|
import {
|
|
139
145
|
OptionType,
|
|
@@ -141,8 +147,13 @@ import {
|
|
|
141
147
|
TagerFormSubmitEvent,
|
|
142
148
|
SeoChangeEvent,
|
|
143
149
|
TabType,
|
|
144
|
-
|
|
150
|
+
FormFieldSelect,
|
|
151
|
+
FormField,
|
|
152
|
+
FormFieldUrlAliasInput,
|
|
153
|
+
FormFieldCheckbox,
|
|
154
|
+
SeoFieldGroup,
|
|
145
155
|
} from '@tager/admin-ui';
|
|
156
|
+
import { Page } from '@tager/admin-layout';
|
|
146
157
|
|
|
147
158
|
import {
|
|
148
159
|
useFetchCategories,
|
|
@@ -152,9 +163,10 @@ import {
|
|
|
152
163
|
import {
|
|
153
164
|
getBlogCategoryFormUrl,
|
|
154
165
|
getBlogCategoryListUrl,
|
|
155
|
-
} from '../../../
|
|
166
|
+
} from '../../../utils/paths';
|
|
156
167
|
import { CategoryFormValues, Language } from '../../../typings/model';
|
|
157
168
|
import { createCategory, updateCategory } from '../../../services/requests';
|
|
169
|
+
import TabList from '../../Posts/PostForm/components/TabList/TabList.vue';
|
|
158
170
|
|
|
159
171
|
import {
|
|
160
172
|
convertCategoryFormValuesToPayload,
|
|
@@ -164,20 +176,31 @@ import {
|
|
|
164
176
|
|
|
165
177
|
export default defineComponent({
|
|
166
178
|
name: 'CategoryForm',
|
|
167
|
-
components: {
|
|
168
|
-
|
|
169
|
-
|
|
179
|
+
components: {
|
|
180
|
+
Page,
|
|
181
|
+
SeoFieldGroup,
|
|
182
|
+
FormFieldCheckbox,
|
|
183
|
+
TabList,
|
|
184
|
+
FormFieldUrlAliasInput,
|
|
185
|
+
FormField,
|
|
186
|
+
FormFieldSelect,
|
|
187
|
+
FormFooter,
|
|
188
|
+
},
|
|
189
|
+
setup() {
|
|
190
|
+
const { t } = useI18n();
|
|
191
|
+
const router = useRouter();
|
|
192
|
+
const route = useRoute();
|
|
193
|
+
const toast = useToast();
|
|
194
|
+
|
|
170
195
|
const categoryId = computed<string>(
|
|
171
|
-
() =>
|
|
196
|
+
() => route.params.categoryId as string
|
|
172
197
|
);
|
|
173
198
|
const isCreation = computed<boolean>(() => categoryId.value === 'create');
|
|
174
199
|
|
|
175
200
|
/** Fetch module config */
|
|
176
201
|
|
|
177
|
-
const {
|
|
178
|
-
|
|
179
|
-
loading: isModuleConfigLoading,
|
|
180
|
-
} = useFetchModuleConfig({ context });
|
|
202
|
+
const { data: moduleConfig, loading: isModuleConfigLoading } =
|
|
203
|
+
useFetchModuleConfig();
|
|
181
204
|
|
|
182
205
|
const languageList = computed<Language[]>(
|
|
183
206
|
() => moduleConfig.value?.languages ?? []
|
|
@@ -197,15 +220,12 @@ export default defineComponent({
|
|
|
197
220
|
|
|
198
221
|
/** Fetch Categories */
|
|
199
222
|
|
|
200
|
-
const {
|
|
201
|
-
|
|
202
|
-
loading: isCategoriesLoading,
|
|
203
|
-
} = useFetchCategories({ context });
|
|
223
|
+
const { data: categories, loading: isCategoriesLoading } =
|
|
224
|
+
useFetchCategories();
|
|
204
225
|
|
|
205
226
|
/** Fetch Category */
|
|
206
227
|
|
|
207
228
|
const { data: category, loading: isCategoryLoading } = useFetchCategory({
|
|
208
|
-
context,
|
|
209
229
|
categoryId,
|
|
210
230
|
isCreation,
|
|
211
231
|
});
|
|
@@ -239,13 +259,13 @@ export default defineComponent({
|
|
|
239
259
|
errors.value = {};
|
|
240
260
|
|
|
241
261
|
if (event.type === 'create') {
|
|
242
|
-
|
|
262
|
+
router.push(
|
|
243
263
|
getBlogCategoryFormUrl({ categoryId: String(data.id) })
|
|
244
264
|
);
|
|
245
265
|
}
|
|
246
266
|
|
|
247
267
|
if (event.type === 'create_exit' || event.type === 'save_exit') {
|
|
248
|
-
|
|
268
|
+
navigateBack(router, getBlogCategoryListUrl());
|
|
249
269
|
}
|
|
250
270
|
|
|
251
271
|
if (event.type === 'create_create-another') {
|
|
@@ -256,23 +276,23 @@ export default defineComponent({
|
|
|
256
276
|
);
|
|
257
277
|
}
|
|
258
278
|
|
|
259
|
-
|
|
279
|
+
toast.show({
|
|
260
280
|
variant: 'success',
|
|
261
|
-
title:
|
|
281
|
+
title: t('blog:success'),
|
|
262
282
|
body: isCreation.value
|
|
263
|
-
?
|
|
264
|
-
:
|
|
283
|
+
? t('blog:blogCategoryWasSuccessfullyCreated')
|
|
284
|
+
: t('blog:blogCategoryWasSuccessfullyUpdated'),
|
|
265
285
|
});
|
|
266
286
|
})
|
|
267
287
|
.catch((error) => {
|
|
268
288
|
console.error(error);
|
|
269
289
|
errors.value = convertRequestErrorToMap(error);
|
|
270
|
-
|
|
290
|
+
toast.show({
|
|
271
291
|
variant: 'danger',
|
|
272
|
-
title:
|
|
292
|
+
title: t('blog:error'),
|
|
273
293
|
body: isCreation.value
|
|
274
|
-
?
|
|
275
|
-
:
|
|
294
|
+
? t('blog:blogCategoryCreationWasFailed')
|
|
295
|
+
: t('blog:blogCategoryUpdateWasFailed'),
|
|
276
296
|
});
|
|
277
297
|
})
|
|
278
298
|
.finally(() => {
|
|
@@ -7,7 +7,7 @@ import { Category, Language, ModuleConfig } from '../../../typings/model';
|
|
|
7
7
|
import {
|
|
8
8
|
getBlogCategoryFormUrl,
|
|
9
9
|
getBlogPostListUrl,
|
|
10
|
-
} from '../../../
|
|
10
|
+
} from '../../../utils/paths';
|
|
11
11
|
import { getNameWithDepth } from '../../../utils/common';
|
|
12
12
|
|
|
13
13
|
export function convertCategoryList(
|