@tager/admin-blog 0.3.42 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/constants/paths.d.ts +6 -14
  2. package/dist/constants/routes.d.ts +5 -5
  3. package/dist/dev/App.vue.d.ts +5 -0
  4. package/dist/dev/config.d.ts +2 -0
  5. package/dist/dev/env.d.ts +1 -0
  6. package/dist/dev/main.d.ts +3 -0
  7. package/dist/hooks/index.d.ts +4 -4
  8. package/dist/hooks/useFetchCategories.d.ts +3 -6
  9. package/dist/hooks/useFetchCategory.d.ts +7 -8
  10. package/dist/hooks/useFetchModuleConfig.d.ts +3 -6
  11. package/dist/hooks/useFetchPosts.d.ts +3 -6
  12. package/dist/index.mjs +2313 -0
  13. package/dist/locales/apply.d.ts +1 -0
  14. package/dist/locales/en.d.ts +87 -86
  15. package/dist/locales/ru.d.ts +3 -3
  16. package/dist/main.d.ts +3 -4
  17. package/dist/services/requests.d.ts +59 -59
  18. package/dist/style.css +1 -0
  19. package/dist/typings/common.d.ts +1 -1
  20. package/dist/typings/model.d.ts +106 -106
  21. package/dist/utils/common.d.ts +2 -2
  22. package/dist/utils/paths.d.ts +8 -0
  23. package/dist/views/Categories/CategoryForm/CategoryForm.helpers.d.ts +7 -7
  24. package/dist/views/Categories/CategoryForm/CategoryForm.vue.d.ts +53 -116
  25. package/dist/views/Categories/CategoryForm/index.d.ts +1 -1
  26. package/dist/views/Categories/CategoryList/CategoryList.helpers.d.ts +7 -7
  27. package/dist/views/Categories/CategoryList/CategoryList.vue.d.ts +26 -57
  28. package/dist/views/Categories/CategoryList/hooks/index.d.ts +1 -1
  29. package/dist/views/Categories/CategoryList/hooks/useAdvancedSearch.d.ts +19 -16
  30. package/dist/views/Categories/CategoryList/index.d.ts +1 -1
  31. package/dist/views/Posts/PostForm/PostForm.helpers.d.ts +32 -32
  32. package/dist/views/Posts/PostForm/PostForm.vue.d.ts +2768 -9398
  33. package/dist/views/Posts/PostForm/index.d.ts +1 -1
  34. package/dist/views/Posts/PostList/PostList.helpers.d.ts +7 -7
  35. package/dist/views/Posts/PostList/PostList.vue.d.ts +38 -78
  36. package/dist/views/Posts/PostList/hooks/index.d.ts +1 -1
  37. package/dist/views/Posts/PostList/hooks/useAdvancedSearch.d.ts +27 -24
  38. package/dist/views/Posts/PostList/index.d.ts +1 -1
  39. package/package.json +51 -49
  40. package/src/constants/paths.ts +0 -22
  41. package/src/constants/routes.ts +9 -9
  42. package/src/dev/App.vue +56 -0
  43. package/src/dev/config.ts +23 -0
  44. package/src/dev/env.ts +17 -0
  45. package/src/dev/main.ts +49 -0
  46. package/src/hooks/useFetchCategories.ts +2 -7
  47. package/src/hooks/useFetchCategory.ts +3 -6
  48. package/src/hooks/useFetchModuleConfig.ts +2 -7
  49. package/src/hooks/useFetchPosts.ts +2 -5
  50. package/src/locales/apply.ts +9 -0
  51. package/src/locales/en.ts +3 -3
  52. package/src/locales/ru.ts +4 -2
  53. package/src/main.ts +3 -8
  54. package/src/utils/paths.ts +23 -0
  55. package/src/views/Categories/CategoryForm/CategoryForm.vue +81 -65
  56. package/src/views/Categories/CategoryList/CategoryList.helpers.ts +1 -1
  57. package/src/views/Categories/CategoryList/CategoryList.vue +86 -58
  58. package/src/views/Categories/CategoryList/hooks/useAdvancedSearch.ts +9 -12
  59. package/src/views/Posts/PostForm/PostForm.vue +259 -224
  60. package/src/views/Posts/PostList/PostList.helpers.ts +3 -3
  61. package/src/views/Posts/PostList/PostList.vue +168 -168
  62. package/src/views/Posts/PostList/hooks/useAdvancedSearch.ts +22 -30
  63. package/CHANGELOG.md +0 -13
  64. package/dist/constants/menu.d.ts +0 -5
  65. package/dist/dev.d.ts +0 -1
  66. package/dist/index.esm.js +0 -5294
  67. package/dist/index.umd.js +0 -5321
  68. package/dist/router/index.d.ts +0 -4
  69. package/dist/views/Posts/PostForm/components/TabList/TabList.types.d.ts +0 -5
  70. package/dist/views/Posts/PostForm/components/TabList/index.d.ts +0 -2
  71. package/src/constants/menu.ts +0 -31
  72. package/src/dev.ts +0 -34
  73. package/src/router/index.ts +0 -40
  74. package/src/typings/sfc.d.ts +0 -12
  75. package/src/typings/shims-tsx.d.ts +0 -13
  76. package/src/typings/shims-vue.d.ts +0 -11
  77. package/src/typings/translate.d.ts +0 -10
  78. package/src/views/App.vue +0 -22
  79. package/src/views/Home.vue +0 -31
  80. package/src/views/Posts/PostForm/components/TabList/TabList.types.ts +0 -5
  81. package/src/views/Posts/PostForm/components/TabList/TabList.vue +0 -92
  82. package/src/views/Posts/PostForm/components/TabList/index.ts +0 -2
