Skip to content

Commit

Permalink
Refine design and functionality of group list and create, edit group
Browse files Browse the repository at this point in the history
  • Loading branch information
Tirokk committed Sep 26, 2022
1 parent e5acca7 commit 7b11122
Show file tree
Hide file tree
Showing 11 changed files with 292 additions and 175 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
<template #default="{ toggleMenu }">
<slot name="button" :toggleMenu="toggleMenu">
<base-button
data-test="group-menu-button"
icon="ellipsis-v"
size="large"
size="small"
circle
ghost
@click.prevent="toggleMenu()"
data-test="group-menu-button"
/>
</slot>
</template>
Expand Down Expand Up @@ -36,7 +35,7 @@
import Dropdown from '~/components/Dropdown'
export default {
name: 'ContentMenu',
name: 'GroupContentMenu',
components: {
Dropdown,
},
Expand Down
69 changes: 29 additions & 40 deletions webapp/components/Group/GroupForm.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<template>
<div>
<!-- Wolle: <div v-if="update">add: slug, location, tiptap editor in description</div> -->
<!-- Wolle: <ds-container> -->
<ds-form
class="group-form"
ref="groupForm"
Expand Down Expand Up @@ -97,6 +95,8 @@
:loading="loadingGeo"
@input.native="handleCityInput"
/>
<!-- TODO: implement clear button -->
<!-- <base-button icon="close" circle ghost size="small" :disabled="formData.locationName.length === 0" @click="clear" /> -->
</ds-space>
<ds-space margin-top="large">
<categories-select
Expand Down Expand Up @@ -198,50 +198,39 @@ export default {
},
computed: {
submitDisable() {
if (
this.formData.name !== '' &&
this.formData.groupType !== '' &&
this.formData.about !== '' &&
this.formData.description !== '' &&
this.formData.actionRadius !== '' &&
this.formData.locationName !== '' &&
this.formData.categoryIds.length > 0
) {
return false
}
return true
return (
this.formData.name === '' ||
this.formData.groupType === '' ||
// this.formData.about === '' || // not mandatory
this.formData.description === '' ||
this.formData.actionRadius === '' ||
// this.formData.locationName === '' || // not mandatory
this.formData.categoryIds.length === 0
)
},
submitDisableEdit() {
if (
this.formData.name !== this.group.name ||
this.formData.groupType !== this.group.groupType ||
this.formData.about !== this.group.about ||
this.formData.description !== this.group.description ||
this.formData.actionRadius !== this.group.actionRadius ||
this.formData.locationName !== this.group.locationName ||
this.formData.categoryIds.length === 0 ||
!this.sameCategories
) {
return false
}
return true
return (
this.formData.name === this.group.name &&
this.formData.slug === this.group.slug &&
// this.formData.groupType === this.group.groupType && // can not be changed for now
this.formData.about === this.group.about &&
this.formData.description === this.group.description &&
this.formData.actionRadius === this.group.actionRadius &&
this.formData.locationName === (this.group.locationName ? this.group.locationName : '') &&
this.sameCategories
)
},
sameCategories() {
const formDataCategories = this.formData.categoryIds.map((categoryIds) => categoryIds)
const groupDataCategories = this.group.categories.map((category) => category.id)
let result
let each = true
const formDataCategories = this.formData.categoryIds.map((id) => id).sort()
const groupDataCategories = this.group.categories.map((category) => category.id).sort()
let equal = true
if (formDataCategories.length !== groupDataCategories.length) return false
if (JSON.stringify(formDataCategories) !== JSON.stringify(groupDataCategories)) {
formDataCategories.forEach((element) => {
result = groupDataCategories.filter((groupCategorieId) => groupCategorieId === element)
if (result.length === 0) each = false
})
return each
}
return true
formDataCategories.forEach((id, index) => {
equal = equal && id === groupDataCategories[index]
})
return equal
},
},
methods: {
Expand Down Expand Up @@ -311,7 +300,7 @@ export default {
}
</script>

<style lang="scss">
<style lang="scss" scoped>
.select-label {
margin-bottom: 3pt;
color: $text-color-soft;
Expand Down
112 changes: 6 additions & 106 deletions webapp/components/Group/GroupList.vue
Original file line number Diff line number Diff line change
@@ -1,121 +1,21 @@
<template>
<div>
<!-- Wolle: <ds-container class="group-card"> -->
<!-- Wolle: <ds-space>
<div @click="onlyOwnerGroups(true)" ref="myGruops">
<ds-button>{{ $t('group.showMyCreatedGroups') }}</ds-button>
</div>
<div @click="onlyOwnerGroups(false)" ref="allGruops" hidden>
<ds-button>{{ $t('group.showAllMyGroups') }}</ds-button>
</div>
</ds-space> -->
<ds-space margin-bottom="small" v-for="item in items" :key="item.id">
<!-- Wolle: <ds-card :ref="item.myRole === null ? 'null' : item.myRole"> -->
<ds-card>
<ds-flex>
<ds-flex-item width="90%" centered>
<ds-space margin="large">
<nuxt-link :to="`/group/${item.id}`">
<ds-text size="x-large">{{ item.name }}</ds-text>
</nuxt-link>
<ds-text size="small">
{{ item.groupType }}
<ds-chip v-if="item.myRole === 'owner'" color="inverse">{{ item.myRole }}</ds-chip>
<ds-chip v-if="item.myRole === 'usual' || item.myRole === 'pending'">
{{ item.myRole }}
</ds-chip>
</ds-text>
<ds-space v-if="item.about" margin-top="small">
<ds-text bold>{{ item.about }}</ds-text>
</ds-space>
<ds-space margin-top="small">
<div v-html="item.descriptionExcerpt"></div>
</ds-space>
<ds-space margin-top="small">
<ds-chip v-for="category in item.categories" :key="category.name">
<ds-icon :name="category.icon"></ds-icon>
{{ category.name }}
</ds-chip>
<ds-space margin="x-small">
<div v-if="item.locationName">{{ item.locationName }}</div>
<div v-if="item.actionRadius">{{ item.actionRadius }}</div>
</ds-space>
</ds-space>
</ds-space>
</ds-flex-item>
<ds-flex-item width="10%" centered>
<group-menu
v-if="item.myRole === 'owner'"
resource-type="group"
:resource="item"
:isOwner="item.myRole"
@joinGroup="joinGroup"
/>
</ds-flex-item>
</ds-flex>
</ds-card>
<ds-space margin-bottom="small" v-for="group in groups" :key="group.id">
<group-teaser :group="group" />
</ds-space>
<!-- Wolle: </ds-container> -->
</div>
</template>

<script>
import GroupMenu from '~/components/Group/GroupMenu'
import { joinGroupMutation } from '~/graphql/groups.js'
import GroupTeaser from '~/components/Group/GroupTeaser'
export default {
name: 'GroupList',
components: {
GroupMenu,
GroupTeaser,
},
props: {
items: { type: Array, default: () => [] },
},
methods: {
editGroup(item) {
this.$router.push({ path: `/group/edit/${item.id}` })
},
async joinGroup(value) {
const { id } = value
const variables = { groupId: id, userId: this.$store.getters['auth/user'].id }
try {
await this.$apollo.mutate({
mutation: joinGroupMutation(),
variables,
})
this.$toast.success(this.$t('group.groupCreated'))
} catch (error) {
this.$toast.error(error.message)
}
},
// Wolle: onlyOwnerGroups(bool) {
// this.$refs.myGruops.hidden = bool
// this.$refs.allGruops.hidden = !bool
// if (this.$refs.usual) {
// this.$refs.usual.forEach((element) => {
// element.$el.hidden = bool
// })
// }
// if (this.$refs.null) {
// this.$refs.null.forEach((element) => {
// element.$el.hidden = bool
// })
// }
// if (this.$refs.pending) {
// this.$refs.pending.forEach((element) => {
// element.$el.hidden = bool
// })
// }
// },
groups: { type: Array, default: () => [] },
},
}
</script>
<style scoped>
.border-bottom {
border-bottom: 1px solid #17b53f;
background-color: rgb(255, 255, 255);
padding-left: 20px;
}
</style>
Loading

0 comments on commit 7b11122

Please sign in to comment.