@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.
Files changed (82) hide show
  1. package/dist/constants/paths.d.ts +6 -14
  2. package/dist/constants/routes.d.ts +5 -5
  3. package/dist/dev/App.vue.d.ts +5 -0
  4. package/dist/dev/config.d.ts +2 -0
  5. package/dist/dev/env.d.ts +1 -0
  6. package/dist/dev/main.d.ts +3 -0
  7. package/dist/hooks/index.d.ts +4 -4
  8. package/dist/hooks/useFetchCategories.d.ts +3 -6
  9. package/dist/hooks/useFetchCategory.d.ts +7 -8
  10. package/dist/hooks/useFetchModuleConfig.d.ts +3 -6
  11. package/dist/hooks/useFetchPosts.d.ts +3 -6
  12. package/dist/index.mjs +2313 -0
  13. package/dist/locales/apply.d.ts +1 -0
  14. package/dist/locales/en.d.ts +87 -86
  15. package/dist/locales/ru.d.ts +3 -3
  16. package/dist/main.d.ts +3 -4
  17. package/dist/services/requests.d.ts +59 -59
  18. package/dist/style.css +1 -0
  19. package/dist/typings/common.d.ts +1 -1
  20. package/dist/typings/model.d.ts +106 -106
  21. package/dist/utils/common.d.ts +2 -2
  22. package/dist/utils/paths.d.ts +8 -0
  23. package/dist/views/Categories/CategoryForm/CategoryForm.helpers.d.ts +7 -7
  24. package/dist/views/Categories/CategoryForm/CategoryForm.vue.d.ts +53 -116
  25. package/dist/views/Categories/CategoryForm/index.d.ts +1 -1
  26. package/dist/views/Categories/CategoryList/CategoryList.helpers.d.ts +7 -7
  27. package/dist/views/Categories/CategoryList/CategoryList.vue.d.ts +26 -57
  28. package/dist/views/Categories/CategoryList/hooks/index.d.ts +1 -1
  29. package/dist/views/Categories/CategoryList/hooks/useAdvancedSearch.d.ts +19 -16
  30. package/dist/views/Categories/CategoryList/index.d.ts +1 -1
  31. package/dist/views/Posts/PostForm/PostForm.helpers.d.ts +32 -32
  32. package/dist/views/Posts/PostForm/PostForm.vue.d.ts +2768 -9398
  33. package/dist/views/Posts/PostForm/index.d.ts +1 -1
  34. package/dist/views/Posts/PostList/PostList.helpers.d.ts +7 -7
  35. package/dist/views/Posts/PostList/PostList.vue.d.ts +38 -78
  36. package/dist/views/Posts/PostList/hooks/index.d.ts +1 -1
  37. package/dist/views/Posts/PostList/hooks/useAdvancedSearch.d.ts +27 -24
  38. package/dist/views/Posts/PostList/index.d.ts +1 -1
  39. package/package.json +51 -49
  40. package/src/constants/paths.ts +0 -22
  41. package/src/constants/routes.ts +9 -9
  42. package/src/dev/App.vue +56 -0
  43. package/src/dev/config.ts +23 -0
  44. package/src/dev/env.ts +17 -0
  45. package/src/dev/main.ts +49 -0
  46. package/src/hooks/useFetchCategories.ts +2 -7
  47. package/src/hooks/useFetchCategory.ts +3 -6
  48. package/src/hooks/useFetchModuleConfig.ts +2 -7
  49. package/src/hooks/useFetchPosts.ts +2 -5
  50. package/src/locales/apply.ts +9 -0
  51. package/src/locales/en.ts +3 -3
  52. package/src/locales/ru.ts +4 -2
  53. package/src/main.ts +3 -8
  54. package/src/utils/paths.ts +23 -0
  55. package/src/views/Categories/CategoryForm/CategoryForm.vue +81 -65
  56. package/src/views/Categories/CategoryList/CategoryList.helpers.ts +1 -1
  57. package/src/views/Categories/CategoryList/CategoryList.vue +86 -58
  58. package/src/views/Categories/CategoryList/hooks/useAdvancedSearch.ts +9 -12
  59. package/src/views/Posts/PostForm/PostForm.vue +259 -224
  60. package/src/views/Posts/PostList/PostList.helpers.ts +3 -3
  61. package/src/views/Posts/PostList/PostList.vue +168 -168
  62. package/src/views/Posts/PostList/hooks/useAdvancedSearch.ts +22 -30
  63. package/CHANGELOG.md +0 -13
  64. package/dist/constants/menu.d.ts +0 -5
  65. package/dist/dev.d.ts +0 -1
  66. package/dist/index.esm.js +0 -5294
  67. package/dist/index.umd.js +0 -5321
  68. package/dist/router/index.d.ts +0 -4
  69. package/dist/views/Posts/PostForm/components/TabList/TabList.types.d.ts +0 -5
  70. package/dist/views/Posts/PostForm/components/TabList/index.d.ts +0 -2
  71. package/src/constants/menu.ts +0 -31
  72. package/src/dev.ts +0 -34
  73. package/src/router/index.ts +0 -40
  74. package/src/typings/sfc.d.ts +0 -12
  75. package/src/typings/shims-tsx.d.ts +0 -13
  76. package/src/typings/shims-vue.d.ts +0 -11
  77. package/src/typings/translate.d.ts +0 -10
  78. package/src/views/App.vue +0 -22
  79. package/src/views/Home.vue +0 -31
  80. package/src/views/Posts/PostForm/components/TabList/TabList.types.ts +0 -5
  81. package/src/views/Posts/PostForm/components/TabList/TabList.vue +0 -92
  82. package/src/views/Posts/PostForm/components/TabList/index.ts +0 -2