@@ -1,223 +1,242 @@
1
1
  <template>
2
- <page
3
- :title="isCreation ? $t('blog:createPost') : $t('blog:updatePost')"
4
- :is-content-loading='isContentLoading'
5
- :header-buttons='headerButtonList'
6
- :footer='{
2
+ <Page
3
+ :title="
4
+ isCreation ? $i18n.t('blog:createPost') : $i18n.t('blog:updatePost')
5
+ "
6
+ :is-content-loading="isContentLoading"
7
+ :header-buttons="headerButtonList"
8
+ :footer="{
7
9
  backHref: postListUrl,
8
10
  onSubmit: submitForm,
9
11
  isSubmitting: isSubmitting,
10
- }'
12
+ }"
11
13
  >
12
- <template v-slot:content>
13
- <form novalidate @submit.prevent='submitForm'>
14
- <tab-list
15
- :tab-list='tabList'
16
- :selected-tab-id='selectedTabId'
17
- @tab:update='selectedTabId = $event.tabId'
18
- />
14
+ <template #content>
15
+ <form novalidate @submit.prevent="submitForm">
16
+ <TabList v-model:tab-id="selectedTabId" :tab-list="tabList" />
19
17
 
20
18
  <template v-if="selectedTabId === 'common'">
21
-
22
- <form-field-select
23
- v-if='isCreation && isLangSpecific'
24
- v-model='values.language'
25
- name='language'
26
- :label="$t('blog:language')"
27
- :options='languageOptionList'
28
- :error='errors.language'
19
+ <FormFieldSelect
20
+ v-if="isCreation && isLangSpecific"
21
+ v-model:value="values.language"
22
+ name="language"
23
+ :label="$i18n.t('blog:language')"
24
+ :options="languageOptionList"
25
+ :error="errors.language"
29
26
  />
30
27
 
31
- <form-field
32
- v-model='values.title'
33
- name='title'
34
- :label="$t('blog:title')"
35
- :error='errors.title'
36
- @input='handleTitleChange'
28
+ <FormField
29
+ v-model:value="values.title"
30
+ name="title"
31
+ :label="$i18n.t('blog:title')"
32
+ :error="errors.title"
33
+ @input="handleTitleChange"
37
34
  />
