@tager/admin-blog 0.3.43 → 1.0.2

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