@tager/admin-blog 0.3.42 → 1.0.1
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 +2313 -0
- package/dist/locales/apply.d.ts +1 -0
- package/dist/locales/en.d.ts +87 -86
- package/dist/locales/ru.d.ts +3 -3
- package/dist/main.d.ts +3 -4
- package/dist/services/requests.d.ts +59 -59
- package/dist/style.css +1 -0
- package/dist/typings/common.d.ts +1 -1
- package/dist/typings/model.d.ts +106 -106
- 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 -32
- package/dist/views/Posts/PostForm/PostForm.vue.d.ts +2768 -9398
- 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 -78
- 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 +3 -3
- package/src/locales/ru.ts +4 -2
- package/src/main.ts +3 -8
- package/src/utils/paths.ts +23 -0
- package/src/views/Categories/CategoryForm/CategoryForm.vue +81 -65
- 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.vue +259 -224
- package/src/views/Posts/PostList/PostList.helpers.ts +3 -3
- package/src/views/Posts/PostList/PostList.vue +168 -168
- 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 -5294
- package/dist/index.umd.js +0 -5321
- package/dist/router/index.d.ts +0 -4
- package/dist/views/Posts/PostForm/components/TabList/TabList.types.d.ts +0 -5
- package/dist/views/Posts/PostForm/components/TabList/index.d.ts +0 -2
- 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
- package/src/views/Posts/PostForm/components/TabList/TabList.types.ts +0 -5
- package/src/views/Posts/PostForm/components/TabList/TabList.vue +0 -92
- package/src/views/Posts/PostForm/components/TabList/index.ts +0 -2
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
:title="$t('blog:blogCategories')"
|
|
2
|
+
<Page
|
|
3
|
+
:title="$i18n.t('blog:blogCategories')"
|
|
4
4
|
:header-buttons="[
|
|
5
5
|
{
|
|
6
|
-
text: $t('blog:newCategory'),
|
|
6
|
+
text: $i18n.t('blog:newCategory'),
|
|
7
7
|
href: getBlogCategoryFormUrl({ categoryId: 'create' }),
|
|
8
8
|
},
|
|
9
9
|
]"
|
|
10
10
|
>
|
|
11
|
-
<template
|
|
12
|
-
<
|
|
11
|
+
<template #content>
|
|
12
|
+
<DataTable
|
|
13
13
|
:column-defs="columnDefs"
|
|
14
14
|
:row-data="rowData"
|
|
15
15
|
:loading="isRowDataLoading"
|
|
@@ -24,88 +24,102 @@
|
|
|
24
24
|
data-table="blog-category"
|
|
25
25
|
@change="handleChange"
|
|
26
26
|
>
|
|
27
|
-
<template v-if="isLangSpecific"
|
|
28
|
-
<
|
|
27
|
+
<template v-if="isLangSpecific" #filters>
|
|
28
|
+
<AdvancedSearch :tags="tags" @click:tag="tagRemovalHandler">
|
|
29
29
|
<div class="filters">
|
|
30
|
-
<
|
|
31
|
-
v-model="languageFilter"
|
|
30
|
+
<FormFieldMultiSelect
|
|
31
|
+
v-model:values="languageFilter"
|
|
32
32
|
:options="languageOptionList"
|
|
33
33
|
name="languageFilter"
|
|
34
34
|
:searchable="true"
|
|
35
|
-
:label="$t('blog:language')"
|
|
35
|
+
:label="$i18n.t('blog:language')"
|
|
36
36
|
class="filter"
|
|
37
37
|
/>
|
|
38
38
|
</div>
|
|
39
|
-
</
|
|
39
|
+
</AdvancedSearch>
|
|
40
40
|
</template>
|
|
41
41
|
|
|
42
|
-
<template
|
|
43
|
-
<
|
|
42
|
+
<template #cell(link-to-posts)="{ row }">
|
|
43
|
+
<CountButton
|
|
44
44
|
:href="getLinkToPostsByCategory(row.id)"
|
|
45
45
|
variant="outline-secondary"
|
|
46
46
|
:count="row.postsCount"
|
|
47
47
|
>
|
|
48
|
-
{{ $t('blog:posts') }}
|
|
49
|
-
</
|
|
48
|
+
{{ $i18n.t('blog:posts') }}
|
|
49
|
+
</CountButton>
|
|
50
50
|
</template>
|
|
51
51
|
|
|
52
|
-
<template
|
|
53
|
-
<
|
|
52
|
+
<template #cell(actions)="{ row, rowIndex }">
|
|
53
|
+
<BaseButton
|
|
54
54
|
variant="icon"
|
|
55
|
-
:title="$t('blog:edit')"
|
|
55
|
+
:title="$i18n.t('blog:edit')"
|
|
56
56
|
:disabled="isDeleting(row.id)"
|
|
57
57
|
:href="getBlogCategoryFormUrl({ categoryId: row.id })"
|
|
58
58
|
>
|
|
59
|
-
<
|
|
60
|
-
</
|
|
59
|
+
<EditIcon />
|
|
60
|
+
</BaseButton>
|
|
61
61
|
|
|
62
|
-
<
|
|
62
|
+
<BaseButton
|
|
63
63
|
variant="icon"
|
|
64
|
-
:title="$t('blog:moveUp')"
|
|
64
|
+
:title="$i18n.t('blog:moveUp')"
|
|
65
65
|
:disabled="rowIndex === 0 || isCategoryMoving"
|
|
66
66
|
@click="startMoveCategory(row.id, 'up')"
|
|
67
67
|
>
|
|
68
|
-
<
|
|
69
|
-
</
|
|
68
|
+
<NorthIcon />
|
|
69
|
+
</BaseButton>
|
|
70
70
|
|
|
71
|
-
<
|
|
71
|
+
<BaseButton
|
|
72
72
|
variant="icon"
|
|
73
|
-
:title="$t('blog:moveDown')"
|
|
73
|
+
:title="$i18n.t('blog:moveDown')"
|
|
74
74
|
:disabled="rowIndex === rowData.length - 1 || isCategoryMoving"
|
|
75
75
|
@click="startMoveCategory(row.id, 'down')"
|
|
76
76
|
>
|
|
77
|
-
<
|
|
78
|
-
</
|
|
77
|
+
<SouthIcon />
|
|
78
|
+
</BaseButton>
|
|
79
79
|
|
|
80
|
-
<
|
|
80
|
+
<BaseButton
|
|
81
81
|
variant="icon"
|
|
82
|
-
:title="$t('blog:remove')"
|
|
82
|
+
:title="$i18n.t('blog:remove')"
|
|
83
83
|
:disabled="isDeleting(row.id) || row.postsCount > 0"
|
|
84
84
|
@click="handleCategoryDelete(row.id)"
|
|
85
85
|
>
|
|
86
|
-
<
|
|
87
|
-
</
|
|
86
|
+
<DeleteIcon />
|
|
87
|
+
</BaseButton>
|
|
88
88
|
</template>
|
|
89
|
-
</
|
|
89
|
+
</DataTable>
|
|
90
90
|
</template>
|
|
91
|
-
</
|
|
91
|
+
</Page>
|
|
92
92
|
</template>
|
|
93
93
|
|
|
94
94
|
<script lang="ts">
|
|
95
|
-
import { computed, ref, defineComponent, watch } from '
|
|
95
|
+
import { computed, ref, defineComponent, watch } from 'vue';
|
|
96
96
|
import isEqual from 'lodash.isequal';
|
|
97
|
+
import { useRoute, useRouter } from 'vue-router';
|
|
97
98
|
|
|
98
|
-
import { useResourceDelete } from '@tager/admin-services';
|
|
99
|
-
import {
|
|
99
|
+
import { useI18n, useResourceDelete } from '@tager/admin-services';
|
|
100
|
+
import {
|
|
101
|
+
AdvancedSearch,
|
|
102
|
+
BaseButton,
|
|
103
|
+
CountButton,
|
|
104
|
+
DeleteIcon,
|
|
105
|
+
EditIcon,
|
|
106
|
+
FormFieldMultiSelect,
|
|
107
|
+
NorthIcon,
|
|
108
|
+
SouthIcon,
|
|
109
|
+
useDataTable,
|
|
110
|
+
DataTable,
|
|
111
|
+
} from '@tager/admin-ui';
|
|
112
|
+
import { Page } from '@tager/admin-layout';
|
|
100
113
|
|
|
101
114
|
import { useFetchModuleConfig } from '../../../hooks';
|
|
102
|
-
import { getBlogCategoryFormUrl } from '../../../
|
|
115
|
+
import { getBlogCategoryFormUrl } from '../../../utils/paths';
|
|
103
116
|
import {
|
|
104
117
|
deleteCategory,
|
|
105
118
|
getCategories,
|
|
106
119
|
moveCategory,
|
|
107
120
|
} from '../../../services/requests';
|
|
108
121
|
import { Category, Language } from '../../../typings/model';
|
|
122
|
+
import { BLOG_ROUTE_PATHS } from '../../../constants/paths';
|
|
109
123
|
|
|
110
124
|
import {
|
|
111
125
|
convertCategoryList,
|
|
@@ -116,13 +130,27 @@ import { useAdvancedSearch } from './hooks';
|
|
|
116
130
|
|
|
117
131
|
export default defineComponent({
|
|
118
132
|
name: 'BlogCategoryList',
|
|
119
|
-
|
|
133
|
+
components: {
|
|
134
|
+
DeleteIcon,
|
|
135
|
+
SouthIcon,
|
|
136
|
+
NorthIcon,
|
|
137
|
+
EditIcon,
|
|
138
|
+
BaseButton,
|
|
139
|
+
CountButton,
|
|
140
|
+
FormFieldMultiSelect,
|
|
141
|
+
AdvancedSearch,
|
|
142
|
+
Page,
|
|
143
|
+
DataTable,
|
|
144
|
+
},
|
|
145
|
+
setup() {
|
|
146
|
+
const { t } = useI18n();
|
|
147
|
+
const route = useRoute();
|
|
148
|
+
const router = useRouter();
|
|
149
|
+
|
|
120
150
|
/** Fetch module config **/
|
|
121
151
|
|
|
122
|
-
const {
|
|
123
|
-
|
|
124
|
-
loading: isModuleConfigLoading,
|
|
125
|
-
} = useFetchModuleConfig({ context });
|
|
152
|
+
const { data: moduleConfig, loading: isModuleConfigLoading } =
|
|
153
|
+
useFetchModuleConfig();
|
|
126
154
|
|
|
127
155
|
const languageList = computed<Language[]>(
|
|
128
156
|
() => moduleConfig.value?.languages ?? []
|
|
@@ -136,7 +164,7 @@ export default defineComponent({
|
|
|
136
164
|
filterParams,
|
|
137
165
|
tags,
|
|
138
166
|
tagRemovalHandler,
|
|
139
|
-
} = useAdvancedSearch({
|
|
167
|
+
} = useAdvancedSearch({ languageList, route, t });
|
|
140
168
|
|
|
141
169
|
const isLangSpecific = computed<boolean>(
|
|
142
170
|
() => languageOptionList.value.length > 1
|
|
@@ -163,7 +191,6 @@ export default defineComponent({
|
|
|
163
191
|
...filterParams.value,
|
|
164
192
|
}),
|
|
165
193
|
initialValue: [],
|
|
166
|
-
context,
|
|
167
194
|
resourceName: 'Blog categories',
|
|
168
195
|
pageSize: 100,
|
|
169
196
|
});
|
|
@@ -173,26 +200,27 @@ export default defineComponent({
|
|
|
173
200
|
return;
|
|
174
201
|
}
|
|
175
202
|
|
|
203
|
+
if (route.path !== BLOG_ROUTE_PATHS.CATEGORY_LIST) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
|
|
176
207
|
const newQuery = {
|
|
177
208
|
...filterParams.value,
|
|
178
|
-
query: (
|
|
209
|
+
query: (route.query.query ?? '') as string,
|
|
179
210
|
};
|
|
180
211
|
|
|
181
|
-
if (!isEqual(
|
|
182
|
-
|
|
212
|
+
if (!isEqual(route.query, newQuery)) {
|
|
213
|
+
router.replace({ query: newQuery });
|
|
183
214
|
fetchCategoryList();
|
|
184
215
|
}
|
|
185
216
|
});
|
|
186
217
|
|
|
187
|
-
const {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
onSuccess: fetchCategoryList,
|
|
194
|
-
context,
|
|
195
|
-
});
|
|
218
|
+
const { isDeleting, handleResourceDelete: handleCategoryDelete } =
|
|
219
|
+
useResourceDelete({
|
|
220
|
+
deleteResource: deleteCategory,
|
|
221
|
+
resourceName: 'Post',
|
|
222
|
+
onSuccess: fetchCategoryList,
|
|
223
|
+
});
|
|
196
224
|
|
|
197
225
|
const isCategoryMoving = ref<boolean>(false);
|
|
198
226
|
|
|
@@ -222,7 +250,7 @@ export default defineComponent({
|
|
|
222
250
|
);
|
|
223
251
|
|
|
224
252
|
const columnDefs = computed(() =>
|
|
225
|
-
getCategoryTableColumnDefs(moduleConfig.value,
|
|
253
|
+
getCategoryTableColumnDefs(moduleConfig.value, t)
|
|
226
254
|
);
|
|
227
255
|
|
|
228
256
|
return {
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Ref,
|
|
5
|
-
ref,
|
|
6
|
-
SetupContext,
|
|
7
|
-
watch,
|
|
8
|
-
} from '@vue/composition-api';
|
|
1
|
+
import { computed, ComputedRef, Ref, ref, SetupContext, watch } from 'vue';
|
|
2
|
+
import { RouteLocationNormalizedLoaded } from 'vue-router';
|
|
3
|
+
import { TFunction } from 'i18next';
|
|
9
4
|
|
|
10
5
|
import {
|
|
11
6
|
FilterTagType,
|
|
@@ -17,8 +12,9 @@ import {
|
|
|
17
12
|
import { Language } from '../../../../typings/model';
|
|
18
13
|
|
|
19
14
|
interface Params {
|
|
20
|
-
|
|
15
|
+
t: TFunction;
|
|
21
16
|
languageList: ComputedRef<Language[]>;
|
|
17
|
+
route: RouteLocationNormalizedLoaded;
|
|
22
18
|
}
|
|
23
19
|
|
|
24
20
|
interface State {
|
|
@@ -26,6 +22,7 @@ interface State {
|
|
|
26
22
|
languageOptionList: ComputedRef<OptionType[]>;
|
|
27
23
|
filterParams: ComputedRef<Record<string, string | string[]>>;
|
|
28
24
|
tags: ComputedRef<FilterTagType[]>;
|
|
25
|
+
|
|
29
26
|
tagRemovalHandler(event: FilterTagType): void;
|
|
30
27
|
}
|
|
31
28
|
|
|
@@ -33,7 +30,7 @@ enum FilterTypes {
|
|
|
33
30
|
LANGUAGE = 'language',
|
|
34
31
|
}
|
|
35
32
|
|
|
36
|
-
export function useAdvancedSearch({
|
|
33
|
+
export function useAdvancedSearch({ languageList, route, t }: Params): State {
|
|
37
34
|
/** Language **/
|
|
38
35
|
|
|
39
36
|
const languageOptionList = computed<OptionType[]>(() =>
|
|
@@ -42,7 +39,7 @@ export function useAdvancedSearch({ context, languageList }: Params): State {
|
|
|
42
39
|
|
|
43
40
|
const initialLanguageFilter = computed<OptionType[]>(() => {
|
|
44
41
|
const queryValue = getFilterParamAsStringArray(
|
|
45
|
-
|
|
42
|
+
route.query,
|
|
46
43
|
FilterTypes.LANGUAGE
|
|
47
44
|
);
|
|
48
45
|
return languageOptionList.value.filter(({ value }) =>
|
|
@@ -81,7 +78,7 @@ export function useAdvancedSearch({ context, languageList }: Params): State {
|
|
|
81
78
|
value,
|
|
82
79
|
label,
|
|
83
80
|
name: FilterTypes.LANGUAGE,
|
|
84
|
-
title:
|
|
81
|
+
title: t('blog:language'),
|
|
85
82
|
})),
|
|
86
83
|
]);
|
|
87
84
|
|