38
35
 
39
- <form-field-url-alias-input
40
- id='urlAlias'
41
- v-model='values.urlAlias'
42
- name='urlAlias'
43
- :label="$t('blog:link')"
44
- :url-template='urlAliasTemplate'
45
- :error='errors.urlAlias'
46
- @change='handleAliasChange'
36
+ <FormFieldUrlAliasInput
37
+ id="urlAlias"
38
+ v-model:value="values.urlAlias"
39
+ name="urlAlias"
40
+ :label="$i18n.t('blog:link')"
41
+ :url-template="urlAliasTemplate"
42
+ :error="errors.urlAlias"
43
+ @change="handleAliasChange"
47
44
  />
48
45
 
49
- <div class='status'>
50
- <div class='status-value'>
51
- <form-field-select
52
- v-model='values.status'
53
- name='status'
54
- :error='errors.status'
55
- :label="$t('blog:status')"
56
- :no-options-message="$t('blog:noTemplates')"
57
- :options='statusOptions'
46
+ <div class="status">
47
+ <div class="status-value">
48
+ <FormFieldSelect
49
+ v-model:value="values.status"
50
+ name="status"
51
+ :error="errors.status"
52
+ :label="$i18n.t('blog:status')"
53
+ :no-options-message="$i18n.t('blog:noTemplates')"
54
+ :options="statusOptions"
58
55
  />
59
56
  </div>
60
- <div class='status-checkbox' v-if='values.status.value === "PUBLISHED" || values.status.value === "DRAFT"'>
61
- <form-field-checkbox
62
- v-model='values.statusDateEnabled'
63
- name='statusDateEnabled'
64
- :label="$t(values.status.value === 'PUBLISHED' ? 'blog:scheduleArchive' : 'blog:schedulePublish')"
65
- :error='errors.status'
57
+ <div
58
+ v-if="
59
+ values.status.value === 'PUBLISHED' ||
60
+ values.status.value === 'DRAFT'
61
+ "
62
+ class="status-checkbox"
63
+ >
64
+ <FormFieldCheckbox
65
+ v-model:checked="values.statusDateEnabled"
66
+ name="statusDateEnabled"
67
+ :label="
68
+ $i18n.t(
69
+ values.status.value === 'PUBLISHED'
70
+ ? 'blog:scheduleArchive'
71
+ : 'blog:schedulePublish'
72
+ )
73
+ "
74
+ :error="errors.status"
66
75
  />
67
76
  </div>
68
- <div class='status-date'
69
- v-if='values.statusDateEnabled && (values.status.value === "PUBLISHED" || values.status.value === "DRAFT")'>
70
- <form-field
71
- v-model='values.statusDate'
72
- name='statusDate'
73
- type='date'
74
- :label="$t(values.status.value === 'PUBLISHED' ? 'blog:archiveAt' : 'blog:publishAt')"
75
- :error='errors.statusDate'
77
+ <div
78
+ v-if="
79
+ values.statusDateEnabled &&
80
+ (values.status.value === 'PUBLISHED' ||
81
+ values.status.value === 'DRAFT')
82
+ "
83
+ class="status-date"
84
+ >
85
+ <FormField
86
+ v-model:value="values.statusDate"
87
+ name="statusDate"
88
+ type="date"
89
+ :label="
90
+ $i18n.t(
91
+ values.status.value === 'PUBLISHED'
92
+ ? 'blog:archiveAt'
93
+ : 'blog:publishAt'
94
+ )
95
+ "
96
+ :error="errors.statusDate"
76
97
  />
77
98
  </div>
78
99
  </div>
79
100
 
80
- <form-field
81
- v-model='values.datetime'
82
- name='datetime'
83
- :label="$t('blog:date')"
84
- type='date'
85
- :error='errors.datetime'
101
+ <FormField
102
+ v-model:value="values.datetime"
103
+ name="datetime"
104
+ :label="$i18n.t('blog:date')"
105
+ type="date"
106
+ :error="errors.datetime"
86
107
  />
