@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
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
Language,
|
|
10
10
|
PostShort,
|
|
11
11
|
} from '../../../typings/model';
|
|
12
|
-
import { getBlogPostFormUrl } from '../../../
|
|
12
|
+
import { getBlogPostFormUrl } from '../../../utils/paths';
|
|
13
13
|
|
|
14
14
|
export function convertPostList(
|
|
15
15
|
postList: PostShort[],
|
|
@@ -64,8 +64,8 @@ export function getPostTableColumnDefs(
|
|
|
64
64
|
id: 2,
|
|
65
65
|
name: t('blog:status'),
|
|
66
66
|
field: 'status',
|
|
67
|
-
style: { width: '
|
|
68
|
-
headStyle: { width: '
|
|
67
|
+
style: { width: '140px' },
|
|
68
|
+
headStyle: { width: '140px' },
|
|
69
69
|
},
|
|
70
70
|
{
|
|
71
71
|
id: 3,
|
|
@@ -1,187 +1,207 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
:title=
|
|
2
|
+
<Page
|
|
3
|
+
:title="pageTitle"
|
|
4
4
|
:header-buttons="[
|
|
5
5
|
{
|
|
6
|
-
text: $t('blog:newPost'),
|
|
6
|
+
text: $i18n.t('blog:newPost'),
|
|
7
7
|
href: getBlogPostFormUrl({ postId: 'create' }),
|
|
8
8
|
},
|
|
9
9
|
]"
|
|
10
10
|
>
|
|
11
|
-
<template
|
|
12
|
-
<
|
|
13
|
-
:column-defs=
|
|
14
|
-
:row-data=
|
|
15
|
-
:loading=
|
|
16
|
-
:error-message=
|
|
17
|
-
:search-query=
|
|
18
|
-
:pagination=
|
|
11
|
+
<template #content>
|
|
12
|
+
<DataTable
|
|
13
|
+
:column-defs="columnDefs"
|
|
14
|
+
:row-data="rowData"
|
|
15
|
+
:loading="isRowDataLoading"
|
|
16
|
+
:error-message="errorMessage"
|
|
17
|
+
:search-query="searchQuery"
|
|
18
|
+
:pagination="{
|
|
19
19
|
pageNumber,
|
|
20
20
|
pageCount,
|
|
21
21
|
pageSize,
|
|
22
22
|
disabled: isRowDataLoading,
|
|
23
|
-
}
|
|
24
|
-
data-table=
|
|
25
|
-
@change=
|
|
23
|
+
}"
|
|
24
|
+
data-table="blog-post"
|
|
25
|
+
@change="handleChange"
|
|
26
26
|
>
|
|
27
|
-
<template
|
|
28
|
-
<
|
|
29
|
-
<div class=
|
|
30
|
-
<
|
|
31
|
-
v-model=
|
|
32
|
-
:options=
|
|
33
|
-
name=
|
|
34
|
-
:searchable=
|
|
35
|
-
:label="$t('blog:category')"
|
|
36
|
-
class=
|
|
27
|
+
<template #filters>
|
|
28
|
+
<AdvancedSearch :tags="tags" @click:tag="tagRemovalHandler">
|
|
29
|
+
<div class="filters">
|
|
30
|
+
<FormFieldMultiSelect
|
|
31
|
+
v-model:selected-options="categoryFilter"
|
|
32
|
+
:options="categoryOptionList"
|
|
33
|
+
name="categoryFilter"
|
|
34
|
+
:searchable="true"
|
|
35
|
+
:label="$i18n.t('blog:category')"
|
|
36
|
+
class="filter"
|
|
37
37
|
/>
|
|
38
38
|
|
|
39
|
-
<
|
|
40
|
-
v-if=
|
|
41
|
-
v-model=
|
|
42
|
-
:options=
|
|
43
|
-
name=
|
|
44
|
-
:searchable=
|
|
45
|
-
:label="$t('blog:language')"
|
|
46
|
-
class=
|
|
39
|
+
<FormFieldMultiSelect
|
|
40
|
+
v-if="isLangSpecific"
|
|
41
|
+
v-model:selected-options="languageFilter"
|
|
42
|
+
:options="languageOptionList"
|
|
43
|
+
name="languageFilter"
|
|
44
|
+
:searchable="true"
|
|
45
|
+
:label="$i18n.t('blog:language')"
|
|
46
|
+
class="filter"
|
|
47
|
+
/>
|
|
48
|
+
<FormFieldMultiSelect
|
|
49
|
+
v-model:selected-options="statusFilter"
|
|
50
|
+
:options="statusOptionList"
|
|
51
|
+
name="statusFilter"
|
|
52
|
+
:searchable="true"
|
|
53
|
+
:label="$i18n.t('blog:status')"
|
|
54
|
+
class="filter"
|
|
55
|
+
/>
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
<div class="filters">
|
|
59
|
+
<FormField
|
|
60
|
+
v-model:value="fromDateFilter"
|
|
61
|
+
:label="$i18n.t('blog:dateOfPublicationFrom')"
|
|
62
|
+
name="fromDateFilter"
|
|
63
|
+
type="date"
|
|
64
|
+
:max="toDateFilter"
|
|
47
65
|
/>
|
|
48
66
|
|
|
49
|
-
<
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
<form-field
|
|
56
|
-
v-model='fromDateFilter'
|
|
57
|
-
:label="$t('blog:From')"
|
|
58
|
-
name='fromDateFilter'
|
|
59
|
-
type='date'
|
|
60
|
-
:max='toDateFilter'
|
|
61
|
-
/>
|
|
62
|
-
|
|
63
|
-
<form-field
|
|
64
|
-
v-model='toDateFilter'
|
|
65
|
-
:label="$t('blog:To')"
|
|
66
|
-
name='toDateFilter'
|
|
67
|
-
type='date'
|
|
68
|
-
:min='fromDateFilter'
|
|
69
|
-
/>
|
|
70
|
-
</div>
|
|
71
|
-
</div>
|
|
72
|
-
|
|
73
|
-
<form-field-multi-select
|
|
74
|
-
v-model='statusFilter'
|
|
75
|
-
:options='statusOptionList'
|
|
76
|
-
name='statusFilter'
|
|
77
|
-
:searchable='true'
|
|
78
|
-
:label="$t('blog:status')"
|
|
79
|
-
class='filter'
|
|
67
|
+
<FormField
|
|
68
|
+
v-model:value="toDateFilter"
|
|
69
|
+
:label="$i18n.t('blog:dateOfPublicationTo')"
|
|
70
|
+
name="toDateFilter"
|
|
71
|
+
type="date"
|
|
72
|
+
:min="fromDateFilter"
|
|
80
73
|
/>
|
|
81
74
|
</div>
|
|
82
|
-
</
|
|
75
|
+
</AdvancedSearch>
|
|
83
76
|
</template>
|
|
84
77
|
|
|
85
|
-
<template
|
|
86
|
-
<div class=
|
|
87
|
-
<span>{{ getStatuses(t)[row.status] }}</span>
|
|
88
|
-
<span v-if=
|
|
89
|
-
{{ t('blog:
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
78
|
+
<template #cell(status)="{ row }">
|
|
79
|
+
<div class="status">
|
|
80
|
+
<span>{{ getStatuses($i18n.t)[row.status] }}</span>
|
|
81
|
+
<span v-if="row.status === 'PUBLISHED' && row.archiveAt">
|
|
82
|
+
{{ $i18n.t('blog:archiveAtLabel') }}:
|
|
83
|
+
<i>{{ formatDateTime(new Date(row.archiveAt), true) }}</i>
|
|
84
|
+
</span>
|
|
85
|
+
<span v-if="row.status === 'DRAFT' && row.publishAt">
|
|
86
|
+
{{ $i18n.t('blog:publishAtLabel') }}:
|
|
87
|
+
<i>{{ formatDateTime(new Date(row.publishAt), true) }}</i>
|
|
93
88
|
</span>
|
|
94
89
|
</div>
|
|
95
90
|
</template>
|
|
96
91
|
|
|
97
|
-
<template
|
|
98
|
-
<
|
|
99
|
-
variant=
|
|
100
|
-
:title="$t('blog:edit')"
|
|
101
|
-
:disabled=
|
|
102
|
-
:href=
|
|
92
|
+
<template #cell(actions)="{ row }">
|
|
93
|
+
<BaseButton
|
|
94
|
+
variant="icon"
|
|
95
|
+
:title="$i18n.t('blog:edit')"
|
|
96
|
+
:disabled="isBusy(row.id)"
|
|
97
|
+
:href="getBlogPostFormUrl({ postId: row.id })"
|
|
103
98
|
>
|
|
104
|
-
<
|
|
105
|
-
</
|
|
106
|
-
|
|
107
|
-
<
|
|
108
|
-
variant=
|
|
109
|
-
:title="$t('blog:clone')"
|
|
110
|
-
:disabled=
|
|
111
|
-
@click=
|
|
99
|
+
<EditIcon />
|
|
100
|
+
</BaseButton>
|
|
101
|
+
|
|
102
|
+
<BaseButton
|
|
103
|
+
variant="icon"
|
|
104
|
+
:title="$i18n.t('blog:clone')"
|
|
105
|
+
:disabled="isBusy(row.id)"
|
|
106
|
+
@click="handleResourceClone(row.id)"
|
|
112
107
|
>
|
|
113
|
-
<
|
|
114
|
-
</
|
|
115
|
-
|
|
116
|
-
<
|
|
117
|
-
variant=
|
|
118
|
-
:title="$t('blog:remove')"
|
|
119
|
-
:disabled=
|
|
120
|
-
@click=
|
|
108
|
+
<ContentCopyIcon />
|
|
109
|
+
</BaseButton>
|
|
110
|
+
|
|
111
|
+
<BaseButton
|
|
112
|
+
variant="icon"
|
|
113
|
+
:title="$i18n.t('blog:remove')"
|
|
114
|
+
:disabled="isBusy(row.id)"
|
|
115
|
+
@click="handleResourceDelete(row.id)"
|
|
121
116
|
>
|
|
122
|
-
<
|
|
123
|
-
</
|
|
117
|
+
<DeleteIcon />
|
|
118
|
+
</BaseButton>
|
|
124
119
|
</template>
|
|
125
|
-
</
|
|
120
|
+
</DataTable>
|
|
126
121
|
</template>
|
|
127
|
-
</
|
|
122
|
+
</Page>
|
|
128
123
|
</template>
|
|
129
124
|
|
|
130
|
-
<script lang=
|
|
131
|
-
import { computed, defineComponent, watch } from '
|
|
125
|
+
<script lang="ts">
|
|
126
|
+
import { computed, defineComponent, watch } from 'vue';
|
|
132
127
|
import isEqual from 'lodash.isequal';
|
|
133
128
|
import pick from 'lodash.pick';
|
|
129
|
+
import { useRoute, useRouter } from 'vue-router';
|
|
134
130
|
|
|
135
131
|
import {
|
|
136
132
|
ColumnDefinition,
|
|
137
133
|
OptionType,
|
|
138
134
|
useDataTable,
|
|
139
|
-
|
|
140
|
-
|
|
135
|
+
formatDateTime,
|
|
136
|
+
AdvancedSearch,
|
|
137
|
+
FormFieldMultiSelect,
|
|
138
|
+
FormField,
|
|
139
|
+
BaseButton,
|
|
140
|
+
EditIcon,
|
|
141
|
+
ContentCopyIcon,
|
|
142
|
+
DeleteIcon,
|
|
143
|
+
DataTable,
|
|
141
144
|
} from '@tager/admin-ui';
|
|
142
145
|
import {
|
|
143
146
|
Nullable,
|
|
147
|
+
useI18n,
|
|
144
148
|
useResourceClone,
|
|
145
|
-
useResourceDelete
|
|
149
|
+
useResourceDelete,
|
|
146
150
|
} from '@tager/admin-services';
|
|
151
|
+
import { Page } from '@tager/admin-layout';
|
|
147
152
|
|
|
148
153
|
import { useFetchModuleConfig, useFetchCategories } from '../../../hooks';
|
|
149
154
|
import {
|
|
150
155
|
clonePost,
|
|
151
156
|
deleteBlogPost,
|
|
152
|
-
getPosts
|
|
157
|
+
getPosts,
|
|
153
158
|
} from '../../../services/requests';
|
|
154
|
-
import { getBlogPostFormUrl } from '../../../
|
|
159
|
+
import { getBlogPostFormUrl } from '../../../utils/paths';
|
|
155
160
|
import {
|
|
156
161
|
Category,
|
|
157
162
|
Language,
|
|
158
163
|
PostFull,
|
|
159
|
-
PostShort
|
|
164
|
+
PostShort,
|
|
160
165
|
} from '../../../typings/model';
|
|
161
166
|
import { getStatusOptions } from '../PostForm/PostForm.helpers';
|
|
162
167
|
|
|
163
|
-
import {
|
|
168
|
+
import {
|
|
169
|
+
convertPostList,
|
|
170
|
+
getPostTableColumnDefs,
|
|
171
|
+
getStatuses,
|
|
172
|
+
} from './PostList.helpers';
|
|
164
173
|
import { useAdvancedSearch } from './hooks';
|
|
165
174
|
|
|
166
175
|
export default defineComponent({
|
|
167
|
-
name: '
|
|
168
|
-
|
|
169
|
-
|
|
176
|
+
name: 'PostList',
|
|
177
|
+
components: {
|
|
178
|
+
DeleteIcon,
|
|
179
|
+
ContentCopyIcon,
|
|
180
|
+
EditIcon,
|
|
181
|
+
BaseButton,
|
|
182
|
+
FormField,
|
|
183
|
+
FormFieldMultiSelect,
|
|
184
|
+
AdvancedSearch,
|
|
185
|
+
Page,
|
|
186
|
+
DataTable,
|
|
187
|
+
},
|
|
188
|
+
setup() {
|
|
189
|
+
const { t } = useI18n();
|
|
190
|
+
const route = useRoute();
|
|
191
|
+
const router = useRouter();
|
|
170
192
|
|
|
171
193
|
const categoryId = computed<string>(() => {
|
|
172
|
-
return Array.isArray(
|
|
173
|
-
?
|
|
174
|
-
:
|
|
194
|
+
return Array.isArray(route.query.category)
|
|
195
|
+
? (route.query.category[0] as string) ?? ''
|
|
196
|
+
: (route.query.category as string);
|
|
175
197
|
});
|
|
176
198
|
|
|
177
199
|
const statusOptionList = computed<OptionType[]>(() => getStatusOptions(t));
|
|
178
200
|
|
|
179
201
|
/** Fetch module config **/
|
|
180
202
|
|
|
181
|
-
const {
|
|
182
|
-
|
|
183
|
-
loading: isModuleConfigLoading
|
|
184
|
-
} = useFetchModuleConfig({ context });
|
|
203
|
+
const { data: moduleConfig, loading: isModuleConfigLoading } =
|
|
204
|
+
useFetchModuleConfig();
|
|
185
205
|
|
|
186
206
|
const languageList = computed<Language[]>(
|
|
187
207
|
() => moduleConfig.value?.languages ?? []
|
|
@@ -189,27 +209,27 @@ export default defineComponent({
|
|
|
189
209
|
|
|
190
210
|
/** Fetch category list **/
|
|
191
211
|
|
|
192
|
-
const {
|
|
193
|
-
|
|
194
|
-
loading: isCategoryListLoading
|
|
195
|
-
} = useFetchCategories({ context });
|
|
212
|
+
const { data: categoryList, loading: isCategoryListLoading } =
|
|
213
|
+
useFetchCategories();
|
|
196
214
|
|
|
197
215
|
const selectedCategory = computed<Nullable<Category>>(() =>
|
|
198
216
|
categoryId.value
|
|
199
217
|
? categoryList.value.find(
|
|
200
|
-
|
|
201
|
-
|
|
218
|
+
({ id }) => String(id) === String(categoryId.value)
|
|
219
|
+
) ?? null
|
|
202
220
|
: null
|
|
203
221
|
);
|
|
204
222
|
|
|
205
223
|
const pageTitle = computed<string>(() => {
|
|
206
224
|
return selectedCategory.value
|
|
207
|
-
? `${
|
|
208
|
-
|
|
209
|
-
}"`
|
|
210
|
-
: context.root.$t('blog:posts');
|
|
225
|
+
? `${t('blog:postsByCategory')} "${selectedCategory.value.name}"`
|
|
226
|
+
: t('blog:posts');
|
|
211
227
|
});
|
|
212
228
|
|
|
229
|
+
const isLangSpecific = computed<boolean>(
|
|
230
|
+
() => languageOptionList.value.length > 1
|
|
231
|
+
);
|
|
232
|
+
|
|
213
233
|
/** Advanced search **/
|
|
214
234
|
|
|
215
235
|
const {
|
|
@@ -222,18 +242,15 @@ export default defineComponent({
|
|
|
222
242
|
filterParams,
|
|
223
243
|
tags,
|
|
224
244
|
tagRemovalHandler,
|
|
225
|
-
statusFilter
|
|
245
|
+
statusFilter,
|
|
226
246
|
} = useAdvancedSearch({
|
|
227
|
-
|
|
247
|
+
t,
|
|
248
|
+
route,
|
|
228
249
|
categoryList,
|
|
229
250
|
languageList,
|
|
230
|
-
statusOptionList
|
|
251
|
+
statusOptionList,
|
|
231
252
|
});
|
|
232
253
|
|
|
233
|
-
const isLangSpecific = computed<boolean>(
|
|
234
|
-
() => languageOptionList.value.length > 1
|
|
235
|
-
);
|
|
236
|
-
|
|
237
254
|
/** Fetch Post list **/
|
|
238
255
|
|
|
239
256
|
const {
|
|
@@ -245,19 +262,18 @@ export default defineComponent({
|
|
|
245
262
|
handleChange,
|
|
246
263
|
pageNumber,
|
|
247
264
|
pageCount,
|
|
248
|
-
pageSize
|
|
265
|
+
pageSize,
|
|
249
266
|
} = useDataTable<PostShort>({
|
|
250
267
|
fetchEntityList: (params) =>
|
|
251
268
|
getPosts({
|
|
252
269
|
query: params.searchQuery,
|
|
253
270
|
pageNumber: params.pageNumber,
|
|
254
271
|
pageSize: params.pageSize,
|
|
255
|
-
...filterParams.value
|
|
272
|
+
...filterParams.value,
|
|
256
273
|
}),
|
|
257
274
|
initialValue: [],
|
|
258
|
-
context,
|
|
259
275
|
resourceName: 'Blog post list',
|
|
260
|
-
pageSize: 100
|
|
276
|
+
pageSize: 100,
|
|
261
277
|
});
|
|
262
278
|
|
|
263
279
|
watch(filterParams, () => {
|
|
@@ -266,12 +282,12 @@ export default defineComponent({
|
|
|
266
282
|
}
|
|
267
283
|
|
|
268
284
|
const newQuery = {
|
|
269
|
-
...pick(
|
|
270
|
-
...filterParams.value
|
|
285
|
+
...pick(route.query, ['query', 'pageNumber']),
|
|
286
|
+
...filterParams.value,
|
|
271
287
|
};
|
|
272
288
|
|
|
273
|
-
if (!isEqual(
|
|
274
|
-
|
|
289
|
+
if (!isEqual(route.query, newQuery)) {
|
|
290
|
+
router.replace({ query: newQuery });
|
|
275
291
|
fetchPostList();
|
|
276
292
|
}
|
|
277
293
|
});
|
|
@@ -295,7 +311,6 @@ export default defineComponent({
|
|
|
295
311
|
deleteResource: deleteBlogPost,
|
|
296
312
|
resourceName: 'Post',
|
|
297
313
|
onSuccess: fetchPostList,
|
|
298
|
-
context
|
|
299
314
|
});
|
|
300
315
|
|
|
301
316
|
const { isCloning, handleResourceClone } = useResourceClone({
|
|
@@ -304,7 +319,6 @@ export default defineComponent({
|
|
|
304
319
|
successMessage: t('blog:cloneSuccess'),
|
|
305
320
|
failureMessage: t('blog:cloneFailure'),
|
|
306
321
|
onSuccessRedirectTo: (data: PostFull) => `/blog/posts/${data.id}`,
|
|
307
|
-
context
|
|
308
322
|
});
|
|
309
323
|
|
|
310
324
|
function isBusy(postId: number): boolean {
|
|
@@ -312,7 +326,7 @@ export default defineComponent({
|
|
|
312
326
|
}
|
|
313
327
|
|
|
314
328
|
const columnDefs = computed<ColumnDefinition<PostShort>[]>(() =>
|
|
315
|
-
getPostTableColumnDefs(moduleConfig.value,
|
|
329
|
+
getPostTableColumnDefs(moduleConfig.value, t)
|
|
316
330
|
);
|
|
317
331
|
|
|
318
332
|
return {
|
|
@@ -349,36 +363,23 @@ export default defineComponent({
|
|
|
349
363
|
|
|
350
364
|
// Clone
|
|
351
365
|
handleResourceClone,
|
|
352
|
-
isBusy
|
|
366
|
+
isBusy,
|
|
353
367
|
};
|
|
354
|
-
}
|
|
368
|
+
},
|
|
355
369
|
});
|
|
356
370
|
</script>
|
|
357
371
|
|
|
358
|
-
<style scoped lang=
|
|
372
|
+
<style scoped lang="scss">
|
|
359
373
|
.filters {
|
|
360
|
-
|
|
361
|
-
|
|
374
|
+
margin-bottom: 1rem;
|
|
375
|
+
width: 100%;
|
|
376
|
+
display: grid;
|
|
377
|
+
gap: 1rem;
|
|
378
|
+
grid-template-columns: 1fr 1fr;
|
|
362
379
|
|
|
363
380
|
&:not(:first-child) {
|
|
364
|
-
margin-top:
|
|
381
|
+
margin-top: 1rem;
|
|
365
382
|
}
|
|
366
|
-
|
|
367
|
-
.filter {
|
|
368
|
-
padding: 10px 10px 0;
|
|
369
|
-
width: 50%;
|
|
370
|
-
margin: 0;
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
.date-label {
|
|
375
|
-
margin-bottom: 0.5rem;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
.date-content {
|
|
379
|
-
display: grid;
|
|
380
|
-
grid-template-columns: repeat(2, 1fr);
|
|
381
|
-
column-gap: 10px;
|
|
382
383
|
}
|
|
383
384
|
|
|
384
385
|
.status {
|
|
@@ -395,6 +396,5 @@ export default defineComponent({
|
|
|
395
396
|
display: block;
|
|
396
397
|
}
|
|
397
398
|
}
|
|
398
|
-
;
|
|
399
399
|
}
|
|
400
400
|
</style>
|
|
@@ -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, watch } from 'vue';
|
|
2
|
+
import { TFunction } from 'i18next';
|
|
3
|
+
import { RouteLocationNormalizedLoaded } from 'vue-router';
|
|
9
4
|
|
|
10
5
|
import {
|
|
11
6
|
FilterTagType,
|
|
@@ -20,10 +15,12 @@ import { Category, Language } from '../../../../typings/model';
|
|
|
20
15
|
import { getNameWithDepth } from '../../../../utils/common';
|
|
21
16
|
|
|
22
17
|
interface Params {
|
|
23
|
-
|
|
24
|
-
categoryList: ComputedRef<Category[]>;
|
|
18
|
+
categoryList: Ref<Category[]>;
|
|
25
19
|
languageList: ComputedRef<Language[]>;
|
|
26
20
|
statusOptionList: ComputedRef<OptionType[]>;
|
|
21
|
+
|
|
22
|
+
t: TFunction;
|
|
23
|
+
route: RouteLocationNormalizedLoaded;
|
|
27
24
|
}
|
|
28
25
|
|
|
29
26
|
interface State {
|
|
@@ -36,6 +33,7 @@ interface State {
|
|
|
36
33
|
statusFilter: Ref<OptionType[]>;
|
|
37
34
|
filterParams: ComputedRef<Record<string, string | string[]>>;
|
|
38
35
|
tags: ComputedRef<FilterTagType[]>;
|
|
36
|
+
|
|
39
37
|
tagRemovalHandler(event: FilterTagType): void;
|
|
40
38
|
}
|
|
41
39
|
|
|
@@ -50,7 +48,8 @@ enum FilterTypes {
|
|
|
50
48
|
export const dateFormat = (date: string) => date.split('-').reverse().join('.');
|
|
51
49
|
|
|
52
50
|
export function useAdvancedSearch({
|
|
53
|
-
|
|
51
|
+
t,
|
|
52
|
+
route,
|
|
54
53
|
categoryList,
|
|
55
54
|
languageList,
|
|
56
55
|
statusOptionList,
|
|
@@ -66,9 +65,10 @@ export function useAdvancedSearch({
|
|
|
66
65
|
|
|
67
66
|
const initialCategoryFilter = computed<OptionType[]>(() => {
|
|
68
67
|
const queryValue = getFilterParamAsStringArray(
|
|
69
|
-
|
|
68
|
+
route.query,
|
|
70
69
|
FilterTypes.CATEGORY
|
|
71
70
|
);
|
|
71
|
+
|
|
72
72
|
return categoryOptionList.value.filter(({ value }) =>
|
|
73
73
|
queryValue.some((selected) => selected === value)
|
|
74
74
|
);
|
|
@@ -88,7 +88,7 @@ export function useAdvancedSearch({
|
|
|
88
88
|
|
|
89
89
|
const initialLanguageFilter = computed<OptionType[]>(() => {
|
|
90
90
|
const queryValue = getFilterParamAsStringArray(
|
|
91
|
-
|
|
91
|
+
route.query,
|
|
92
92
|
FilterTypes.LANGUAGE
|
|
93
93
|
);
|
|
94
94
|
return languageOptionList.value.filter(({ value }) =>
|
|
@@ -105,11 +105,7 @@ export function useAdvancedSearch({
|
|
|
105
105
|
/** From date **/
|
|
106
106
|
|
|
107
107
|
const initialFromDateFilter = computed<string>(
|
|
108
|
-
() =>
|
|
109
|
-
getFilterParamAsString(
|
|
110
|
-
context.root.$route.query,
|
|
111
|
-
FilterTypes.FROM_DATE
|
|
112
|
-
) ?? ''
|
|
108
|
+
() => getFilterParamAsString(route.query, FilterTypes.FROM_DATE) ?? ''
|
|
113
109
|
);
|
|
114
110
|
|
|
115
111
|
const fromDateFilter = ref<string>(initialFromDateFilter.value);
|
|
@@ -121,9 +117,7 @@ export function useAdvancedSearch({
|
|
|
121
117
|
/** To date **/
|
|
122
118
|
|
|
123
119
|
const initialToDateFilter = computed<string>(
|
|
124
|
-
() =>
|
|
125
|
-
getFilterParamAsString(context.root.$route.query, FilterTypes.TO_DATE) ??
|
|
126
|
-
''
|
|
120
|
+
() => getFilterParamAsString(route.query, FilterTypes.TO_DATE) ?? ''
|
|
127
121
|
);
|
|
128
122
|
|
|
129
123
|
const toDateFilter = ref<string>(initialToDateFilter.value);
|
|
@@ -148,20 +142,18 @@ export function useAdvancedSearch({
|
|
|
148
142
|
}
|
|
149
143
|
|
|
150
144
|
if (fromDateFilter.value && !toDateFilter.value) {
|
|
151
|
-
label = `${
|
|
152
|
-
fromDateFilter.value
|
|
153
|
-
)}`;
|
|
145
|
+
label = `${t('blog:from')} ${dateFormat(fromDateFilter.value)}`;
|
|
154
146
|
}
|
|
155
147
|
|
|
156
148
|
if (!fromDateFilter.value && toDateFilter.value) {
|
|
157
|
-
label = `${
|
|
149
|
+
label = `${t('blog:to')} ${dateFormat(toDateFilter.value)}`;
|
|
158
150
|
}
|
|
159
151
|
|
|
160
152
|
return {
|
|
161
153
|
value: '',
|
|
162
154
|
label,
|
|
163
155
|
name: FilterTypes.FROM_DATE,
|
|
164
|
-
title:
|
|
156
|
+
title: t('blog:dateOfPublication'),
|
|
165
157
|
};
|
|
166
158
|
});
|
|
167
159
|
|
|
@@ -169,7 +161,7 @@ export function useAdvancedSearch({
|
|
|
169
161
|
|
|
170
162
|
const initialStatusFilter = computed<OptionType[]>(() => {
|
|
171
163
|
const queryValue = getFilterParamAsStringArray(
|
|
172
|
-
|
|
164
|
+
route.query,
|
|
173
165
|
FilterTypes.STATUS
|
|
174
166
|
);
|
|
175
167
|
return statusOptionList.value.filter(({ value }) =>
|
|
@@ -235,20 +227,20 @@ export function useAdvancedSearch({
|
|
|
235
227
|
value,
|
|
236
228
|
label,
|
|
237
229
|
name: FilterTypes.CATEGORY,
|
|
238
|
-
title:
|
|
230
|
+
title: t('blog:category'),
|
|
239
231
|
})),
|
|
240
232
|
...languageFilter.value.map(({ value, label }) => ({
|
|
241
233
|
value,
|
|
242
234
|
label,
|
|
243
235
|
name: FilterTypes.LANGUAGE,
|
|
244
|
-
title:
|
|
236
|
+
title: t('blog:language'),
|
|
245
237
|
})),
|
|
246
238
|
date.value,
|
|
247
239
|
...statusFilter.value.map(({ value, label }) => ({
|
|
248
240
|
value,
|
|
249
241
|
label,
|
|
250
242
|
name: FilterTypes.STATUS,
|
|
251
|
-
title:
|
|
243
|
+
title: t('blog:status'),
|
|
252
244
|
})),
|
|
253
245
|
].filter(isNotNullish)
|
|
254
246
|
);
|
package/CHANGELOG.md
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# [0.0.2] (2020-06-06)
|
|
2
|
-
|
|
3
|
-
### Features
|
|
4
|
-
|
|
5
|
-
* **services:** Use VUE_APP_API_ORIGIN env variable as initial api origin value in ApiService
|
|
6
|
-
|
|
7
|
-
# [0.0.3] (2020-06-06)
|
|
8
|
-
|
|
9
|
-
### Bug Fixes
|
|
10
|
-
|
|
11
|
-
* **services:** Use api origin from ApiService to configure url for file upload
|
|
12
|
-
|
|
13
|
-
|