@tager/admin-blog 0.3.43 → 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.
Files changed (81) 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 +2363 -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/components/TabList/TabList.types.d.ts +5 -5
  34. package/dist/views/Posts/PostForm/components/TabList/TabList.vue.d.ts +23 -0
  35. package/dist/views/Posts/PostForm/components/TabList/index.d.ts +2 -2
  36. package/dist/views/Posts/PostForm/index.d.ts +1 -1
  37. package/dist/views/Posts/PostList/PostList.helpers.d.ts +7 -7
  38. package/dist/views/Posts/PostList/PostList.vue.d.ts +38 -78
  39. package/dist/views/Posts/PostList/hooks/index.d.ts +1 -1
  40. package/dist/views/Posts/PostList/hooks/useAdvancedSearch.d.ts +27 -24
  41. package/dist/views/Posts/PostList/index.d.ts +1 -1
  42. package/package.json +51 -49
  43. package/src/constants/paths.ts +0 -22
  44. package/src/constants/routes.ts +9 -9
  45. package/src/dev/App.vue +56 -0
  46. package/src/dev/config.ts +23 -0
  47. package/src/dev/env.ts +17 -0
  48. package/src/dev/main.ts +49 -0
  49. package/src/hooks/useFetchCategories.ts +2 -7
  50. package/src/hooks/useFetchCategory.ts +3 -6
  51. package/src/hooks/useFetchModuleConfig.ts +2 -7
  52. package/src/hooks/useFetchPosts.ts +2 -5
  53. package/src/locales/apply.ts +9 -0
  54. package/src/locales/en.ts +3 -3
  55. package/src/locales/ru.ts +4 -2
  56. package/src/main.ts +3 -8
  57. package/src/utils/paths.ts +23 -0
  58. package/src/views/Categories/CategoryForm/CategoryForm.vue +81 -61
  59. package/src/views/Categories/CategoryList/CategoryList.helpers.ts +1 -1
  60. package/src/views/Categories/CategoryList/CategoryList.vue +86 -58
  61. package/src/views/Categories/CategoryList/hooks/useAdvancedSearch.ts +9 -12
  62. package/src/views/Posts/PostForm/PostForm.vue +262 -223
  63. package/src/views/Posts/PostForm/components/TabList/TabList.vue +2 -2
  64. package/src/views/Posts/PostList/PostList.helpers.ts +1 -1
  65. package/src/views/Posts/PostList/PostList.vue +168 -168
  66. package/src/views/Posts/PostList/hooks/useAdvancedSearch.ts +22 -30
  67. package/CHANGELOG.md +0 -13
  68. package/dist/constants/menu.d.ts +0 -5
  69. package/dist/dev.d.ts +0 -1
  70. package/dist/index.esm.js +0 -5294
  71. package/dist/index.umd.js +0 -5321
  72. package/dist/router/index.d.ts +0 -4
  73. package/src/constants/menu.ts +0 -31
  74. package/src/dev.ts +0 -34
  75. package/src/router/index.ts +0 -40
  76. package/src/typings/sfc.d.ts +0 -12
  77. package/src/typings/shims-tsx.d.ts +0 -13
  78. package/src/typings/shims-vue.d.ts +0 -11
  79. package/src/typings/translate.d.ts +0 -10
  80. package/src/views/App.vue +0 -22
  81. package/src/views/Home.vue +0 -31
@@ -1,15 +1,15 @@
1
1
  <template>
2
- <page
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 v-slot:content>
12
- <data-table
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" v-slot:filters>
28
- <advanced-search :tags="tags" @click:tag="tagRemovalHandler">
27
+ <template v-if="isLangSpecific" #filters>
28
+ <AdvancedSearch :tags="tags" @click:tag="tagRemovalHandler">
29
29
  <div class="filters">
30
- <form-field-multi-select
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
- </advanced-search>
39
+ </AdvancedSearch>
40
40
  </template>
41
41
 
42
- <template v-slot:cell(link-to-posts)="{ row }">
43
- <count-button
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
- </count-button>
48
+ {{ $i18n.t('blog:posts') }}
49
+ </CountButton>
50
50
  </template>
51
51
 
52
- <template v-slot:cell(actions)="{ row, rowIndex }">
53
- <base-button
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
- <svg-icon name="edit" />
60
- </base-button>
59
+ <EditIcon />
60
+ </BaseButton>
61
61
 
62
- <base-button
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
- <svg-icon name="north" />
69
- </base-button>
68
+ <NorthIcon />
69
+ </BaseButton>
70
70
 
71
- <base-button
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
- <svg-icon name="south" />
78
- </base-button>
77
+ <SouthIcon />
78
+ </BaseButton>
79
79
 
80
- <base-button
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
- <svg-icon name="delete" />
87
- </base-button>
86
+ <DeleteIcon />
87
+ </BaseButton>
88
88
  </template>
89
- </data-table>
89
+ </DataTable>
90
90
  </template>
91
- </page>
91
+ </Page>
92
92
  </template>
93
93
 
94
94
  <script lang="ts">
95
- import { computed, ref, defineComponent, watch } from '@vue/composition-api';
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 { useDataTable } from '@tager/admin-ui';
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 '../../../constants/paths';
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
- setup(props, context) {
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
- data: moduleConfig,
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({ context, languageList });
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: (context.root.$route.query.query ?? '') as string,
209
+ query: (route.query.query ?? '') as string,
179
210
  };
180
211
 
181
- if (!isEqual(context.root.$route.query, newQuery)) {
182
- context.root.$router.replace({ query: newQuery });
212
+ if (!isEqual(route.query, newQuery)) {
213
+ router.replace({ query: newQuery });
183
214
  fetchCategoryList();
184
215
  }
185
216
  });
186
217
 
187
- const {
188
- isDeleting,
189
- handleResourceDelete: handleCategoryDelete,
190
- } = useResourceDelete({
191
- deleteResource: deleteCategory,
192
- resourceName: 'Post',
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, context.root.$t)
253
+ getCategoryTableColumnDefs(moduleConfig.value, t)
226
254
  );
227
255
 
228
256
  return {
@@ -1,11 +1,6 @@
1
- import {
2
- computed,
3
- ComputedRef,
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
- context: SetupContext;
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({ context, languageList }: Params): State {
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
- context.root.$route.query,
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: context.root.$t('blog:language'),
81
+ title: t('blog:language'),
85
82
  })),
86
83
  ]);
87
84