87
108
 
88
- <form-field
89
- v-model='values.excerpt'
90
- name='excerpt'
91
- :label="$t('blog:excerpt')"
92
- type='textarea'
93
- :error='errors.excerpt'
109
+ <FormField
110
+ v-model:value="values.excerpt"
111
+ name="excerpt"
112
+ :label="$i18n.t('blog:excerpt')"
113
+ type="textarea"
114
+ :error="errors.excerpt"
94
115
  />
95
116
 
96
- <form-field-rich-text-input
97
- v-model='values.body'
98
- name='body'
99
- :label="$t('blog:body')"
100
- :error='errors.body'
101
- :get-upload-adapter-options='getUploadAdapterOptions'
117
+ <FormFieldRichTextInput
118
+ v-model:value="values.body"
119
+ name="body"
120
+ :label="$i18n.t('blog:body')"
121
+ :error="errors.body"
122
+ :get-upload-adapter-options="getUploadAdapterOptions"
102
123
  />
103
124
 
104
125
  <ShortCodeConstructor
105
- :short-code-config-list='
126
+ :short-code-config-list="
106
127
  moduleConfig ? moduleConfig.shortcodes : []
107
- '
128
+ "
108
129
  />
109
130
  </template>
110
131
 
111
132
  <template v-if="selectedTabId === 'images'">
112
- <form-field-file-input
113
- v-model='values.coverImage'
114
- :label="$t('blog:coverImage')"
115
- name='coverImage'
116
- file-type='image'
117
- :scenario='moduleConfig ? moduleConfig.fileScenarios.cover : null'
133
+ <FormFieldFileInput
134
+ v-model:value="values.coverImage"
135
+ :label="$i18n.t('blog:coverImage')"
136
+ name="coverImage"
137
+ file-type="image"
138
+ :scenario="moduleConfig ? moduleConfig.fileScenarios.cover : null"
118
139
  />
119
140
 
120
- <form-field-file-input
121
- v-model='values.image'
122
- name='image'
123
- :label="$t('blog:innerImage')"
124
- file-type='image'
125
- :scenario='moduleConfig ? moduleConfig.fileScenarios.image : null'
141
+ <FormFieldFileInput
142
+ v-model:value="values.image"
143
+ name="image"
144
+ :label="$i18n.t('blog:innerImage')"
145
+ file-type="image"
146
+ :scenario="moduleConfig ? moduleConfig.fileScenarios.image : null"
126
147
  />
127
148
 
128
- <form-field-file-input
129
- v-model='values.imageMobile'
130
- name='imageMobile'
131
- :label="$t('blog:innerImageMobile')"
132
- file-type='image'
133
- :scenario='
149
+ <FormFieldFileInput
150
+ v-model:value="values.imageMobile"
151
+ name="imageMobile"
152
+ :label="$i18n.t('blog:innerImageMobile')"
153
+ file-type="image"
154
+ :scenario="
134
155
  moduleConfig ? moduleConfig.fileScenarios.imageMobile : null
135
- '
156
+ "
136
157
  />
137
158
  </template>
138
159
 
139
160
  <template v-if="selectedTabId === 'relations'">
140
- <form-field
141
- v-model='values.tags'
142
- name='tags'
143
- :label="$t('blog:tags')"
144
- :error='errors.tags'
161
+ <FormField
162
+ v-model:value="values.tags"
163
+ name="tags"
164
+ :label="$i18n.t('blog:tags')"
165
+ :error="errors.tags"
145
166
  />
146
167
 
147
- <form-field-multi-select
148
- :selected-options='values.categories'
149
- name='categories'
150
- :label="$t('blog:categories')"
151
- :options='categoryOptionList'
152
- :error='errors.categories'
153
- @change='handleCategoriesChange'
168
+ <FormFieldMultiSelect
169
+ v-model:selected-options="values.categories"
170
+ name="categories"
171
+ :label="$i18n.t('blog:categories')"
172
+ :options="categoryOptionList"
173
+ :error="errors.categories"
174
+ @change="handleCategoriesChange"
154
175
  />
