@tager/admin-blog 0.3.31 → 0.3.36

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 (41) hide show
  1. package/dist/hooks/index.d.ts +0 -3
  2. package/dist/index.esm.js +120 -206
  3. package/dist/index.umd.js +119 -206
  4. package/dist/locales/en.d.ts +1 -0
  5. package/dist/services/requests.d.ts +2 -3
  6. package/dist/typings/model.d.ts +2 -16
  7. package/dist/utils/common.d.ts +0 -2
  8. package/dist/views/Categories/CategoryForm/CategoryForm.helpers.d.ts +3 -1
  9. package/dist/views/Categories/CategoryForm/CategoryForm.vue.d.ts +25 -20
  10. package/dist/views/Categories/CategoryList/CategoryList.helpers.d.ts +1 -1
  11. package/dist/views/Categories/CategoryList/CategoryList.vue.d.ts +0 -2
  12. package/dist/views/Posts/PostList/PostList.helpers.d.ts +1 -1
  13. package/dist/views/Posts/PostList/PostList.vue.d.ts +0 -2
  14. package/package.json +2 -4
  15. package/src/dev.ts +0 -4
  16. package/src/hooks/index.ts +0 -3
  17. package/src/locales/en.ts +1 -0
  18. package/src/locales/ru.ts +1 -0
  19. package/src/services/requests.ts +1 -6
  20. package/src/typings/model.ts +2 -21
  21. package/src/utils/common.ts +0 -10
  22. package/src/views/App.vue +1 -9
  23. package/src/views/Categories/CategoryForm/CategoryForm.helpers.ts +24 -4
  24. package/src/views/Categories/CategoryForm/CategoryForm.vue +39 -13
  25. package/src/views/Categories/CategoryList/CategoryList.helpers.ts +9 -12
  26. package/src/views/Categories/CategoryList/CategoryList.vue +8 -25
  27. package/src/views/Posts/PostForm/PostForm.vue +1 -1
  28. package/src/views/Posts/PostList/PostList.helpers.ts +8 -11
  29. package/src/views/Posts/PostList/PostList.vue +9 -30
  30. package/dist/constants/scopes.d.ts +0 -11
  31. package/dist/hooks/useStore.d.ts +0 -4
  32. package/dist/hooks/useUserPermission.d.ts +0 -3
  33. package/dist/hooks/useUserProfile.d.ts +0 -3
  34. package/dist/store/index.d.ts +0 -6
  35. package/dist/store/user.d.ts +0 -14
  36. package/src/constants/scopes.ts +0 -11
  37. package/src/hooks/useStore.ts +0 -8
  38. package/src/hooks/useUserPermission.ts +0 -16
  39. package/src/hooks/useUserProfile.ts +0 -13
  40. package/src/store/index.ts +0 -21
  41. package/src/store/user.ts +0 -110
@@ -1,20 +1,6 @@
1
1
  import { Nullable, FileType } from '@tager/admin-services';
2
2
  import { FieldConfigUnion, FieldShortType, IncomingValueUnion } from '@tager/admin-dynamic-field';
3
3
  import { OptionType, ShortCodeItemType, SingleFileInputValueType } from '@tager/admin-ui';
