@tager/admin-blog 0.3.42 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/constants/paths.d.ts +6 -14
  2. package/dist/constants/routes.d.ts +5 -5
  3. package/dist/dev/App.vue.d.ts +5 -0
  4. package/dist/dev/config.d.ts +2 -0
  5. package/dist/dev/env.d.ts +1 -0
  6. package/dist/dev/main.d.ts +3 -0
  7. package/dist/hooks/index.d.ts +4 -4
  8. package/dist/hooks/useFetchCategories.d.ts +3 -6
  9. package/dist/hooks/useFetchCategory.d.ts +7 -8
  10. package/dist/hooks/useFetchModuleConfig.d.ts +3 -6
  11. package/dist/hooks/useFetchPosts.d.ts +3 -6
  12. package/dist/index.mjs +2313 -0
  13. package/dist/locales/apply.d.ts +1 -0
  14. package/dist/locales/en.d.ts +87 -86
  15. package/dist/locales/ru.d.ts +3 -3
  16. package/dist/main.d.ts +3 -4
  17. package/dist/services/requests.d.ts +59 -59
  18. package/dist/style.css +1 -0
  19. package/dist/typings/common.d.ts +1 -1
  20. package/dist/typings/model.d.ts +106 -106
  21. package/dist/utils/common.d.ts +2 -2
  22. package/dist/utils/paths.d.ts +8 -0
  23. package/dist/views/Categories/CategoryForm/CategoryForm.helpers.d.ts +7 -7
  24. package/dist/views/Categories/CategoryForm/CategoryForm.vue.d.ts +53 -116
  25. package/dist/views/Categories/CategoryForm/index.d.ts +1 -1
  26. package/dist/views/Categories/CategoryList/CategoryList.helpers.d.ts +7 -7
  27. package/dist/views/Categories/CategoryList/CategoryList.vue.d.ts +26 -57
  28. package/dist/views/Categories/CategoryList/hooks/index.d.ts +1 -1
  29. package/dist/views/Categories/CategoryList/hooks/useAdvancedSearch.d.ts +19 -16
  30. package/dist/views/Categories/CategoryList/index.d.ts +1 -1
  31. package/dist/views/Posts/PostForm/PostForm.helpers.d.ts +32 -32
  32. package/dist/views/Posts/PostForm/PostForm.vue.d.ts +2768 -9398
  33. package/dist/views/Posts/PostForm/index.d.ts +1 -1
  34. package/dist/views/Posts/PostList/PostList.helpers.d.ts +7 -7
  35. package/dist/views/Posts/PostList/PostList.vue.d.ts +38 -78
  36. package/dist/views/Posts/PostList/hooks/index.d.ts +1 -1
  37. package/dist/views/Posts/PostList/hooks/useAdvancedSearch.d.ts +27 -24
  38. package/dist/views/Posts/PostList/index.d.ts +1 -1
  39. package/package.json +51 -49
  40. package/src/constants/paths.ts +0 -22
  41. package/src/constants/routes.ts +9 -9
  42. package/src/dev/App.vue +56 -0
  43. package/src/dev/config.ts +23 -0
  44. package/src/dev/env.ts +17 -0
  45. package/src/dev/main.ts +49 -0
  46. package/src/hooks/useFetchCategories.ts +2 -7
  47. package/src/hooks/useFetchCategory.ts +3 -6
  48. package/src/hooks/useFetchModuleConfig.ts +2 -7
  49. package/src/hooks/useFetchPosts.ts +2 -5
  50. package/src/locales/apply.ts +9 -0
  51. package/src/locales/en.ts +3 -3
  52. package/src/locales/ru.ts +4 -2
  53. package/src/main.ts +3 -8
  54. package/src/utils/paths.ts +23 -0
  55. package/src/views/Categories/CategoryForm/CategoryForm.vue +81 -65
  56. package/src/views/Categories/CategoryList/CategoryList.helpers.ts +1 -1
  57. package/src/views/Categories/CategoryList/CategoryList.vue +86 -58
  58. package/src/views/Categories/CategoryList/hooks/useAdvancedSearch.ts +9 -12
  59. package/src/views/Posts/PostForm/PostForm.vue +259 -224
  60. package/src/views/Posts/PostList/PostList.helpers.ts +3 -3
  61. package/src/views/Posts/PostList/PostList.vue +168 -168
  62. package/src/views/Posts/PostList/hooks/useAdvancedSearch.ts +22 -30
  63. package/CHANGELOG.md +0 -13
  64. package/dist/constants/menu.d.ts +0 -5
  65. package/dist/dev.d.ts +0 -1
  66. package/dist/index.esm.js +0 -5294
  67. package/dist/index.umd.js +0 -5321
  68. package/dist/router/index.d.ts +0 -4
  69. package/dist/views/Posts/PostForm/components/TabList/TabList.types.d.ts +0 -5
  70. package/dist/views/Posts/PostForm/components/TabList/index.d.ts +0 -2
  71. package/src/constants/menu.ts +0 -31
  72. package/src/dev.ts +0 -34
  73. package/src/router/index.ts +0 -40
  74. package/src/typings/sfc.d.ts +0 -12
  75. package/src/typings/shims-tsx.d.ts +0 -13
  76. package/src/typings/shims-vue.d.ts +0 -11
  77. package/src/typings/translate.d.ts +0 -10
  78. package/src/views/App.vue +0 -22
  79. package/src/views/Home.vue +0 -31
  80. package/src/views/Posts/PostForm/components/TabList/TabList.types.ts +0 -5
  81. package/src/views/Posts/PostForm/components/TabList/TabList.vue +0 -92
  82. package/src/views/Posts/PostForm/components/TabList/index.ts +0 -2