155
176
 
156
- <form-field-multi-select
157
- v-model='values.relatedPosts'
158
- name='relatedPosts'
159
- :label="$t('blog:relatedPosts')"
160
- :options='postOptionList'
161
- :error='errors.relatedPosts'
162
- :searchable='true'
177
+ <FormFieldMultiSelect
178
+ v-model:selected-options="values.relatedPosts"
179
+ name="relatedPosts"
180
+ :label="$i18n.t('blog:relatedPosts')"
181
+ :options="postOptionList"
182
+ :error="errors.relatedPosts"
183
+ :searchable="true"
163
184
  />
164
185
  </template>
165
186
 
166
187
  <template v-if="selectedTabId === 'additional'">
167
188
  <DynamicField
168
- v-for='field of values.additionalFields'
169
- :key='field.name'
170
- :field='field'
189
+ v-for="field of values.additionalFields"
190
+ :key="field.name"
191
+ :field="field"
171
192
  />
172
193
  </template>
173
194
 
174
195
  <template v-if="selectedTabId === 'seo'">
175
- <seo-field-group
176
- :title='values.pageTitle'
177
- :title-error-message='errors.pageTitle'
178
- :title-label="$t('blog:pageTitle')"
179
- :description='values.pageDescription'
180
- :description-error-message='errors.pageDescription'
181
- :description-label="$t('blog:pageDescription')"
182
- :image='values.openGraphImage'
183
- :image-error-message='errors.openGraphImage'
184
- :image-label="$t('blog:openGraphImage')"
185
- :image-scenario='
196
+ <SeoFieldGroup
197
+ :title="values.pageTitle"
198
+ :title-error-message="errors.pageTitle"
199
+ :title-label="$i18n.t('blog:pageTitle')"
200
+ :description="values.pageDescription"
201
+ :description-error-message="errors.pageDescription"
202
+ :description-label="$i18n.t('blog:pageDescription')"
203
+ :image="values.openGraphImage"
204
+ :image-error-message="errors.openGraphImage"
205
+ :image-label="$i18n.t('blog:openGraphImage')"
206
+ :image-scenario="
186
207
  moduleConfig ? moduleConfig.fileScenarios.openGraph : null
187
- '
188
- @change='handleSeoFieldGroupChange'
208
+ "
209
+ @change="handleSeoFieldGroupChange"
189
210
  />
190
211
  </template>
191
212
  </form>
192
213
  </template>
193
214
 
194
- <template v-slot:footer>
215
+ <template #footer>
195
216
  <FormFooter
196
- :back-href='postListUrl'
197
- :on-submit='submitForm'
198
- :is-submitting='isSubmitting'
199
- :is-creation='isCreation'
200
- :can-create-another='isCreation'
217
+ :back-href="postListUrl"
218
+ :is-submitting="isSubmitting"
219
+ :is-creation="isCreation"
220
+ :can-create-another="isCreation"
221
+ @submit="submitForm"
201
222
  />
202
223
  </template>
203
- </page>
224
+ </Page>
204
225
  </template>
205
226
 
206
- <script lang='ts'>
207
- import {
208
- computed,
209
- defineComponent,
210
- onMounted,
211
- ref,
212
- watch
213
- } from '@vue/composition-api';
227
+ <script lang="ts">
228
+ import { computed, defineComponent, onMounted, ref, watch } from 'vue';
229
+ import { useRoute, useRouter } from 'vue-router';
214
230
 
215
231
  import {
216
232
  convertRequestErrorToMap,
217
233
  isNotNullish,
218
234
  Nullable,
219
235
  useResource,
220
- urlTranslit
236
+ urlTranslit,
237
+ useI18n,
238
+ useToast,
239
+ navigateBack,
221
240
  } from '@tager/admin-services';