4
- import { Scope } from '../constants/scopes';
5
- import { Values } from './common';
6
- export declare type ScopeType = Values<typeof Scope>;
7
- export interface RoleModel {
8
- readonly id: number;
9
- readonly name: string;
10
- readonly scopes: Array<ScopeType>;
11
- }
12
- export interface UserModel {
13
- readonly id: number;
14
- readonly name: string;
15
- readonly email: string;
16
- readonly roles: Array<RoleModel>;
17
- }
18
4
  export interface SeoInfo {
19
5
  readonly pageTitle: Nullable<string>;
20
6
  readonly pageDescription: Nullable<string>;
@@ -33,7 +19,7 @@ export interface Category extends SeoInfo {
33
19
  readonly urlAlias: string;
34
20
  readonly postsCount: string;
35
21
  readonly parent: Nullable<{
36
- id: number;
22
+ id: Nullable<number>;
37
23
  name: string;
38
24
  }>;
39
25
  readonly depth: number;
@@ -96,7 +82,7 @@ export interface ModuleConfig {
96
82
  export interface CategoryFormValues {
97
83
  language: Nullable<OptionType>;
98
84
  name: string;
99
- parent: Nullable<OptionType<number>>;
85
+ parent: OptionType<Nullable<number>>;
100
86
  urlAlias: string;
101
87
  pageTitle: Nullable<string>;
102
88
  pageDescription: Nullable<string>;
@@ -1,4 +1,2 @@
1
- export declare function namespace(namespace: string, name: string): string;
2
- export declare function userNamespace(name: string): string;
3
1
  export declare function generateNumberArray(length: number): Array<number>;
4
2
  export declare function getNameWithDepth(name: string, depth: number): string;
@@ -1,5 +1,7 @@
1
+ import { TFunction } from 'i18next';
1
2
  import { Nullable } from '@tager/admin-services';
2
3
  import { OptionType } from '@tager/admin-ui';
3
4
  import { Category, CategoryFormValues, CategoryPayload } from '../../../typings/model';
4
- export declare function convertCategoryToFormValues(category: Nullable<Category>, languageOptionList: OptionType[]): CategoryFormValues;
5
+ export declare function convertCategoryToFormValues(category: Nullable<Category>, languageOptionList: OptionType[], t: TFunction): CategoryFormValues;
5
6
  export declare function convertCategoryFormValuesToPayload(values: CategoryFormValues): CategoryPayload;
7
+ export declare function convertCategoryListToOptions(categoryList: Category[], languageId: Nullable<string>, t: TFunction): OptionType<Nullable<number>>[];
@@ -1,3 +1,4 @@
1
+ import { Nullable } from '@tager/admin-services';
1
2
  import { OptionType, TagerFormSubmitEvent, SeoChangeEvent, TabType } from '@tager/admin-ui';
2
3
  declare const _default: import("vue").ComponentOptions<import("vue").default, import("@vue/composition-api").ShallowUnwrapRef<{
3
4
  isCreation: import("@vue/composition-api").ComputedRef<boolean>;
@@ -10,16 +11,16 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
10
11
  } | null;
11
12
  name: string;
12
13
  parent: {
13
- value: number;
14
+ value: Nullable<number>;
14
15
  label: string;
15
16
  disabled?: boolean | undefined;
16
- } | null;
17
+ };
17
18
  urlAlias: string;
18
- pageTitle: import("@tager/admin-services").Nullable<string>;
19
- pageDescription: import("@tager/admin-services").Nullable<string>;
20
- pageKeywords: import("@tager/admin-services").Nullable<string>;
21
- openGraphTitle: import("@tager/admin-services").Nullable<string>;
22
- openGraphDescription: import("@tager/admin-services").Nullable<string>;
19
+ pageTitle: Nullable<string>;
20
+ pageDescription: Nullable<string>;
21
+ pageKeywords: Nullable<string>;
22
+ openGraphTitle: Nullable<string>;
23
+ openGraphDescription: Nullable<string>;
23
24
  openGraphImage: {
24
25
  id: string;
25
26
  file: {
@@ -41,9 +42,11 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
41
42
  categoryListUrl: "/blog/categories";
42
43
  submitForm: (event: TagerFormSubmitEvent) => void;
43
44
  isSubmitting: import("@vue/composition-api").Ref<boolean>;
44
- moduleConfig: import("@vue/composition-api").Ref<import("@tager/admin-services").Nullable<import("../../../typings/model").ModuleConfig>>;
45
- categoryOptionList: import("@vue/composition-api").ComputedRef<OptionType<number>[]>;
46
- imageScenario: import("@vue/composition-api").ComputedRef<import("@tager/admin-services").Nullable<string>>;
45
+ moduleConfig: import("@vue/composition-api").Ref<Nullable<import("../../../typings/model").ModuleConfig>>;
46
+ parentCategoryOptionList: import("@vue/composition-api").ComputedRef<OptionType<Nullable<number>>[]>;
47
+ handleNameChange: (value: string) => void;
48
+ handleAliasChange: () => void;
49
+ imageScenario: import("@vue/composition-api").ComputedRef<Nullable<string>>;
47
50
  handleSeoFieldGroupChange: ({ title, description, keywords, image, }: SeoChangeEvent) => void;
48
51
  tabList: import("@vue/composition-api").ComputedRef<TabType[]>;
49
52
  selectedTabId: import("@vue/composition-api").Ref<string>;
@@ -64,16 +67,16 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
64
67
  } | null;
65
68
  name: string;
66
69
  parent: {
67
- value: number;
70
+ value: Nullable<number>;
68
71
  label: string;
69
72
  disabled?: boolean | undefined;
70
- } | null;
73
+ };
71
74
  urlAlias: string;
72
- pageTitle: import("@tager/admin-services").Nullable<string>;
73
- pageDescription: import("@tager/admin-services").Nullable<string>;
74
- pageKeywords: import("@tager/admin-services").Nullable<string>;
75
- openGraphTitle: import("@tager/admin-services").Nullable<string>;
76
- openGraphDescription: import("@tager/admin-services").Nullable<string>;
75
+ pageTitle: Nullable<string>;
76
+ pageDescription: Nullable<string>;
77
+ pageKeywords: Nullable<string>;
78
+ openGraphTitle: Nullable<string>;
79
+ openGraphDescription: Nullable<string>;
77
80
  openGraphImage: {
78
81
  id: string;
79
82
  file: {
@@ -95,9 +98,11 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
95
98
  categoryListUrl: "/blog/categories";
96
99
  submitForm: (event: TagerFormSubmitEvent) => void;
97
100
  isSubmitting: import("@vue/composition-api").Ref<boolean>;
98
- moduleConfig: import("@vue/composition-api").Ref<import("@tager/admin-services").Nullable<import("../../../typings/model").ModuleConfig>>;
99
- categoryOptionList: import("@vue/composition-api").ComputedRef<OptionType<number>[]>;
100
- imageScenario: import("@vue/composition-api").ComputedRef<import("@tager/admin-services").Nullable<string>>;
101
+ moduleConfig: import("@vue/composition-api").Ref<Nullable<import("../../../typings/model").ModuleConfig>>;
102
+ parentCategoryOptionList: import("@vue/composition-api").ComputedRef<OptionType<Nullable<number>>[]>;
103
+ handleNameChange: (value: string) => void;
104
+ handleAliasChange: () => void;
105
+ imageScenario: import("@vue/composition-api").ComputedRef<Nullable<string>>;
101
106
  handleSeoFieldGroupChange: ({ title, description, keywords, image, }: SeoChangeEvent) => void;
102
107
  tabList: import("@vue/composition-api").ComputedRef<TabType[]>;
103
108
  selectedTabId: import("@vue/composition-api").Ref<string>;
@@ -3,5 +3,5 @@ import { Nullable } from '@tager/admin-services';
3
3
  import { ColumnDefinition } from '@tager/admin-ui';
4
4
  import { Category, Language, ModuleConfig } from '../../../typings/model';
5
5
  export declare function convertCategoryList(categoryList: Category[], languages: Language[]): Category[];
6
- export declare function getCategoryTableColumnDefs(moduleConfig: Nullable<ModuleConfig>, t: TFunction, canViewAdministrators: boolean): ColumnDefinition<Category>[];
6
+ export declare function getCategoryTableColumnDefs(moduleConfig: Nullable<ModuleConfig>, t: TFunction): ColumnDefinition<Category>[];
7
7
  export declare function getLinkToPostsByCategory(categoryId: number): string;
@@ -22,7 +22,6 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
22
22
  languageOptionList: import("@vue/composition-api").ComputedRef<import("@tager/admin-ui").OptionType<string>[]>;
23
23
  tags: import("@vue/composition-api").ComputedRef<import("@tager/admin-ui").FilterTagType[]>;
24
24
  tagRemovalHandler: (event: import("@tager/admin-ui").FilterTagType) => void;
25
- canViewAdministrators: import("@vue/composition-api").ComputedRef<boolean>;
26
25
  }> & {
27
26
  [key: string]: unknown;
28
27
  }, {}, {}, unknown, {
@@ -50,7 +49,6 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
50
49
  languageOptionList: import("@vue/composition-api").ComputedRef<import("@tager/admin-ui").OptionType<string>[]>;
51
50
  tags: import("@vue/composition-api").ComputedRef<import("@tager/admin-ui").FilterTagType[]>;
52
51
  tagRemovalHandler: (event: import("@tager/admin-ui").FilterTagType) => void;
53
- canViewAdministrators: import("@vue/composition-api").ComputedRef<boolean>;
54
52
  }>, {
55
53
  [x: string]: any;
56
54
  }, {}, {}, {
@@ -3,4 +3,4 @@ import { Nullable } from '@tager/admin-services';
3
3
  import { ColumnDefinition } from '@tager/admin-ui';
4
4
  import { Category, ModuleConfig, Language, PostShort } from '../../../typings/model';
5
5
  export declare function convertPostList(postList: PostShort[], selectedCategory: Nullable<Category>, languages: Language[]): PostShort[];
6
- export declare function getPostTableColumnDefs(moduleConfig: Nullable<ModuleConfig>, t: TFunction, canViewAdministrators: boolean): ColumnDefinition<PostShort>[];
6
+ export declare function getPostTableColumnDefs(moduleConfig: Nullable<ModuleConfig>, t: TFunction): ColumnDefinition<PostShort>[];
@@ -25,7 +25,6 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
25
25
  toDateFilter: import("@vue/composition-api").Ref<string>;
26
26
  tags: import("@vue/composition-api").ComputedRef<import("@tager/admin-ui").FilterTagType[]>;
27
27
  tagRemovalHandler: (event: import("@tager/admin-ui").FilterTagType) => void;
28
- canViewAdministrators: import("@vue/composition-api").ComputedRef<boolean>;
29
28
  handleResourceClone: (entityId: string | number) => void;
30
29
  isBusy: (postId: number) => boolean;
31
30
  }> & {
@@ -58,7 +57,6 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
58
57
  toDateFilter: import("@vue/composition-api").Ref<string>;
59
58
  tags: import("@vue/composition-api").ComputedRef<import("@tager/admin-ui").FilterTagType[]>;
60
59
  tagRemovalHandler: (event: import("@tager/admin-ui").FilterTagType) => void;
61
- canViewAdministrators: import("@vue/composition-api").ComputedRef<boolean>;
62
60
  handleResourceClone: (entityId: string | number) => void;
63
61
  isBusy: (postId: number) => boolean;
64
62
  }>, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tager/admin-blog",
3
- "version": "0.3.31",
3
+ "version": "0.3.36",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.umd.js",
6
6
  "module": "dist/index.esm.js",
@@ -21,8 +21,7 @@
21
21
  "dependencies": {
22
22
  "lodash.isequal": "^4.5.0",
23
23
  "lodash.pick": "^4.4.0",
24
- "path-to-regexp": "^6.1.0",
25
- "vuex": "^3.6.2"
24
+ "path-to-regexp": "^6.1.0"
26
25
  },
27
26
  "devDependencies": {
28
27
  "@rollup/plugin-commonjs": "^15.0.0",
@@ -40,7 +39,6 @@
40
39
  "@vue/cli-plugin-eslint": "~4.5.6",
41
40
  "@vue/cli-plugin-router": "~4.5.6",
42
41
  "@vue/cli-plugin-typescript": "~4.5.6",
43
- "@vue/cli-plugin-vuex": "^4.5.14",
44
42
  "@vue/cli-service": "~4.5.6",
45
43
  "@vue/composition-api": "^1.0.0-beta.14",
46
44
  "@vue/eslint-config-prettier": "^6.0.0",
package/src/dev.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import Vue, { CreateElement } from 'vue';
2
2
  import VueCompositionApi, { createApp } from '@vue/composition-api';
3
- import Vuex from 'vuex';
4
3
 
5
4
  import { configStore, i18n } from '@tager/admin-services';
6
5
  import { AdminUiPlugin } from '@tager/admin-ui';
@@ -9,7 +8,6 @@ import { AdminLayoutPlugin } from '@tager/admin-layout';
9
8
  import '@tager/admin-ui/dist/admin-ui.css';
10
9
 
11
10
  import router from './router';
12
- import store from './store';
13
11
  import config from './config/config.json';
14
12
  import App from './views/App.vue';
15
13
  import EN from './locales/en';
@@ -26,11 +24,9 @@ i18n.init({ debug: false }).then(() => {
26
24
  const app = createApp({
27
25
  router,
28
26
  render: (h: CreateElement) => h(App),
29
- store,
30
27
  });
31
28
 
32
29
  app.use(i18n.getPlugin());
33
- app.use(Vuex);
34
30
  app.use(AdminUiPlugin);
35
31
  app.use(AdminLayoutPlugin);
36
32
 
@@ -2,6 +2,3 @@ export { useFetchPosts } from './useFetchPosts';
2
2
  export { useFetchCategory } from './useFetchCategory';
3
3
  export { useFetchCategories } from './useFetchCategories';
4
4
  export { useFetchModuleConfig } from './useFetchModuleConfig';
5
- export { useStore } from './useStore';
6
- export { useUserProfile } from './useUserProfile';
7
- export { useUserPermission } from './useUserPermission';
package/src/locales/en.ts CHANGED
@@ -74,6 +74,7 @@ const EN = {
74
74
  },
75
75
 
76
76
  parentCategory: 'Parent category',
77
+ noParent: 'No parent',
77
78
  };
78
79
 
79
80
  export default EN;
package/src/locales/ru.ts CHANGED
@@ -76,6 +76,7 @@ const RU: typeof EN = {
76
76
  },
77
77
 
78
78
  parentCategory: 'Родительская категория',
79
+ noParent: 'Нет родительской',
79
80
  };
80
81
 
81
82
  export default RU;
@@ -6,14 +6,9 @@ import {
6
6
  ModuleConfig,
7
7
  PostShort,
8
8
  PostFull,
9
- UserModel,
10
9
  CategoryPayload,
11
10
  } from '../typings/model';
12
11
 
13
- export function getUserProfile(): Promise<ResponseBody<UserModel>> {
14
- return request.get({ path: '/admin/self' });
15
- }
16
-
17
12
  /** Blog Posts */
18
13
 
19
14
  export function getPosts(params?: {
@@ -24,7 +19,7 @@ export function getPosts(params?: {
24
19
  return request.get({ path: '/admin/blog/posts', params });
25
20
  }
26
21
 
27
- export function getCountPosts(): Promise<ResponseBody<{ count: number }>> {
22
+ export function getBlogPostCount(): Promise<ResponseBody<{ count: number }>> {
28
23
  return request.get({ path: '/admin/blog/posts/count' });
29
24
  }
30
25
 
@@ -10,25 +10,6 @@ import {
10
10
  SingleFileInputValueType,
11
11
  } from '@tager/admin-ui';
12
12
 
13
- import { Scope } from '../constants/scopes';
14
-
15
- import { Values } from './common';
16
-
17
- export type ScopeType = Values<typeof Scope>;
18
-
19
- export interface RoleModel {
20
- readonly id: number;
21
- readonly name: string;
22
- readonly scopes: Array<ScopeType>;
23
- }
24
-
25
- export interface UserModel {
26
- readonly id: number;
27
- readonly name: string;
28
- readonly email: string;
29
- readonly roles: Array<RoleModel>;
30
- }
31
-
32
13
  export interface SeoInfo {
33
14
  readonly pageTitle: Nullable<string>;
34
15
  readonly pageDescription: Nullable<string>;
@@ -47,7 +28,7 @@ export interface Category extends SeoInfo {
47
28
  readonly urlTemplate: string;
48
29
  readonly urlAlias: string;
49
30
  readonly postsCount: string;
50
- readonly parent: Nullable<{ id: number; name: string }>;
31
+ readonly parent: Nullable<{ id: Nullable<number>; name: string }>;
51
32
  readonly depth: number;
52
33
  }
53
34
 
@@ -115,7 +96,7 @@ export interface ModuleConfig {
115
96
  export interface CategoryFormValues {
116
97
  language: Nullable<OptionType>;
117
98
  name: string;
118
- parent: Nullable<OptionType<number>>;
99
+ parent: OptionType<Nullable<number>>;
119
100
  urlAlias: string;
120
101
 
121
102
  pageTitle: Nullable<string>;
@@ -1,13 +1,3 @@
1
- import { USER_MODULE_NAMESPACE } from '../store/user';
2
-
3
- export function namespace(namespace: string, name: string): string {
4
- return `${namespace}/${name}`;
5
- }
6
-
7
- export function userNamespace(name: string): string {
8
- return namespace(USER_MODULE_NAMESPACE, name);
9
- }
10
-
11
1
  export function generateNumberArray(length: number): Array<number> {
12
2
  return Array.from({ length }, (_, index) => index);
13
3
  }
package/src/views/App.vue CHANGED
@@ -5,23 +5,15 @@
5
5
  </template>
6
6
 
7
7
  <script lang="ts">
8
- import { defineComponent, onMounted, SetupContext } from '@vue/composition-api';
8
+ import { defineComponent, SetupContext } from '@vue/composition-api';
9
9
 
10
- import { userNamespace } from '../utils/common';
11
- import { useStore } from '../hooks';
12
- import { USER_ACTION_TYPES } from '../store/user';
13
10
  import { getBlogMenuItem } from '../constants/menu';
14
11
 
15
12
  export default defineComponent({
16
13
  name: 'App',
17
14
  setup(props, context: SetupContext) {
18
- const store = useStore(context);
19
15
  const blogMenuItem = getBlogMenuItem({ t: context.root.$t });
20
16
 
21
- onMounted(() => {
22
- store.dispatch(userNamespace(USER_ACTION_TYPES.FETCH_USER_PROFILE));
23
- });
24
-
25
17
  return {
26
18
  sidebarMenuList: [blogMenuItem],
27
19
  };
@@ -1,3 +1,5 @@
1
+ import { TFunction } from 'i18next';
2
+
1
3
  import { createId, Nullable } from '@tager/admin-services';
2
4
  import { OptionType } from '@tager/admin-ui';
3
5
 
@@ -6,10 +8,12 @@ import {
6
8
  CategoryFormValues,
7
9
  CategoryPayload,
8
10
  } from '../../../typings/model';
11
+ import { getNameWithDepth } from '../../../utils/common';
9
12
 
10
13
  export function convertCategoryToFormValues(
11
14
  category: Nullable<Category>,
12
- languageOptionList: OptionType[]
15
+ languageOptionList: OptionType[],
16
+ t: TFunction
13
17
  ): CategoryFormValues {
14
18
  const currentLangOption = languageOptionList.find(
15
19
  ({ value }) => value === category?.language
@@ -19,7 +23,7 @@ export function convertCategoryToFormValues(
19
23
  return {
20
24
  language: currentLangOption ?? null,
21
25
  name: '',
22
- parent: null,
26
+ parent: { value: null, label: t('blog:noParent') },
23
27
  urlAlias: '',
24
28
 
25
29
  pageTitle: '',
@@ -36,7 +40,7 @@ export function convertCategoryToFormValues(
36
40
  name: category.name,
37
41
  parent: category.parent
38
42
  ? { value: category.parent.id, label: category.parent.name }
39
- : null,
43
+ : { value: null, label: t('blog:noParent') },
40
44
  urlAlias: category.urlAlias,
41
45
 
42
46
  pageTitle: category.pageTitle ?? '',
@@ -56,7 +60,7 @@ export function convertCategoryFormValuesToPayload(
56
60
  return {
57
61
  language: values.language?.value ?? null,
58
62
  name: values.name,
59
- parent: values.parent?.value ?? null,
63
+ parent: values.parent.value,
60
64
  urlAlias: values.urlAlias,
61
65
  isDefault: false,
62
66
 
@@ -65,3 +69,19 @@ export function convertCategoryFormValuesToPayload(
65
69
  openGraphImage: values.openGraphImage?.file.id ?? null,
66
70
  };
67
71
  }
72
+
73
+ export function convertCategoryListToOptions(
74
+ categoryList: Category[],
75
+ languageId: Nullable<string>,
76
+ t: TFunction
77
+ ): OptionType<Nullable<number>>[] {
78
+ return [
79
+ { value: null, label: t('blog:noParent') },
80
+ ...categoryList
81
+ .filter(({ language }) => (languageId ? language === languageId : true))
82
+ .map(({ id, name, depth }) => ({
83
+ value: id,
84
+ label: getNameWithDepth(name, depth),
85
+ })),
86
+ ];
87
+ }
@@ -22,13 +22,15 @@
22
22
  name="name"
23
23
  :label="$t('blog:name')"
24
24
  :error="errors.name"
25
+ @input="handleNameChange"
25
26
  />
26
27
 
27
28
  <form-field-select
29
+ v-if="!isLangSpecific || values.language"
28
30
  v-model="values.parent"
29
31
  name="parentCategory"
30
32
  :label="$t('blog:parentCategory')"
31
- :options="categoryOptionList"
33
+ :options="parentCategoryOptionList"
32
34
  :error="errors.parent"
33
35
  />
34
36
 
@@ -39,6 +41,7 @@
39
41
  :label="$t('blog:link')"
40
42
  :url-template="pagePath"
41
43
  :error="errors.urlAlias"
44
+ @change="handleAliasChange"
42
45
  />
43
46
  </template>
44
47
 
@@ -67,10 +70,11 @@
67
70
  />
68
71
 
69
72
  <form-field-select
73
+ v-if="!isLangSpecific || values.language"
70
74
  v-model="values.parent"
71
75
  name="parentCategory"
72
76
  :label="$t('blog:parentCategory')"
73
- :options="categoryOptionList"
77
+ :options="parentCategoryOptionList"
74
78
  :error="errors.parent"
75
79
  />
76
80
 
@@ -121,6 +125,8 @@ import { computed, defineComponent, ref, watch } from '@vue/composition-api';
121
125
  import {
122
126
  convertRequestErrorToMap,
123
127
  getWebsiteOrigin,
128
+ Nullable,
129
+ urlTranslit,
124
130
  } from '@tager/admin-services';
125
131
  import {
126
132
  OptionType,
@@ -131,7 +137,6 @@ import {
131
137
  useTranslation,
132
138
  } from '@tager/admin-ui';
133
139
 
134
- import { convertCategoryListToOptions } from '../../Posts/PostForm/PostForm.helpers';
135
140
  import {
136
141
  useFetchCategories,
137
142
  useFetchCategory,
@@ -146,6 +151,7 @@ import { createCategory, updateCategory } from '../../../services/requests';
146
151
 
147
152
  import {
148
153
  convertCategoryFormValuesToPayload,
154
+ convertCategoryListToOptions,
149
155
  convertCategoryToFormValues,
150
156
  } from './CategoryForm.helpers';
151
157
 
@@ -200,14 +206,15 @@ export default defineComponent({
200
206
  /** Form State */
201
207
  const isSubmitting = ref<boolean>(false);
202
208
  const values = ref<CategoryFormValues>(
203
- convertCategoryToFormValues(category.value, languageOptionList.value)
209
+ convertCategoryToFormValues(category.value, languageOptionList.value, t)
204
210
  );
205
211
  const errors = ref<Record<string, string>>({});
206
212
 
207
- watch(category, () => {
213
+ watch([category, languageOptionList], () => {
208
214
  values.value = convertCategoryToFormValues(
209
215
  category.value,
210
- languageOptionList.value
216
+ languageOptionList.value,
217
+ t
211
218
  );
212
219
  });
213
220
 
@@ -237,7 +244,8 @@ export default defineComponent({
237
244
  if (event.type === 'create_create-another') {
238
245
  values.value = convertCategoryToFormValues(
239
246
  null,
240
- languageOptionList.value
247
+ languageOptionList.value,
248
+ t
241
249
  );
242
250
  }
243
251
 
@@ -267,11 +275,13 @@ export default defineComponent({
267
275
 
268
276
  /** Category Options */
269
277
 
270
- const categoryOptionList = computed<OptionType<number>[]>(() =>
271
- convertCategoryListToOptions(
272
- categories.value,
273
- values.value.language?.value ?? null
274
- )
278
+ const parentCategoryOptionList = computed<OptionType<Nullable<number>>[]>(
279
+ () =>
280
+ convertCategoryListToOptions(
281
+ categories.value,
282
+ values.value.language?.value ?? null,
283
+ t
284
+ )
275
285
  );
276
286
 
277
287
  /** Misc */
@@ -310,6 +320,20 @@ export default defineComponent({
310
320
 
311
321
  const selectedTabId = ref<string>(tabList.value[0].id);
312
322
 
323
+ /** Url Alias **/
324
+
325
+ const urlAliasChanged = ref<boolean>(false);
326
+
327
+ const handleNameChange = (value: string) => {
328
+ if (isCreation.value && !urlAliasChanged.value) {
329
+ values.value.urlAlias = urlTranslit(value);
330
+ }
331
+ };
332
+
333
+ const handleAliasChange = () => {
334
+ urlAliasChanged.value = true;
335
+ };
336
+
313
337
  return {
314
338
  isCreation,
315
339
  isContentLoading: isContentLoading,
@@ -322,7 +346,9 @@ export default defineComponent({
322
346
  submitForm,
323
347
  isSubmitting,
324
348
  moduleConfig,
325
- categoryOptionList,
349
+ parentCategoryOptionList,
350
+ handleNameChange,
351
+ handleAliasChange,
326
352
 
327
353
  // SEO
328
354
  imageScenario,
@@ -32,8 +32,7 @@ export function convertCategoryList(
32
32
 
33
33
  export function getCategoryTableColumnDefs(
34
34
  moduleConfig: Nullable<ModuleConfig>,
35
- t: TFunction,
36
- canViewAdministrators: boolean
35
+ t: TFunction
37
36
  ): ColumnDefinition<Category>[] {
38
37
  const isLangSpecific = moduleConfig
39
38
  ? moduleConfig.languages.length > 0
@@ -77,16 +76,14 @@ export function getCategoryTableColumnDefs(
77
76
  field: 'linkToPosts',
78
77
  style: { whiteSpace: 'nowrap', width: '130px' },
79
78
  },
80
- canViewAdministrators
81
- ? {
82
- id: 5,
83
- name: t('blog:actions'),
84
- field: 'actions',
85
- style: { whiteSpace: 'nowrap', width: '170px' },
86
- headStyle: { whiteSpace: 'nowrap', width: '170px' },
87
- class: 'actions-cell',
88
- }
89
- : null,
79
+ {
80
+ id: 5,
81
+ name: t('blog:actions'),
82
+ field: 'actions',
83
+ style: { whiteSpace: 'nowrap', width: '170px' },
84
+ headStyle: { whiteSpace: 'nowrap', width: '170px' },
85
+ class: 'actions-cell',
86
+ },
90
87
  ];
91
88
 
92
89
  return COLUMN_DEFS.filter(notEmpty);