@tager/admin-blog 0.3.38 → 0.3.42
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/index.esm.js +426 -186
- package/dist/index.umd.js +424 -184
- package/dist/locales/en.d.ts +7 -1
- package/dist/services/requests.d.ts +2 -0
- package/dist/typings/model.d.ts +3 -0
- package/dist/views/Categories/CategoryForm/CategoryForm.vue.d.ts +2 -0
- package/dist/views/Posts/PostForm/PostForm.helpers.d.ts +6 -1
- package/dist/views/Posts/PostForm/PostForm.vue.d.ts +18 -2
- package/dist/views/Posts/PostList/PostList.vue.d.ts +20 -9
- package/dist/views/Posts/PostList/hooks/useAdvancedSearch.d.ts +3 -1
- package/package.json +3 -3
- package/src/locales/en.ts +9 -2
- package/src/locales/ru.ts +9 -2
- package/src/services/requests.ts +2 -0
- package/src/typings/model.ts +3 -0
- package/src/views/Categories/CategoryForm/CategoryForm.helpers.ts +3 -1
- package/src/views/Categories/CategoryForm/CategoryForm.vue +7 -0
- package/src/views/Posts/PostForm/PostForm.helpers.ts +34 -10
- package/src/views/Posts/PostForm/PostForm.vue +192 -131
- package/src/views/Posts/PostList/PostList.helpers.ts +24 -21
- package/src/views/Posts/PostList/PostList.vue +117 -67
- package/src/views/Posts/PostList/hooks/useAdvancedSearch.ts +35 -0
package/dist/locales/en.d.ts
CHANGED
|
@@ -31,7 +31,6 @@ declare const EN: {
|
|
|
31
31
|
actions: string;
|
|
32
32
|
updatePost: string;
|
|
33
33
|
title: string;
|
|
34
|
-
status: string;
|
|
35
34
|
link: string;
|
|
36
35
|
excerpt: string;
|
|
37
36
|
body: string;
|
|
@@ -73,8 +72,15 @@ declare const EN: {
|
|
|
73
72
|
};
|
|
74
73
|
parentCategory: string;
|
|
75
74
|
noParent: string;
|
|
75
|
+
status: string;
|
|
76
76
|
statusPublished: string;
|
|
77
77
|
statusDraft: string;
|
|
78
78
|
statusArchived: string;
|
|
79
|
+
scheduleArchive: string;
|
|
80
|
+
schedulePublish: string;
|
|
81
|
+
archiveAt: string;
|
|
82
|
+
publishAt: string;
|
|
83
|
+
archiveAtLabel: string;
|
|
84
|
+
publishAtLabel: string;
|
|
79
85
|
};
|
|
80
86
|
export default EN;
|
|
@@ -30,6 +30,8 @@ export interface PostCreationPayload {
|
|
|
30
30
|
relatedPosts: number[];
|
|
31
31
|
tags: string[];
|
|
32
32
|
additionalFields: FieldShortType<OutgoingValueUnion>[];
|
|
33
|
+
archiveAt: Nullable<string>;
|
|
34
|
+
publishAt: Nullable<string>;
|
|
33
35
|
}
|
|
34
36
|
export declare function createBlogPost(payload: PostCreationPayload): Promise<ResponseBody<PostFull>>;
|
|
35
37
|
export declare type PostUpdatePayload = PostCreationPayload & {
|
package/dist/typings/model.d.ts
CHANGED
|
@@ -53,6 +53,8 @@ export interface PostFull extends SeoInfo {
|
|
|
53
53
|
readonly relatedPosts: Pick<PostShort, 'id' | 'title'>[];
|
|
54
54
|
readonly tags: string[];
|
|
55
55
|
readonly additionalFields: FieldShortType<IncomingValueUnion>[];
|
|
56
|
+
readonly archiveAt: Nullable<string>;
|
|
57
|
+
readonly publishAt: Nullable<string>;
|
|
56
58
|
}
|
|
57
59
|
export interface Language {
|
|
58
60
|
readonly id: string;
|
|
@@ -84,6 +86,7 @@ export interface CategoryFormValues {
|
|
|
84
86
|
name: string;
|
|
85
87
|
parent: OptionType<Nullable<number>>;
|
|
86
88
|
urlAlias: string;
|
|
89
|
+
isDefault: boolean;
|
|
87
90
|
pageTitle: Nullable<string>;
|
|
88
91
|
pageDescription: Nullable<string>;
|
|
89
92
|
pageKeywords: Nullable<string>;
|
|
@@ -16,6 +16,7 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
|
|
|
16
16
|
disabled?: boolean | undefined;
|
|
17
17
|
};
|
|
18
18
|
urlAlias: string;
|
|
19
|
+
isDefault: boolean;
|
|
19
20
|
pageTitle: Nullable<string>;
|
|
20
21
|
pageDescription: Nullable<string>;
|
|
21
22
|
pageKeywords: Nullable<string>;
|
|
@@ -72,6 +73,7 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
|
|
|
72
73
|
disabled?: boolean | undefined;
|
|
73
74
|
};
|
|
74
75
|
urlAlias: string;
|
|
76
|
+
isDefault: boolean;
|
|
75
77
|
pageTitle: Nullable<string>;
|
|
76
78
|
pageDescription: Nullable<string>;
|
|
77
79
|
pageKeywords: Nullable<string>;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { TFunction } from 'i18next';
|
|
1
2
|
import { Nullable } from '@tager/admin-services';
|
|
2
3
|
import { OptionType, SingleFileInputValueType } from '@tager/admin-ui';
|
|
3
4
|
import { FieldConfigUnion, FieldUnion } from '@tager/admin-dynamic-field';
|
|
4
5
|
import { PostCreationPayload, PostUpdatePayload } from '../../../services/requests';
|
|
5
6
|
import { Category, PostFull } from '../../../typings/model';
|
|
7
|
+
export declare const getStatusOptions: (t: TFunction) => OptionType[];
|
|
6
8
|
export interface FormValues {
|
|
7
9
|
title: string;
|
|
8
10
|
excerpt: string;
|
|
@@ -20,8 +22,11 @@ export interface FormValues {
|
|
|
20
22
|
relatedPosts: OptionType<number>[];
|
|
21
23
|
tags: string;
|
|
22
24
|
additionalFields: FieldUnion[];
|
|
25
|
+
status: OptionType;
|
|
26
|
+
statusDateEnabled: boolean;
|
|
27
|
+
statusDate: Nullable<string>;
|
|
23
28
|
}
|
|
24
|
-
export declare function convertPostToFormValues(post: Nullable<PostFull>, languageOptionList: OptionType[], postOptionList: OptionType<number>[], additionalFieldList: FieldConfigUnion[]): FormValues;
|
|
29
|
+
export declare function convertPostToFormValues(post: Nullable<PostFull>, languageOptionList: OptionType[], postOptionList: OptionType<number>[], additionalFieldList: FieldConfigUnion[], statusOptions: OptionType[]): FormValues;
|
|
25
30
|
export declare function convertFormValuesToCreationPayload(values: FormValues): PostCreationPayload;
|
|
26
31
|
export declare function convertFormValuesToUpdatePayload(values: FormValues): PostUpdatePayload;
|
|
27
32
|
export declare function convertCategoryListToOptions(categoryList: Category[], languageId: Nullable<string>): OptionType<number>[];
|
|
@@ -4657,6 +4657,13 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
|
|
|
4657
4657
|
};
|
|
4658
4658
|
value: null;
|
|
4659
4659
|
})[];
|
|
4660
|
+
status: {
|
|
4661
|
+
value: string;
|
|
4662
|
+
label: string;
|
|
4663
|
+
disabled?: boolean | undefined;
|
|
4664
|
+
};
|
|
4665
|
+
statusDateEnabled: boolean;
|
|
4666
|
+
statusDate: Nullable<string>;
|
|
4660
4667
|
}>;
|
|
4661
4668
|
errors: import("@vue/composition-api").Ref<{
|
|
4662
4669
|
[x: string]: string;
|
|
@@ -4679,11 +4686,12 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
|
|
|
4679
4686
|
href: string;
|
|
4680
4687
|
target?: string | undefined;
|
|
4681
4688
|
}[]>;
|
|
4682
|
-
handleSeoFieldGroupChange: ({ title, description, image
|
|
4689
|
+
handleSeoFieldGroupChange: ({ title, description, image }: SeoChangeEvent) => void;
|
|
4683
4690
|
handleTitleChange: (value: string) => void;
|
|
4684
4691
|
handleAliasChange: () => void;
|
|
4685
4692
|
urlAliasTemplate: import("@vue/composition-api").ComputedRef<string>;
|
|
4686
4693
|
handleCategoriesChange: (selectedOptions: OptionType<number>[]) => void;
|
|
4694
|
+
statusOptions: import("@vue/composition-api").ComputedRef<OptionType<string>[]>;
|
|
4687
4695
|
}> & {
|
|
4688
4696
|
[key: string]: unknown;
|
|
4689
4697
|
}, {}, {}, unknown, {
|
|
@@ -9347,6 +9355,13 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
|
|
|
9347
9355
|
};
|
|
9348
9356
|
value: null;
|
|
9349
9357
|
})[];
|
|
9358
|
+
status: {
|
|
9359
|
+
value: string;
|
|
9360
|
+
label: string;
|
|
9361
|
+
disabled?: boolean | undefined;
|
|
9362
|
+
};
|
|
9363
|
+
statusDateEnabled: boolean;
|
|
9364
|
+
statusDate: Nullable<string>;
|
|
9350
9365
|
}>;
|
|
9351
9366
|
errors: import("@vue/composition-api").Ref<{
|
|
9352
9367
|
[x: string]: string;
|
|
@@ -9369,11 +9384,12 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
|
|
|
9369
9384
|
href: string;
|
|
9370
9385
|
target?: string | undefined;
|
|
9371
9386
|
}[]>;
|
|
9372
|
-
handleSeoFieldGroupChange: ({ title, description, image
|
|
9387
|
+
handleSeoFieldGroupChange: ({ title, description, image }: SeoChangeEvent) => void;
|
|
9373
9388
|
handleTitleChange: (value: string) => void;
|
|
9374
9389
|
handleAliasChange: () => void;
|
|
9375
9390
|
urlAliasTemplate: import("@vue/composition-api").ComputedRef<string>;
|
|
9376
9391
|
handleCategoriesChange: (selectedOptions: OptionType<number>[]) => void;
|
|
9392
|
+
statusOptions: import("@vue/composition-api").ComputedRef<OptionType<string>[]>;
|
|
9377
9393
|
}>, {
|
|
9378
9394
|
[x: string]: any;
|
|
9379
9395
|
}, {}, {}, {
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { ColumnDefinition } from '@tager/admin-ui';
|
|
1
|
+
import { ColumnDefinition, OptionType, formatDateTime } from '@tager/admin-ui';
|
|
2
2
|
import { getBlogPostFormUrl } from '../../../constants/paths';
|
|
3
3
|
import { Category, PostShort } from '../../../typings/model';
|
|
4
|
+
import { getStatuses } from './PostList.helpers';
|
|
4
5
|
declare const _default: import("vue").ComponentOptions<import("vue").default, import("@vue/composition-api").ShallowUnwrapRef<{
|
|
6
|
+
t: import("i18next").TFunction;
|
|
7
|
+
formatDateTime: typeof formatDateTime;
|
|
5
8
|
columnDefs: import("@vue/composition-api").ComputedRef<ColumnDefinition<PostShort>[]>;
|
|
6
9
|
rowData: import("@vue/composition-api").ComputedRef<PostShort[]>;
|
|
7
10
|
handleResourceDelete: (entityId: string | number) => void;
|
|
@@ -16,15 +19,18 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
|
|
|
16
19
|
pageNumber: import("@vue/composition-api").Ref<number>;
|
|
17
20
|
pageCount: import("@vue/composition-api").ComputedRef<number>;
|
|
18
21
|
pageSize: import("@vue/composition-api").Ref<number>;
|
|
19
|
-
categoryFilter: import("@vue/composition-api").Ref<
|
|
20
|
-
categoryOptionList: import("@vue/composition-api").ComputedRef<
|
|
22
|
+
categoryFilter: import("@vue/composition-api").Ref<OptionType<string>[]>;
|
|
23
|
+
categoryOptionList: import("@vue/composition-api").ComputedRef<OptionType<string>[]>;
|
|
21
24
|
isLangSpecific: import("@vue/composition-api").ComputedRef<boolean>;
|
|
22
|
-
languageFilter: import("@vue/composition-api").Ref<
|
|
23
|
-
languageOptionList: import("@vue/composition-api").ComputedRef<
|
|
25
|
+
languageFilter: import("@vue/composition-api").Ref<OptionType<string>[]>;
|
|
26
|
+
languageOptionList: import("@vue/composition-api").ComputedRef<OptionType<string>[]>;
|
|
24
27
|
fromDateFilter: import("@vue/composition-api").Ref<string>;
|
|
25
28
|
toDateFilter: import("@vue/composition-api").Ref<string>;
|
|
29
|
+
statusFilter: import("@vue/composition-api").Ref<OptionType<string>[]>;
|
|
30
|
+
statusOptionList: import("@vue/composition-api").ComputedRef<OptionType<string>[]>;
|
|
26
31
|
tags: import("@vue/composition-api").ComputedRef<import("@tager/admin-ui").FilterTagType[]>;
|
|
27
32
|
tagRemovalHandler: (event: import("@tager/admin-ui").FilterTagType) => void;
|
|
33
|
+
getStatuses: typeof getStatuses;
|
|
28
34
|
handleResourceClone: (entityId: string | number) => void;
|
|
29
35
|
isBusy: (postId: number) => boolean;
|
|
30
36
|
}> & {
|
|
@@ -34,6 +40,8 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
|
|
|
34
40
|
}> & import("vue").VueConstructor<import("vue").default> & (new (...args: any[]) => import("@vue/composition-api").ComponentRenderProxy<{
|
|
35
41
|
[x: string]: any;
|
|
36
42
|
}, import("@vue/composition-api").ShallowUnwrapRef<{
|
|
43
|
+
t: import("i18next").TFunction;
|
|
44
|
+
formatDateTime: typeof formatDateTime;
|
|
37
45
|
columnDefs: import("@vue/composition-api").ComputedRef<ColumnDefinition<PostShort>[]>;
|
|
38
46
|
rowData: import("@vue/composition-api").ComputedRef<PostShort[]>;
|
|
39
47
|
handleResourceDelete: (entityId: string | number) => void;
|
|
@@ -48,15 +56,18 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
|
|
|
48
56
|
pageNumber: import("@vue/composition-api").Ref<number>;
|
|
49
57
|
pageCount: import("@vue/composition-api").ComputedRef<number>;
|
|
50
58
|
pageSize: import("@vue/composition-api").Ref<number>;
|
|
51
|
-
categoryFilter: import("@vue/composition-api").Ref<
|
|
52
|
-
categoryOptionList: import("@vue/composition-api").ComputedRef<
|
|
59
|
+
categoryFilter: import("@vue/composition-api").Ref<OptionType<string>[]>;
|
|
60
|
+
categoryOptionList: import("@vue/composition-api").ComputedRef<OptionType<string>[]>;
|
|
53
61
|
isLangSpecific: import("@vue/composition-api").ComputedRef<boolean>;
|
|
54
|
-
languageFilter: import("@vue/composition-api").Ref<
|
|
55
|
-
languageOptionList: import("@vue/composition-api").ComputedRef<
|
|
62
|
+
languageFilter: import("@vue/composition-api").Ref<OptionType<string>[]>;
|
|
63
|
+
languageOptionList: import("@vue/composition-api").ComputedRef<OptionType<string>[]>;
|
|
56
64
|
fromDateFilter: import("@vue/composition-api").Ref<string>;
|
|
57
65
|
toDateFilter: import("@vue/composition-api").Ref<string>;
|
|
66
|
+
statusFilter: import("@vue/composition-api").Ref<OptionType<string>[]>;
|
|
67
|
+
statusOptionList: import("@vue/composition-api").ComputedRef<OptionType<string>[]>;
|
|
58
68
|
tags: import("@vue/composition-api").ComputedRef<import("@tager/admin-ui").FilterTagType[]>;
|
|
59
69
|
tagRemovalHandler: (event: import("@tager/admin-ui").FilterTagType) => void;
|
|
70
|
+
getStatuses: typeof getStatuses;
|
|
60
71
|
handleResourceClone: (entityId: string | number) => void;
|
|
61
72
|
isBusy: (postId: number) => boolean;
|
|
62
73
|
}>, {
|
|
@@ -5,6 +5,7 @@ interface Params {
|
|
|
5
5
|
context: SetupContext;
|
|
6
6
|
categoryList: ComputedRef<Category[]>;
|
|
7
7
|
languageList: ComputedRef<Language[]>;
|
|
8
|
+
statusOptionList: ComputedRef<OptionType[]>;
|
|
8
9
|
}
|
|
9
10
|
interface State {
|
|
10
11
|
categoryFilter: Ref<OptionType[]>;
|
|
@@ -13,10 +14,11 @@ interface State {
|
|
|
13
14
|
languageOptionList: ComputedRef<OptionType[]>;
|
|
14
15
|
fromDateFilter: Ref<string>;
|
|
15
16
|
toDateFilter: Ref<string>;
|
|
17
|
+
statusFilter: Ref<OptionType[]>;
|
|
16
18
|
filterParams: ComputedRef<Record<string, string | string[]>>;
|
|
17
19
|
tags: ComputedRef<FilterTagType[]>;
|
|
18
20
|
tagRemovalHandler(event: FilterTagType): void;
|
|
19
21
|
}
|
|
20
22
|
export declare const dateFormat: (date: string) => string;
|
|
21
|
-
export declare function useAdvancedSearch({ context, categoryList, languageList, }: Params): State;
|
|
23
|
+
export declare function useAdvancedSearch({ context, categoryList, languageList, statusOptionList, }: Params): State;
|
|
22
24
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tager/admin-blog",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.42",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.umd.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"@rollup/plugin-commonjs": "^15.0.0",
|
|
28
28
|
"@rollup/plugin-node-resolve": "^9.0.0",
|
|
29
29
|
"@tager/admin-dynamic-field": "^0.1.18",
|
|
30
|
-
"@tager/admin-layout": "^0.5.
|
|
30
|
+
"@tager/admin-layout": "^0.5.4",
|
|
31
31
|
"@tager/admin-services": "^0.2.26",
|
|
32
|
-
"@tager/admin-ui": "^0.8.
|
|
32
|
+
"@tager/admin-ui": "^0.8.96",
|
|
33
33
|
"@types/lodash.isequal": "^4.5.5",
|
|
34
34
|
"@types/lodash.pick": "^4.4.6",
|
|
35
35
|
"@types/node": "12.x",
|
package/src/locales/en.ts
CHANGED
|
@@ -31,7 +31,6 @@ const EN = {
|
|
|
31
31
|
actions: 'Actions',
|
|
32
32
|
updatePost: 'Update post',
|
|
33
33
|
title: 'Title',
|
|
34
|
-
status: 'Status',
|
|
35
34
|
link: 'Link',
|
|
36
35
|
excerpt: 'Excerpt',
|
|
37
36
|
body: 'Body',
|
|
@@ -77,9 +76,17 @@ const EN = {
|
|
|
77
76
|
parentCategory: 'Parent category',
|
|
78
77
|
noParent: 'No parent',
|
|
79
78
|
|
|
79
|
+
status: 'Status',
|
|
80
80
|
statusPublished: 'Published',
|
|
81
81
|
statusDraft: 'Draft',
|
|
82
|
-
statusArchived: 'Archived'
|
|
82
|
+
statusArchived: 'Archived',
|
|
83
|
+
|
|
84
|
+
scheduleArchive: 'Schedule archive',
|
|
85
|
+
schedulePublish: 'Schedule publish',
|
|
86
|
+
archiveAt: 'Archive at',
|
|
87
|
+
publishAt: 'Publish at',
|
|
88
|
+
archiveAtLabel: 'Archive at',
|
|
89
|
+
publishAtLabel: 'Publish at',
|
|
83
90
|
};
|
|
84
91
|
|
|
85
92
|
export default EN;
|
package/src/locales/ru.ts
CHANGED
|
@@ -34,7 +34,6 @@ const RU: typeof EN = {
|
|
|
34
34
|
updatePost: 'Обновить пост',
|
|
35
35
|
title: 'Заголовок',
|
|
36
36
|
link: 'Ссылка',
|
|
37
|
-
status: 'Статус',
|
|
38
37
|
excerpt: 'Краткое описание',
|
|
39
38
|
defaultCategory: 'Категория по-умолчанию',
|
|
40
39
|
body: 'Содержание',
|
|
@@ -79,9 +78,17 @@ const RU: typeof EN = {
|
|
|
79
78
|
parentCategory: 'Родительская категория',
|
|
80
79
|
noParent: 'Нет родительской',
|
|
81
80
|
|
|
81
|
+
status: 'Статус',
|
|
82
82
|
statusPublished: 'Опубликован',
|
|
83
83
|
statusDraft: 'Черновик',
|
|
84
|
-
statusArchived: '
|
|
84
|
+
statusArchived: 'В архиве',
|
|
85
|
+
|
|
86
|
+
scheduleArchive: 'Запланировать перенос в архив',
|
|
87
|
+
schedulePublish: 'Запланировать публикацию',
|
|
88
|
+
archiveAt: 'Перенести в архив в',
|
|
89
|
+
publishAt: 'Опубликовать в',
|
|
90
|
+
archiveAtLabel: 'Перенос в архив',
|
|
91
|
+
publishAtLabel: 'Публикация',
|
|
85
92
|
};
|
|
86
93
|
|
|
87
94
|
export default RU;
|
package/src/services/requests.ts
CHANGED
package/src/typings/model.ts
CHANGED
|
@@ -62,6 +62,8 @@ export interface PostFull extends SeoInfo {
|
|
|
62
62
|
readonly relatedPosts: Pick<PostShort, 'id' | 'title'>[];
|
|
63
63
|
readonly tags: string[];
|
|
64
64
|
readonly additionalFields: FieldShortType<IncomingValueUnion>[];
|
|
65
|
+
readonly archiveAt: Nullable<string>;
|
|
66
|
+
readonly publishAt: Nullable<string>;
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
export interface Language {
|
|
@@ -98,6 +100,7 @@ export interface CategoryFormValues {
|
|
|
98
100
|
name: string;
|
|
99
101
|
parent: OptionType<Nullable<number>>;
|
|
100
102
|
urlAlias: string;
|
|
103
|
+
isDefault: boolean;
|
|
101
104
|
|
|
102
105
|
pageTitle: Nullable<string>;
|
|
103
106
|
pageDescription: Nullable<string>;
|
|
@@ -25,6 +25,7 @@ export function convertCategoryToFormValues(
|
|
|
25
25
|
name: '',
|
|
26
26
|
parent: { value: null, label: t('blog:noParent') },
|
|
27
27
|
urlAlias: '',
|
|
28
|
+
isDefault: false,
|
|
28
29
|
|
|
29
30
|
pageTitle: '',
|
|
30
31
|
pageDescription: '',
|
|
@@ -37,6 +38,7 @@ export function convertCategoryToFormValues(
|
|
|
37
38
|
|
|
38
39
|
return {
|
|
39
40
|
language: currentLangOption ?? null,
|
|
41
|
+
isDefault: category.isDefault,
|
|
40
42
|
name: category.name,
|
|
41
43
|
parent: category.parent
|
|
42
44
|
? { value: category.parent.id, label: category.parent.name }
|
|
@@ -62,7 +64,7 @@ export function convertCategoryFormValuesToPayload(
|
|
|
62
64
|
name: values.name,
|
|
63
65
|
parent: values.parent.value,
|
|
64
66
|
urlAlias: values.urlAlias,
|
|
65
|
-
isDefault:
|
|
67
|
+
isDefault: values.isDefault,
|
|
66
68
|
|
|
67
69
|
pageTitle: values.pageTitle,
|
|
68
70
|
pageDescription: values.pageDescription,
|
|
@@ -1,18 +1,26 @@
|
|
|
1
|
+
import { TFunction } from 'i18next';
|
|
2
|
+
|
|
1
3
|
import { createId, Nullable } from '@tager/admin-services';
|
|
2
4
|
import { OptionType, SingleFileInputValueType } from '@tager/admin-ui';
|
|
3
5
|
import {
|
|
4
6
|
FieldConfigUnion,
|
|
5
7
|
FieldUnion,
|
|
6
|
-
universalFieldUtils
|
|
8
|
+
universalFieldUtils
|
|
7
9
|
} from '@tager/admin-dynamic-field';
|
|
8
10
|
|
|
9
11
|
import {
|
|
10
12
|
PostCreationPayload,
|
|
11
|
-
PostUpdatePayload
|
|
13
|
+
PostUpdatePayload
|
|
12
14
|
} from '../../../services/requests';
|
|
13
15
|
import { getNameWithDepth } from '../../../utils/common';
|
|
14
16
|
import { Category, PostFull } from '../../../typings/model';
|
|
15
17
|
|
|
18
|
+
export const getStatusOptions = (t: TFunction): OptionType[] => [
|
|
19
|
+
{ label: t('blog:statusPublished'), value: 'PUBLISHED' },
|
|
20
|
+
{ label: t('blog:statusDraft'), value: 'DRAFT' },
|
|
21
|
+
{ label: t('blog:statusArchived'), value: 'ARCHIVED' }
|
|
22
|
+
];
|
|
23
|
+
|
|
16
24
|
export interface FormValues {
|
|
17
25
|
title: string;
|
|
18
26
|
excerpt: string;
|
|
@@ -30,13 +38,17 @@ export interface FormValues {
|
|
|
30
38
|
relatedPosts: OptionType<number>[];
|
|
31
39
|
tags: string;
|
|
32
40
|
additionalFields: FieldUnion[];
|
|
41
|
+
status: OptionType;
|
|
42
|
+
statusDateEnabled: boolean;
|
|
43
|
+
statusDate: Nullable<string>;
|
|
33
44
|
}
|
|
34
45
|
|
|
35
46
|
export function convertPostToFormValues(
|
|
36
47
|
post: Nullable<PostFull>,
|
|
37
48
|
languageOptionList: OptionType[],
|
|
38
49
|
postOptionList: OptionType<number>[],
|
|
39
|
-
additionalFieldList: FieldConfigUnion[]
|
|
50
|
+
additionalFieldList: FieldConfigUnion[],
|
|
51
|
+
statusOptions: OptionType[]
|
|
40
52
|
): FormValues {
|
|
41
53
|
if (!post) {
|
|
42
54
|
return {
|
|
@@ -58,6 +70,9 @@ export function convertPostToFormValues(
|
|
|
58
70
|
additionalFields: additionalFieldList.map((fieldConfig) =>
|
|
59
71
|
universalFieldUtils.createFormField(fieldConfig, null)
|
|
60
72
|
),
|
|
73
|
+
status: statusOptions[0],
|
|
74
|
+
statusDateEnabled: false,
|
|
75
|
+
statusDate: null
|
|
61
76
|
};
|
|
62
77
|
}
|
|
63
78
|
|
|
@@ -69,6 +84,10 @@ export function convertPostToFormValues(
|
|
|
69
84
|
post.relatedPosts.some((relatedPost) => relatedPost.id === option.value)
|
|
70
85
|
);
|
|
71
86
|
|
|
87
|
+
const foundStatus =
|
|
88
|
+
statusOptions.find(({ value }) => value === post.status) ??
|
|
89
|
+
statusOptions[0];
|
|
90
|
+
|
|
72
91
|
return {
|
|
73
92
|
title: post.title,
|
|
74
93
|
excerpt: post.excerpt,
|
|
@@ -89,20 +108,23 @@ export function convertPostToFormValues(
|
|
|
89
108
|
urlAlias: post.urlAlias,
|
|
90
109
|
categories: post.categories.map((category) => ({
|
|
91
110
|
value: category.id,
|
|
92
|
-
label: category.name
|
|
111
|
+
label: category.name
|
|
93
112
|
})),
|
|
94
113
|
language: currentLangOption ?? null,
|
|
95
114
|
relatedPosts: selectedPostOptionList,
|
|
96
115
|
tags: post.tags.join(','),
|
|
97
|
-
additionalFields: additionalFieldList.map((fieldConfig
|
|
116
|
+
additionalFields: additionalFieldList.map((fieldConfig) => {
|
|
98
117
|
const postAdditionalField = post.additionalFields.find(
|
|
99
|
-
(
|
|
118
|
+
({ name }) => name === fieldConfig.name
|
|
100
119
|
);
|
|
101
120
|
return universalFieldUtils.createFormField(
|
|
102
121
|
fieldConfig,
|
|
103
122
|
postAdditionalField?.value
|
|
104
123
|
);
|
|
105
124
|
}),
|
|
125
|
+
status: foundStatus,
|
|
126
|
+
statusDateEnabled: post.status === 'PUBLISHED' ? !!post.archiveAt : (post.status === 'DRAFT' ? !!post.publishAt : false),
|
|
127
|
+
statusDate: post.status === 'PUBLISHED' && post.archiveAt ? post.archiveAt.substr(0, 10) : (post.status === 'DRAFT' && post.publishAt ? post.publishAt.substr(0, 10) : null)
|
|
106
128
|
};
|
|
107
129
|
}
|
|
108
130
|
|
|
@@ -121,7 +143,6 @@ export function convertFormValuesToCreationPayload(
|
|
|
121
143
|
pageTitle: values.pageTitle,
|
|
122
144
|
pageDescription: values.pageDescription,
|
|
123
145
|
openGraphImage: values.openGraphImage?.file.id ?? null,
|
|
124
|
-
status: 'PUBLISHED',
|
|
125
146
|
categories: values.categories.map((option) => option.value),
|
|
126
147
|
language: values.language?.value ?? null,
|
|
127
148
|
relatedPosts: values.relatedPosts.map(
|
|
@@ -130,8 +151,11 @@ export function convertFormValuesToCreationPayload(
|
|
|
130
151
|
tags: values.tags.split(',').filter((tag) => tag.trim().length > 0),
|
|
131
152
|
additionalFields: values.additionalFields.map((field) => ({
|
|
132
153
|
name: field.config.name,
|
|
133
|
-
value: universalFieldUtils.getOutgoingValue(field)
|
|
154
|
+
value: universalFieldUtils.getOutgoingValue(field)
|
|
134
155
|
})),
|
|
156
|
+
status: values.status.value,
|
|
157
|
+
archiveAt: values.status.value === 'PUBLISHED' && values.statusDateEnabled && values.statusDate ? values.statusDate : null,
|
|
158
|
+
publishAt: values.status.value === 'DRAFT' && values.statusDateEnabled && values.statusDate ? values.statusDate : null
|
|
135
159
|
};
|
|
136
160
|
}
|
|
137
161
|
|
|
@@ -140,7 +164,7 @@ export function convertFormValuesToUpdatePayload(
|
|
|
140
164
|
): PostUpdatePayload {
|
|
141
165
|
return {
|
|
142
166
|
...convertFormValuesToCreationPayload(values),
|
|
143
|
-
urlAlias: values.urlAlias
|
|
167
|
+
urlAlias: values.urlAlias
|
|
144
168
|
};
|
|
145
169
|
}
|
|
146
170
|
|
|
@@ -152,6 +176,6 @@ export function convertCategoryListToOptions(
|
|
|
152
176
|
.filter(({ language }) => (languageId ? language === languageId : true))
|
|
153
177
|
.map(({ id, name, depth }) => ({
|
|
154
178
|
value: id,
|
|
155
|
-
label: getNameWithDepth(name, depth)
|
|
179
|
+
label: getNameWithDepth(name, depth)
|
|
156
180
|
}));
|
|
157
181
|
}
|