get it working

This commit is contained in:
Moriz Wahl 2023-04-25 13:27:25 +02:00
parent 3244f3f86d
commit 8df7d5d265
2 changed files with 265 additions and 264 deletions

View File

@ -20,12 +20,12 @@
</template> </template>
<script> <script>
import CategoryQuery from '~/graphql/CategoryQuery' import CategoryQuery from '~/graphql/CategoryQuery'
import { CATEGORIES_MAX } from '~/constants/categories.js' import { CATEGORIES_MAX } from '~/constants/categories.js'
import xor from 'lodash/xor' import xor from 'lodash/xor'
import SortCategories from '~/mixins/sortCategoriesMixin.js' import SortCategories from '~/mixins/sortCategoriesMixin.js'
export default { export default {
inject: { inject: {
$parentForm: { $parentForm: {
default: null, default: null,
@ -45,9 +45,10 @@
}, },
watch: { watch: {
existingCategoryIds() { existingCategoryIds() {
console.log('existingCategoryIds', this.selectedCategoryIds) if (!this.selectedCategoryIds.length && this.existingCategoryIds.length) {
if (!this.selectedCategoryIds.length)
this.selectedCategoryIds = this.existingCategoryIds this.selectedCategoryIds = this.existingCategoryIds
this.$forceUpdate()
}
}, },
}, },
computed: { computed: {
@ -85,11 +86,11 @@
}, },
}, },
}, },
} }
</script> </script>
<style lang="scss"> <style lang="scss">
.categories-select { .categories-select {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
@ -97,5 +98,5 @@
margin-right: $space-xx-small; margin-right: $space-xx-small;
margin-bottom: $space-xx-small; margin-bottom: $space-xx-small;
} }
} }
</style> </style>

View File

@ -94,16 +94,16 @@
</template> </template>
<script> <script>
import gql from 'graphql-tag' import gql from 'graphql-tag'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import Editor from '~/components/Editor/Editor' import Editor from '~/components/Editor/Editor'
import PostMutations from '~/graphql/PostMutations.js' import PostMutations from '~/graphql/PostMutations.js'
import CategoriesSelect from '~/components/CategoriesSelect/CategoriesSelect' import CategoriesSelect from '~/components/CategoriesSelect/CategoriesSelect'
import ImageUploader from '~/components/Uploader/ImageUploader' import ImageUploader from '~/components/Uploader/ImageUploader'
import links from '~/constants/links.js' import links from '~/constants/links.js'
import PageParamsLink from '~/components/_new/features/PageParamsLink/PageParamsLink.vue' import PageParamsLink from '~/components/_new/features/PageParamsLink/PageParamsLink.vue'
export default { export default {
components: { components: {
Editor, Editor,
ImageUploader, ImageUploader,
@ -138,7 +138,7 @@
imageAspectRatio, imageAspectRatio,
imageType, imageType,
imageBlurred, imageBlurred,
categoryIds: categories ? categories.map((category) => category.id) : [] categoryIds: categories ? categories.map((category) => category.id) : [], // : this.groupCategories.map((cat) => cat.id) || [],
}, },
formSchema: { formSchema: {
title: { required: true, min: 3, max: 100 }, title: { required: true, min: 3, max: 100 },
@ -178,13 +178,13 @@
return this.group && this.group.name return this.group && this.group.name
}, },
groupCategories() { groupCategories() {
return this.group && this.group.categories return this.group && this.group.categories // && group.categories.map((cat) => cat.id )
}, },
}, },
watch: { watch: {
groupCategories() { groupCategories() {
console.log('groupCategories', this.groupCategories) if (!this.formData.categoryIds.length && this.groupCategories)
if (!this.formData.categoryIds && this.groupCategories) this.formData.categoryIds = this.groupCategories this.formData.categoryIds = this.groupCategories.map((cat) => cat.id)
}, },
}, },
methods: { methods: {
@ -284,7 +284,7 @@
}, },
}, },
}, },
} }
</script> </script>
<style lang="scss"> <style lang="scss">