@@ -1,19 +1,14 @@
1
- import { onMounted, SetupContext } from '@vue/composition-api';
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, SetupContext } from '@vue/composition-api';
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(params: {
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
 
@@ -0,0 +1,9 @@
1
+ import { i18n } from '@tager/admin-services';
2
+
3
+ import { EN } from './en';
4
+ import { RU } from './ru';
5
+
6
+ export function applyTranslations() {
7
+ i18n.addTranslations('en', 'blog', EN);
8
+ i18n.addTranslations('ru', 'blog', RU);
9
+ }
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',
@@ -88,5 +90,3 @@ const EN = {
88
90
  archiveAtLabel: 'Archive at',
89
91
  publishAtLabel: 'Publish at',
90
92
  };
91
-
92
- export default EN;
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: 'От',
package/src/main.ts CHANGED
@@ -1,12 +1,7 @@
1
- import { i18n } from '@tager/admin-services';
1
+ import { applyTranslations } from './locales/apply';
2
2
 
3
- import EN from './locales/en';
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 './constants/menu';
11
- export * from './constants/paths';
6
+ export * from './utils/paths';
12
7
  export * from './services/requests';
@@ -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
- <page
2
+ <Page
3
3
  :title="
4
- isCreation ? $t('blog:createBlogCategory') : $t('blog:updateBlogCategory')
4
+ isCreation
5
+ ? $i18n.t('blog:createBlogCategory')
6
+ : $i18n.t('blog:updateBlogCategory')
5
7
  "
6
8
  :is-content-loading="isContentLoading"
7
9
  >
8
- <template v-slot:content>
10
+ <template #content>
9
11
  <form novalidate @submit.prevent="submitForm">
10
12
  <template v-if="isCreation">
11
- <form-field-select
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
- <form-field
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
- <form-field-select
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
- <form-field-url-alias-input
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,53 @@
46
48
  </template>
47
49
 
48
50
  <template v-else>
49
- <tab-list
50
- :tab-list="tabList"
51
- :selected-tab-id="selectedTabId"
52
- @tab:update="selectedTabId = $event.tabId"
53
- />
51
+ <TabList v-model:tab-id="selectedTabId" :tab-list="tabList" />
54
52
 
55
53
  <template v-if="selectedTabId === 'common'">
56
- <form-field-select
54
+ <FormFieldSelect
57
55
  v-if="isLangSpecific"
58
- v-model="values.language"
56
+ v-model:value="values.language"
59
57
  name="language"
60
- :label="$t('blog:language')"
58
+ :label="$i18n.t('blog:language')"
61
59
  :options="languageOptionList"
62
60
  :error="errors.language"
63
61
  />
64
62
 
65
- <form-field-checkbox
66
- v-model="values.isDefault"
63
+ <FormFieldCheckbox
64
+ v-model:checked="values.isDefault"
67
65
  name="isDefault"
68
- :label="$t('blog:defaultCategory')"
66
+ :label="$i18n.t('blog:defaultCategory')"
69
67
  :error="errors.isDefault"
70
68
  />
71
69
 
72
- <form-field
73
- v-model="values.name"
70
+ <FormField
71
+ v-model:value="values.name"
74
72
  name="name"
75
- :label="$t('blog:name')"
73
+ :label="$i18n.t('blog:name')"
76
74
  :error="errors.name"
77
75
  />
78
76
 
79
- <form-field-select
77
+ <FormFieldSelect
80
78
  v-if="!isLangSpecific || values.language"
81
- v-model="values.parent"
79
+ v-model:value="values.parent"
82
80
  name="parentCategory"
83
- :label="$t('blog:parentCategory')"
81
+ :label="$i18n.t('blog:parentCategory')"
84
82
  :options="parentCategoryOptionList"
85
83
  :error="errors.parent"
86
84
  />
87
85
 
88
- <form-field-url-alias-input
86
+ <FormFieldUrlAliasInput
89
87
  id="urlAlias"
90
- v-model="values.urlAlias"
88
+ v-model:value="values.urlAlias"
91
89
  name="urlAlias"
92
- :label="$t('blog:link')"
90
+ :label="$i18n.t('blog:link')"
93
91
  :url-template="pagePath"
94
92
  :error="errors.urlAlias"
95
93
  />
96
94
  </template>
97
95
 
98
96
  <template v-if="selectedTabId === 'seo'">
99
- <seo-field-group
97
+ <SeoFieldGroup
100
98
  :title="values.pageTitle"
101
99
  :title-error-message="errors.pageTitle"
102
100
  :description="values.pageDescription"
@@ -114,26 +112,30 @@
114
112
  </form>
115
113
  </template>
116
114
 
117
- <template v-slot:footer>
115
+ <template #footer>
118
116
  <FormFooter
119
117
  :back-href="categoryListUrl"
120
- :on-submit="submitForm"
121
118
  :is-submitting="isSubmitting"
122
119
  :is-creation="isCreation"
123
120
  :can-create-another="isCreation"
121
+ @submit="submitForm"
124
122
  />
125
123
  </template>
126
- </page>
124
+ </Page>
127
125
  </template>
128
126
 
129
127
  <script lang="ts">
130
- import { computed, defineComponent, ref, watch } from '@vue/composition-api';
128
+ import { computed, defineComponent, ref, watch } from 'vue';
129
+ import { useRoute, useRouter } from 'vue-router';
131
130
 
132
131
  import {
133
132
  convertRequestErrorToMap,
134
133
  getWebsiteOrigin,
134
+ navigateBack,
135
135
  Nullable,
136
136
  urlTranslit,
137
+ useI18n,
138
+ useToast,
137
139
  } from '@tager/admin-services';
138
140
  import {
139
141
  OptionType,
@@ -141,8 +143,14 @@ import {
141
143
  TagerFormSubmitEvent,
142
144
  SeoChangeEvent,
143
145
  TabType,
144
- useTranslation,
146
+ FormFieldSelect,
147
+ FormField,
148
+ FormFieldUrlAliasInput,
149
+ FormFieldCheckbox,
150
+ SeoFieldGroup,
151
+ TabList,
145
152
  } from '@tager/admin-ui';
153
+ import { Page } from '@tager/admin-layout';
146
154
 
147
155
  import {
148
156
  useFetchCategories,
@@ -152,7 +160,7 @@ import {
152
160
  import {
153
161
  getBlogCategoryFormUrl,
154
162
  getBlogCategoryListUrl,
155
- } from '../../../constants/paths';
163
+ } from '../../../utils/paths';
156
164
  import { CategoryFormValues, Language } from '../../../typings/model';
157
165
  import { createCategory, updateCategory } from '../../../services/requests';
158
166
 
@@ -164,20 +172,31 @@ import {
164
172
 
165
173
  export default defineComponent({
166
174
  name: 'CategoryForm',
167
- components: { FormFooter },
168
- setup(props, context) {
169
- const { t } = useTranslation(context);
175
+ components: {
176
+ Page,
177
+ SeoFieldGroup,
178
+ FormFieldCheckbox,
179
+ TabList,
180
+ FormFieldUrlAliasInput,
181
+ FormField,
182
+ FormFieldSelect,
183
+ FormFooter,
184
+ },
185
+ setup() {
186
+ const { t } = useI18n();
187
+ const router = useRouter();
188
+ const route = useRoute();
189
+ const toast = useToast();
190
+
170
191
  const categoryId = computed<string>(
171
- () => context.root.$route.params.categoryId
192
+ () => route.params.categoryId as string
172
193
  );
173
194
  const isCreation = computed<boolean>(() => categoryId.value === 'create');
174
195
 
175
196
  /** Fetch module config */
176
197
 
177
- const {
178
- data: moduleConfig,
179
- loading: isModuleConfigLoading,
180
- } = useFetchModuleConfig({ context });
198
+ const { data: moduleConfig, loading: isModuleConfigLoading } =
199
+ useFetchModuleConfig();
181
200
 
182
201
  const languageList = computed<Language[]>(
183
202
  () => moduleConfig.value?.languages ?? []
@@ -197,15 +216,12 @@ export default defineComponent({
197
216
 
198
217
  /** Fetch Categories */
199
218
 
200
- const {
201
- data: categories,
202
- loading: isCategoriesLoading,
203
- } = useFetchCategories({ context });
219
+ const { data: categories, loading: isCategoriesLoading } =
220
+ useFetchCategories();
204
221
 
205
222
  /** Fetch Category */
206
223
 
207
224
  const { data: category, loading: isCategoryLoading } = useFetchCategory({
208
- context,
209
225
  categoryId,
210
226
  isCreation,
211
227
  });
@@ -239,13 +255,13 @@ export default defineComponent({
239
255
  errors.value = {};
240
256
 
241
257
  if (event.type === 'create') {
242
- context.root.$router.push(
258
+ router.push(
243
259
  getBlogCategoryFormUrl({ categoryId: String(data.id) })
244
260
  );
245
261
  }
246
262
 
247
263
  if (event.type === 'create_exit' || event.type === 'save_exit') {
248
- context.root.$router.push(getBlogCategoryListUrl());
264
+ navigateBack(router, getBlogCategoryListUrl());
249
265
  }
250
266
 
251
267
  if (event.type === 'create_create-another') {
@@ -256,23 +272,23 @@ export default defineComponent({
256
272
  );
257
273
  }
258
274
 
259
- context.root.$toast({
275
+ toast.show({
260
276
  variant: 'success',
261
- title: context.root.$t('blog:success'),
277
+ title: t('blog:success'),
262
278
  body: isCreation.value
263
- ? context.root.$t('blog:blogCategoryWasSuccessfullyCreated')
264
- : context.root.$t('blog:blogCategoryWasSuccessfullyUpdated'),
279
+ ? t('blog:blogCategoryWasSuccessfullyCreated')
280
+ : t('blog:blogCategoryWasSuccessfullyUpdated'),
265
281
  });
266
282
  })
267
283
  .catch((error) => {
268
284
  console.error(error);
269
285
  errors.value = convertRequestErrorToMap(error);
270
- context.root.$toast({
286
+ toast.show({
271
287
  variant: 'danger',
272
- title: context.root.$t('blog:error'),
288
+ title: t('blog:error'),
273
289
  body: isCreation.value
274
- ? context.root.$t('blog:blogCategoryCreationWasFailed')
275
- : context.root.$t('blog:blogCategoryUpdateWasFailed'),
290
+ ? t('blog:blogCategoryCreationWasFailed')
291
+ : t('blog:blogCategoryUpdateWasFailed'),
276
292
  });
277
293
  })
278
294
  .finally(() => {
@@ -7,7 +7,7 @@ import { Category, Language, ModuleConfig } from '../../../typings/model';
7
7
  import {
8
8
  getBlogCategoryFormUrl,
9
9
  getBlogPostListUrl,
10
- } from '../../../constants/paths';
10
+ } from '../../../utils/paths';
11
11
  import { getNameWithDepth } from '../../../utils/common';
12
12
 
13
13
  export function convertCategoryList(