222
241
  import {
223
242
  createTabErrorFinder,
@@ -226,24 +245,31 @@ import {
226
245
  ShortCodeConstructor,
227
246
  SeoChangeEvent,
228
247
  FormFooter,
229
- TagerFormSubmitEvent
248
+ TagerFormSubmitEvent,
249
+ FormFieldSelect,
250
+ FormField,
251
+ FormFieldUrlAliasInput,
252
+ FormFieldCheckbox,
253
+ FormFieldRichTextInput,
254
+ FormFieldFileInput,
255
+ FormFieldMultiSelect,
256
+ SeoFieldGroup,
257
+ TabList,
230
258
  } from '@tager/admin-ui';
231
259
  import { DynamicField } from '@tager/admin-dynamic-field';
260
+ import { Page } from '@tager/admin-layout';
232
261
 
233
- import {
234
- getBlogPostFormUrl,
235
- getBlogPostListUrl
236
- } from '../../../constants/paths';
262
+ import { getBlogPostFormUrl, getBlogPostListUrl } from '../../../utils/paths';
237
263
  import {
238
264
  createBlogPost,
239
265
  getPost,
240
- updateBlogPost
266
+ updateBlogPost,
241
267
  } from '../../../services/requests';
242
268
  import { Language, PostFull } from '../../../typings/model';
243
269
  import {
244
270
  useFetchModuleConfig,
245
271
  useFetchCategories,
246
- useFetchPosts
272
+ useFetchPosts,
247
273
  } from '../../../hooks';
248
274
 
249
275
  import {
@@ -252,28 +278,43 @@ import {
252
278
  convertFormValuesToUpdatePayload,
253
279
  convertPostToFormValues,
254
280
  FormValues,
255
- getStatusOptions
281
+ getStatusOptions,
256
282
  } from './PostForm.helpers';
257
283
 
258
284
  export default defineComponent({
259
285
  name: 'BlogPostForm',
260
- components: { DynamicField, ShortCodeConstructor, FormFooter },
261
- setup(props, context) {
262
- const postId = computed<string>(() => context.root.$route.params.postId);
286
+ components: {
287
+ SeoFieldGroup,
288
+ FormFieldMultiSelect,
289
+ FormFieldFileInput,
290
+ FormFieldRichTextInput,
291
+ FormFieldCheckbox,
292
+ FormFieldUrlAliasInput,
293
+ FormField,
294
+ FormFieldSelect,
295
+ TabList,
296
+ Page,
297
+ DynamicField,
298
+ ShortCodeConstructor,
299
+ FormFooter,
300
+ },
301
+ setup() {
302
+ const route = useRoute();
303
+ const router = useRouter();
304
+ const toast = useToast();
305
+ const { t } = useI18n();
306
+
307
+ const postId = computed<string>(() => route.params.postId as string);
263
308
  const isCreation = computed<boolean>(() => postId.value === 'create');
264
309
 
265
310
  const urlAliasChanged = ref<boolean>(false);
266
311
 
267
- const statusOptions = computed<OptionType[]>(() =>
268
- getStatusOptions(context.root.$t)
269
- );
312
+ const statusOptions = computed<OptionType[]>(() => getStatusOptions(t));
270
313
 
271
314
  /** Fetch module config **/
272
315
 
273
- const {
274
- data: moduleConfig,
275
- loading: isModuleConfigLoading
276
- } = useFetchModuleConfig({ context });
316
+ const { data: moduleConfig, loading: isModuleConfigLoading } =
317
+ useFetchModuleConfig();
277
318
 
278
319
  const languageList = computed<Language[]>(
279
320
  () => moduleConfig.value?.languages ?? []
@@ -282,7 +323,7 @@ export default defineComponent({
282
323
  const languageOptionList = computed<OptionType[]>(() =>
283
324
  languageList.value.map(({ id, name }) => ({
284
325
  value: id,
285
- label: name
326
+ label: name,
286
327
  }))
287
328
  );
288
329
 
@@ -290,18 +331,18 @@ export default defineComponent({
290
331
 
291
332
  /** Fetch category list */
292
333
 
293
- const {
294
- data: categoryList,
295
- loading: isCategoryListLoading
296
- } = useFetchCategories({ context });
334
+ const { data: categoryList, loading: isCategoryListLoading } =
335
+ useFetchCategories();
297
336
 
298
337
  /** Fetch Post */
299
338
 
300
- const [fetchPost, { data: post, loading: isPostLoading }] = useResource<Nullable<PostFull>>({
301
- fetchResource: () => getPost(postId.value),
339
+ const [fetchPost, { data: post, loading: isPostLoading }] = useResource<
340
+ Nullable<PostFull>
341
+ >({
342
+ fetchResource: () =>
343
+ postId.value ? getPost(postId.value) : new Promise(() => null),
302
344
  initialValue: null,
303
- context,
304
- resourceName: 'Post'
345
+ resourceName: 'Post',
305
346
  });
306
347
 
307
348
  onMounted(() => {
@@ -317,16 +358,14 @@ export default defineComponent({
317
358
  });
318
359
 
319
360
  /** Fetch post list */
320
- const { data: postList, loading: isPostListLoading } = useFetchPosts({
321
- context
322
- });
361
+ const { data: postList, loading: isPostListLoading } = useFetchPosts();
323
362
 
324
363
  const postOptionList = computed<OptionType<number>[]>(() =>
325
364
  postList.value
326
365
  .filter((relatedPost) => relatedPost.id !== post.value?.id)
327
366
  .map((post) => ({
328
367
  value: post.id,
329
- label: post.title
368
+ label: post.title,
330
369
  }))
331
370
  );
332
371
 
@@ -368,17 +407,11 @@ export default defineComponent({
368
407
  errors.value = {};
369
408
 
370
409
  if (event.type === 'create') {
371
- context.root.$router.push(
372
- getBlogPostFormUrl({ postId: String(data.id) })
373
- );
410
+ router.push(getBlogPostFormUrl({ postId: String(data.id) }));
374
411
  }
375
412
 
376
413
  if (event.type === 'create_exit' || event.type === 'save_exit') {
377
- if (context.root.$previousRoute) {
378
- context.root.$router.back();
379
- } else {
380
- context.root.$router.push(getBlogPostListUrl());
381
- }
414
+ navigateBack(router, getBlogPostListUrl());
382
415
  }
383
416
 
384
417
  if (event.type === 'create_create-another') {
@@ -391,23 +424,23 @@ export default defineComponent({
391
424
  );
392
425
  }
393
426
 
394
- context.root.$toast({
427
+ toast.show({
395
428
  variant: 'success',
396
- title: context.root.$t('blog:success'),
429
+ title: t('blog:success'),
397
430
  body: isCreation.value
398
- ? context.root.$t('blog:blogPostWasSuccessfullyCreated')
399
- : context.root.$t('blog:blogPostWasSuccessfullyUpdated')
431
+ ? t('blog:blogPostWasSuccessfullyCreated')
432
+ : t('blog:blogPostWasSuccessfullyUpdated'),
400
433
  });
401
434
  })
402
435
  .catch((error) => {
403
436
  console.error(error);
404
437
  errors.value = convertRequestErrorToMap(error);
405
- context.root.$toast({
438
+ toast.show({
406
439
  variant: 'danger',
407
- title: context.root.$t('blog:error'),
440
+ title: t('blog:error'),
408
441
  body: isCreation.value
409
- ? context.root.$t('blog:blogPostCreationWasFailed')
410
- : context.root.$t('blog:blogPostUpdateWasFailed')
442
+ ? t('blog:blogPostCreationWasFailed')
443
+ : t('blog:blogPostUpdateWasFailed'),
411
444
  });
412
445
  })
413
446
  .finally(() => {
@@ -473,32 +506,32 @@ export default defineComponent({
473
506
  return [
474
507
  {
475
508
  id: 'common',
476
- label: context.root.$t('blog:common'),
509
+ label: t('blog:common'),
477
510
  hasErrors: hasErrors([
478
511
  'title',
479
512
  'language',
480
513
  'urlAlias',
481
514
  'excerpt',
482
515
  'body',
483
- 'date'
484
- ])
516
+ 'date',
517
+ ]),
485
518
  },
486
519
  {
487
520
  id: 'images',
488
- label: context.root.$t('blog:images'),
489
- hasErrors: hasErrors(['coverImage', 'image'])
521
+ label: t('blog:images'),
522
+ hasErrors: hasErrors(['coverImage', 'image']),
490
523
  },
491
524
  {
492
525
  id: 'relations',
493
- label: context.root.$t('blog:relations'),
494
- hasErrors: hasErrors(['categories', 'relatedPosts', 'tags'])
526
+ label: t('blog:relations'),
527
+ hasErrors: hasErrors(['categories', 'relatedPosts', 'tags']),
495
528
  },
496
529
  values.value.additionalFields.length > 0
497
530
  ? {
498
- id: 'additional',
499
- label: context.root.$t('blog:additionalFields'),
500
- hasErrors: hasErrors([])
501
- }
531
+ id: 'additional',
532
+ label: t('blog:additionalFields'),
533
+ hasErrors: hasErrors([]),
534
+ }
502
535
  : null,
503
536
  {
504
537
  id: 'seo',
@@ -506,31 +539,33 @@ export default defineComponent({
506
539
  hasErrors: hasErrors([
507
540
  'pageTitle',
508
541
  'pageDescription',
509
- 'openGraphImage'
510
- ])
511
- }
542
+ 'openGraphImage',
543
+ ]),
544
+ },
512
545
  ].filter(isNotNullish);
513
546
  });
514
547
 
515
548
  const selectedTabId = ref<string>(tabList.value[0].id);
516
549
 
517
- const headerButtonList = computed<{ text: string; href: string; target?: string }[]>(() =>
550
+ const headerButtonList = computed<
551
+ { text: string; href: string; target?: string }[]
552
+ >(() =>
518
553
  [
519
554
  post.value
520
555
  ? {
521
- text: context.root.$t('blog:viewPost'),
522
- href: process.env.VUE_APP_WEBSITE_URL + post.value.url,
523
- target: '_blank'
524
- }
525
- : null
556
+ text: t('blog:viewPost'),
557
+ href: process.env.VUE_APP_WEBSITE_URL + post.value.url,
558
+ target: '_blank',
559
+ }
560
+ : null,
526
561
  ].filter(isNotNullish)
527
562
  );
528
563
 
529
564
  function handleSeoFieldGroupChange({
530
- title,
531
- description,
532
- image
533
- }: SeoChangeEvent) {
565
+ title,
566
+ description,
567
+ image,
568
+ }: SeoChangeEvent) {
534
569
  values.value.pageTitle = title;
535
570
  values.value.pageDescription = description;
536
571
  values.value.openGraphImage = image;
@@ -579,7 +614,7 @@ export default defineComponent({
579
614
 
580
615
  const newSelectedOption: OptionType<number> = {
581
616
  value: foundSelectedCategory.id,
582
- label: foundSelectedCategory.name
617
+ label: foundSelectedCategory.name,
583
618
  };
584
619
 
585
620
  if (
@@ -626,13 +661,13 @@ export default defineComponent({
626
661
  urlAliasTemplate,
627
662
  handleCategoriesChange,
628
663
 
629
- statusOptions
664
+ statusOptions,
630
665
  };
631
- }
666
+ },
632
667
  });
633
668
  </script>
634
669
 
635
- <style scoped lang='scss'>
670
+ <style scoped lang="scss">
636
671
  .status {
637
672
  display: flex;
638
673
  align-items: flex-end;
@@ -651,4 +686,4 @@ export default defineComponent({
651
686
  margin-left: 20px;
652
687
  flex: 1 1 1px;
653
688
  }
654
- </style>
689
+ </style>