package/dist/index.mjs ADDED
@@ -0,0 +1,2313 @@
1
+ import { i18n, request, useResource, createId, notEmpty, isNotNullish, useI18n, useResourceDelete, useResourceClone, useToast, navigateBack, convertRequestErrorToMap, urlTranslit, getWebsiteOrigin } from "@tager/admin-services";
2
+ import { onMounted, watch, computed, ref, defineComponent, resolveComponent, openBlock, createBlock, withCtx, createVNode, createElementVNode, createCommentVNode, toDisplayString, createElementBlock, createTextVNode, withModifiers, Fragment, renderList, createSlots } from "vue";
3
+ import isEqual from "lodash.isequal";
4
+ import pick from "lodash.pick";
5
+ import { useRoute, useRouter } from "vue-router";
6
+ import { getFilterParamAsStringArray, getFilterParamAsString, getFilterParams, DeleteIcon, ContentCopyIcon, EditIcon, BaseButton, FormField, FormFieldMultiSelect, AdvancedSearch, DataTable, useDataTable, formatDateTime, SeoFieldGroup, FormFieldFileInput, FormFieldRichTextInput, FormFieldCheckbox, FormFieldUrlAliasInput, FormFieldSelect, TabList, ShortCodeConstructor, FormFooter, createTabErrorFinder, SouthIcon, NorthIcon, CountButton } from "@tager/admin-ui";
7
+ import { Page } from "@tager/admin-layout";
8
+ import { universalFieldUtils, DynamicField } from "@tager/admin-dynamic-field";
9
+ import { compile } from "path-to-regexp";
10
+ import "i18next";
11
+ const EN = {
12
+ yes: "Yes",
13
+ no: "no",
14
+ blog: "Blog",
15
+ posts: "Posts",
16
+ categories: "Categories",
17
+ createPost: "Create post",
18
+ createCategory: "Create category",
19
+ home: "Home",
20
+ allPosts: "All posts",
21
+ postForm: "Post Form",
22
+ allCategories: "All categories",
23
+ categoryForm: "Category Form",
24
+ success: "Success",
25
+ error: "Error",
26
+ newPost: "New Post",
27
+ edit: "Edit",
28
+ remove: "Remove",
29
+ postsByCategory: "Posts by category",
30
+ name: "Name",
31
+ image: "Image",
32
+ language: "Language",
33
+ languages: "Languages",
34
+ date: "Date",
35
+ dateOfPublication: "Date of publication",
36
+ dateOfPublicationFrom: "Date of publication - From",
37
+ dateOfPublicationTo: "Date of publication - To",
38
+ from: "from",
39
+ to: "to",
40
+ From: "From",
41
+ To: "To",
42
+ category: "Category",
43
+ actions: "Actions",
44
+ updatePost: "Update post",
45
+ title: "Title",
46
+ link: "Link",
47
+ excerpt: "Excerpt",
48
+ body: "Body",
49
+ defaultCategory: "Default Category",
50
+ coverImage: "Cover Image",
51
+ innerImage: "Post Image",
52
+ innerImageMobile: "Post Image (Mobile)",
53
+ tags: "Tags",
54
+ relatedPosts: "Related posts",
55
+ blogPostWasSuccessfullyCreated: "Blog post was successfully created",
56
+ blogPostWasSuccessfullyUpdated: "Blog post was successfully updated",
57
+ blogPostCreationWasFailed: "Blog post creation was failed",
58
+ blogPostUpdateWasFailed: "Blog post update was failed",
59
+ common: "Common",
60
+ images: "Images",
61
+ relations: "Relations",
62
+ additionalFields: "Additional Fields",
63
+ viewPost: "View Post",
64
+ blogCategories: "Blog Categories",
65
+ newCategory: "New Category",
66
+ moveUp: "Move up",
67
+ moveDown: "Move down",
68
+ createBlogCategory: "Create Blog category",
69
+ updateBlogCategory: "Update Blog category",
70
+ pageTitle: "Page title",
71
+ pageDescription: "Page description",
72
+ openGraphImage: "Open graph image",
73
+ blogCategoryWasSuccessfullyCreated: "Blog category was successfully created",
74
+ blogCategoryWasSuccessfullyUpdated: "Blog category was successfully updated",
75
+ blogCategoryCreationWasFailed: "Blog category creation was failed",
76
+ blogCategoryUpdateWasFailed: "Blog category update was failed",
77
+ clone: "Clone",
78
+ cloneConfirm: "Are you sure you want to clone the page?",
79
+ cloneSuccess: "Page have copied successfully",
80
+ cloneFailure: "Page copy failure",
81
+ tabs: {
82
+ common: "Common",
83
+ seo: "SEO"
84
+ },
85
+ parentCategory: "Parent category",
86
+ noParent: "No parent",
87
+ status: "Status",
88
+ statusPublished: "Published",
89
+ statusDraft: "Draft",
90
+ statusArchived: "Archived",
91
+ scheduleArchive: "Schedule archive",
92
+ schedulePublish: "Schedule publish",
93
+ archiveAt: "Archive at",
94
+ publishAt: "Publish at",
95
+ archiveAtLabel: "Archive at",
96
+ publishAtLabel: "Publish at"
97
+ };
98
+ const RU = {
99
+ yes: "\u0414\u0430",
100
+ no: "\u041D\u0435\u0442",
101
+ blog: "\u0411\u043B\u043E\u0433",
102
+ posts: "\u041F\u043E\u0441\u0442\u044B",
103
+ categories: "\u041A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u0438",
104
+ createPost: "\u0421\u043E\u0437\u0434\u0430\u0442\u044C \u043F\u043E\u0441\u0442",
105
+ createCategory: "\u0421\u043E\u0437\u0434\u0430\u0442\u044C \u043A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u044E",
106
+ home: "\u0413\u043B\u0430\u0432\u043D\u0430\u044F",
107
+ allPosts: "\u0412\u0441\u0435 \u043F\u043E\u0441\u0442\u044B",
108
+ postForm: "\u0424\u043E\u0440\u043C\u0430 \u043F\u043E\u0441\u0442\u0430",
109
+ allCategories: "\u0412\u0441\u0435 \u043A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u0438",
110
+ categoryForm: "\u0424\u043E\u0440\u043C\u0430 \u043A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u0438",
111
+ success: "\u0423\u0441\u043F\u0435\u0445",
112
+ error: "\u041E\u0448\u0438\u0431\u043A\u0430",
113
+ newPost: "\u041D\u043E\u0432\u044B\u0439 \u043F\u043E\u0441\u0442",
114
+ edit: "\u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C",
115
+ remove: "\u0423\u0434\u0430\u043B\u0438\u0442\u044C",
116
+ postsByCategory: "\u041F\u043E\u0441\u0442\u044B \u043F\u043E \u043A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u044F\u043C",
117
+ name: "\u041D\u0430\u0437\u0432\u0430\u043D\u0438\u0435",
118
+ image: "\u0418\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0435",
119
+ language: "\u042F\u0437\u044B\u043A",
120
+ languages: "\u042F\u0437\u044B\u043A\u0438",
121
+ date: "\u0414\u0430\u0442\u0430",
122
+ dateOfPublication: "\u0414\u0430\u0442\u0430 \u043F\u0443\u0431\u043B\u0438\u043A\u0430\u0446\u0438\u0438",
123
+ dateOfPublicationFrom: "\u0414\u0430\u0442\u0430 \u043F\u0443\u0431\u043B\u0438\u043A\u0430\u0446\u0438\u0438 - \u041E\u0442",
124
+ dateOfPublicationTo: "\u0414\u0430\u0442\u0430 \u043F\u0443\u0431\u043B\u0438\u043A\u0430\u0446\u0438\u0438 - \u0414\u043E",
125
+ from: "\u043E\u0442",
126
+ to: "\u0434\u043E",
127
+ From: "\u041E\u0442",
128
+ To: "\u0414\u043E",
129
+ category: "\u041A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u044F",
130
+ actions: "\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u044F",
131
+ updatePost: "\u041E\u0431\u043D\u043E\u0432\u0438\u0442\u044C \u043F\u043E\u0441\u0442",
132
+ title: "\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A",
133
+ link: "\u0421\u0441\u044B\u043B\u043A\u0430",
134
+ excerpt: "\u041A\u0440\u0430\u0442\u043A\u043E\u0435 \u043E\u043F\u0438\u0441\u0430\u043D\u0438\u0435",
135
+ defaultCategory: "\u041A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u044F \u043F\u043E-\u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E",
136
+ body: "\u0421\u043E\u0434\u0435\u0440\u0436\u0430\u043D\u0438\u0435",
137
+ coverImage: "\u041E\u0431\u043B\u043E\u0436\u043A\u0430",
138
+ innerImage: "\u041A\u0430\u0440\u0442\u0438\u043D\u043A\u0430 \u043F\u043E\u0441\u0442\u0430",
139
+ innerImageMobile: "\u041A\u0430\u0440\u0442\u0438\u043D\u043A\u0430 \u043F\u043E\u0441\u0442\u0430 (Mobile)",
140
+ tags: "\u0422\u0435\u0433\u0438",
141
+ relatedPosts: "\u041F\u043E\u0445\u043E\u0436\u0438\u0435 \u043F\u043E\u0441\u0442\u044B",
142
+ blogPostWasSuccessfullyCreated: "\u0417\u0430\u043F\u0438\u0441\u044C \u0432 \u0431\u043B\u043E\u0433\u0435 \u0443\u0441\u043F\u0435\u0448\u043D\u043E \u0441\u043E\u0437\u0434\u0430\u043D\u0430",
143
+ blogPostWasSuccessfullyUpdated: "\u0417\u0430\u043F\u0438\u0441\u044C \u0432 \u0431\u043B\u043E\u0433\u0435 \u0443\u0441\u043F\u0435\u0448\u043D\u043E \u043E\u0431\u043D\u043E\u0432\u043B\u0435\u043D\u043E",
144
+ blogPostCreationWasFailed: "\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0441\u043E\u0437\u0434\u0430\u0442\u044C \u0437\u0430\u043F\u0438\u0441\u044C \u0432 \u0431\u043B\u043E\u0433\u0435",
145
+ blogPostUpdateWasFailed: "\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043E\u0431\u043D\u043E\u0432\u0438\u0442\u044C \u0437\u0430\u043F\u0438\u0441\u044C \u0432 \u0431\u043B\u043E\u0433\u0435",
146
+ common: "\u041E\u0431\u0449\u0438\u0435",
147
+ images: "\u041A\u0430\u0440\u0442\u0438\u043D\u043A\u0438",
148
+ relations: "\u0421\u0432\u044F\u0437\u0438",
149
+ additionalFields: "\u0414\u043E\u043F\u043E\u043B\u043D\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u0435 \u043F\u043E\u043B\u044F",
150
+ viewPost: "\u041F\u043E\u0441\u043C\u043E\u0442\u0440\u0435\u0442\u044C \u043F\u043E\u0441\u0442",
151
+ blogCategories: "\u041A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u0438",
152
+ newCategory: "\u041D\u043E\u0432\u0430\u044F \u043A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u044F",
153
+ moveUp: "\u0414\u0432\u0438\u0433\u0430\u0442\u044C\u0441\u044F \u0432\u0432\u0435\u0440\u0445",
154
+ moveDown: "\u0414\u0432\u0438\u0433\u0430\u0442\u044C\u0441\u044F \u0432\u043D\u0438\u0437",
155
+ createBlogCategory: "\u0421\u043E\u0437\u0434\u0430\u0442\u044C \u043A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u044E \u0431\u043B\u043E\u0433\u0430",
156
+ updateBlogCategory: "\u041E\u0431\u043D\u043E\u0432\u0438\u0442\u044C \u043A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u044E \u0431\u043B\u043E\u0433\u0430",
157
+ pageTitle: "\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u044B",
158
+ pageDescription: "\u041E\u043F\u0438\u0441\u0430\u043D\u0438\u0435 \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u044B",
159
+ openGraphImage: "\u041A\u0430\u0440\u0442\u0438\u043D\u043A\u0430 \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u044B",
160
+ blogCategoryWasSuccessfullyCreated: "\u041A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u044F \u0431\u043B\u043E\u0433\u0430 \u0431\u044B\u043B\u0430 \u0443\u0441\u043F\u0435\u0448\u043D\u043E \u0441\u043E\u0437\u0434\u0430\u043D\u0430",
161
+ blogCategoryWasSuccessfullyUpdated: "\u041A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u044F \u0431\u043B\u043E\u0433\u0430 \u0443\u0441\u043F\u0435\u0448\u043D\u043E \u043E\u0431\u043D\u043E\u0432\u043B\u0435\u043D\u0430",
162
+ blogCategoryCreationWasFailed: "\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0441\u043E\u0437\u0434\u0430\u0442\u044C \u043A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u044E \u0431\u043B\u043E\u0433\u0430",
163
+ blogCategoryUpdateWasFailed: "\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043E\u0431\u043D\u043E\u0432\u0438\u0442\u044C \u043A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u044E \u0431\u043B\u043E\u0433\u0430",
164
+ clone: "\u041A\u043B\u043E\u043D\u0438\u0440\u043E\u0432\u0430\u0442\u044C",
165
+ cloneConfirm: "\u0412\u044B \u0443\u0432\u0435\u0440\u0435\u043D\u044B, \u0447\u0442\u043E \u0445\u043E\u0442\u0438\u0442\u0435 \u0441\u043E\u0437\u0434\u0430\u0442\u044C \u043A\u043E\u043F\u0438\u044E \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u044B?",
166
+ cloneSuccess: "\u041A\u043E\u043F\u0438\u044F \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u044B \u0443\u0441\u043F\u0435\u0448\u043D\u043E \u0441\u043E\u0437\u0434\u0430\u043D\u0430",
167
+ cloneFailure: "\u041E\u0448\u0438\u0431\u043A\u0430 \u043A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u044F \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u044B",
168
+ tabs: {
169
+ common: "\u041E\u0431\u0449\u0438\u0435",
170
+ seo: "SEO"
171
+ },
172
+ parentCategory: "\u0420\u043E\u0434\u0438\u0442\u0435\u043B\u044C\u0441\u043A\u0430\u044F \u043A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u044F",
173
+ noParent: "\u041D\u0435\u0442 \u0440\u043E\u0434\u0438\u0442\u0435\u043B\u044C\u0441\u043A\u043E\u0439",
174
+ status: "\u0421\u0442\u0430\u0442\u0443\u0441",
175
+ statusPublished: "\u041E\u043F\u0443\u0431\u043B\u0438\u043A\u043E\u0432\u0430\u043D",
176
+ statusDraft: "\u0427\u0435\u0440\u043D\u043E\u0432\u0438\u043A",
177
+ statusArchived: "\u0412 \u0430\u0440\u0445\u0438\u0432\u0435",
178
+ scheduleArchive: "\u0417\u0430\u043F\u043B\u0430\u043D\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u043F\u0435\u0440\u0435\u043D\u043E\u0441 \u0432 \u0430\u0440\u0445\u0438\u0432",
179
+ schedulePublish: "\u0417\u0430\u043F\u043B\u0430\u043D\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u043F\u0443\u0431\u043B\u0438\u043A\u0430\u0446\u0438\u044E",
180
+ archiveAt: "\u041F\u0435\u0440\u0435\u043D\u0435\u0441\u0442\u0438 \u0432 \u0430\u0440\u0445\u0438\u0432 \u0432",
181
+ publishAt: "\u041E\u043F\u0443\u0431\u043B\u0438\u043A\u043E\u0432\u0430\u0442\u044C \u0432",
182
+ archiveAtLabel: "\u041F\u0435\u0440\u0435\u043D\u043E\u0441 \u0432 \u0430\u0440\u0445\u0438\u0432",
183
+ publishAtLabel: "\u041F\u0443\u0431\u043B\u0438\u043A\u0430\u0446\u0438\u044F"
184
+ };
185
+ function applyTranslations() {
186
+ i18n.addTranslations("en", "blog", EN);
187
+ i18n.addTranslations("ru", "blog", RU);
188
+ }
189
+ function getPosts(params) {
190
+ return request.get({ path: "/admin/blog/posts", params });
191
+ }
192
+ function getBlogPostCount() {
193
+ return request.get({ path: "/admin/blog/posts/count" });
194
+ }
195
+ function getPost(postId) {
196
+ return request.get({ path: `/admin/blog/posts/${postId}` });
197
+ }
198
+ function clonePost(postId) {
199
+ return request.post({ path: `/admin/blog/posts/${postId}/clone` });
200
+ }
201
+ function createBlogPost(payload) {
202
+ return request.post({ path: "/admin/blog/posts", body: payload });
203
+ }
204
+ function updateBlogPost(postId, payload) {
205
+ return request.put({ path: `/admin/blog/posts/${postId}`, body: payload });
206
+ }
207
+ function deleteBlogPost(postId) {
208
+ return request.delete({ path: `/admin/blog/posts/${postId}` });
209
+ }
210
+ function getCategories(params) {
211
+ return request.get({ path: "/admin/blog/categories", params });
212
+ }
213
+ function getCategory(categoryId) {
214
+ return request.get({ path: `/admin/blog/categories/${categoryId}` });
215
+ }
216
+ function createCategory(payload) {
217
+ return request.post({ path: "/admin/blog/categories", body: payload });
218
+ }
219
+ function updateCategory(categoryId, payload) {
220
+ return request.put({
221
+ path: `/admin/blog/categories/${categoryId}`,
222
+ body: payload
223
+ });
224
+ }
225
+ function deleteCategory(categoryId) {
226
+ return request.delete({
227
+ path: `/admin/blog/categories/${categoryId}`
228
+ });
229
+ }
230
+ function moveCategory(categoryId, direction) {
231
+ return request.post({
232
+ path: `/admin/blog/categories/move/${categoryId}/${direction}`
233
+ });
234
+ }
235
+ function getModuleConfig() {
236
+ return request.get({
237
+ path: `/admin/blog/module-info`
238
+ });
239
+ }
240
+ function useFetchPosts() {
241
+ const [fetchPosts, resource] = useResource({
242
+ fetchResource: () => getPosts({ pageNumber: 1, pageSize: 99999 }),
243
+ initialValue: [],
244
+ resourceName: "Blog posts"
245
+ });
246
+ onMounted(() => {
247
+ fetchPosts();
248
+ });
249
+ return resource;
250
+ }
251
+ function useFetchCategory({
252
+ categoryId,
253
+ isCreation
254
+ }) {
255
+ const [fetchCategory, resource] = useResource({
256
+ fetchResource: () => getCategory(categoryId.value),
257
+ initialValue: null,
258
+ resourceName: "Blog category"
259
+ });
260
+ onMounted(() => {
261
+ if (isCreation.value || !categoryId.value) {
262
+ return;
263
+ }
264
+ fetchCategory();
265
+ });
266
+ watch(categoryId, () => {
267
+ if (isCreation.value || !categoryId.value) {
268
+ return;
269
+ }
270
+ fetchCategory();
271
+ });
272
+ return resource;
273
+ }
274
+ function useFetchCategories() {
275
+ const [fetchCategories, resource] = useResource({
276
+ fetchResource: getCategories,
277
+ initialValue: [],
278
+ resourceName: "Blog categories"
279
+ });
280
+ onMounted(() => {
281
+ fetchCategories();
282
+ });
283
+ return resource;
284
+ }
285
+ function useFetchModuleConfig() {
286
+ const [fetchModuleConfig, resource] = useResource({
287
+ fetchResource: getModuleConfig,
288
+ initialValue: null,
289
+ resourceName: "Module configuration"
290
+ });
291
+ onMounted(() => {
292
+ fetchModuleConfig();
293
+ });
294
+ return resource;
295
+ }
296
+ const BLOG_ROUTE_PATHS = {
297
+ POST_LIST: "/blog/posts",
298
+ POST_FORM: "/blog/posts/:postId",
299
+ CATEGORY_LIST: "/blog/categories",
300
+ CATEGORY_FORM: "/blog/categories/:categoryId"
301
+ };
302
+ function getBlogPostListUrl() {
303
+ return BLOG_ROUTE_PATHS.POST_LIST;
304
+ }
305
+ function getBlogPostFormUrl(params) {
306
+ return compile(BLOG_ROUTE_PATHS.POST_FORM)({ postId: params.postId });
307
+ }
308
+ function getBlogCategoryListUrl() {
309
+ return BLOG_ROUTE_PATHS.CATEGORY_LIST;
310
+ }
311
+ function getBlogCategoryFormUrl(params) {
312
+ return compile(BLOG_ROUTE_PATHS.CATEGORY_FORM)({
313
+ categoryId: params.categoryId
314
+ });
315
+ }
316
+ function generateNumberArray(length) {
317
+ return Array.from({ length }, (_, index) => index);
318
+ }
319
+ function getNameWithDepth(name, depth) {
320
+ return generateNumberArray(depth).map(() => "\u2014").join(" ") + " " + name;
321
+ }
322
+ const getStatusOptions = (t) => [
323
+ { label: t("blog:statusPublished"), value: "PUBLISHED" },
324
+ { label: t("blog:statusDraft"), value: "DRAFT" },
325
+ { label: t("blog:statusArchived"), value: "ARCHIVED" }
326
+ ];
327
+ function convertPostToFormValues(post, languageOptionList, postOptionList, additionalFieldList, statusOptions) {
328
+ var _a, _b, _c;
329
+ if (!post) {
330
+ return {
331
+ title: "",
332
+ excerpt: "",
333
+ body: "",
334
+ datetime: "",
335
+ coverImage: null,
336
+ image: null,
337
+ imageMobile: null,
338
+ pageTitle: "",
339
+ pageDescription: "",
340
+ openGraphImage: null,
341
+ urlAlias: "",
342
+ categories: [],
343
+ language: null,
344
+ relatedPosts: [],
345
+ tags: "",
346
+ additionalFields: additionalFieldList.map(
347
+ (fieldConfig) => universalFieldUtils.createFormField(fieldConfig, null)
348
+ ),
349
+ status: statusOptions[0],
350
+ statusDateEnabled: false,
351
+ statusDate: null
352
+ };
353
+ }
354
+ const currentLangOption = languageOptionList.find(
355
+ (option) => option.value === post.language
356
+ );
357
+ const selectedPostOptionList = postOptionList.filter(
358
+ (option) => post.relatedPosts.some((relatedPost) => relatedPost.id === option.value)
359
+ );
360
+ const foundStatus = (_a = statusOptions.find(({ value }) => value === post.status)) != null ? _a : statusOptions[0];
361
+ return {
362
+ title: post.title,
363
+ excerpt: post.excerpt,
364
+ body: post.body,
365
+ datetime: post.datetime ? post.datetime.substr(0, 10) : "",
366
+ coverImage: post.coverImage ? { id: createId(), file: post.coverImage } : null,
367
+ image: post.image ? { id: createId(), file: post.image } : null,
368
+ imageMobile: post.imageMobile ? { id: createId(), file: post.imageMobile } : null,
369
+ pageTitle: (_b = post.pageTitle) != null ? _b : "",
370
+ pageDescription: (_c = post.pageDescription) != null ? _c : "",
371
+ openGraphImage: post.openGraphImage ? { id: createId(), file: post.openGraphImage } : null,
372
+ urlAlias: post.urlAlias,
373
+ categories: post.categories.map((category) => ({
374
+ value: category.id,
375
+ label: category.name
376
+ })),
377
+ language: currentLangOption != null ? currentLangOption : null,
378
+ relatedPosts: selectedPostOptionList,
379
+ tags: post.tags.join(","),
380
+ additionalFields: additionalFieldList.map((fieldConfig) => {
381
+ const postAdditionalField = post.additionalFields.find(
382
+ ({ name }) => name === fieldConfig.name
383
+ );
384
+ return universalFieldUtils.createFormField(
385
+ fieldConfig,
386
+ postAdditionalField == null ? void 0 : postAdditionalField.value
387
+ );
388
+ }),
389
+ status: foundStatus,
390
+ statusDateEnabled: post.status === "PUBLISHED" ? !!post.archiveAt : post.status === "DRAFT" ? !!post.publishAt : false,
391
+ statusDate: post.status === "PUBLISHED" && post.archiveAt ? post.archiveAt.substr(0, 10) : post.status === "DRAFT" && post.publishAt ? post.publishAt.substr(0, 10) : null
392
+ };
393
+ }
394
+ function convertFormValuesToCreationPayload(values) {
395
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
396
+ return {
397
+ title: values.title,
398
+ excerpt: values.excerpt,
399
+ urlAlias: values.urlAlias,
400
+ body: values.body,
401
+ datetime: values.datetime,
402
+ coverImage: (_b = (_a = values.coverImage) == null ? void 0 : _a.file.id) != null ? _b : null,
403
+ image: (_d = (_c = values.image) == null ? void 0 : _c.file.id) != null ? _d : null,
404
+ imageMobile: (_f = (_e = values.imageMobile) == null ? void 0 : _e.file.id) != null ? _f : null,
405
+ pageTitle: values.pageTitle,
406
+ pageDescription: values.pageDescription,
407
+ openGraphImage: (_h = (_g = values.openGraphImage) == null ? void 0 : _g.file.id) != null ? _h : null,
408
+ categories: values.categories.map((option) => option.value),
409
+ language: (_j = (_i = values.language) == null ? void 0 : _i.value) != null ? _j : null,
410
+ relatedPosts: values.relatedPosts.map(
411
+ (relatedPostOption) => relatedPostOption.value
412
+ ),
413
+ tags: values.tags.split(",").filter((tag) => tag.trim().length > 0),
414
+ additionalFields: values.additionalFields.map((field) => ({
415
+ name: field.config.name,
416
+ value: universalFieldUtils.getOutgoingValue(field)
417
+ })),
418
+ status: values.status.value,
419
+ archiveAt: values.status.value === "PUBLISHED" && values.statusDateEnabled && values.statusDate ? values.statusDate : null,
420
+ publishAt: values.status.value === "DRAFT" && values.statusDateEnabled && values.statusDate ? values.statusDate : null
421
+ };
422
+ }
423
+ function convertFormValuesToUpdatePayload(values) {
424
+ return {
425
+ ...convertFormValuesToCreationPayload(values),
426
+ urlAlias: values.urlAlias
427
+ };
428
+ }
429
+ function convertCategoryListToOptions$1(categoryList, languageId) {
430
+ return categoryList.filter(({ language }) => languageId ? language === languageId : true).map(({ id, name, depth }) => ({
431
+ value: id,
432
+ label: getNameWithDepth(name, depth)
433
+ }));
434
+ }
435
+ function convertPostList(postList, selectedCategory, languages) {
436
+ return postList.filter(
437
+ (post) => selectedCategory ? post.categories.some(({ id }) => id === selectedCategory.id) : true
438
+ ).map((post) => {
439
+ if (languages.length > 0) {
440
+ const foundLanguage = languages.find(({ id }) => id === post.language);
441
+ return {
442
+ ...post,
443
+ language: foundLanguage ? foundLanguage.name : post.language
444
+ };
445
+ }
446
+ return post;
447
+ });
448
+ }
449
+ function getStatuses(t) {
450
+ return {
451
+ PUBLISHED: t("blog:statusPublished"),
452
+ DRAFT: t("blog:statusDraft"),
453
+ ARCHIVED: t("blog:statusArchived")
454
+ };
455
+ }
456
+ function getPostTableColumnDefs(moduleConfig, t) {
457
+ const isLangSpecific = moduleConfig ? moduleConfig.languages.length > 0 : false;
458
+ const COLUMN_DEFS = [
459
+ {
460
+ id: 1,
461
+ name: "ID",
462
+ field: "id",
463
+ style: { width: "50px", textAlign: "center" },
464
+ headStyle: { width: "50px", textAlign: "center" }
465
+ },
466
+ {
467
+ id: 2,
468
+ name: t("blog:status"),
469
+ field: "status",
470
+ style: { width: "140px" },
471
+ headStyle: { width: "140px" }
472
+ },
473
+ {
474
+ id: 3,
475
+ name: t("blog:name"),
476
+ field: "name",
477
+ type: "name",
478
+ format: ({ row }) => ({
479
+ adminLink: {
480
+ text: row.title,
481
+ url: getBlogPostFormUrl({ postId: row.id })
482
+ },
483
+ websiteLink: {
484
+ text: row.url,
485
+ url: [
486
+ {}.VUE_APP_WEBSITE_URL || window.location.origin,
487
+ row.url
488
+ ].join("")
489
+ }
490
+ })
491
+ },
492
+ {
493
+ id: 4,
494
+ name: t("blog:image"),
495
+ field: "image",
496
+ type: "image",
497
+ style: { width: "250px" },
498
+ headStyle: { width: "250px" }
499
+ },
500
+ isLangSpecific ? { id: 5, name: t("blog:language"), field: "language" } : null,
501
+ {
502
+ id: 6,
503
+ name: t("blog:date"),
504
+ field: "datetime",
505
+ type: "datetime",
506
+ options: { ignoreStartOfDayTime: true }
507
+ },
508
+ {
509
+ id: 7,
510
+ name: t("blog:categories"),
511
+ field: "categories",
512
+ format: ({ row }) => row.categories.map((category) => category.name).join(", ")
513
+ },
514
+ {
515
+ id: 8,
516
+ name: t("blog:actions"),
517
+ field: "actions",
518
+ style: { whiteSpace: "nowrap", width: "120px" },
519
+ headStyle: { whiteSpace: "nowrap", width: "120px" }
520
+ }
521
+ ];
522
+ return COLUMN_DEFS.filter(notEmpty);
523
+ }
524
+ const dateFormat = (date) => date.split("-").reverse().join(".");
525
+ function useAdvancedSearch$1({
526
+ t,
527
+ route,
528
+ categoryList,
529
+ languageList,
530
+ statusOptionList
531
+ }) {
532
+ const categoryOptionList = computed(
533
+ () => categoryList.value.map(({ id, name, depth }) => ({
534
+ value: String(id),
535
+ label: getNameWithDepth(name, depth)
536
+ }))
537
+ );
538
+ const initialCategoryFilter = computed(() => {
539
+ const queryValue = getFilterParamAsStringArray(
540
+ route.query,
541
+ "category"
542
+ );
543
+ return categoryOptionList.value.filter(
544
+ ({ value }) => queryValue.some((selected) => selected === value)
545
+ );
546
+ });
547
+ const categoryFilter = ref(initialCategoryFilter.value);
548
+ watch(initialCategoryFilter, () => {
549
+ categoryFilter.value = initialCategoryFilter.value;
550
+ });
551
+ const languageOptionList = computed(
552
+ () => languageList.value.map(({ id, name }) => ({ value: id, label: name }))
553
+ );
554
+ const initialLanguageFilter = computed(() => {
555
+ const queryValue = getFilterParamAsStringArray(
556
+ route.query,
557
+ "language"
558
+ );
559
+ return languageOptionList.value.filter(
560
+ ({ value }) => queryValue.some((selected) => selected === value)
561
+ );
562
+ });
563
+ const languageFilter = ref(initialLanguageFilter.value);
564
+ watch(initialLanguageFilter, () => {
565
+ languageFilter.value = initialLanguageFilter.value;
566
+ });
567
+ const initialFromDateFilter = computed(
568
+ () => {
569
+ var _a;
570
+ return (_a = getFilterParamAsString(route.query, "from-date")) != null ? _a : "";
571
+ }
572
+ );
573
+ const fromDateFilter = ref(initialFromDateFilter.value);
574
+ watch(initialFromDateFilter, () => {
575
+ fromDateFilter.value = initialFromDateFilter.value;
576
+ });
577
+ const initialToDateFilter = computed(
578
+ () => {
579
+ var _a;
580
+ return (_a = getFilterParamAsString(route.query, "to-date")) != null ? _a : "";
581
+ }
582
+ );
583
+ const toDateFilter = ref(initialToDateFilter.value);
584
+ watch(initialToDateFilter, () => {
585
+ toDateFilter.value = initialToDateFilter.value;
586
+ });
587
+ const date = computed(() => {
588
+ if (!fromDateFilter.value && !toDateFilter.value) {
589
+ return null;
590
+ }
591
+ let label = "";
592
+ if (fromDateFilter.value && toDateFilter.value) {
593
+ label = `${dateFormat(fromDateFilter.value)} - ${dateFormat(
594
+ toDateFilter.value
595
+ )}`;
596
+ }
597
+ if (fromDateFilter.value && !toDateFilter.value) {
598
+ label = `${t("blog:from")} ${dateFormat(fromDateFilter.value)}`;
599
+ }
600
+ if (!fromDateFilter.value && toDateFilter.value) {
601
+ label = `${t("blog:to")} ${dateFormat(toDateFilter.value)}`;
602
+ }
603
+ return {
604
+ value: "",
605
+ label,
606
+ name: "from-date",
607
+ title: t("blog:dateOfPublication")
608
+ };
609
+ });
610
+ const initialStatusFilter = computed(() => {
611
+ const queryValue = getFilterParamAsStringArray(
612
+ route.query,
613
+ "status"
614
+ );
615
+ return statusOptionList.value.filter(
616
+ ({ value }) => queryValue.some((selected) => selected === value)
617
+ );
618
+ });
619
+ const statusFilter = ref(initialStatusFilter.value);
620
+ watch(initialStatusFilter, () => {
621
+ statusFilter.value = initialStatusFilter.value;
622
+ });
623
+ const filterParams = computed(() => {
624
+ const filters = {
625
+ ["category"]: categoryFilter.value.map(({ value }) => value),
626
+ ["language"]: languageFilter.value.map(({ value }) => value),
627
+ ["status"]: statusFilter.value.map(({ value }) => value)
628
+ };
629
+ if (fromDateFilter.value) {
630
+ filters["from-date"] = fromDateFilter.value;
631
+ }
632
+ if (toDateFilter.value) {
633
+ filters["to-date"] = toDateFilter.value;
634
+ }
635
+ return getFilterParams(filters);
636
+ });
637
+ function tagRemovalHandler(event) {
638
+ if (event.name === "category") {
639
+ categoryFilter.value = categoryFilter.value.filter(
640
+ ({ value }) => value !== event.value
641
+ );
642
+ }
643
+ if (event.name === "language") {
644
+ languageFilter.value = languageFilter.value.filter(
645
+ ({ value }) => value !== event.value
646
+ );
647
+ }
648
+ if (event.name === "from-date") {
649
+ fromDateFilter.value = "";
650
+ toDateFilter.value = "";
651
+ }
652
+ if (event.name === "status") {
653
+ statusFilter.value = statusFilter.value.filter(
654
+ ({ value }) => value !== event.value
655
+ );
656
+ }
657
+ }
658
+ const tags = computed(
659
+ () => [
660
+ ...categoryFilter.value.map(({ value, label }) => ({
661
+ value,
662
+ label,
663
+ name: "category",
664
+ title: t("blog:category")
665
+ })),
666
+ ...languageFilter.value.map(({ value, label }) => ({
667
+ value,
668
+ label,
669
+ name: "language",
670
+ title: t("blog:language")
671
+ })),
672
+ date.value,
673
+ ...statusFilter.value.map(({ value, label }) => ({
674
+ value,
675
+ label,
676
+ name: "status",
677
+ title: t("blog:status")
678
+ }))
679
+ ].filter(isNotNullish)
680
+ );
681
+ const selectedCategoryOptionList = computed(() => {
682
+ if (languageFilter.value.length === 0) {
683
+ return categoryOptionList.value;
684
+ }
685
+ const selectedList = categoryList.value.filter(
686
+ ({ language }) => languageFilter.value.some(({ value }) => value === language)
687
+ );
688
+ return selectedList.map(({ id, name, depth }) => ({
689
+ value: String(id),
690
+ label: getNameWithDepth(name, depth)
691
+ }));
692
+ });
693
+ return {
694
+ categoryFilter,
695
+ categoryOptionList: selectedCategoryOptionList,
696
+ languageFilter,
697
+ languageOptionList,
698
+ fromDateFilter,
699
+ toDateFilter,
700
+ statusFilter,
701
+ tagRemovalHandler,
702
+ tags,
703
+ filterParams
704
+ };
705
+ }
706
+ var PostList_vue_vue_type_style_index_0_scoped_true_lang = "";
707
+ var _export_sfc = (sfc, props) => {
708
+ const target = sfc.__vccOpts || sfc;
709
+ for (const [key, val] of props) {
710
+ target[key] = val;
711
+ }
712
+ return target;
713
+ };
714
+ const _sfc_main$3 = defineComponent({
715
+ name: "PostList",
716
+ components: {
717
+ DeleteIcon,
718
+ ContentCopyIcon,
719
+ EditIcon,
720
+ BaseButton,
721
+ FormField,
722
+ FormFieldMultiSelect,
723
+ AdvancedSearch,
724
+ Page,
725
+ DataTable
726
+ },
727
+ setup() {
728
+ const { t } = useI18n();
729
+ const route = useRoute();
730
+ const router = useRouter();
731
+ const categoryId = computed(() => {
732
+ var _a;
733
+ return Array.isArray(route.query.category) ? (_a = route.query.category[0]) != null ? _a : "" : route.query.category;
734
+ });
735
+ const statusOptionList = computed(() => getStatusOptions(t));
736
+ const { data: moduleConfig, loading: isModuleConfigLoading } = useFetchModuleConfig();
737
+ const languageList = computed(
738
+ () => {
739
+ var _a, _b;
740
+ return (_b = (_a = moduleConfig.value) == null ? void 0 : _a.languages) != null ? _b : [];
741
+ }
742
+ );
743
+ const { data: categoryList, loading: isCategoryListLoading } = useFetchCategories();
744
+ const selectedCategory = computed(
745
+ () => {
746
+ var _a;
747
+ return categoryId.value ? (_a = categoryList.value.find(
748
+ ({ id }) => String(id) === String(categoryId.value)
749
+ )) != null ? _a : null : null;
750
+ }
751
+ );
752
+ const pageTitle = computed(() => {
753
+ return selectedCategory.value ? `${t("blog:postsByCategory")} "${selectedCategory.value.name}"` : t("blog:posts");
754
+ });
755
+ const isLangSpecific = computed(
756
+ () => languageOptionList.value.length > 1
757
+ );
758
+ const {
759
+ categoryFilter,
760
+ categoryOptionList,
761
+ languageFilter,
762
+ languageOptionList,
763
+ fromDateFilter,
764
+ toDateFilter,
765
+ filterParams,
766
+ tags,
767
+ tagRemovalHandler,
768
+ statusFilter
769
+ } = useAdvancedSearch$1({
770
+ t,
771
+ route,
772
+ categoryList,
773
+ languageList,
774
+ statusOptionList
775
+ });
776
+ const {
777
+ fetchEntityList: fetchPostList,
778
+ isLoading: isPostLoading,
779
+ rowData: postList,
780
+ errorMessage,
781
+ searchQuery,
782
+ handleChange,
783
+ pageNumber,
784
+ pageCount,
785
+ pageSize
786
+ } = useDataTable({
787
+ fetchEntityList: (params) => getPosts({
788
+ query: params.searchQuery,
789
+ pageNumber: params.pageNumber,
790
+ pageSize: params.pageSize,
791
+ ...filterParams.value
792
+ }),
793
+ initialValue: [],
794
+ resourceName: "Blog post list",
795
+ pageSize: 100
796
+ });
797
+ watch(filterParams, () => {
798
+ if (isModuleConfigLoading.value || isCategoryListLoading.value) {
799
+ return;
800
+ }
801
+ const newQuery = {
802
+ ...pick(route.query, ["query", "pageNumber"]),
803
+ ...filterParams.value
804
+ };
805
+ if (!isEqual(route.query, newQuery)) {
806
+ router.replace({ query: newQuery });
807
+ fetchPostList();
808
+ }
809
+ });
810
+ const displayedPostList = computed(
811
+ () => {
812
+ var _a, _b;
813
+ return convertPostList(
814
+ postList.value,
815
+ selectedCategory.value,
816
+ (_b = (_a = moduleConfig.value) == null ? void 0 : _a.languages) != null ? _b : []
817
+ );
818
+ }
819
+ );
820
+ const isRowDataLoading = computed(
821
+ () => isCategoryListLoading.value || isPostLoading.value || isModuleConfigLoading.value
822
+ );
823
+ const { isDeleting, handleResourceDelete } = useResourceDelete({
824
+ deleteResource: deleteBlogPost,
825
+ resourceName: "Post",
826
+ onSuccess: fetchPostList
827
+ });
828
+ const { isCloning, handleResourceClone } = useResourceClone({
829
+ cloneResource: clonePost,
830
+ confirmMessage: t("blog:cloneConfirm"),
831
+ successMessage: t("blog:cloneSuccess"),
832
+ failureMessage: t("blog:cloneFailure"),
833
+ onSuccessRedirectTo: (data) => `/blog/posts/${data.id}`
834
+ });
835
+ function isBusy(postId) {
836
+ return isDeleting(postId) || isCloning(postId) || isRowDataLoading.value;
837
+ }
838
+ const columnDefs = computed(
839
+ () => getPostTableColumnDefs(moduleConfig.value, t)
840
+ );
841
+ return {
842
+ t,
843
+ formatDateTime,
844
+ columnDefs,
845
+ rowData: displayedPostList,
846
+ handleResourceDelete,
847
+ isDeleting,
848
+ categoryList,
849
+ isRowDataLoading,
850
+ errorMessage,
851
+ getBlogPostFormUrl,
852
+ pageTitle,
853
+ searchQuery,
854
+ handleChange,
855
+ pageNumber,
856
+ pageCount,
857
+ pageSize,
858
+ categoryFilter,
859
+ categoryOptionList,
860
+ isLangSpecific,
861
+ languageFilter,
862
+ languageOptionList,
863
+ fromDateFilter,
864
+ toDateFilter,
865
+ statusFilter,
866
+ statusOptionList,
867
+ tags,
868
+ tagRemovalHandler,
869
+ getStatuses,
870
+ handleResourceClone,
871
+ isBusy
872
+ };
873
+ }
874
+ });
875
+ const _hoisted_1$2 = { class: "filters" };
876
+ const _hoisted_2$1 = { class: "filters" };
877
+ const _hoisted_3$1 = { class: "status" };
878
+ const _hoisted_4$1 = { key: 0 };
879
+ const _hoisted_5 = { key: 1 };
880
+ function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
881
+ const _component_FormFieldMultiSelect = resolveComponent("FormFieldMultiSelect");
882
+ const _component_FormField = resolveComponent("FormField");
883
+ const _component_AdvancedSearch = resolveComponent("AdvancedSearch");
884
+ const _component_EditIcon = resolveComponent("EditIcon");
885
+ const _component_BaseButton = resolveComponent("BaseButton");
886
+ const _component_ContentCopyIcon = resolveComponent("ContentCopyIcon");
887
+ const _component_DeleteIcon = resolveComponent("DeleteIcon");
888
+ const _component_DataTable = resolveComponent("DataTable");
889
+ const _component_Page = resolveComponent("Page");
890
+ return openBlock(), createBlock(_component_Page, {
891
+ title: _ctx.pageTitle,
892
+ "header-buttons": [
893
+ {
894
+ text: _ctx.$i18n.t("blog:newPost"),
895
+ href: _ctx.getBlogPostFormUrl({ postId: "create" })
896
+ }
897
+ ]
898
+ }, {
899
+ content: withCtx(() => [
900
+ createVNode(_component_DataTable, {
901
+ "column-defs": _ctx.columnDefs,
902
+ "row-data": _ctx.rowData,
903
+ loading: _ctx.isRowDataLoading,
904
+ "error-message": _ctx.errorMessage,
905
+ "search-query": _ctx.searchQuery,
906
+ pagination: {
907
+ pageNumber: _ctx.pageNumber,
908
+ pageCount: _ctx.pageCount,
909
+ pageSize: _ctx.pageSize,
910
+ disabled: _ctx.isRowDataLoading
911
+ },
912
+ "data-table": "blog-post",
913
+ onChange: _ctx.handleChange
914
+ }, {
915
+ filters: withCtx(() => [
916
+ createVNode(_component_AdvancedSearch, {
917
+ tags: _ctx.tags,
918
+ "onClick:tag": _ctx.tagRemovalHandler
919
+ }, {
920
+ default: withCtx(() => [
921
+ createElementVNode("div", _hoisted_1$2, [
922
+ createVNode(_component_FormFieldMultiSelect, {
923
+ "selected-options": _ctx.categoryFilter,
924
+ "onUpdate:selected-options": _cache[0] || (_cache[0] = ($event) => _ctx.categoryFilter = $event),
925
+ options: _ctx.categoryOptionList,
926
+ name: "categoryFilter",
927
+ searchable: true,
928
+ label: _ctx.$i18n.t("blog:category"),
929
+ class: "filter"
930
+ }, null, 8, ["selected-options", "options", "label"]),
931
+ _ctx.isLangSpecific ? (openBlock(), createBlock(_component_FormFieldMultiSelect, {
932
+ key: 0,
933
+ "selected-options": _ctx.languageFilter,
934
+ "onUpdate:selected-options": _cache[1] || (_cache[1] = ($event) => _ctx.languageFilter = $event),
935
+ options: _ctx.languageOptionList,
936
+ name: "languageFilter",
937
+ searchable: true,
938
+ label: _ctx.$i18n.t("blog:language"),
939
+ class: "filter"
940
+ }, null, 8, ["selected-options", "options", "label"])) : createCommentVNode("", true),
941
+ createVNode(_component_FormFieldMultiSelect, {
942
+ "selected-options": _ctx.statusFilter,
943
+ "onUpdate:selected-options": _cache[2] || (_cache[2] = ($event) => _ctx.statusFilter = $event),
944
+ options: _ctx.statusOptionList,
945
+ name: "statusFilter",
946
+ searchable: true,
947
+ label: _ctx.$i18n.t("blog:status"),
948
+ class: "filter"
949
+ }, null, 8, ["selected-options", "options", "label"])
950
+ ]),
951
+ createElementVNode("div", _hoisted_2$1, [
952
+ createVNode(_component_FormField, {
953
+ value: _ctx.fromDateFilter,
954
+ "onUpdate:value": _cache[3] || (_cache[3] = ($event) => _ctx.fromDateFilter = $event),
955
+ label: _ctx.$i18n.t("blog:dateOfPublicationFrom"),
956
+ name: "fromDateFilter",
957
+ type: "date",
958
+ max: _ctx.toDateFilter
959
+ }, null, 8, ["value", "label", "max"]),
960
+ createVNode(_component_FormField, {
961
+ value: _ctx.toDateFilter,
962
+ "onUpdate:value": _cache[4] || (_cache[4] = ($event) => _ctx.toDateFilter = $event),
963
+ label: _ctx.$i18n.t("blog:dateOfPublicationTo"),
964
+ name: "toDateFilter",
965
+ type: "date",
966
+ min: _ctx.fromDateFilter
967
+ }, null, 8, ["value", "label", "min"])
968
+ ])
969
+ ]),
970
+ _: 1
971
+ }, 8, ["tags", "onClick:tag"])
972
+ ]),
973
+ "cell(status)": withCtx(({ row }) => [
974
+ createElementVNode("div", _hoisted_3$1, [
975
+ createElementVNode("span", null, toDisplayString(_ctx.getStatuses(_ctx.$i18n.t)[row.status]), 1),
976
+ row.status === "PUBLISHED" && row.archiveAt ? (openBlock(), createElementBlock("span", _hoisted_4$1, [
977
+ createTextVNode(toDisplayString(_ctx.$i18n.t("blog:archiveAtLabel")) + ": ", 1),
978
+ createElementVNode("i", null, toDisplayString(_ctx.formatDateTime(new Date(row.archiveAt), true)), 1)
979
+ ])) : createCommentVNode("", true),
980
+ row.status === "DRAFT" && row.publishAt ? (openBlock(), createElementBlock("span", _hoisted_5, [
981
+ createTextVNode(toDisplayString(_ctx.$i18n.t("blog:publishAtLabel")) + ": ", 1),
982
+ createElementVNode("i", null, toDisplayString(_ctx.formatDateTime(new Date(row.publishAt), true)), 1)
983
+ ])) : createCommentVNode("", true)
984
+ ])
985
+ ]),
986
+ "cell(actions)": withCtx(({ row }) => [
987
+ createVNode(_component_BaseButton, {
988
+ variant: "icon",
989
+ title: _ctx.$i18n.t("blog:edit"),
990
+ disabled: _ctx.isBusy(row.id),
991
+ href: _ctx.getBlogPostFormUrl({ postId: row.id })
992
+ }, {
993
+ default: withCtx(() => [
994
+ createVNode(_component_EditIcon)
995
+ ]),
996
+ _: 2
997
+ }, 1032, ["title", "disabled", "href"]),
998
+ createVNode(_component_BaseButton, {
999
+ variant: "icon",
1000
+ title: _ctx.$i18n.t("blog:clone"),
1001
+ disabled: _ctx.isBusy(row.id),
1002
+ onClick: ($event) => _ctx.handleResourceClone(row.id)
1003
+ }, {
1004
+ default: withCtx(() => [
1005
+ createVNode(_component_ContentCopyIcon)
1006
+ ]),
1007
+ _: 2
1008
+ }, 1032, ["title", "disabled", "onClick"]),
1009
+ createVNode(_component_BaseButton, {
1010
+ variant: "icon",
1011
+ title: _ctx.$i18n.t("blog:remove"),
1012
+ disabled: _ctx.isBusy(row.id),
1013
+ onClick: ($event) => _ctx.handleResourceDelete(row.id)
1014
+ }, {
1015
+ default: withCtx(() => [
1016
+ createVNode(_component_DeleteIcon)
1017
+ ]),
1018
+ _: 2
1019
+ }, 1032, ["title", "disabled", "onClick"])
1020
+ ]),
1021
+ _: 1
1022
+ }, 8, ["column-defs", "row-data", "loading", "error-message", "search-query", "pagination", "onChange"])
1023
+ ]),
1024
+ _: 1
1025
+ }, 8, ["title", "header-buttons"]);
1026
+ }
1027
+ var BlogPostList = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$3], ["__scopeId", "data-v-2ee9b750"]]);
1028
+ var PostForm_vue_vue_type_style_index_0_scoped_true_lang = "";
1029
+ const _sfc_main$2 = defineComponent({
1030
+ name: "BlogPostForm",
1031
+ components: {
1032
+ SeoFieldGroup,
1033
+ FormFieldMultiSelect,
1034
+ FormFieldFileInput,
1035
+ FormFieldRichTextInput,
1036
+ FormFieldCheckbox,
1037
+ FormFieldUrlAliasInput,
1038
+ FormField,
1039
+ FormFieldSelect,
1040
+ TabList,
1041
+ Page,
1042
+ DynamicField,
1043
+ ShortCodeConstructor,
1044
+ FormFooter
1045
+ },
1046
+ setup() {
1047
+ var _a, _b;
1048
+ const route = useRoute();
1049
+ const router = useRouter();
1050
+ const toast = useToast();
1051
+ const { t } = useI18n();
1052
+ const postId = computed(() => route.params.postId);
1053
+ const isCreation = computed(() => postId.value === "create");
1054
+ const urlAliasChanged = ref(false);
1055
+ const statusOptions = computed(() => getStatusOptions(t));
1056
+ const { data: moduleConfig, loading: isModuleConfigLoading } = useFetchModuleConfig();
1057
+ const languageList = computed(
1058
+ () => {
1059
+ var _a2, _b2;
1060
+ return (_b2 = (_a2 = moduleConfig.value) == null ? void 0 : _a2.languages) != null ? _b2 : [];
1061
+ }
1062
+ );
1063
+ const languageOptionList = computed(
1064
+ () => languageList.value.map(({ id, name }) => ({
1065
+ value: id,
1066
+ label: name
1067
+ }))
1068
+ );
1069
+ const isLangSpecific = computed(() => languageOptionList.value.length > 0);
1070
+ const { data: categoryList, loading: isCategoryListLoading } = useFetchCategories();
1071
+ const [fetchPost, { data: post, loading: isPostLoading }] = useResource({
1072
+ fetchResource: () => postId.value ? getPost(postId.value) : new Promise(() => null),
1073
+ initialValue: null,
1074
+ resourceName: "Post"
1075
+ });
1076
+ onMounted(() => {
1077
+ if (isCreation.value)
1078
+ return;
1079
+ fetchPost();
1080
+ });
1081
+ watch(postId, () => {
1082
+ if (isCreation.value)
1083
+ return;
1084
+ fetchPost();
1085
+ });
1086
+ const { data: postList, loading: isPostListLoading } = useFetchPosts();
1087
+ const postOptionList = computed(
1088
+ () => postList.value.filter((relatedPost) => {
1089
+ var _a2;
1090
+ return relatedPost.id !== ((_a2 = post.value) == null ? void 0 : _a2.id);
1091
+ }).map((post2) => ({
1092
+ value: post2.id,
1093
+ label: post2.title
1094
+ }))
1095
+ );
1096
+ const isSubmitting = ref(false);
1097
+ const values = ref(
1098
+ convertPostToFormValues(
1099
+ post.value,
1100
+ languageOptionList.value,
1101
+ postOptionList.value,
1102
+ (_b = (_a = moduleConfig.value) == null ? void 0 : _a.fields) != null ? _b : [],
1103
+ statusOptions.value
1104
+ )
1105
+ );
1106
+ const errors = ref({});
1107
+ watch([post, languageOptionList, postOptionList, moduleConfig], () => {
1108
+ var _a2, _b2;
1109
+ values.value = convertPostToFormValues(
1110
+ post.value,
1111
+ languageOptionList.value,
1112
+ postOptionList.value,
1113
+ (_b2 = (_a2 = moduleConfig.value) == null ? void 0 : _a2.fields) != null ? _b2 : [],
1114
+ statusOptions.value
1115
+ );
1116
+ });
1117
+ function submitForm(event) {
1118
+ isSubmitting.value = true;
1119
+ const creationBody = convertFormValuesToCreationPayload(values.value);
1120
+ const updateBody = convertFormValuesToUpdatePayload(values.value);
1121
+ const requestPromise = isCreation.value ? createBlogPost(creationBody) : updateBlogPost(postId.value, updateBody);
1122
+ requestPromise.then(({ data }) => {
1123
+ var _a2, _b2;
1124
+ errors.value = {};
1125
+ if (event.type === "create") {
1126
+ router.push(getBlogPostFormUrl({ postId: String(data.id) }));
1127
+ }
1128
+ if (event.type === "create_exit" || event.type === "save_exit") {
1129
+ navigateBack(router, getBlogPostListUrl());
1130
+ }
1131
+ if (event.type === "create_create-another") {
1132
+ values.value = convertPostToFormValues(
1133
+ null,
1134
+ languageOptionList.value,
1135
+ postOptionList.value,
1136
+ (_b2 = (_a2 = moduleConfig.value) == null ? void 0 : _a2.fields) != null ? _b2 : [],
1137
+ statusOptions.value
1138
+ );
1139
+ }
1140
+ toast.show({
1141
+ variant: "success",
1142
+ title: t("blog:success"),
1143
+ body: isCreation.value ? t("blog:blogPostWasSuccessfullyCreated") : t("blog:blogPostWasSuccessfullyUpdated")
1144
+ });
1145
+ }).catch((error) => {
1146
+ console.error(error);
1147
+ errors.value = convertRequestErrorToMap(error);
1148
+ toast.show({
1149
+ variant: "danger",
1150
+ title: t("blog:error"),
1151
+ body: isCreation.value ? t("blog:blogPostCreationWasFailed") : t("blog:blogPostUpdateWasFailed")
1152
+ });
1153
+ }).finally(() => {
1154
+ isSubmitting.value = false;
1155
+ });
1156
+ }
1157
+ const categoryOptionList = computed(
1158
+ () => {
1159
+ var _a2, _b2;
1160
+ return convertCategoryListToOptions$1(
1161
+ categoryList.value,
1162
+ (_b2 = (_a2 = values.value.language) == null ? void 0 : _a2.value) != null ? _b2 : null
1163
+ );
1164
+ }
1165
+ );
1166
+ watch([categoryOptionList, moduleConfig], () => {
1167
+ var _a2;
1168
+ function isOptionExist(selectedCategoryOption) {
1169
+ return categoryOptionList.value.some(
1170
+ (option) => option.value === selectedCategoryOption.value
1171
+ );
1172
+ }
1173
+ if (isCreation.value) {
1174
+ if ((_a2 = moduleConfig == null ? void 0 : moduleConfig.value) == null ? void 0 : _a2.defaultCategories) {
1175
+ const defaultIds = moduleConfig.value.defaultCategories.map(
1176
+ (item) => item.id
1177
+ );
1178
+ values.value.categories = categoryOptionList.value.filter(
1179
+ (item) => {
1180
+ return defaultIds.indexOf(item.value) !== -1;
1181
+ }
1182
+ );
1183
+ }
1184
+ }
1185
+ values.value.categories = values.value.categories.filter(isOptionExist);
1186
+ });
1187
+ const isContentLoading = computed(
1188
+ () => isPostLoading.value || isCategoryListLoading.value || isPostListLoading.value || isModuleConfigLoading.value
1189
+ );
1190
+ function getUploadAdapterOptions() {
1191
+ var _a2;
1192
+ return { uploadScenario: (_a2 = moduleConfig.value) == null ? void 0 : _a2.fileScenarios.content };
1193
+ }
1194
+ const blogPagePath = computed(() => {
1195
+ var _a2, _b2;
1196
+ const origin = {}.VUE_APP_WEBSITE_URL || window.location.origin;
1197
+ return origin + ((_b2 = (_a2 = post.value) == null ? void 0 : _a2.urlTemplate) != null ? _b2 : "");
1198
+ });
1199
+ const tabList = computed(() => {
1200
+ const hasErrors = createTabErrorFinder(errors.value);
1201
+ return [
1202
+ {
1203
+ id: "common",
1204
+ label: t("blog:common"),
1205
+ hasErrors: hasErrors([
1206
+ "title",
1207
+ "language",
1208
+ "urlAlias",
1209
+ "excerpt",
1210
+ "body",
1211
+ "date"
1212
+ ])
1213
+ },
1214
+ {
1215
+ id: "images",
1216
+ label: t("blog:images"),
1217
+ hasErrors: hasErrors(["coverImage", "image"])
1218
+ },
1219
+ {
1220
+ id: "relations",
1221
+ label: t("blog:relations"),
1222
+ hasErrors: hasErrors(["categories", "relatedPosts", "tags"])
1223
+ },
1224
+ values.value.additionalFields.length > 0 ? {
1225
+ id: "additional",
1226
+ label: t("blog:additionalFields"),
1227
+ hasErrors: hasErrors([])
1228
+ } : null,
1229
+ {
1230
+ id: "seo",
1231
+ label: "SEO",
1232
+ hasErrors: hasErrors([
1233
+ "pageTitle",
1234
+ "pageDescription",
1235
+ "openGraphImage"
1236
+ ])
1237
+ }
1238
+ ].filter(isNotNullish);
1239
+ });
1240
+ const selectedTabId = ref(tabList.value[0].id);
1241
+ const headerButtonList = computed(
1242
+ () => [
1243
+ post.value ? {
1244
+ text: t("blog:viewPost"),
1245
+ href: {}.VUE_APP_WEBSITE_URL + post.value.url,
1246
+ target: "_blank"
1247
+ } : null
1248
+ ].filter(isNotNullish)
1249
+ );
1250
+ function handleSeoFieldGroupChange({
1251
+ title,
1252
+ description,
1253
+ image
1254
+ }) {
1255
+ values.value.pageTitle = title;
1256
+ values.value.pageDescription = description;
1257
+ values.value.openGraphImage = image;
1258
+ }
1259
+ function handleTitleChange(value) {
1260
+ if (isCreation.value && urlAliasChanged.value === false) {
1261
+ values.value.urlAlias = urlTranslit(value);
1262
+ }
1263
+ }
1264
+ function handleAliasChange() {
1265
+ urlAliasChanged.value = true;
1266
+ }
1267
+ const urlAliasTemplate = computed(() => {
1268
+ if (!moduleConfig.value || !moduleConfig.value.urlPostTemplate) {
1269
+ return "";
1270
+ }
1271
+ let result = moduleConfig.value.urlPostTemplate;
1272
+ if (values.value.language) {
1273
+ result = result.replace("{language}", values.value.language.value);
1274
+ }
1275
+ if (postId.value !== "create") {
1276
+ result = result.replace("{id}", postId.value);
1277
+ }
1278
+ return result;
1279
+ });
1280
+ const handleCategoriesChange = (selectedOptions) => {
1281
+ const newSelectedOptions = [];
1282
+ selectedOptions.forEach((selectedOption) => {
1283
+ const findTreeSelectedCategory = (categoryId) => {
1284
+ const foundSelectedCategory = categoryList.value.find(
1285
+ ({ id }) => id === categoryId
1286
+ );
1287
+ if (!foundSelectedCategory) {
1288
+ return;
1289
+ }
1290
+ const newSelectedOption = {
1291
+ value: foundSelectedCategory.id,
1292
+ label: foundSelectedCategory.name
1293
+ };
1294
+ if (!newSelectedOptions.some(
1295
+ ({ value }) => value === newSelectedOption.value
1296
+ )) {
1297
+ newSelectedOptions.push(newSelectedOption);
1298
+ }
1299
+ if (foundSelectedCategory.parent) {
1300
+ findTreeSelectedCategory(foundSelectedCategory.parent.id);
1301
+ }
1302
+ };
1303
+ findTreeSelectedCategory(selectedOption.value);
1304
+ });
1305
+ values.value.categories = newSelectedOptions;
1306
+ };
1307
+ return {
1308
+ isCreation,
1309
+ postId,
1310
+ pagePath: blogPagePath,
1311
+ categoryOptionList,
1312
+ values,
1313
+ errors,
1314
+ isContentLoading,
1315
+ postListUrl: getBlogPostListUrl(),
1316
+ submitForm,
1317
+ isLangSpecific,
1318
+ languageOptionList,
1319
+ isSubmitting,
1320
+ moduleConfig,
1321
+ postOptionList,
1322
+ getUploadAdapterOptions,
1323
+ tabList,
1324
+ selectedTabId,
1325
+ headerButtonList,
1326
+ handleSeoFieldGroupChange,
1327
+ handleTitleChange,
1328
+ handleAliasChange,
1329
+ urlAliasTemplate,
1330
+ handleCategoriesChange,
1331
+ statusOptions
1332
+ };
1333
+ }
1334
+ });
1335
+ const _hoisted_1$1 = { class: "status" };
1336
+ const _hoisted_2 = { class: "status-value" };
1337
+ const _hoisted_3 = {
1338
+ key: 0,
1339
+ class: "status-checkbox"
1340
+ };
1341
+ const _hoisted_4 = {
1342
+ key: 1,
1343
+ class: "status-date"
1344
+ };
1345
+ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
1346
+ const _component_TabList = resolveComponent("TabList");
1347
+ const _component_FormFieldSelect = resolveComponent("FormFieldSelect");
1348
+ const _component_FormField = resolveComponent("FormField");
1349
+ const _component_FormFieldUrlAliasInput = resolveComponent("FormFieldUrlAliasInput");
1350
+ const _component_FormFieldCheckbox = resolveComponent("FormFieldCheckbox");
1351
+ const _component_FormFieldRichTextInput = resolveComponent("FormFieldRichTextInput");
1352
+ const _component_ShortCodeConstructor = resolveComponent("ShortCodeConstructor");
1353
+ const _component_FormFieldFileInput = resolveComponent("FormFieldFileInput");
1354
+ const _component_FormFieldMultiSelect = resolveComponent("FormFieldMultiSelect");
1355
+ const _component_DynamicField = resolveComponent("DynamicField");
1356
+ const _component_SeoFieldGroup = resolveComponent("SeoFieldGroup");
1357
+ const _component_FormFooter = resolveComponent("FormFooter");
1358
+ const _component_Page = resolveComponent("Page");
1359
+ return openBlock(), createBlock(_component_Page, {
1360
+ title: _ctx.isCreation ? _ctx.$i18n.t("blog:createPost") : _ctx.$i18n.t("blog:updatePost"),
1361
+ "is-content-loading": _ctx.isContentLoading,
1362
+ "header-buttons": _ctx.headerButtonList,
1363
+ footer: {
1364
+ backHref: _ctx.postListUrl,
1365
+ onSubmit: _ctx.submitForm,
1366
+ isSubmitting: _ctx.isSubmitting
1367
+ }
1368
+ }, {
1369
+ content: withCtx(() => [
1370
+ createElementVNode("form", {
1371
+ novalidate: "",
1372
+ onSubmit: _cache[16] || (_cache[16] = withModifiers((...args) => _ctx.submitForm && _ctx.submitForm(...args), ["prevent"]))
1373
+ }, [
1374
+ createVNode(_component_TabList, {
1375
+ "tab-id": _ctx.selectedTabId,
1376
+ "onUpdate:tab-id": _cache[0] || (_cache[0] = ($event) => _ctx.selectedTabId = $event),
1377
+ "tab-list": _ctx.tabList
1378
+ }, null, 8, ["tab-id", "tab-list"]),
1379
+ _ctx.selectedTabId === "common" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
1380
+ _ctx.isCreation && _ctx.isLangSpecific ? (openBlock(), createBlock(_component_FormFieldSelect, {
1381
+ key: 0,
1382
+ value: _ctx.values.language,
1383
+ "onUpdate:value": _cache[1] || (_cache[1] = ($event) => _ctx.values.language = $event),
1384
+ name: "language",
1385
+ label: _ctx.$i18n.t("blog:language"),
1386
+ options: _ctx.languageOptionList,
1387
+ error: _ctx.errors.language
1388
+ }, null, 8, ["value", "label", "options", "error"])) : createCommentVNode("", true),
1389
+ createVNode(_component_FormField, {
1390
+ value: _ctx.values.title,
1391
+ "onUpdate:value": _cache[2] || (_cache[2] = ($event) => _ctx.values.title = $event),
1392
+ name: "title",
1393
+ label: _ctx.$i18n.t("blog:title"),
1394
+ error: _ctx.errors.title,
1395
+ onInput: _ctx.handleTitleChange
1396
+ }, null, 8, ["value", "label", "error", "onInput"]),
1397
+ createVNode(_component_FormFieldUrlAliasInput, {
1398
+ id: "urlAlias",
1399
+ value: _ctx.values.urlAlias,
1400
+ "onUpdate:value": _cache[3] || (_cache[3] = ($event) => _ctx.values.urlAlias = $event),
1401
+ name: "urlAlias",
1402
+ label: _ctx.$i18n.t("blog:link"),
1403
+ "url-template": _ctx.urlAliasTemplate,
1404
+ error: _ctx.errors.urlAlias,
1405
+ onChange: _ctx.handleAliasChange
1406
+ }, null, 8, ["value", "label", "url-template", "error", "onChange"]),
1407
+ createElementVNode("div", _hoisted_1$1, [
1408
+ createElementVNode("div", _hoisted_2, [
1409
+ createVNode(_component_FormFieldSelect, {
1410
+ value: _ctx.values.status,
1411
+ "onUpdate:value": _cache[4] || (_cache[4] = ($event) => _ctx.values.status = $event),
1412
+ name: "status",
1413
+ error: _ctx.errors.status,
1414
+ label: _ctx.$i18n.t("blog:status"),
1415
+ "no-options-message": _ctx.$i18n.t("blog:noTemplates"),
1416
+ options: _ctx.statusOptions
1417
+ }, null, 8, ["value", "error", "label", "no-options-message", "options"])
1418
+ ]),
1419
+ _ctx.values.status.value === "PUBLISHED" || _ctx.values.status.value === "DRAFT" ? (openBlock(), createElementBlock("div", _hoisted_3, [
1420
+ createVNode(_component_FormFieldCheckbox, {
1421
+ checked: _ctx.values.statusDateEnabled,
1422
+ "onUpdate:checked": _cache[5] || (_cache[5] = ($event) => _ctx.values.statusDateEnabled = $event),
1423
+ name: "statusDateEnabled",
1424
+ label: _ctx.$i18n.t(
1425
+ _ctx.values.status.value === "PUBLISHED" ? "blog:scheduleArchive" : "blog:schedulePublish"
1426
+ ),
1427
+ error: _ctx.errors.status
1428
+ }, null, 8, ["checked", "label", "error"])
1429
+ ])) : createCommentVNode("", true),
1430
+ _ctx.values.statusDateEnabled && (_ctx.values.status.value === "PUBLISHED" || _ctx.values.status.value === "DRAFT") ? (openBlock(), createElementBlock("div", _hoisted_4, [
1431
+ createVNode(_component_FormField, {
1432
+ value: _ctx.values.statusDate,
1433
+ "onUpdate:value": _cache[6] || (_cache[6] = ($event) => _ctx.values.statusDate = $event),
1434
+ name: "statusDate",
1435
+ type: "date",
1436
+ label: _ctx.$i18n.t(
1437
+ _ctx.values.status.value === "PUBLISHED" ? "blog:archiveAt" : "blog:publishAt"
1438
+ ),
1439
+ error: _ctx.errors.statusDate
1440
+ }, null, 8, ["value", "label", "error"])
1441
+ ])) : createCommentVNode("", true)
1442
+ ]),
1443
+ createVNode(_component_FormField, {
1444
+ value: _ctx.values.datetime,
1445
+ "onUpdate:value": _cache[7] || (_cache[7] = ($event) => _ctx.values.datetime = $event),
1446
+ name: "datetime",
1447
+ label: _ctx.$i18n.t("blog:date"),
1448
+ type: "date",
1449
+ error: _ctx.errors.datetime
1450
+ }, null, 8, ["value", "label", "error"]),
1451
+ createVNode(_component_FormField, {
1452
+ value: _ctx.values.excerpt,
1453
+ "onUpdate:value": _cache[8] || (_cache[8] = ($event) => _ctx.values.excerpt = $event),
1454
+ name: "excerpt",
1455
+ label: _ctx.$i18n.t("blog:excerpt"),
1456
+ type: "textarea",
1457
+ error: _ctx.errors.excerpt
1458
+ }, null, 8, ["value", "label", "error"]),
1459
+ createVNode(_component_FormFieldRichTextInput, {
1460
+ value: _ctx.values.body,
1461
+ "onUpdate:value": _cache[9] || (_cache[9] = ($event) => _ctx.values.body = $event),
1462
+ name: "body",
1463
+ label: _ctx.$i18n.t("blog:body"),
1464
+ error: _ctx.errors.body,
1465
+ "get-upload-adapter-options": _ctx.getUploadAdapterOptions
1466
+ }, null, 8, ["value", "label", "error", "get-upload-adapter-options"]),
1467
+ createVNode(_component_ShortCodeConstructor, {
1468
+ "short-code-config-list": _ctx.moduleConfig ? _ctx.moduleConfig.shortcodes : []
1469
+ }, null, 8, ["short-code-config-list"])
1470
+ ], 64)) : createCommentVNode("", true),
1471
+ _ctx.selectedTabId === "images" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
1472
+ createVNode(_component_FormFieldFileInput, {
1473
+ value: _ctx.values.coverImage,
1474
+ "onUpdate:value": _cache[10] || (_cache[10] = ($event) => _ctx.values.coverImage = $event),
1475
+ label: _ctx.$i18n.t("blog:coverImage"),
1476
+ name: "coverImage",
1477
+ "file-type": "image",
1478
+ scenario: _ctx.moduleConfig ? _ctx.moduleConfig.fileScenarios.cover : null
1479
+ }, null, 8, ["value", "label", "scenario"]),
1480
+ createVNode(_component_FormFieldFileInput, {
1481
+ value: _ctx.values.image,
1482
+ "onUpdate:value": _cache[11] || (_cache[11] = ($event) => _ctx.values.image = $event),
1483
+ name: "image",
1484
+ label: _ctx.$i18n.t("blog:innerImage"),
1485
+ "file-type": "image",
1486
+ scenario: _ctx.moduleConfig ? _ctx.moduleConfig.fileScenarios.image : null
1487
+ }, null, 8, ["value", "label", "scenario"]),
1488
+ createVNode(_component_FormFieldFileInput, {
1489
+ value: _ctx.values.imageMobile,
1490
+ "onUpdate:value": _cache[12] || (_cache[12] = ($event) => _ctx.values.imageMobile = $event),
1491
+ name: "imageMobile",
1492
+ label: _ctx.$i18n.t("blog:innerImageMobile"),
1493
+ "file-type": "image",
1494
+ scenario: _ctx.moduleConfig ? _ctx.moduleConfig.fileScenarios.imageMobile : null
1495
+ }, null, 8, ["value", "label", "scenario"])
1496
+ ], 64)) : createCommentVNode("", true),
1497
+ _ctx.selectedTabId === "relations" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
1498
+ createVNode(_component_FormField, {
1499
+ value: _ctx.values.tags,
1500
+ "onUpdate:value": _cache[13] || (_cache[13] = ($event) => _ctx.values.tags = $event),
1501
+ name: "tags",
1502
+ label: _ctx.$i18n.t("blog:tags"),
1503
+ error: _ctx.errors.tags
1504
+ }, null, 8, ["value", "label", "error"]),
1505
+ createVNode(_component_FormFieldMultiSelect, {
1506
+ "selected-options": _ctx.values.categories,
1507
+ "onUpdate:selected-options": _cache[14] || (_cache[14] = ($event) => _ctx.values.categories = $event),
1508
+ name: "categories",
1509
+ label: _ctx.$i18n.t("blog:categories"),
1510
+ options: _ctx.categoryOptionList,
1511
+ error: _ctx.errors.categories,
1512
+ onChange: _ctx.handleCategoriesChange
1513
+ }, null, 8, ["selected-options", "label", "options", "error", "onChange"]),
1514
+ createVNode(_component_FormFieldMultiSelect, {
1515
+ "selected-options": _ctx.values.relatedPosts,
1516
+ "onUpdate:selected-options": _cache[15] || (_cache[15] = ($event) => _ctx.values.relatedPosts = $event),
1517
+ name: "relatedPosts",
1518
+ label: _ctx.$i18n.t("blog:relatedPosts"),
1519
+ options: _ctx.postOptionList,
1520
+ error: _ctx.errors.relatedPosts,
1521
+ searchable: true
1522
+ }, null, 8, ["selected-options", "label", "options", "error"])
1523
+ ], 64)) : createCommentVNode("", true),
1524
+ _ctx.selectedTabId === "additional" ? (openBlock(true), createElementBlock(Fragment, { key: 3 }, renderList(_ctx.values.additionalFields, (field) => {
1525
+ return openBlock(), createBlock(_component_DynamicField, {
1526
+ key: field.name,
1527
+ field
1528
+ }, null, 8, ["field"]);
1529
+ }), 128)) : createCommentVNode("", true),
1530
+ _ctx.selectedTabId === "seo" ? (openBlock(), createBlock(_component_SeoFieldGroup, {
1531
+ key: 4,
1532
+ title: _ctx.values.pageTitle,
1533
+ "title-error-message": _ctx.errors.pageTitle,
1534
+ "title-label": _ctx.$i18n.t("blog:pageTitle"),
1535
+ description: _ctx.values.pageDescription,
1536
+ "description-error-message": _ctx.errors.pageDescription,
1537
+ "description-label": _ctx.$i18n.t("blog:pageDescription"),
1538
+ image: _ctx.values.openGraphImage,
1539
+ "image-error-message": _ctx.errors.openGraphImage,
1540
+ "image-label": _ctx.$i18n.t("blog:openGraphImage"),
1541
+ "image-scenario": _ctx.moduleConfig ? _ctx.moduleConfig.fileScenarios.openGraph : null,
1542
+ onChange: _ctx.handleSeoFieldGroupChange
1543
+ }, null, 8, ["title", "title-error-message", "title-label", "description", "description-error-message", "description-label", "image", "image-error-message", "image-label", "image-scenario", "onChange"])) : createCommentVNode("", true)
1544
+ ], 32)
1545
+ ]),
1546
+ footer: withCtx(() => [
1547
+ createVNode(_component_FormFooter, {
1548
+ "back-href": _ctx.postListUrl,
1549
+ "is-submitting": _ctx.isSubmitting,
1550
+ "is-creation": _ctx.isCreation,
1551
+ "can-create-another": _ctx.isCreation,
1552
+ onSubmit: _ctx.submitForm
1553
+ }, null, 8, ["back-href", "is-submitting", "is-creation", "can-create-another", "onSubmit"])
1554
+ ]),
1555
+ _: 1
1556
+ }, 8, ["title", "is-content-loading", "header-buttons", "footer"]);
1557
+ }
1558
+ var BlogPostForm = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2], ["__scopeId", "data-v-62596ad5"]]);
1559
+ function convertCategoryList(categoryList, languages) {
1560
+ return categoryList.map((category) => {
1561
+ if (languages.length > 0) {
1562
+ const foundLanguage = languages.find(
1563
+ ({ id }) => category.language === id
1564
+ );
1565
+ return {
1566
+ ...category,
1567
+ language: foundLanguage ? foundLanguage.name : category.language
1568
+ };
1569
+ }
1570
+ return category;
1571
+ });
1572
+ }
1573
+ function getCategoryTableColumnDefs(moduleConfig, t) {
1574
+ const isLangSpecific = moduleConfig ? moduleConfig.languages.length > 0 : false;
1575
+ const COLUMN_DEFS = [
1576
+ {
1577
+ id: 1,
1578
+ name: t("blog:name"),
1579
+ field: "name",
1580
+ type: "name",
1581
+ format: ({ row }) => ({
1582
+ adminLink: {
1583
+ url: getBlogCategoryFormUrl({ categoryId: row.id }),
1584
+ text: getNameWithDepth(row.name, row.depth)
1585
+ },
1586
+ paramList: row.isDefault ? [{ name: t("blog:defaultCategory"), value: t("blog:yes") }] : []
1587
+ })
1588
+ },
1589
+ {
1590
+ id: 2,
1591
+ name: t("blog:link"),
1592
+ field: "path",
1593
+ type: "link",
1594
+ format: ({ row }) => ({
1595
+ url: `${getWebsiteOrigin()}${row.url}`,
1596
+ text: row.url
1597
+ }),
1598
+ options: {
1599
+ shouldOpenNewTab: true
1600
+ }
1601
+ },
1602
+ isLangSpecific ? { id: 3, name: t("blog:language"), field: "language" } : null,
1603
+ {
1604
+ id: 4,
1605
+ name: t("blog:posts"),
1606
+ field: "linkToPosts",
1607
+ style: { whiteSpace: "nowrap", width: "130px" }
1608
+ },
1609
+ {
1610
+ id: 5,
1611
+ name: t("blog:actions"),
1612
+ field: "actions",
1613
+ style: { whiteSpace: "nowrap", width: "170px" },
1614
+ headStyle: { whiteSpace: "nowrap", width: "170px" },
1615
+ class: "actions-cell"
1616
+ }
1617
+ ];
1618
+ return COLUMN_DEFS.filter(notEmpty);
1619
+ }
1620
+ function getLinkToPostsByCategory(categoryId) {
1621
+ return `${getBlogPostListUrl()}?filter[category]=${categoryId}`;
1622
+ }
1623
+ function useAdvancedSearch({ languageList, route, t }) {
1624
+ const languageOptionList = computed(
1625
+ () => languageList.value.map(({ id, name }) => ({ value: id, label: name }))
1626
+ );
1627
+ const initialLanguageFilter = computed(() => {
1628
+ const queryValue = getFilterParamAsStringArray(
1629
+ route.query,
1630
+ "language"
1631
+ );
1632
+ return languageOptionList.value.filter(
1633
+ ({ value }) => queryValue.some((selected) => selected === value)
1634
+ );
1635
+ });
1636
+ const languageFilter = ref(initialLanguageFilter.value);
1637
+ watch(initialLanguageFilter, () => {
1638
+ languageFilter.value = initialLanguageFilter.value;
1639
+ });
1640
+ const filterParams = computed(
1641
+ () => getFilterParams({
1642
+ ["language"]: languageFilter.value.map(({ value }) => value)
1643
+ })
1644
+ );
1645
+ function tagRemovalHandler(event) {
1646
+ if (event.name === "language") {
1647
+ languageFilter.value = languageFilter.value.filter(
1648
+ ({ value }) => value !== event.value
1649
+ );
1650
+ }
1651
+ }
1652
+ const tags = computed(() => [
1653
+ ...languageFilter.value.map(({ value, label }) => ({
1654
+ value,
1655
+ label,
1656
+ name: "language",
1657
+ title: t("blog:language")
1658
+ }))
1659
+ ]);
1660
+ return {
1661
+ languageFilter,
1662
+ languageOptionList,
1663
+ tagRemovalHandler,
1664
+ tags,
1665
+ filterParams
1666
+ };
1667
+ }
1668
+ const _sfc_main$1 = defineComponent({
1669
+ name: "BlogCategoryList",
1670
+ components: {
1671
+ DeleteIcon,
1672
+ SouthIcon,
1673
+ NorthIcon,
1674
+ EditIcon,
1675
+ BaseButton,
1676
+ CountButton,
1677
+ FormFieldMultiSelect,
1678
+ AdvancedSearch,
1679
+ Page,
1680
+ DataTable
1681
+ },
1682
+ setup() {
1683
+ const { t } = useI18n();
1684
+ const route = useRoute();
1685
+ const router = useRouter();
1686
+ const { data: moduleConfig, loading: isModuleConfigLoading } = useFetchModuleConfig();
1687
+ const languageList = computed(
1688
+ () => {
1689
+ var _a, _b;
1690
+ return (_b = (_a = moduleConfig.value) == null ? void 0 : _a.languages) != null ? _b : [];
1691
+ }
1692
+ );
1693
+ const {
1694
+ languageFilter,
1695
+ languageOptionList,
1696
+ filterParams,
1697
+ tags,
1698
+ tagRemovalHandler
1699
+ } = useAdvancedSearch({ languageList, route, t });
1700
+ const isLangSpecific = computed(
1701
+ () => languageOptionList.value.length > 1
1702
+ );
1703
+ const {
1704
+ fetchEntityList: fetchCategoryList,
1705
+ isLoading: isCategoryListLoading,
1706
+ rowData: categoryList,
1707
+ errorMessage,
1708
+ searchQuery,
1709
+ handleChange,
1710
+ pageNumber,
1711
+ pageCount,
1712
+ pageSize
1713
+ } = useDataTable({
1714
+ fetchEntityList: (params) => getCategories({
1715
+ query: params.searchQuery,
1716
+ pageNumber: params.pageNumber,
1717
+ pageSize: params.pageSize,
1718
+ ...filterParams.value
1719
+ }),
1720
+ initialValue: [],
1721
+ resourceName: "Blog categories",
1722
+ pageSize: 100
1723
+ });
1724
+ watch(filterParams, () => {
1725
+ var _a;
1726
+ if (isModuleConfigLoading.value || isCategoryListLoading.value) {
1727
+ return;
1728
+ }
1729
+ if (route.path !== BLOG_ROUTE_PATHS.CATEGORY_LIST) {
1730
+ return;
1731
+ }
1732
+ const newQuery = {
1733
+ ...filterParams.value,
1734
+ query: (_a = route.query.query) != null ? _a : ""
1735
+ };
1736
+ if (!isEqual(route.query, newQuery)) {
1737
+ router.replace({ query: newQuery });
1738
+ fetchCategoryList();
1739
+ }
1740
+ });
1741
+ const { isDeleting, handleResourceDelete: handleCategoryDelete } = useResourceDelete({
1742
+ deleteResource: deleteCategory,
1743
+ resourceName: "Post",
1744
+ onSuccess: fetchCategoryList
1745
+ });
1746
+ const isCategoryMoving = ref(false);
1747
+ function startMoveCategory(categoryId, direction) {
1748
+ isCategoryMoving.value = true;
1749
+ moveCategory(categoryId, direction).then((response) => {
1750
+ if (response.success) {
1751
+ return fetchCategoryList();
1752
+ }
1753
+ }).catch(console.error).finally(() => {
1754
+ isCategoryMoving.value = false;
1755
+ });
1756
+ }
1757
+ const isRowDataLoading = computed(
1758
+ () => isCategoryListLoading.value || isModuleConfigLoading.value
1759
+ );
1760
+ const displayedCategoryList = computed(
1761
+ () => convertCategoryList(categoryList.value, languageList.value)
1762
+ );
1763
+ const columnDefs = computed(
1764
+ () => getCategoryTableColumnDefs(moduleConfig.value, t)
1765
+ );
1766
+ return {
1767
+ columnDefs,
1768
+ rowData: displayedCategoryList,
1769
+ isRowDataLoading,
1770
+ errorMessage,
1771
+ isLangSpecific,
1772
+ handleCategoryDelete,
1773
+ isDeleting,
1774
+ getBlogCategoryFormUrl,
1775
+ getLinkToPostsByCategory,
1776
+ startMoveCategory,
1777
+ isCategoryMoving,
1778
+ searchQuery,
1779
+ handleChange,
1780
+ pageNumber,
1781
+ pageCount,
1782
+ pageSize,
1783
+ languageFilter,
1784
+ languageOptionList,
1785
+ tags,
1786
+ tagRemovalHandler
1787
+ };
1788
+ }
1789
+ });
1790
+ const _hoisted_1 = { class: "filters" };
1791
+ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
1792
+ const _component_FormFieldMultiSelect = resolveComponent("FormFieldMultiSelect");
1793
+ const _component_AdvancedSearch = resolveComponent("AdvancedSearch");
1794
+ const _component_CountButton = resolveComponent("CountButton");
1795
+ const _component_EditIcon = resolveComponent("EditIcon");
1796
+ const _component_BaseButton = resolveComponent("BaseButton");
1797
+ const _component_NorthIcon = resolveComponent("NorthIcon");
1798
+ const _component_SouthIcon = resolveComponent("SouthIcon");
1799
+ const _component_DeleteIcon = resolveComponent("DeleteIcon");
1800
+ const _component_DataTable = resolveComponent("DataTable");
1801
+ const _component_Page = resolveComponent("Page");
1802
+ return openBlock(), createBlock(_component_Page, {
1803
+ title: _ctx.$i18n.t("blog:blogCategories"),
1804
+ "header-buttons": [
1805
+ {
1806
+ text: _ctx.$i18n.t("blog:newCategory"),
1807
+ href: _ctx.getBlogCategoryFormUrl({ categoryId: "create" })
1808
+ }
1809
+ ]
1810
+ }, {
1811
+ content: withCtx(() => [
1812
+ createVNode(_component_DataTable, {
1813
+ "column-defs": _ctx.columnDefs,
1814
+ "row-data": _ctx.rowData,
1815
+ loading: _ctx.isRowDataLoading,
1816
+ "error-message": _ctx.errorMessage,
1817
+ "search-query": _ctx.searchQuery,
1818
+ pagination: {
1819
+ pageNumber: _ctx.pageNumber,
1820
+ pageCount: _ctx.pageCount,
1821
+ pageSize: _ctx.pageSize,
1822
+ disabled: _ctx.isRowDataLoading
1823
+ },
1824
+ "data-table": "blog-category",
1825
+ onChange: _ctx.handleChange
1826
+ }, createSlots({
1827
+ "cell(link-to-posts)": withCtx(({ row }) => [
1828
+ createVNode(_component_CountButton, {
1829
+ href: _ctx.getLinkToPostsByCategory(row.id),
1830
+ variant: "outline-secondary",
1831
+ count: row.postsCount
1832
+ }, {
1833
+ default: withCtx(() => [
1834
+ createTextVNode(toDisplayString(_ctx.$i18n.t("blog:posts")), 1)
1835
+ ]),
1836
+ _: 2
1837
+ }, 1032, ["href", "count"])
1838
+ ]),
1839
+ "cell(actions)": withCtx(({ row, rowIndex }) => [
1840
+ createVNode(_component_BaseButton, {
1841
+ variant: "icon",
1842
+ title: _ctx.$i18n.t("blog:edit"),
1843
+ disabled: _ctx.isDeleting(row.id),
1844
+ href: _ctx.getBlogCategoryFormUrl({ categoryId: row.id })
1845
+ }, {
1846
+ default: withCtx(() => [
1847
+ createVNode(_component_EditIcon)
1848
+ ]),
1849
+ _: 2
1850
+ }, 1032, ["title", "disabled", "href"]),
1851
+ createVNode(_component_BaseButton, {
1852
+ variant: "icon",
1853
+ title: _ctx.$i18n.t("blog:moveUp"),
1854
+ disabled: rowIndex === 0 || _ctx.isCategoryMoving,
1855
+ onClick: ($event) => _ctx.startMoveCategory(row.id, "up")
1856
+ }, {
1857
+ default: withCtx(() => [
1858
+ createVNode(_component_NorthIcon)
1859
+ ]),
1860
+ _: 2
1861
+ }, 1032, ["title", "disabled", "onClick"]),
1862
+ createVNode(_component_BaseButton, {
1863
+ variant: "icon",
1864
+ title: _ctx.$i18n.t("blog:moveDown"),
1865
+ disabled: rowIndex === _ctx.rowData.length - 1 || _ctx.isCategoryMoving,
1866
+ onClick: ($event) => _ctx.startMoveCategory(row.id, "down")
1867
+ }, {
1868
+ default: withCtx(() => [
1869
+ createVNode(_component_SouthIcon)
1870
+ ]),
1871
+ _: 2
1872
+ }, 1032, ["title", "disabled", "onClick"]),
1873
+ createVNode(_component_BaseButton, {
1874
+ variant: "icon",
1875
+ title: _ctx.$i18n.t("blog:remove"),
1876
+ disabled: _ctx.isDeleting(row.id) || row.postsCount > 0,
1877
+ onClick: ($event) => _ctx.handleCategoryDelete(row.id)
1878
+ }, {
1879
+ default: withCtx(() => [
1880
+ createVNode(_component_DeleteIcon)
1881
+ ]),
1882
+ _: 2
1883
+ }, 1032, ["title", "disabled", "onClick"])
1884
+ ]),
1885
+ _: 2
1886
+ }, [
1887
+ _ctx.isLangSpecific ? {
1888
+ name: "filters",
1889
+ fn: withCtx(() => [
1890
+ createVNode(_component_AdvancedSearch, {
1891
+ tags: _ctx.tags,
1892
+ "onClick:tag": _ctx.tagRemovalHandler
1893
+ }, {
1894
+ default: withCtx(() => [
1895
+ createElementVNode("div", _hoisted_1, [
1896
+ createVNode(_component_FormFieldMultiSelect, {
1897
+ values: _ctx.languageFilter,
1898
+ "onUpdate:values": _cache[0] || (_cache[0] = ($event) => _ctx.languageFilter = $event),
1899
+ options: _ctx.languageOptionList,
1900
+ name: "languageFilter",
1901
+ searchable: true,
1902
+ label: _ctx.$i18n.t("blog:language"),
1903
+ class: "filter"
1904
+ }, null, 8, ["values", "options", "label"])
1905
+ ])
1906
+ ]),
1907
+ _: 1
1908
+ }, 8, ["tags", "onClick:tag"])
1909
+ ])
1910
+ } : void 0
1911
+ ]), 1032, ["column-defs", "row-data", "loading", "error-message", "search-query", "pagination", "onChange"])
1912
+ ]),
1913
+ _: 1
1914
+ }, 8, ["title", "header-buttons"]);
1915
+ }
1916
+ var BlogCategoryList = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
1917
+ function convertCategoryToFormValues(category, languageOptionList, t) {
1918
+ var _a, _b, _c, _d, _e;
1919
+ const currentLangOption = languageOptionList.find(
1920
+ ({ value }) => value === (category == null ? void 0 : category.language)
1921
+ );
1922
+ if (!category) {
1923
+ return {
1924
+ language: currentLangOption != null ? currentLangOption : null,
1925
+ name: "",
1926
+ parent: { value: null, label: t("blog:noParent") },
1927
+ urlAlias: "",
1928
+ isDefault: false,
1929
+ pageTitle: "",
1930
+ pageDescription: "",
1931
+ pageKeywords: "",
1932
+ openGraphTitle: "",
1933
+ openGraphDescription: "",
1934
+ openGraphImage: null
1935
+ };
1936
+ }
1937
+ return {
1938
+ language: currentLangOption != null ? currentLangOption : null,
1939
+ isDefault: category.isDefault,
1940
+ name: category.name,
1941
+ parent: category.parent ? { value: category.parent.id, label: category.parent.name } : { value: null, label: t("blog:noParent") },
1942
+ urlAlias: category.urlAlias,
1943
+ pageTitle: (_a = category.pageTitle) != null ? _a : "",
1944
+ pageDescription: (_b = category.pageDescription) != null ? _b : "",
1945
+ pageKeywords: (_c = category.pageKeywords) != null ? _c : "",
1946
+ openGraphTitle: (_d = category.openGraphTitle) != null ? _d : "",
1947
+ openGraphDescription: (_e = category.openGraphDescription) != null ? _e : "",
1948
+ openGraphImage: category.openGraphImage ? { id: createId(), file: category.openGraphImage } : null
1949
+ };
1950
+ }
1951
+ function convertCategoryFormValuesToPayload(values) {
1952
+ var _a, _b, _c, _d;
1953
+ return {
1954
+ language: (_b = (_a = values.language) == null ? void 0 : _a.value) != null ? _b : null,
1955
+ name: values.name,
1956
+ parent: values.parent.value,
1957
+ urlAlias: values.urlAlias,
1958
+ isDefault: values.isDefault,
1959
+ pageTitle: values.pageTitle,
1960
+ pageDescription: values.pageDescription,
1961
+ openGraphImage: (_d = (_c = values.openGraphImage) == null ? void 0 : _c.file.id) != null ? _d : null
1962
+ };
1963
+ }
1964
+ function convertCategoryListToOptions(categoryList, languageId, t) {
1965
+ return [
1966
+ { value: null, label: t("blog:noParent") },
1967
+ ...categoryList.filter(({ language }) => languageId ? language === languageId : true).map(({ id, name, depth }) => ({
1968
+ value: id,
1969
+ label: getNameWithDepth(name, depth)
1970
+ }))
1971
+ ];
1972
+ }
1973
+ const _sfc_main = defineComponent({
1974
+ name: "CategoryForm",
1975
+ components: {
1976
+ Page,
1977
+ SeoFieldGroup,
1978
+ FormFieldCheckbox,
1979
+ TabList,
1980
+ FormFieldUrlAliasInput,
1981
+ FormField,
1982
+ FormFieldSelect,
1983
+ FormFooter
1984
+ },
1985
+ setup() {
1986
+ const { t } = useI18n();
1987
+ const router = useRouter();
1988
+ const route = useRoute();
1989
+ const toast = useToast();
1990
+ const categoryId = computed(
1991
+ () => route.params.categoryId
1992
+ );
1993
+ const isCreation = computed(() => categoryId.value === "create");
1994
+ const { data: moduleConfig, loading: isModuleConfigLoading } = useFetchModuleConfig();
1995
+ const languageList = computed(
1996
+ () => {
1997
+ var _a, _b;
1998
+ return (_b = (_a = moduleConfig.value) == null ? void 0 : _a.languages) != null ? _b : [];
1999
+ }
2000
+ );
2001
+ const languageOptionList = computed(
2002
+ () => languageList.value.map(({ id, name }) => ({ value: id, label: name }))
2003
+ );
2004
+ const isLangSpecific = computed(
2005
+ () => languageOptionList.value.length > 0
2006
+ );
2007
+ const imageScenario = computed(
2008
+ () => {
2009
+ var _a, _b, _c;
2010
+ return (_c = (_b = (_a = moduleConfig.value) == null ? void 0 : _a.fileScenarios) == null ? void 0 : _b.openGraph) != null ? _c : null;
2011
+ }
2012
+ );
2013
+ const { data: categories, loading: isCategoriesLoading } = useFetchCategories();
2014
+ const { data: category, loading: isCategoryLoading } = useFetchCategory({
2015
+ categoryId,
2016
+ isCreation
2017
+ });
2018
+ const isSubmitting = ref(false);
2019
+ const values = ref(
2020
+ convertCategoryToFormValues(category.value, languageOptionList.value, t)
2021
+ );
2022
+ const errors = ref({});
2023
+ watch([category, languageOptionList], () => {
2024
+ values.value = convertCategoryToFormValues(
2025
+ category.value,
2026
+ languageOptionList.value,
2027
+ t
2028
+ );
2029
+ });
2030
+ function submitForm(event) {
2031
+ isSubmitting.value = true;
2032
+ const body = convertCategoryFormValuesToPayload(values.value);
2033
+ const requestPromise = isCreation.value ? createCategory(body) : updateCategory(categoryId.value, body);
2034
+ requestPromise.then(({ data }) => {
2035
+ errors.value = {};
2036
+ if (event.type === "create") {
2037
+ router.push(
2038
+ getBlogCategoryFormUrl({ categoryId: String(data.id) })
2039
+ );
2040
+ }
2041
+ if (event.type === "create_exit" || event.type === "save_exit") {
2042
+ navigateBack(router, getBlogCategoryListUrl());
2043
+ }
2044
+ if (event.type === "create_create-another") {
2045
+ values.value = convertCategoryToFormValues(
2046
+ null,
2047
+ languageOptionList.value,
2048
+ t
2049
+ );
2050
+ }
2051
+ toast.show({
2052
+ variant: "success",
2053
+ title: t("blog:success"),
2054
+ body: isCreation.value ? t("blog:blogCategoryWasSuccessfullyCreated") : t("blog:blogCategoryWasSuccessfullyUpdated")
2055
+ });
2056
+ }).catch((error) => {
2057
+ console.error(error);
2058
+ errors.value = convertRequestErrorToMap(error);
2059
+ toast.show({
2060
+ variant: "danger",
2061
+ title: t("blog:error"),
2062
+ body: isCreation.value ? t("blog:blogCategoryCreationWasFailed") : t("blog:blogCategoryUpdateWasFailed")
2063
+ });
2064
+ }).finally(() => {
2065
+ isSubmitting.value = false;
2066
+ });
2067
+ }
2068
+ const parentCategoryOptionList = computed(
2069
+ () => {
2070
+ var _a, _b;
2071
+ return convertCategoryListToOptions(
2072
+ categories.value,
2073
+ (_b = (_a = values.value.language) == null ? void 0 : _a.value) != null ? _b : null,
2074
+ t
2075
+ );
2076
+ }
2077
+ );
2078
+ const isContentLoading = computed(
2079
+ () => isCategoryLoading.value || isModuleConfigLoading.value || isCategoriesLoading.value
2080
+ );
2081
+ const categoryPagePath = computed(() => {
2082
+ var _a, _b;
2083
+ return `${getWebsiteOrigin()}${(_b = (_a = category.value) == null ? void 0 : _a.urlTemplate) != null ? _b : ""}`;
2084
+ });
2085
+ function handleSeoFieldGroupChange({
2086
+ title,
2087
+ description,
2088
+ keywords,
2089
+ image
2090
+ }) {
2091
+ values.value.pageTitle = title;
2092
+ values.value.pageDescription = description;
2093
+ values.value.pageKeywords = keywords;
2094
+ values.value.openGraphImage = image;
2095
+ }
2096
+ const tabList = computed(() => [
2097
+ { id: "common", label: t("blog:tabs.common") },
2098
+ { id: "seo", label: t("blog:tabs.seo") }
2099
+ ]);
2100
+ const selectedTabId = ref(tabList.value[0].id);
2101
+ const urlAliasChanged = ref(false);
2102
+ const handleNameChange = (value) => {
2103
+ if (isCreation.value && !urlAliasChanged.value) {
2104
+ values.value.urlAlias = urlTranslit(value);
2105
+ }
2106
+ };
2107
+ const handleAliasChange = () => {
2108
+ urlAliasChanged.value = true;
2109
+ };
2110
+ return {
2111
+ isCreation,
2112
+ isContentLoading,
2113
+ values,
2114
+ errors,
2115
+ isLangSpecific,
2116
+ languageOptionList,
2117
+ pagePath: categoryPagePath,
2118
+ categoryListUrl: getBlogCategoryListUrl(),
2119
+ submitForm,
2120
+ isSubmitting,
2121
+ moduleConfig,
2122
+ parentCategoryOptionList,
2123
+ handleNameChange,
2124
+ handleAliasChange,
2125
+ imageScenario,
2126
+ handleSeoFieldGroupChange,
2127
+ tabList,
2128
+ selectedTabId
2129
+ };
2130
+ }
2131
+ });
2132
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
2133
+ const _component_FormFieldSelect = resolveComponent("FormFieldSelect");
2134
+ const _component_FormField = resolveComponent("FormField");
2135
+ const _component_FormFieldUrlAliasInput = resolveComponent("FormFieldUrlAliasInput");
2136
+ const _component_TabList = resolveComponent("TabList");
2137
+ const _component_FormFieldCheckbox = resolveComponent("FormFieldCheckbox");
2138
+ const _component_SeoFieldGroup = resolveComponent("SeoFieldGroup");
2139
+ const _component_FormFooter = resolveComponent("FormFooter");
2140
+ const _component_Page = resolveComponent("Page");
2141
+ return openBlock(), createBlock(_component_Page, {
2142
+ title: _ctx.isCreation ? _ctx.$i18n.t("blog:createBlogCategory") : _ctx.$i18n.t("blog:updateBlogCategory"),
2143
+ "is-content-loading": _ctx.isContentLoading
2144
+ }, {
2145
+ content: withCtx(() => [
2146
+ createElementVNode("form", {
2147
+ novalidate: "",
2148
+ onSubmit: _cache[10] || (_cache[10] = withModifiers((...args) => _ctx.submitForm && _ctx.submitForm(...args), ["prevent"]))
2149
+ }, [
2150
+ _ctx.isCreation ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
2151
+ _ctx.isLangSpecific ? (openBlock(), createBlock(_component_FormFieldSelect, {
2152
+ key: 0,
2153
+ value: _ctx.values.language,
2154
+ "onUpdate:value": _cache[0] || (_cache[0] = ($event) => _ctx.values.language = $event),
2155
+ name: "language",
2156
+ label: _ctx.$i18n.t("blog:language"),
2157
+ options: _ctx.languageOptionList,
2158
+ error: _ctx.errors.language
2159
+ }, null, 8, ["value", "label", "options", "error"])) : createCommentVNode("", true),
2160
+ createVNode(_component_FormField, {
2161
+ value: _ctx.values.name,
2162
+ "onUpdate:value": _cache[1] || (_cache[1] = ($event) => _ctx.values.name = $event),
2163
+ name: "name",
2164
+ label: _ctx.$i18n.t("blog:name"),
2165
+ error: _ctx.errors.name,
2166
+ onInput: _ctx.handleNameChange
2167
+ }, null, 8, ["value", "label", "error", "onInput"]),
2168
+ !_ctx.isLangSpecific || _ctx.values.language ? (openBlock(), createBlock(_component_FormFieldSelect, {
2169
+ key: 1,
2170
+ value: _ctx.values.parent,
2171
+ "onUpdate:value": _cache[2] || (_cache[2] = ($event) => _ctx.values.parent = $event),
2172
+ name: "parentCategory",
2173
+ label: _ctx.$i18n.t("blog:parentCategory"),
2174
+ options: _ctx.parentCategoryOptionList,
2175
+ error: _ctx.errors.parent
2176
+ }, null, 8, ["value", "label", "options", "error"])) : createCommentVNode("", true),
2177
+ createVNode(_component_FormFieldUrlAliasInput, {
2178
+ id: "urlAlias",
2179
+ value: _ctx.values.urlAlias,
2180
+ "onUpdate:value": _cache[3] || (_cache[3] = ($event) => _ctx.values.urlAlias = $event),
2181
+ name: "urlAlias",
2182
+ label: _ctx.$i18n.t("blog:link"),
2183
+ "url-template": _ctx.pagePath,
2184
+ error: _ctx.errors.urlAlias,
2185
+ onChange: _ctx.handleAliasChange
2186
+ }, null, 8, ["value", "label", "url-template", "error", "onChange"])
2187
+ ], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
2188
+ createVNode(_component_TabList, {
2189
+ "tab-id": _ctx.selectedTabId,
2190
+ "onUpdate:tab-id": _cache[4] || (_cache[4] = ($event) => _ctx.selectedTabId = $event),
2191
+ "tab-list": _ctx.tabList
2192
+ }, null, 8, ["tab-id", "tab-list"]),
2193
+ _ctx.selectedTabId === "common" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
2194
+ _ctx.isLangSpecific ? (openBlock(), createBlock(_component_FormFieldSelect, {
2195
+ key: 0,
2196
+ value: _ctx.values.language,
2197
+ "onUpdate:value": _cache[5] || (_cache[5] = ($event) => _ctx.values.language = $event),
2198
+ name: "language",
2199
+ label: _ctx.$i18n.t("blog:language"),
2200
+ options: _ctx.languageOptionList,
2201
+ error: _ctx.errors.language
2202
+ }, null, 8, ["value", "label", "options", "error"])) : createCommentVNode("", true),
2203
+ createVNode(_component_FormFieldCheckbox, {
2204
+ checked: _ctx.values.isDefault,
2205
+ "onUpdate:checked": _cache[6] || (_cache[6] = ($event) => _ctx.values.isDefault = $event),
2206
+ name: "isDefault",
2207
+ label: _ctx.$i18n.t("blog:defaultCategory"),
2208
+ error: _ctx.errors.isDefault
2209
+ }, null, 8, ["checked", "label", "error"]),
2210
+ createVNode(_component_FormField, {
2211
+ value: _ctx.values.name,
2212
+ "onUpdate:value": _cache[7] || (_cache[7] = ($event) => _ctx.values.name = $event),
2213
+ name: "name",
2214
+ label: _ctx.$i18n.t("blog:name"),
2215
+ error: _ctx.errors.name
2216
+ }, null, 8, ["value", "label", "error"]),
2217
+ !_ctx.isLangSpecific || _ctx.values.language ? (openBlock(), createBlock(_component_FormFieldSelect, {
2218
+ key: 1,
2219
+ value: _ctx.values.parent,
2220
+ "onUpdate:value": _cache[8] || (_cache[8] = ($event) => _ctx.values.parent = $event),
2221
+ name: "parentCategory",
2222
+ label: _ctx.$i18n.t("blog:parentCategory"),
2223
+ options: _ctx.parentCategoryOptionList,
2224
+ error: _ctx.errors.parent
2225
+ }, null, 8, ["value", "label", "options", "error"])) : createCommentVNode("", true),
2226
+ createVNode(_component_FormFieldUrlAliasInput, {
2227
+ id: "urlAlias",
2228
+ value: _ctx.values.urlAlias,
2229
+ "onUpdate:value": _cache[9] || (_cache[9] = ($event) => _ctx.values.urlAlias = $event),
2230
+ name: "urlAlias",
2231
+ label: _ctx.$i18n.t("blog:link"),
2232
+ "url-template": _ctx.pagePath,
2233
+ error: _ctx.errors.urlAlias
2234
+ }, null, 8, ["value", "label", "url-template", "error"])
2235
+ ], 64)) : createCommentVNode("", true),
2236
+ _ctx.selectedTabId === "seo" ? (openBlock(), createBlock(_component_SeoFieldGroup, {
2237
+ key: 1,
2238
+ title: _ctx.values.pageTitle,
2239
+ "title-error-message": _ctx.errors.pageTitle,
2240
+ description: _ctx.values.pageDescription,
2241
+ "description-error-message": _ctx.errors.pageDescription,
2242
+ "should-display-keywords": false,
2243
+ keywords: _ctx.values.pageKeywords,
2244
+ "keywords-error-message": _ctx.errors.pageKeywords,
2245
+ image: _ctx.values.openGraphImage,
2246
+ "image-scenario": _ctx.imageScenario,
2247
+ "image-error-message": _ctx.errors.openGraphImage,
2248
+ onChange: _ctx.handleSeoFieldGroupChange
2249
+ }, null, 8, ["title", "title-error-message", "description", "description-error-message", "keywords", "keywords-error-message", "image", "image-scenario", "image-error-message", "onChange"])) : createCommentVNode("", true)
2250
+ ], 64))
2251
+ ], 32)
2252
+ ]),
2253
+ footer: withCtx(() => [
2254
+ createVNode(_component_FormFooter, {
2255
+ "back-href": _ctx.categoryListUrl,
2256
+ "is-submitting": _ctx.isSubmitting,
2257
+ "is-creation": _ctx.isCreation,
2258
+ "can-create-another": _ctx.isCreation,
2259
+ onSubmit: _ctx.submitForm
2260
+ }, null, 8, ["back-href", "is-submitting", "is-creation", "can-create-another", "onSubmit"])
2261
+ ]),
2262
+ _: 1
2263
+ }, 8, ["title", "is-content-loading"]);
2264
+ }
2265
+ var BlogCategoryForm = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
2266
+ const BLOG_POST_LIST_ROUTE = {
2267
+ path: BLOG_ROUTE_PATHS.POST_LIST,
2268
+ component: BlogPostList,
2269
+ name: "All posts",
2270
+ meta: {
2271
+ getBreadcrumbs: (route, { t }) => [
2272
+ { url: "/", text: t("blog:home") },
2273
+ { url: BLOG_ROUTE_PATHS.POST_LIST, text: t("blog:allPosts") }
2274
+ ]
2275
+ }
2276
+ };
2277
+ const BLOG_POST_FORM_ROUTE = {
2278
+ path: BLOG_ROUTE_PATHS.POST_FORM,
2279
+ component: BlogPostForm,
2280
+ name: "Post Form",
2281
+ meta: {
2282
+ getBreadcrumbs: (route, { t }) => [
2283
+ { url: "/", text: t("blog:home") },
2284
+ { url: BLOG_ROUTE_PATHS.POST_LIST, text: t("blog:allPosts") },
2285
+ { url: route.path, text: t("blog:postForm") }
2286
+ ]
2287
+ }
2288
+ };
2289
+ const BLOG_CATEGORY_LIST_ROUTE = {
2290
+ path: BLOG_ROUTE_PATHS.CATEGORY_LIST,
2291
+ component: BlogCategoryList,
2292
+ name: "All categories",
2293
+ meta: {
2294
+ getBreadcrumbs: (route, { t }) => [
2295
+ { url: "/", text: t("blog:home") },
2296
+ { url: BLOG_ROUTE_PATHS.CATEGORY_LIST, text: t("blog:allCategories") }
2297
+ ]
2298
+ }
2299
+ };
2300
+ const BLOG_CATEGORY_FORM_ROUTE = {
2301
+ path: BLOG_ROUTE_PATHS.CATEGORY_FORM,
2302
+ component: BlogCategoryForm,
2303
+ name: "Category Form",
2304
+ meta: {
2305
+ getBreadcrumbs: (route, { t }) => [
2306
+ { url: "/", text: t("blog:home") },
2307
+ { url: BLOG_ROUTE_PATHS.CATEGORY_LIST, text: t("blog:allCategories") },
2308
+ { url: route.path, text: t("blog:categoryForm") }
2309
+ ]
2310
+ }
2311
+ };
2312
+ applyTranslations();
2313
+ export { BLOG_CATEGORY_FORM_ROUTE, BLOG_CATEGORY_LIST_ROUTE, BLOG_POST_FORM_ROUTE, BLOG_POST_LIST_ROUTE, clonePost, createBlogPost, createCategory, deleteBlogPost, deleteCategory, getBlogCategoryFormUrl, getBlogCategoryListUrl, getBlogPostCount, getBlogPostFormUrl, getBlogPostListUrl, getCategories, getCategory, getModuleConfig, getPost, getPosts, moveCategory, updateBlogPost, updateCategory };