@tager/admin-blog 0.3.37 → 0.3.41
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 +221 -131
- package/dist/index.umd.js +220 -130
- package/dist/locales/en.d.ts +1 -1
- package/dist/typings/model.d.ts +2 -1
- package/dist/views/Categories/CategoryForm/CategoryForm.vue.d.ts +2 -0
- package/dist/views/Posts/PostForm/PostForm.helpers.d.ts +4 -1
- package/dist/views/Posts/PostForm/PostForm.vue.d.ts +12 -0
- package/dist/views/Posts/PostList/PostList.vue.d.ts +13 -9
- package/dist/views/Posts/PostList/hooks/useAdvancedSearch.d.ts +3 -1
- package/package.json +1 -1
- package/src/locales/en.ts +2 -2
- package/src/locales/ru.ts +2 -2
- package/src/typings/model.ts +2 -1
- 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 +21 -5
- package/src/views/Posts/PostForm/PostForm.vue +25 -4
- package/src/views/Posts/PostList/PostList.helpers.ts +21 -17
- package/src/views/Posts/PostList/PostList.vue +17 -0
- package/src/views/Posts/PostList/hooks/useAdvancedSearch.ts +35 -0
package/dist/index.umd.js
CHANGED
|
@@ -37,7 +37,6 @@
|
|
|
37
37
|
actions: 'Actions',
|
|
38
38
|
updatePost: 'Update post',
|
|
39
39
|
title: 'Title',
|
|
40
|
-
status: 'Status',
|
|
41
40
|
link: 'Link',
|
|
42
41
|
excerpt: 'Excerpt',
|
|
43
42
|
body: 'Body',
|
|
@@ -79,9 +78,10 @@
|
|
|
79
78
|
},
|
|
80
79
|
parentCategory: 'Parent category',
|
|
81
80
|
noParent: 'No parent',
|
|
81
|
+
status: 'Status',
|
|
82
82
|
statusPublished: 'Published',
|
|
83
83
|
statusDraft: 'Draft',
|
|
84
|
-
statusArchived: 'Archived'
|
|
84
|
+
statusArchived: 'Archived',
|
|
85
85
|
};
|
|
86
86
|
|
|
87
87
|
const RU = {
|
|
@@ -118,7 +118,6 @@
|
|
|
118
118
|
updatePost: 'Обновить пост',
|
|
119
119
|
title: 'Заголовок',
|
|
120
120
|
link: 'Ссылка',
|
|
121
|
-
status: 'Статус',
|
|
122
121
|
excerpt: 'Краткое описание',
|
|
123
122
|
defaultCategory: 'Категория по-умолчанию',
|
|
124
123
|
body: 'Содержание',
|
|
@@ -159,9 +158,10 @@
|
|
|
159
158
|
},
|
|
160
159
|
parentCategory: 'Родительская категория',
|
|
161
160
|
noParent: 'Нет родительской',
|
|
161
|
+
status: 'Статус',
|
|
162
162
|
statusPublished: 'Опубликован',
|
|
163
163
|
statusDraft: 'Черновик',
|
|
164
|
-
statusArchived: '
|
|
164
|
+
statusArchived: 'В архиве',
|
|
165
165
|
};
|
|
166
166
|
|
|
167
167
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
@@ -2671,6 +2671,117 @@
|
|
|
2671
2671
|
});
|
|
2672
2672
|
}
|
|
2673
2673
|
|
|
2674
|
+
function generateNumberArray(length) {
|
|
2675
|
+
return Array.from({ length }, (_, index) => index);
|
|
2676
|
+
}
|
|
2677
|
+
function getNameWithDepth(name, depth) {
|
|
2678
|
+
return (generateNumberArray(depth)
|
|
2679
|
+
.map(() => '—')
|
|
2680
|
+
.join(' ') +
|
|
2681
|
+
' ' +
|
|
2682
|
+
name);
|
|
2683
|
+
}
|
|
2684
|
+
|
|
2685
|
+
const getStatusOptions = (t) => [
|
|
2686
|
+
{ label: t('blog:statusPublished'), value: 'PUBLISHED' },
|
|
2687
|
+
{ label: t('blog:statusDraft'), value: 'DRAFT' },
|
|
2688
|
+
{ label: t('blog:statusArchived'), value: 'ARCHIVED' },
|
|
2689
|
+
];
|
|
2690
|
+
function convertPostToFormValues(post, languageOptionList, postOptionList, additionalFieldList, statusOptions) {
|
|
2691
|
+
var _a, _b, _c;
|
|
2692
|
+
if (!post) {
|
|
2693
|
+
return {
|
|
2694
|
+
title: '',
|
|
2695
|
+
excerpt: '',
|
|
2696
|
+
body: '',
|
|
2697
|
+
datetime: '',
|
|
2698
|
+
coverImage: null,
|
|
2699
|
+
image: null,
|
|
2700
|
+
imageMobile: null,
|
|
2701
|
+
pageTitle: '',
|
|
2702
|
+
pageDescription: '',
|
|
2703
|
+
openGraphImage: null,
|
|
2704
|
+
urlAlias: '',
|
|
2705
|
+
categories: [],
|
|
2706
|
+
language: null,
|
|
2707
|
+
relatedPosts: [],
|
|
2708
|
+
tags: '',
|
|
2709
|
+
additionalFields: additionalFieldList.map((fieldConfig) => adminDynamicField.universalFieldUtils.createFormField(fieldConfig, null)),
|
|
2710
|
+
status: statusOptions[0],
|
|
2711
|
+
};
|
|
2712
|
+
}
|
|
2713
|
+
const currentLangOption = languageOptionList.find((option) => option.value === post.language);
|
|
2714
|
+
const selectedPostOptionList = postOptionList.filter((option) => post.relatedPosts.some((relatedPost) => relatedPost.id === option.value));
|
|
2715
|
+
const foundStatus = (_a = statusOptions.find(({ value }) => value === post.status)) !== null && _a !== void 0 ? _a : statusOptions[0];
|
|
2716
|
+
return {
|
|
2717
|
+
title: post.title,
|
|
2718
|
+
excerpt: post.excerpt,
|
|
2719
|
+
body: post.body,
|
|
2720
|
+
datetime: post.datetime ? post.datetime.substr(0, 10) : '',
|
|
2721
|
+
coverImage: post.coverImage
|
|
2722
|
+
? { id: adminServices.createId(), file: post.coverImage }
|
|
2723
|
+
: null,
|
|
2724
|
+
image: post.image ? { id: adminServices.createId(), file: post.image } : null,
|
|
2725
|
+
imageMobile: post.imageMobile
|
|
2726
|
+
? { id: adminServices.createId(), file: post.imageMobile }
|
|
2727
|
+
: null,
|
|
2728
|
+
pageTitle: (_b = post.pageTitle) !== null && _b !== void 0 ? _b : '',
|
|
2729
|
+
pageDescription: (_c = post.pageDescription) !== null && _c !== void 0 ? _c : '',
|
|
2730
|
+
openGraphImage: post.openGraphImage
|
|
2731
|
+
? { id: adminServices.createId(), file: post.openGraphImage }
|
|
2732
|
+
: null,
|
|
2733
|
+
urlAlias: post.urlAlias,
|
|
2734
|
+
categories: post.categories.map((category) => ({
|
|
2735
|
+
value: category.id,
|
|
2736
|
+
label: category.name,
|
|
2737
|
+
})),
|
|
2738
|
+
language: currentLangOption !== null && currentLangOption !== void 0 ? currentLangOption : null,
|
|
2739
|
+
relatedPosts: selectedPostOptionList,
|
|
2740
|
+
tags: post.tags.join(','),
|
|
2741
|
+
additionalFields: additionalFieldList.map((fieldConfig) => {
|
|
2742
|
+
const postAdditionalField = post.additionalFields.find(({ name }) => name === fieldConfig.name);
|
|
2743
|
+
return adminDynamicField.universalFieldUtils.createFormField(fieldConfig, postAdditionalField === null || postAdditionalField === void 0 ? void 0 : postAdditionalField.value);
|
|
2744
|
+
}),
|
|
2745
|
+
status: foundStatus,
|
|
2746
|
+
};
|
|
2747
|
+
}
|
|
2748
|
+
function convertFormValuesToCreationPayload(values) {
|
|
2749
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2750
|
+
return {
|
|
2751
|
+
title: values.title,
|
|
2752
|
+
excerpt: values.excerpt,
|
|
2753
|
+
urlAlias: values.urlAlias,
|
|
2754
|
+
body: values.body,
|
|
2755
|
+
datetime: values.datetime,
|
|
2756
|
+
coverImage: (_b = (_a = values.coverImage) === null || _a === void 0 ? void 0 : _a.file.id) !== null && _b !== void 0 ? _b : null,
|
|
2757
|
+
image: (_d = (_c = values.image) === null || _c === void 0 ? void 0 : _c.file.id) !== null && _d !== void 0 ? _d : null,
|
|
2758
|
+
imageMobile: (_f = (_e = values.imageMobile) === null || _e === void 0 ? void 0 : _e.file.id) !== null && _f !== void 0 ? _f : null,
|
|
2759
|
+
pageTitle: values.pageTitle,
|
|
2760
|
+
pageDescription: values.pageDescription,
|
|
2761
|
+
openGraphImage: (_h = (_g = values.openGraphImage) === null || _g === void 0 ? void 0 : _g.file.id) !== null && _h !== void 0 ? _h : null,
|
|
2762
|
+
categories: values.categories.map((option) => option.value),
|
|
2763
|
+
language: (_k = (_j = values.language) === null || _j === void 0 ? void 0 : _j.value) !== null && _k !== void 0 ? _k : null,
|
|
2764
|
+
relatedPosts: values.relatedPosts.map((relatedPostOption) => relatedPostOption.value),
|
|
2765
|
+
tags: values.tags.split(',').filter((tag) => tag.trim().length > 0),
|
|
2766
|
+
additionalFields: values.additionalFields.map((field) => ({
|
|
2767
|
+
name: field.config.name,
|
|
2768
|
+
value: adminDynamicField.universalFieldUtils.getOutgoingValue(field),
|
|
2769
|
+
})),
|
|
2770
|
+
status: values.status.value,
|
|
2771
|
+
};
|
|
2772
|
+
}
|
|
2773
|
+
function convertFormValuesToUpdatePayload(values) {
|
|
2774
|
+
return Object.assign(Object.assign({}, convertFormValuesToCreationPayload(values)), { urlAlias: values.urlAlias });
|
|
2775
|
+
}
|
|
2776
|
+
function convertCategoryListToOptions(categoryList, languageId) {
|
|
2777
|
+
return categoryList
|
|
2778
|
+
.filter(({ language }) => (languageId ? language === languageId : true))
|
|
2779
|
+
.map(({ id, name, depth }) => ({
|
|
2780
|
+
value: id,
|
|
2781
|
+
label: getNameWithDepth(name, depth),
|
|
2782
|
+
}));
|
|
2783
|
+
}
|
|
2784
|
+
|
|
2674
2785
|
function convertPostList(postList, selectedCategory, languages) {
|
|
2675
2786
|
return postList
|
|
2676
2787
|
.filter((post) => selectedCategory
|
|
@@ -2701,7 +2812,7 @@
|
|
|
2701
2812
|
name: 'ID',
|
|
2702
2813
|
field: 'id',
|
|
2703
2814
|
style: { width: '50px', textAlign: 'center' },
|
|
2704
|
-
headStyle: { width: '50px', textAlign: 'center' }
|
|
2815
|
+
headStyle: { width: '50px', textAlign: 'center' },
|
|
2705
2816
|
},
|
|
2706
2817
|
{
|
|
2707
2818
|
id: 2,
|
|
@@ -2709,9 +2820,7 @@
|
|
|
2709
2820
|
field: 'status',
|
|
2710
2821
|
style: { width: '120px' },
|
|
2711
2822
|
headStyle: { width: '120px' },
|
|
2712
|
-
format: ({ row }) =>
|
|
2713
|
-
return getStatuses(t)[row.status];
|
|
2714
|
-
}
|
|
2823
|
+
format: ({ row }) => getStatuses(t)[row.status],
|
|
2715
2824
|
},
|
|
2716
2825
|
{
|
|
2717
2826
|
id: 2,
|
|
@@ -2721,16 +2830,16 @@
|
|
|
2721
2830
|
format: ({ row }) => ({
|
|
2722
2831
|
adminLink: {
|
|
2723
2832
|
text: row.title,
|
|
2724
|
-
url: getBlogPostFormUrl({ postId: row.id })
|
|
2833
|
+
url: getBlogPostFormUrl({ postId: row.id }),
|
|
2725
2834
|
},
|
|
2726
2835
|
websiteLink: {
|
|
2727
2836
|
text: row.url,
|
|
2728
2837
|
url: [
|
|
2729
2838
|
process.env.VUE_APP_WEBSITE_URL || window.location.origin,
|
|
2730
|
-
row.url
|
|
2731
|
-
].join('')
|
|
2732
|
-
}
|
|
2733
|
-
})
|
|
2839
|
+
row.url,
|
|
2840
|
+
].join(''),
|
|
2841
|
+
},
|
|
2842
|
+
}),
|
|
2734
2843
|
},
|
|
2735
2844
|
{
|
|
2736
2845
|
id: 3,
|
|
@@ -2738,49 +2847,45 @@
|
|
|
2738
2847
|
field: 'image',
|
|
2739
2848
|
type: 'image',
|
|
2740
2849
|
style: { width: '250px' },
|
|
2741
|
-
headStyle: { width: '250px' }
|
|
2850
|
+
headStyle: { width: '250px' },
|
|
2742
2851
|
},
|
|
2743
2852
|
isLangSpecific
|
|
2744
2853
|
? { id: 4, name: t('blog:language'), field: 'language' }
|
|
2745
2854
|
: null,
|
|
2746
|
-
{
|
|
2855
|
+
{
|
|
2856
|
+
id: 5,
|
|
2857
|
+
name: t('blog:date'),
|
|
2858
|
+
field: 'datetime',
|
|
2859
|
+
type: 'datetime',
|
|
2860
|
+
options: { ignoreStartOfDayTime: true },
|
|
2861
|
+
},
|
|
2747
2862
|
{
|
|
2748
2863
|
id: 6,
|
|
2749
2864
|
name: t('blog:categories'),
|
|
2750
2865
|
field: 'categories',
|
|
2751
|
-
format: ({ row }) => row.categories.map((category) => category.name).join(', ')
|
|
2866
|
+
format: ({ row }) => row.categories.map((category) => category.name).join(', '),
|
|
2752
2867
|
},
|
|
2753
2868
|
{
|
|
2754
2869
|
id: 7,
|
|
2755
2870
|
name: t('blog:actions'),
|
|
2756
2871
|
field: 'actions',
|
|
2757
2872
|
style: { whiteSpace: 'nowrap', width: '120px' },
|
|
2758
|
-
headStyle: { whiteSpace: 'nowrap', width: '120px' }
|
|
2759
|
-
}
|
|
2873
|
+
headStyle: { whiteSpace: 'nowrap', width: '120px' },
|
|
2874
|
+
},
|
|
2760
2875
|
];
|
|
2761
2876
|
return COLUMN_DEFS.filter(adminServices.notEmpty);
|
|
2762
2877
|
}
|
|
2763
2878
|
|
|
2764
|
-
function generateNumberArray(length) {
|
|
2765
|
-
return Array.from({ length }, (_, index) => index);
|
|
2766
|
-
}
|
|
2767
|
-
function getNameWithDepth(name, depth) {
|
|
2768
|
-
return (generateNumberArray(depth)
|
|
2769
|
-
.map(() => '—')
|
|
2770
|
-
.join(' ') +
|
|
2771
|
-
' ' +
|
|
2772
|
-
name);
|
|
2773
|
-
}
|
|
2774
|
-
|
|
2775
2879
|
var FilterTypes;
|
|
2776
2880
|
(function (FilterTypes) {
|
|
2777
2881
|
FilterTypes["CATEGORY"] = "category";
|
|
2778
2882
|
FilterTypes["LANGUAGE"] = "language";
|
|
2779
2883
|
FilterTypes["FROM_DATE"] = "from-date";
|
|
2780
2884
|
FilterTypes["TO_DATE"] = "to-date";
|
|
2885
|
+
FilterTypes["STATUS"] = "status";
|
|
2781
2886
|
})(FilterTypes || (FilterTypes = {}));
|
|
2782
2887
|
const dateFormat = (date) => date.split('-').reverse().join('.');
|
|
2783
|
-
function useAdvancedSearch({ context, categoryList, languageList, }) {
|
|
2888
|
+
function useAdvancedSearch({ context, categoryList, languageList, statusOptionList, }) {
|
|
2784
2889
|
/** Category **/
|
|
2785
2890
|
const categoryOptionList = compositionApi.computed(() => categoryList.value.map(({ id, name, depth }) => ({
|
|
2786
2891
|
value: String(id),
|
|
@@ -2838,11 +2943,21 @@
|
|
|
2838
2943
|
title: context.root.$t('blog:dateOfPublication'),
|
|
2839
2944
|
};
|
|
2840
2945
|
});
|
|
2946
|
+
/** Status **/
|
|
2947
|
+
const initialStatusFilter = compositionApi.computed(() => {
|
|
2948
|
+
const queryValue = adminUi.getFilterParamAsStringArray(context.root.$route.query, FilterTypes.STATUS);
|
|
2949
|
+
return statusOptionList.value.filter(({ value }) => queryValue.some((selected) => selected === value));
|
|
2950
|
+
});
|
|
2951
|
+
const statusFilter = compositionApi.ref(initialStatusFilter.value);
|
|
2952
|
+
compositionApi.watch(initialStatusFilter, () => {
|
|
2953
|
+
statusFilter.value = initialStatusFilter.value;
|
|
2954
|
+
});
|
|
2841
2955
|
/** Params **/
|
|
2842
2956
|
const filterParams = compositionApi.computed(() => {
|
|
2843
2957
|
const filters = {
|
|
2844
2958
|
[FilterTypes.CATEGORY]: categoryFilter.value.map(({ value }) => value),
|
|
2845
2959
|
[FilterTypes.LANGUAGE]: languageFilter.value.map(({ value }) => value),
|
|
2960
|
+
[FilterTypes.STATUS]: statusFilter.value.map(({ value }) => value),
|
|
2846
2961
|
};
|
|
2847
2962
|
if (fromDateFilter.value) {
|
|
2848
2963
|
filters[FilterTypes.FROM_DATE] = fromDateFilter.value;
|
|
@@ -2864,6 +2979,9 @@
|
|
|
2864
2979
|
fromDateFilter.value = '';
|
|
2865
2980
|
toDateFilter.value = '';
|
|
2866
2981
|
}
|
|
2982
|
+
if (event.name === FilterTypes.STATUS) {
|
|
2983
|
+
statusFilter.value = statusFilter.value.filter(({ value }) => value !== event.value);
|
|
2984
|
+
}
|
|
2867
2985
|
}
|
|
2868
2986
|
/** Tags **/
|
|
2869
2987
|
const tags = compositionApi.computed(() => [
|
|
@@ -2880,6 +2998,12 @@
|
|
|
2880
2998
|
title: context.root.$t('blog:language'),
|
|
2881
2999
|
})),
|
|
2882
3000
|
date.value,
|
|
3001
|
+
...statusFilter.value.map(({ value, label }) => ({
|
|
3002
|
+
value,
|
|
3003
|
+
label,
|
|
3004
|
+
name: FilterTypes.STATUS,
|
|
3005
|
+
title: context.root.$t('blog:status'),
|
|
3006
|
+
})),
|
|
2883
3007
|
].filter(adminServices.isNotNullish));
|
|
2884
3008
|
/** Helpers **/
|
|
2885
3009
|
const selectedCategoryOptionList = compositionApi.computed(() => {
|
|
@@ -2899,6 +3023,7 @@
|
|
|
2899
3023
|
languageOptionList,
|
|
2900
3024
|
fromDateFilter,
|
|
2901
3025
|
toDateFilter,
|
|
3026
|
+
statusFilter,
|
|
2902
3027
|
tagRemovalHandler,
|
|
2903
3028
|
tags: tags,
|
|
2904
3029
|
filterParams,
|
|
@@ -2914,6 +3039,7 @@
|
|
|
2914
3039
|
return Array.isArray(context.root.$route.query.category)
|
|
2915
3040
|
? (_a = context.root.$route.query.category[0]) !== null && _a !== void 0 ? _a : '' : context.root.$route.query.category;
|
|
2916
3041
|
});
|
|
3042
|
+
const statusOptionList = compositionApi.computed(() => getStatusOptions(t));
|
|
2917
3043
|
/** Fetch module config **/
|
|
2918
3044
|
const { data: moduleConfig, loading: isModuleConfigLoading, } = useFetchModuleConfig({ context });
|
|
2919
3045
|
const languageList = compositionApi.computed(() => { var _a, _b; return (_b = (_a = moduleConfig.value) === null || _a === void 0 ? void 0 : _a.languages) !== null && _b !== void 0 ? _b : []; });
|
|
@@ -2930,10 +3056,11 @@
|
|
|
2930
3056
|
: context.root.$t('blog:posts');
|
|
2931
3057
|
});
|
|
2932
3058
|
/** Advanced search **/
|
|
2933
|
-
const { categoryFilter, categoryOptionList, languageFilter, languageOptionList, fromDateFilter, toDateFilter, filterParams, tags, tagRemovalHandler, } = useAdvancedSearch({
|
|
3059
|
+
const { categoryFilter, categoryOptionList, languageFilter, languageOptionList, fromDateFilter, toDateFilter, filterParams, tags, tagRemovalHandler, statusFilter, } = useAdvancedSearch({
|
|
2934
3060
|
context,
|
|
2935
3061
|
categoryList,
|
|
2936
3062
|
languageList,
|
|
3063
|
+
statusOptionList,
|
|
2937
3064
|
});
|
|
2938
3065
|
const isLangSpecific = compositionApi.computed(() => languageOptionList.value.length > 1);
|
|
2939
3066
|
/** Fetch Post list **/
|
|
@@ -3002,6 +3129,8 @@
|
|
|
3002
3129
|
languageOptionList,
|
|
3003
3130
|
fromDateFilter,
|
|
3004
3131
|
toDateFilter,
|
|
3132
|
+
statusFilter,
|
|
3133
|
+
statusOptionList,
|
|
3005
3134
|
tags,
|
|
3006
3135
|
tagRemovalHandler,
|
|
3007
3136
|
// Clone
|
|
@@ -3278,6 +3407,23 @@
|
|
|
3278
3407
|
1
|
|
3279
3408
|
),
|
|
3280
3409
|
]),
|
|
3410
|
+
_vm._v(" "),
|
|
3411
|
+
_c("form-field-multi-select", {
|
|
3412
|
+
staticClass: "filter",
|
|
3413
|
+
attrs: {
|
|
3414
|
+
options: _vm.statusOptionList,
|
|
3415
|
+
name: "statusFilter",
|
|
3416
|
+
searchable: true,
|
|
3417
|
+
label: _vm.$t("blog:status"),
|
|
3418
|
+
},
|
|
3419
|
+
model: {
|
|
3420
|
+
value: _vm.statusFilter,
|
|
3421
|
+
callback: function ($$v) {
|
|
3422
|
+
_vm.statusFilter = $$v;
|
|
3423
|
+
},
|
|
3424
|
+
expression: "statusFilter",
|
|
3425
|
+
},
|
|
3426
|
+
}),
|
|
3281
3427
|
],
|
|
3282
3428
|
1
|
|
3283
3429
|
),
|
|
@@ -3359,11 +3505,11 @@
|
|
|
3359
3505
|
/* style */
|
|
3360
3506
|
const __vue_inject_styles__ = function (inject) {
|
|
3361
3507
|
if (!inject) return
|
|
3362
|
-
inject("data-v-6697ac14_0", { source: ".filters[data-v-6697ac14] {\n display: flex;\n margin: 0 -10px;\n}\n.filters[data-v-6697ac14]:not(:first-child) {\n margin-top: 10px;\n}\n.filters .filter[data-v-6697ac14] {\n padding: 10px 10px 0;\n width: 50%;\n margin: 0;\n}\n.date-label[data-v-6697ac14] {\n margin-bottom: 0.5rem;\n}\n.date-content[data-v-6697ac14] {\n display: grid;\n grid-template-columns: repeat(2, 1fr);\n column-gap: 10px;\n}\n\n/*# sourceMappingURL=PostList.vue.map */", map: {"version":3,"sources":["/home/runner/work/tager-admin-blog/tager-admin-blog/src/views/Posts/PostList/PostList.vue","PostList.vue"],"names":[],"mappings":"AAqUA;EACA,aAAA;EACA,eAAA;ACpUA;ADsUA;EACA,gBAAA;ACpUA;ADuUA;EACA,oBAAA;EACA,UAAA;EACA,SAAA;ACrUA;ADyUA;EACA,qBAAA;ACtUA;ADyUA;EACA,aAAA;EACA,qCAAA;EACA,gBAAA;ACtUA;;AAEA,uCAAuC","file":"PostList.vue","sourcesContent":["<template>\n <page\n :title=\"pageTitle\"\n :header-buttons=\"[\n {\n text: $t('blog:newPost'),\n href: getBlogPostFormUrl({ postId: 'create' }),\n },\n ]\"\n >\n <template v-slot:content>\n <data-table\n :column-defs=\"columnDefs\"\n :row-data=\"rowData\"\n :loading=\"isRowDataLoading\"\n :error-message=\"errorMessage\"\n :search-query=\"searchQuery\"\n :pagination=\"{\n pageNumber,\n pageCount,\n pageSize,\n disabled: isRowDataLoading,\n }\"\n data-table=\"blog-post\"\n @change=\"handleChange\"\n >\n <template v-slot:filters>\n <advanced-search :tags=\"tags\" @click:tag=\"tagRemovalHandler\">\n <div class=\"filters\">\n <form-field-multi-select\n v-model=\"categoryFilter\"\n :options=\"categoryOptionList\"\n name=\"categoryFilter\"\n :searchable=\"true\"\n :label=\"$t('blog:category')\"\n class=\"filter\"\n />\n\n <form-field-multi-select\n v-if=\"isLangSpecific\"\n v-model=\"languageFilter\"\n :options=\"languageOptionList\"\n name=\"languageFilter\"\n :searchable=\"true\"\n :label=\"$t('blog:language')\"\n class=\"filter\"\n />\n\n <div class=\"filter\">\n <div class=\"date-label\">\n {{ $t('blog:dateOfPublication') }}\n </div>\n\n <div class=\"date-content\">\n <form-field\n v-model=\"fromDateFilter\"\n :label=\"$t('blog:From')\"\n name=\"fromDateFilter\"\n type=\"date\"\n :max=\"toDateFilter\"\n />\n\n <form-field\n v-model=\"toDateFilter\"\n :label=\"$t('blog:To')\"\n name=\"toDateFilter\"\n type=\"date\"\n :min=\"fromDateFilter\"\n />\n </div>\n </div>\n </div>\n </advanced-search>\n </template>\n\n <template v-slot:cell(actions)=\"{ row }\">\n <base-button\n variant=\"icon\"\n :title=\"$t('blog:edit')\"\n :disabled=\"isBusy(row.id)\"\n :href=\"getBlogPostFormUrl({ postId: row.id })\"\n >\n <svg-icon name=\"edit\" />\n </base-button>\n\n <base-button\n variant=\"icon\"\n :title=\"$t('blog:clone')\"\n :disabled=\"isBusy(row.id)\"\n @click=\"handleResourceClone(row.id)\"\n >\n <svg-icon name=\"contentCopy\" />\n </base-button>\n\n <base-button\n variant=\"icon\"\n :title=\"$t('blog:remove')\"\n :disabled=\"isBusy(row.id)\"\n @click=\"handleResourceDelete(row.id)\"\n >\n <svg-icon name=\"delete\" />\n </base-button>\n </template>\n </data-table>\n </template>\n </page>\n</template>\n\n<script lang=\"ts\">\nimport { computed, defineComponent, watch } from '@vue/composition-api';\nimport isEqual from 'lodash.isequal';\nimport pick from 'lodash.pick';\n\nimport {\n ColumnDefinition,\n useDataTable,\n useTranslation,\n} from '@tager/admin-ui';\nimport {\n Nullable,\n useResourceClone,\n useResourceDelete,\n} from '@tager/admin-services';\n\nimport { useFetchModuleConfig, useFetchCategories } from '../../../hooks';\nimport {\n clonePost,\n deleteBlogPost,\n getPosts,\n} from '../../../services/requests';\nimport { getBlogPostFormUrl } from '../../../constants/paths';\nimport {\n Category,\n Language,\n PostFull,\n PostShort,\n} from '../../../typings/model';\n\nimport { convertPostList, getPostTableColumnDefs } from './PostList.helpers';\nimport { useAdvancedSearch } from './hooks';\n\nexport default defineComponent({\n name: 'Posts',\n setup(props, context) {\n const { t } = useTranslation(context);\n\n const categoryId = computed<string>(() => {\n return Array.isArray(context.root.$route.query.category)\n ? context.root.$route.query.category[0] ?? ''\n : context.root.$route.query.category;\n });\n\n /** Fetch module config **/\n\n const {\n data: moduleConfig,\n loading: isModuleConfigLoading,\n } = useFetchModuleConfig({ context });\n\n const languageList = computed<Language[]>(\n () => moduleConfig.value?.languages ?? []\n );\n\n /** Fetch category list **/\n\n const {\n data: categoryList,\n loading: isCategoryListLoading,\n } = useFetchCategories({ context });\n\n const selectedCategory = computed<Nullable<Category>>(() =>\n categoryId.value\n ? categoryList.value.find(\n ({ id }) => String(id) === String(categoryId.value)\n ) ?? null\n : null\n );\n\n const pageTitle = computed<string>(() => {\n return selectedCategory.value\n ? `${context.root.$t('blog:postsByCategory')} \"${\n selectedCategory.value.name\n }\"`\n : context.root.$t('blog:posts');\n });\n\n /** Advanced search **/\n\n const {\n categoryFilter,\n categoryOptionList,\n languageFilter,\n languageOptionList,\n fromDateFilter,\n toDateFilter,\n filterParams,\n tags,\n tagRemovalHandler,\n } = useAdvancedSearch({\n context,\n categoryList,\n languageList,\n });\n\n const isLangSpecific = computed<boolean>(\n () => languageOptionList.value.length > 1\n );\n\n /** Fetch Post list **/\n\n const {\n fetchEntityList: fetchPostList,\n isLoading: isPostLoading,\n rowData: postList,\n errorMessage,\n searchQuery,\n handleChange,\n pageNumber,\n pageCount,\n pageSize,\n } = useDataTable<PostShort>({\n fetchEntityList: (params) =>\n getPosts({\n query: params.searchQuery,\n pageNumber: params.pageNumber,\n pageSize: params.pageSize,\n ...filterParams.value,\n }),\n initialValue: [],\n context,\n resourceName: 'Blog post list',\n pageSize: 100,\n });\n\n watch(filterParams, () => {\n if (isModuleConfigLoading.value || isCategoryListLoading.value) {\n return;\n }\n\n const newQuery = {\n ...pick(context.root.$route.query, ['query', 'pageNumber']),\n ...filterParams.value,\n };\n\n if (!isEqual(context.root.$route.query, newQuery)) {\n context.root.$router.replace({ query: newQuery });\n fetchPostList();\n }\n });\n\n const displayedPostList = computed<PostShort[]>(() =>\n convertPostList(\n postList.value,\n selectedCategory.value,\n moduleConfig.value?.languages ?? []\n )\n );\n\n const isRowDataLoading = computed<boolean>(\n () =>\n isCategoryListLoading.value ||\n isPostLoading.value ||\n isModuleConfigLoading.value\n );\n\n const { isDeleting, handleResourceDelete } = useResourceDelete({\n deleteResource: deleteBlogPost,\n resourceName: 'Post',\n onSuccess: fetchPostList,\n context,\n });\n\n const { isCloning, handleResourceClone } = useResourceClone({\n cloneResource: clonePost,\n confirmMessage: t('blog:cloneConfirm'),\n successMessage: t('blog:cloneSuccess'),\n failureMessage: t('blog:cloneFailure'),\n onSuccessRedirectTo: (data: PostFull) => `/blog/posts/${data.id}`,\n context,\n });\n\n function isBusy(postId: number): boolean {\n return isDeleting(postId) || isCloning(postId) || isRowDataLoading.value;\n }\n\n const columnDefs = computed<ColumnDefinition<PostShort>[]>(() =>\n getPostTableColumnDefs(moduleConfig.value, context.root.$t)\n );\n\n return {\n columnDefs,\n rowData: displayedPostList,\n handleResourceDelete,\n isDeleting,\n categoryList,\n isRowDataLoading,\n errorMessage,\n getBlogPostFormUrl,\n pageTitle,\n searchQuery,\n handleChange,\n pageNumber,\n pageCount,\n pageSize,\n\n // Advanced search\n categoryFilter,\n categoryOptionList,\n isLangSpecific,\n languageFilter,\n languageOptionList,\n fromDateFilter,\n toDateFilter,\n tags,\n tagRemovalHandler,\n\n // Clone\n handleResourceClone,\n isBusy,\n };\n },\n});\n</script>\n\n<style scoped lang=\"scss\">\n.filters {\n display: flex;\n margin: 0 -10px;\n\n &:not(:first-child) {\n margin-top: 10px;\n }\n\n .filter {\n padding: 10px 10px 0;\n width: 50%;\n margin: 0;\n }\n}\n\n.date-label {\n margin-bottom: 0.5rem;\n}\n\n.date-content {\n display: grid;\n grid-template-columns: repeat(2, 1fr);\n column-gap: 10px;\n}\n</style>\n",".filters {\n display: flex;\n margin: 0 -10px;\n}\n.filters:not(:first-child) {\n margin-top: 10px;\n}\n.filters .filter {\n padding: 10px 10px 0;\n width: 50%;\n margin: 0;\n}\n\n.date-label {\n margin-bottom: 0.5rem;\n}\n\n.date-content {\n display: grid;\n grid-template-columns: repeat(2, 1fr);\n column-gap: 10px;\n}\n\n/*# sourceMappingURL=PostList.vue.map */"]}, media: undefined });
|
|
3508
|
+
inject("data-v-075b6310_0", { source: ".filters[data-v-075b6310] {\n display: flex;\n margin: 0 -10px;\n}\n.filters[data-v-075b6310]:not(:first-child) {\n margin-top: 10px;\n}\n.filters .filter[data-v-075b6310] {\n padding: 10px 10px 0;\n width: 50%;\n margin: 0;\n}\n.date-label[data-v-075b6310] {\n margin-bottom: 0.5rem;\n}\n.date-content[data-v-075b6310] {\n display: grid;\n grid-template-columns: repeat(2, 1fr);\n column-gap: 10px;\n}\n\n/*# sourceMappingURL=PostList.vue.map */", map: {"version":3,"sources":["/home/runner/work/tager-admin-blog/tager-admin-blog/src/views/Posts/PostList/PostList.vue","PostList.vue"],"names":[],"mappings":"AAsVA;EACA,aAAA;EACA,eAAA;ACrVA;ADuVA;EACA,gBAAA;ACrVA;ADwVA;EACA,oBAAA;EACA,UAAA;EACA,SAAA;ACtVA;AD0VA;EACA,qBAAA;ACvVA;AD0VA;EACA,aAAA;EACA,qCAAA;EACA,gBAAA;ACvVA;;AAEA,uCAAuC","file":"PostList.vue","sourcesContent":["<template>\n <page\n :title=\"pageTitle\"\n :header-buttons=\"[\n {\n text: $t('blog:newPost'),\n href: getBlogPostFormUrl({ postId: 'create' }),\n },\n ]\"\n >\n <template v-slot:content>\n <data-table\n :column-defs=\"columnDefs\"\n :row-data=\"rowData\"\n :loading=\"isRowDataLoading\"\n :error-message=\"errorMessage\"\n :search-query=\"searchQuery\"\n :pagination=\"{\n pageNumber,\n pageCount,\n pageSize,\n disabled: isRowDataLoading,\n }\"\n data-table=\"blog-post\"\n @change=\"handleChange\"\n >\n <template v-slot:filters>\n <advanced-search :tags=\"tags\" @click:tag=\"tagRemovalHandler\">\n <div class=\"filters\">\n <form-field-multi-select\n v-model=\"categoryFilter\"\n :options=\"categoryOptionList\"\n name=\"categoryFilter\"\n :searchable=\"true\"\n :label=\"$t('blog:category')\"\n class=\"filter\"\n />\n\n <form-field-multi-select\n v-if=\"isLangSpecific\"\n v-model=\"languageFilter\"\n :options=\"languageOptionList\"\n name=\"languageFilter\"\n :searchable=\"true\"\n :label=\"$t('blog:language')\"\n class=\"filter\"\n />\n\n <div class=\"filter\">\n <div class=\"date-label\">\n {{ $t('blog:dateOfPublication') }}\n </div>\n\n <div class=\"date-content\">\n <form-field\n v-model=\"fromDateFilter\"\n :label=\"$t('blog:From')\"\n name=\"fromDateFilter\"\n type=\"date\"\n :max=\"toDateFilter\"\n />\n\n <form-field\n v-model=\"toDateFilter\"\n :label=\"$t('blog:To')\"\n name=\"toDateFilter\"\n type=\"date\"\n :min=\"fromDateFilter\"\n />\n </div>\n </div>\n\n <form-field-multi-select\n v-model=\"statusFilter\"\n :options=\"statusOptionList\"\n name=\"statusFilter\"\n :searchable=\"true\"\n :label=\"$t('blog:status')\"\n class=\"filter\"\n />\n </div>\n </advanced-search>\n </template>\n\n <template v-slot:cell(actions)=\"{ row }\">\n <base-button\n variant=\"icon\"\n :title=\"$t('blog:edit')\"\n :disabled=\"isBusy(row.id)\"\n :href=\"getBlogPostFormUrl({ postId: row.id })\"\n >\n <svg-icon name=\"edit\" />\n </base-button>\n\n <base-button\n variant=\"icon\"\n :title=\"$t('blog:clone')\"\n :disabled=\"isBusy(row.id)\"\n @click=\"handleResourceClone(row.id)\"\n >\n <svg-icon name=\"contentCopy\" />\n </base-button>\n\n <base-button\n variant=\"icon\"\n :title=\"$t('blog:remove')\"\n :disabled=\"isBusy(row.id)\"\n @click=\"handleResourceDelete(row.id)\"\n >\n <svg-icon name=\"delete\" />\n </base-button>\n </template>\n </data-table>\n </template>\n </page>\n</template>\n\n<script lang=\"ts\">\nimport { computed, defineComponent, watch } from '@vue/composition-api';\nimport isEqual from 'lodash.isequal';\nimport pick from 'lodash.pick';\n\nimport {\n ColumnDefinition,\n OptionType,\n useDataTable,\n useTranslation,\n} from '@tager/admin-ui';\nimport {\n Nullable,\n useResourceClone,\n useResourceDelete,\n} from '@tager/admin-services';\n\nimport { useFetchModuleConfig, useFetchCategories } from '../../../hooks';\nimport {\n clonePost,\n deleteBlogPost,\n getPosts,\n} from '../../../services/requests';\nimport { getBlogPostFormUrl } from '../../../constants/paths';\nimport {\n Category,\n Language,\n PostFull,\n PostShort,\n} from '../../../typings/model';\nimport { getStatusOptions } from '../PostForm/PostForm.helpers';\n\nimport { convertPostList, getPostTableColumnDefs } from './PostList.helpers';\nimport { useAdvancedSearch } from './hooks';\n\nexport default defineComponent({\n name: 'Posts',\n setup(props, context) {\n const { t } = useTranslation(context);\n\n const categoryId = computed<string>(() => {\n return Array.isArray(context.root.$route.query.category)\n ? context.root.$route.query.category[0] ?? ''\n : context.root.$route.query.category;\n });\n\n const statusOptionList = computed<OptionType[]>(() => getStatusOptions(t));\n\n /** Fetch module config **/\n\n const {\n data: moduleConfig,\n loading: isModuleConfigLoading,\n } = useFetchModuleConfig({ context });\n\n const languageList = computed<Language[]>(\n () => moduleConfig.value?.languages ?? []\n );\n\n /** Fetch category list **/\n\n const {\n data: categoryList,\n loading: isCategoryListLoading,\n } = useFetchCategories({ context });\n\n const selectedCategory = computed<Nullable<Category>>(() =>\n categoryId.value\n ? categoryList.value.find(\n ({ id }) => String(id) === String(categoryId.value)\n ) ?? null\n : null\n );\n\n const pageTitle = computed<string>(() => {\n return selectedCategory.value\n ? `${context.root.$t('blog:postsByCategory')} \"${\n selectedCategory.value.name\n }\"`\n : context.root.$t('blog:posts');\n });\n\n /** Advanced search **/\n\n const {\n categoryFilter,\n categoryOptionList,\n languageFilter,\n languageOptionList,\n fromDateFilter,\n toDateFilter,\n filterParams,\n tags,\n tagRemovalHandler,\n statusFilter,\n } = useAdvancedSearch({\n context,\n categoryList,\n languageList,\n statusOptionList,\n });\n\n const isLangSpecific = computed<boolean>(\n () => languageOptionList.value.length > 1\n );\n\n /** Fetch Post list **/\n\n const {\n fetchEntityList: fetchPostList,\n isLoading: isPostLoading,\n rowData: postList,\n errorMessage,\n searchQuery,\n handleChange,\n pageNumber,\n pageCount,\n pageSize,\n } = useDataTable<PostShort>({\n fetchEntityList: (params) =>\n getPosts({\n query: params.searchQuery,\n pageNumber: params.pageNumber,\n pageSize: params.pageSize,\n ...filterParams.value,\n }),\n initialValue: [],\n context,\n resourceName: 'Blog post list',\n pageSize: 100,\n });\n\n watch(filterParams, () => {\n if (isModuleConfigLoading.value || isCategoryListLoading.value) {\n return;\n }\n\n const newQuery = {\n ...pick(context.root.$route.query, ['query', 'pageNumber']),\n ...filterParams.value,\n };\n\n if (!isEqual(context.root.$route.query, newQuery)) {\n context.root.$router.replace({ query: newQuery });\n fetchPostList();\n }\n });\n\n const displayedPostList = computed<PostShort[]>(() =>\n convertPostList(\n postList.value,\n selectedCategory.value,\n moduleConfig.value?.languages ?? []\n )\n );\n\n const isRowDataLoading = computed<boolean>(\n () =>\n isCategoryListLoading.value ||\n isPostLoading.value ||\n isModuleConfigLoading.value\n );\n\n const { isDeleting, handleResourceDelete } = useResourceDelete({\n deleteResource: deleteBlogPost,\n resourceName: 'Post',\n onSuccess: fetchPostList,\n context,\n });\n\n const { isCloning, handleResourceClone } = useResourceClone({\n cloneResource: clonePost,\n confirmMessage: t('blog:cloneConfirm'),\n successMessage: t('blog:cloneSuccess'),\n failureMessage: t('blog:cloneFailure'),\n onSuccessRedirectTo: (data: PostFull) => `/blog/posts/${data.id}`,\n context,\n });\n\n function isBusy(postId: number): boolean {\n return isDeleting(postId) || isCloning(postId) || isRowDataLoading.value;\n }\n\n const columnDefs = computed<ColumnDefinition<PostShort>[]>(() =>\n getPostTableColumnDefs(moduleConfig.value, context.root.$t)\n );\n\n return {\n columnDefs,\n rowData: displayedPostList,\n handleResourceDelete,\n isDeleting,\n categoryList,\n isRowDataLoading,\n errorMessage,\n getBlogPostFormUrl,\n pageTitle,\n searchQuery,\n handleChange,\n pageNumber,\n pageCount,\n pageSize,\n\n // Advanced search\n categoryFilter,\n categoryOptionList,\n isLangSpecific,\n languageFilter,\n languageOptionList,\n fromDateFilter,\n toDateFilter,\n statusFilter,\n statusOptionList,\n tags,\n tagRemovalHandler,\n\n // Clone\n handleResourceClone,\n isBusy,\n };\n },\n});\n</script>\n\n<style scoped lang=\"scss\">\n.filters {\n display: flex;\n margin: 0 -10px;\n\n &:not(:first-child) {\n margin-top: 10px;\n }\n\n .filter {\n padding: 10px 10px 0;\n width: 50%;\n margin: 0;\n }\n}\n\n.date-label {\n margin-bottom: 0.5rem;\n}\n\n.date-content {\n display: grid;\n grid-template-columns: repeat(2, 1fr);\n column-gap: 10px;\n}\n</style>\n",".filters {\n display: flex;\n margin: 0 -10px;\n}\n.filters:not(:first-child) {\n margin-top: 10px;\n}\n.filters .filter {\n padding: 10px 10px 0;\n width: 50%;\n margin: 0;\n}\n\n.date-label {\n margin-bottom: 0.5rem;\n}\n\n.date-content {\n display: grid;\n grid-template-columns: repeat(2, 1fr);\n column-gap: 10px;\n}\n\n/*# sourceMappingURL=PostList.vue.map */"]}, media: undefined });
|
|
3363
3509
|
|
|
3364
3510
|
};
|
|
3365
3511
|
/* scoped */
|
|
3366
|
-
const __vue_scope_id__ = "data-v-
|
|
3512
|
+
const __vue_scope_id__ = "data-v-075b6310";
|
|
3367
3513
|
/* module identifier */
|
|
3368
3514
|
const __vue_module_identifier__ = undefined;
|
|
3369
3515
|
/* functional template */
|
|
@@ -3387,98 +3533,6 @@
|
|
|
3387
3533
|
undefined
|
|
3388
3534
|
);
|
|
3389
3535
|
|
|
3390
|
-
function convertPostToFormValues(post, languageOptionList, postOptionList, additionalFieldList) {
|
|
3391
|
-
var _a, _b;
|
|
3392
|
-
if (!post) {
|
|
3393
|
-
return {
|
|
3394
|
-
title: '',
|
|
3395
|
-
excerpt: '',
|
|
3396
|
-
body: '',
|
|
3397
|
-
datetime: '',
|
|
3398
|
-
coverImage: null,
|
|
3399
|
-
image: null,
|
|
3400
|
-
imageMobile: null,
|
|
3401
|
-
pageTitle: '',
|
|
3402
|
-
pageDescription: '',
|
|
3403
|
-
openGraphImage: null,
|
|
3404
|
-
urlAlias: '',
|
|
3405
|
-
categories: [],
|
|
3406
|
-
language: null,
|
|
3407
|
-
relatedPosts: [],
|
|
3408
|
-
tags: '',
|
|
3409
|
-
additionalFields: additionalFieldList.map((fieldConfig) => adminDynamicField.universalFieldUtils.createFormField(fieldConfig, null)),
|
|
3410
|
-
};
|
|
3411
|
-
}
|
|
3412
|
-
const currentLangOption = languageOptionList.find((option) => option.value === post.language);
|
|
3413
|
-
const selectedPostOptionList = postOptionList.filter((option) => post.relatedPosts.some((relatedPost) => relatedPost.id === option.value));
|
|
3414
|
-
return {
|
|
3415
|
-
title: post.title,
|
|
3416
|
-
excerpt: post.excerpt,
|
|
3417
|
-
body: post.body,
|
|
3418
|
-
datetime: post.datetime.substr(0, 10),
|
|
3419
|
-
coverImage: post.coverImage
|
|
3420
|
-
? { id: adminServices.createId(), file: post.coverImage }
|
|
3421
|
-
: null,
|
|
3422
|
-
image: post.image ? { id: adminServices.createId(), file: post.image } : null,
|
|
3423
|
-
imageMobile: post.imageMobile
|
|
3424
|
-
? { id: adminServices.createId(), file: post.imageMobile }
|
|
3425
|
-
: null,
|
|
3426
|
-
pageTitle: (_a = post.pageTitle) !== null && _a !== void 0 ? _a : '',
|
|
3427
|
-
pageDescription: (_b = post.pageDescription) !== null && _b !== void 0 ? _b : '',
|
|
3428
|
-
openGraphImage: post.openGraphImage
|
|
3429
|
-
? { id: adminServices.createId(), file: post.openGraphImage }
|
|
3430
|
-
: null,
|
|
3431
|
-
urlAlias: post.urlAlias,
|
|
3432
|
-
categories: post.categories.map((category) => ({
|
|
3433
|
-
value: category.id,
|
|
3434
|
-
label: category.name,
|
|
3435
|
-
})),
|
|
3436
|
-
language: currentLangOption !== null && currentLangOption !== void 0 ? currentLangOption : null,
|
|
3437
|
-
relatedPosts: selectedPostOptionList,
|
|
3438
|
-
tags: post.tags.join(','),
|
|
3439
|
-
additionalFields: additionalFieldList.map((fieldConfig, index) => {
|
|
3440
|
-
const postAdditionalField = post.additionalFields.find((item) => item.name === fieldConfig.name);
|
|
3441
|
-
return adminDynamicField.universalFieldUtils.createFormField(fieldConfig, postAdditionalField === null || postAdditionalField === void 0 ? void 0 : postAdditionalField.value);
|
|
3442
|
-
}),
|
|
3443
|
-
};
|
|
3444
|
-
}
|
|
3445
|
-
function convertFormValuesToCreationPayload(values) {
|
|
3446
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
3447
|
-
return {
|
|
3448
|
-
title: values.title,
|
|
3449
|
-
excerpt: values.excerpt,
|
|
3450
|
-
urlAlias: values.urlAlias,
|
|
3451
|
-
body: values.body,
|
|
3452
|
-
datetime: values.datetime,
|
|
3453
|
-
coverImage: (_b = (_a = values.coverImage) === null || _a === void 0 ? void 0 : _a.file.id) !== null && _b !== void 0 ? _b : null,
|
|
3454
|
-
image: (_d = (_c = values.image) === null || _c === void 0 ? void 0 : _c.file.id) !== null && _d !== void 0 ? _d : null,
|
|
3455
|
-
imageMobile: (_f = (_e = values.imageMobile) === null || _e === void 0 ? void 0 : _e.file.id) !== null && _f !== void 0 ? _f : null,
|
|
3456
|
-
pageTitle: values.pageTitle,
|
|
3457
|
-
pageDescription: values.pageDescription,
|
|
3458
|
-
openGraphImage: (_h = (_g = values.openGraphImage) === null || _g === void 0 ? void 0 : _g.file.id) !== null && _h !== void 0 ? _h : null,
|
|
3459
|
-
status: 'PUBLISHED',
|
|
3460
|
-
categories: values.categories.map((option) => option.value),
|
|
3461
|
-
language: (_k = (_j = values.language) === null || _j === void 0 ? void 0 : _j.value) !== null && _k !== void 0 ? _k : null,
|
|
3462
|
-
relatedPosts: values.relatedPosts.map((relatedPostOption) => relatedPostOption.value),
|
|
3463
|
-
tags: values.tags.split(',').filter((tag) => tag.trim().length > 0),
|
|
3464
|
-
additionalFields: values.additionalFields.map((field) => ({
|
|
3465
|
-
name: field.config.name,
|
|
3466
|
-
value: adminDynamicField.universalFieldUtils.getOutgoingValue(field),
|
|
3467
|
-
})),
|
|
3468
|
-
};
|
|
3469
|
-
}
|
|
3470
|
-
function convertFormValuesToUpdatePayload(values) {
|
|
3471
|
-
return Object.assign(Object.assign({}, convertFormValuesToCreationPayload(values)), { urlAlias: values.urlAlias });
|
|
3472
|
-
}
|
|
3473
|
-
function convertCategoryListToOptions(categoryList, languageId) {
|
|
3474
|
-
return categoryList
|
|
3475
|
-
.filter(({ language }) => (languageId ? language === languageId : true))
|
|
3476
|
-
.map(({ id, name, depth }) => ({
|
|
3477
|
-
value: id,
|
|
3478
|
-
label: getNameWithDepth(name, depth),
|
|
3479
|
-
}));
|
|
3480
|
-
}
|
|
3481
|
-
|
|
3482
3536
|
var script$1 = compositionApi.defineComponent({
|
|
3483
3537
|
name: 'BlogPostForm',
|
|
3484
3538
|
components: { DynamicField: adminDynamicField.DynamicField, ShortCodeConstructor: adminUi.ShortCodeConstructor, FormFooter: adminUi.FormFooter },
|
|
@@ -3487,6 +3541,7 @@
|
|
|
3487
3541
|
const postId = compositionApi.computed(() => context.root.$route.params.postId);
|
|
3488
3542
|
const isCreation = compositionApi.computed(() => postId.value === 'create');
|
|
3489
3543
|
const urlAliasChanged = compositionApi.ref(false);
|
|
3544
|
+
const statusOptions = compositionApi.computed(() => getStatusOptions(context.root.$t));
|
|
3490
3545
|
/** Fetch module config **/
|
|
3491
3546
|
const { data: moduleConfig, loading: isModuleConfigLoading, } = useFetchModuleConfig({ context });
|
|
3492
3547
|
const languageList = compositionApi.computed(() => { var _a, _b; return (_b = (_a = moduleConfig.value) === null || _a === void 0 ? void 0 : _a.languages) !== null && _b !== void 0 ? _b : []; });
|
|
@@ -3526,11 +3581,11 @@
|
|
|
3526
3581
|
})));
|
|
3527
3582
|
/** Form State **/
|
|
3528
3583
|
const isSubmitting = compositionApi.ref(false);
|
|
3529
|
-
const values = compositionApi.ref(convertPostToFormValues(post.value, languageOptionList.value, postOptionList.value, (_b = (_a = moduleConfig.value) === null || _a === void 0 ? void 0 : _a.fields) !== null && _b !== void 0 ? _b : []));
|
|
3584
|
+
const values = compositionApi.ref(convertPostToFormValues(post.value, languageOptionList.value, postOptionList.value, (_b = (_a = moduleConfig.value) === null || _a === void 0 ? void 0 : _a.fields) !== null && _b !== void 0 ? _b : [], statusOptions.value));
|
|
3530
3585
|
const errors = compositionApi.ref({});
|
|
3531
3586
|
compositionApi.watch([post, languageOptionList, postOptionList, moduleConfig], () => {
|
|
3532
3587
|
var _a, _b;
|
|
3533
|
-
values.value = convertPostToFormValues(post.value, languageOptionList.value, postOptionList.value, (_b = (_a = moduleConfig.value) === null || _a === void 0 ? void 0 : _a.fields) !== null && _b !== void 0 ? _b : []);
|
|
3588
|
+
values.value = convertPostToFormValues(post.value, languageOptionList.value, postOptionList.value, (_b = (_a = moduleConfig.value) === null || _a === void 0 ? void 0 : _a.fields) !== null && _b !== void 0 ? _b : [], statusOptions.value);
|
|
3534
3589
|
});
|
|
3535
3590
|
function submitForm(event) {
|
|
3536
3591
|
isSubmitting.value = true;
|
|
@@ -3555,7 +3610,7 @@
|
|
|
3555
3610
|
}
|
|
3556
3611
|
}
|
|
3557
3612
|
if (event.type === 'create_create-another') {
|
|
3558
|
-
values.value = convertPostToFormValues(null, languageOptionList.value, postOptionList.value, (_b = (_a = moduleConfig.value) === null || _a === void 0 ? void 0 : _a.fields) !== null && _b !== void 0 ? _b : []);
|
|
3613
|
+
values.value = convertPostToFormValues(null, languageOptionList.value, postOptionList.value, (_b = (_a = moduleConfig.value) === null || _a === void 0 ? void 0 : _a.fields) !== null && _b !== void 0 ? _b : [], statusOptions.value);
|
|
3559
3614
|
}
|
|
3560
3615
|
context.root.$toast({
|
|
3561
3616
|
variant: 'success',
|
|
@@ -3673,7 +3728,7 @@
|
|
|
3673
3728
|
values.value.openGraphImage = image;
|
|
3674
3729
|
}
|
|
3675
3730
|
function handleTitleChange(value) {
|
|
3676
|
-
if (urlAliasChanged.value === false) {
|
|
3731
|
+
if (isCreation.value && urlAliasChanged.value === false) {
|
|
3677
3732
|
values.value.urlAlias = adminServices.urlTranslit(value);
|
|
3678
3733
|
}
|
|
3679
3734
|
}
|
|
@@ -3740,6 +3795,7 @@
|
|
|
3740
3795
|
handleAliasChange,
|
|
3741
3796
|
urlAliasTemplate,
|
|
3742
3797
|
handleCategoriesChange,
|
|
3798
|
+
statusOptions,
|
|
3743
3799
|
};
|
|
3744
3800
|
},
|
|
3745
3801
|
});
|
|
@@ -3796,6 +3852,23 @@
|
|
|
3796
3852
|
_vm._v(" "),
|
|
3797
3853
|
_vm.selectedTabId === "common"
|
|
3798
3854
|
? [
|
|
3855
|
+
_c("form-field-select", {
|
|
3856
|
+
attrs: {
|
|
3857
|
+
name: "status",
|
|
3858
|
+
error: _vm.errors.status,
|
|
3859
|
+
label: _vm.$t("blog:status"),
|
|
3860
|
+
"no-options-message": _vm.$t("blog:noTemplates"),
|
|
3861
|
+
options: _vm.statusOptions,
|
|
3862
|
+
},
|
|
3863
|
+
model: {
|
|
3864
|
+
value: _vm.values.status,
|
|
3865
|
+
callback: function ($$v) {
|
|
3866
|
+
_vm.$set(_vm.values, "status", $$v);
|
|
3867
|
+
},
|
|
3868
|
+
expression: "values.status",
|
|
3869
|
+
},
|
|
3870
|
+
}),
|
|
3871
|
+
_vm._v(" "),
|
|
3799
3872
|
_vm.isCreation && _vm.isLangSpecific
|
|
3800
3873
|
? _c("form-field-select", {
|
|
3801
3874
|
attrs: {
|
|
@@ -4530,6 +4603,7 @@
|
|
|
4530
4603
|
name: '',
|
|
4531
4604
|
parent: { value: null, label: t('blog:noParent') },
|
|
4532
4605
|
urlAlias: '',
|
|
4606
|
+
isDefault: false,
|
|
4533
4607
|
pageTitle: '',
|
|
4534
4608
|
pageDescription: '',
|
|
4535
4609
|
pageKeywords: '',
|
|
@@ -4540,6 +4614,7 @@
|
|
|
4540
4614
|
}
|
|
4541
4615
|
return {
|
|
4542
4616
|
language: currentLangOption !== null && currentLangOption !== void 0 ? currentLangOption : null,
|
|
4617
|
+
isDefault: category.isDefault,
|
|
4543
4618
|
name: category.name,
|
|
4544
4619
|
parent: category.parent
|
|
4545
4620
|
? { value: category.parent.id, label: category.parent.name }
|
|
@@ -4562,7 +4637,7 @@
|
|
|
4562
4637
|
name: values.name,
|
|
4563
4638
|
parent: values.parent.value,
|
|
4564
4639
|
urlAlias: values.urlAlias,
|
|
4565
|
-
isDefault:
|
|
4640
|
+
isDefault: values.isDefault,
|
|
4566
4641
|
pageTitle: values.pageTitle,
|
|
4567
4642
|
pageDescription: values.pageDescription,
|
|
4568
4643
|
openGraphImage: (_d = (_c = values.openGraphImage) === null || _c === void 0 ? void 0 : _c.file.id) !== null && _d !== void 0 ? _d : null,
|
|
@@ -4847,6 +4922,21 @@
|
|
|
4847
4922
|
})
|
|
4848
4923
|
: _vm._e(),
|
|
4849
4924
|
_vm._v(" "),
|
|
4925
|
+
_c("form-field-checkbox", {
|
|
4926
|
+
attrs: {
|
|
4927
|
+
name: "isDefault",
|
|
4928
|
+
label: _vm.$t("blog:defaultCategory"),
|
|
4929
|
+
error: _vm.errors.isDefault,
|
|
4930
|
+
},
|
|
4931
|
+
model: {
|
|
4932
|
+
value: _vm.values.isDefault,
|
|
4933
|
+
callback: function ($$v) {
|
|
4934
|
+
_vm.$set(_vm.values, "isDefault", $$v);
|
|
4935
|
+
},
|
|
4936
|
+
expression: "values.isDefault",
|
|
4937
|
+
},
|
|
4938
|
+
}),
|
|
4939
|
+
_vm._v(" "),
|
|
4850
4940
|
_c("form-field", {
|
|
4851
4941
|
attrs: {
|
|
4852
4942
|
name: "name",
|
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,6 +72,7 @@ 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;
|