mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2026-04-27 00:08:45 +00:00
update group data funktion
This commit is contained in:
parent
228a676cd5
commit
99d2ce9d29
@ -37,12 +37,5 @@ export default {
|
|||||||
alert('unfollow group')
|
alert('unfollow group')
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
|
||||||
status(state) {
|
|
||||||
console.log(state)
|
|
||||||
// if (scope === 'hidden') return 'danger'
|
|
||||||
return 'inverse'
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@ -1,6 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<ds-container>
|
<ds-container>
|
||||||
|
update: {{update}}
|
||||||
<ds-form
|
<ds-form
|
||||||
class="group-form"
|
class="group-form"
|
||||||
ref="groupForm"
|
ref="groupForm"
|
||||||
@ -16,7 +17,7 @@
|
|||||||
|
|
||||||
<ds-select
|
<ds-select
|
||||||
icon="user"
|
icon="user"
|
||||||
v-model="formData.status"
|
v-model="formData.groupType"
|
||||||
label="Sichtbarkeit"
|
label="Sichtbarkeit"
|
||||||
:options="['public', 'close', 'hidden']"
|
:options="['public', 'close', 'hidden']"
|
||||||
placeholder="Status ..."
|
placeholder="Status ..."
|
||||||
@ -37,7 +38,7 @@
|
|||||||
|
|
||||||
<ds-select
|
<ds-select
|
||||||
icon="card"
|
icon="card"
|
||||||
v-model="formData.radius"
|
v-model="formData.actionRadius"
|
||||||
label="Radius"
|
label="Radius"
|
||||||
:options="['local', 'regional', 'global']"
|
:options="['local', 'regional', 'global']"
|
||||||
placeholder="Radius ..."
|
placeholder="Radius ..."
|
||||||
@ -60,12 +61,12 @@
|
|||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
primary
|
primary
|
||||||
>
|
>
|
||||||
save
|
{{update ? $t('group.update') : $t('group.save')}}
|
||||||
</ds-button>
|
</ds-button>
|
||||||
</ds-space>
|
</ds-space>
|
||||||
</ds-form>
|
</ds-form>
|
||||||
<ds-space centered>
|
<ds-space centered>
|
||||||
<nuxt-link to="/my-groups">zurück</nuxt-link>
|
<nuxt-link to="/group/my-groups">zurück</nuxt-link>
|
||||||
</ds-space>
|
</ds-space>
|
||||||
</ds-container>
|
</ds-container>
|
||||||
</div>
|
</div>
|
||||||
@ -80,30 +81,36 @@ export default {
|
|||||||
CategoriesSelect,
|
CategoriesSelect,
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
|
update: {
|
||||||
|
type: Boolean,
|
||||||
|
required: false,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
group: {
|
group: {
|
||||||
type: Object,
|
type: Object,
|
||||||
|
required: false,
|
||||||
default: () => ({}),
|
default: () => ({}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
const { name, status, about, description, radius, categories } = this.group
|
const { name, groupType, about, description, actionRadius, categories } = this.groupData
|
||||||
return {
|
return {
|
||||||
categoriesActive: this.$env.CATEGORIES_ACTIVE,
|
categoriesActive: this.$env.CATEGORIES_ACTIVE,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
formData: {
|
formData: {
|
||||||
name: name || '',
|
name: name || '',
|
||||||
status: status || '',
|
groupType: groupType || '',
|
||||||
about: about || '',
|
about: about || '',
|
||||||
description: description || '',
|
description: description || '',
|
||||||
radius: radius || '',
|
actionRadius: actionRadius || '',
|
||||||
categoryIds: categories ? categories.map((category) => category.id) : [],
|
categoryIds: categories ? categories.map((category) => category.id) : [],
|
||||||
},
|
},
|
||||||
formSchema: {
|
formSchema: {
|
||||||
name: { required: true, min: 3, max: 100 },
|
name: { required: true, min: 3, max: 100 },
|
||||||
status: { required: true },
|
groupType: { required: true },
|
||||||
about: { required: true },
|
about: { required: true },
|
||||||
description: { required: true },
|
description: { required: true },
|
||||||
radius: { required: true },
|
actionRadius: { required: true },
|
||||||
categoryIds: {
|
categoryIds: {
|
||||||
type: 'array',
|
type: 'array',
|
||||||
required: this.categoriesActive,
|
required: this.categoriesActive,
|
||||||
@ -121,7 +128,7 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
submit() {
|
submit() {
|
||||||
console.log('submit', this.formData)
|
console.log('submit', this.formData)
|
||||||
this.$emit('createGroup', this.formData)
|
this.update ? this.$emit('updateGroup', this.formData) : this.$emit('createGroup', this.formData)
|
||||||
},
|
},
|
||||||
reset() {
|
reset() {
|
||||||
console.log('reset')
|
console.log('reset')
|
||||||
@ -2,7 +2,6 @@
|
|||||||
<div>
|
<div>
|
||||||
<ds-container class="group-list">
|
<ds-container class="group-list">
|
||||||
<ds-space><h2>Group List</h2></ds-space>
|
<ds-space><h2>Group List</h2></ds-space>
|
||||||
{{items}}
|
|
||||||
<ds-table :data="items" :fields="fields">
|
<ds-table :data="items" :fields="fields">
|
||||||
<template slot="delete" slot-scope="scope">
|
<template slot="delete" slot-scope="scope">
|
||||||
<base-button
|
<base-button
|
||||||
@ -12,22 +11,31 @@
|
|||||||
></base-button>
|
></base-button>
|
||||||
</template>
|
</template>
|
||||||
<template slot="name" slot-scope="scope">
|
<template slot="name" slot-scope="scope">
|
||||||
<nuxt-link to="/group/g1/testgruppe">{{ scope.row.name }}</nuxt-link>
|
<nuxt-link :to="`/group/g1/${scope.row.name}`">{{ scope.row.name }}</nuxt-link>
|
||||||
|
<small>{{scope.row}}</small>
|
||||||
</template>
|
</template>
|
||||||
<template slot="categories" slot-scope="scope">
|
<template slot="categories" slot-scope="scope">
|
||||||
<ds-tag v-for="categorie in categories" :key="categorie.id" :color="status">{{ categorie.name }}</ds-tag>
|
<ds-tag v-for="categorie in scope.row.categories" :key="categorie.id" color="primary">{{ categorie.name }}</ds-tag>
|
||||||
</template>
|
</template>
|
||||||
<template slot="edit" slot-scope="scope">
|
<template slot="edit" slot-scope="scope">
|
||||||
<base-button
|
<base-button
|
||||||
v-if="!scope.row.owner"
|
v-if="!scope.row.owner"
|
||||||
icon="close"
|
icon="edit"
|
||||||
@click="unfollowGroup(scope.row)"
|
@click="editGroup(scope.row)"
|
||||||
></base-button>
|
></base-button>
|
||||||
|
|
||||||
<nuxt-link :to="{ name: 'group-create' }">
|
<nuxt-link :to="{ name: 'group-create' }">
|
||||||
<ds-icon v-show="scope.row.owner" name="ellipsis-v"></ds-icon>
|
<ds-icon v-show="scope.row.owner" name="ellipsis-v"></ds-icon>
|
||||||
</nuxt-link>
|
</nuxt-link>
|
||||||
</template>
|
</template>
|
||||||
|
<template slot="unfollow" slot-scope="scope">
|
||||||
|
<base-button
|
||||||
|
:disabled="!scope.row.owner ? 'disable' : false"
|
||||||
|
v-if="!scope.row.owner"
|
||||||
|
icon="close"
|
||||||
|
@click="unfollowGroup(scope.row)"
|
||||||
|
></base-button>
|
||||||
|
</template>
|
||||||
</ds-table>
|
</ds-table>
|
||||||
</ds-container>
|
</ds-container>
|
||||||
</div>
|
</div>
|
||||||
@ -40,6 +48,10 @@ export default {
|
|||||||
fields: { type: Array, default: () => [] },
|
fields: { type: Array, default: () => [] },
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
editGroup(formData) {
|
||||||
|
console.log('GroupListedit group', formData)
|
||||||
|
this.$router.push({ path: `/group/edit/${formData.id}` })
|
||||||
|
},
|
||||||
deleteGroup() {
|
deleteGroup() {
|
||||||
alert('delete group')
|
alert('delete group')
|
||||||
},
|
},
|
||||||
@ -39,10 +39,57 @@ export const createGroupMutation = gql`
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
export const updateGroupMutation = gql`
|
||||||
|
mutation (
|
||||||
|
$id: ID!
|
||||||
|
$name: String
|
||||||
|
$slug: String
|
||||||
|
$about: String
|
||||||
|
$description: String
|
||||||
|
$actionRadius: GroupActionRadius
|
||||||
|
$categoryIds: [ID]
|
||||||
|
$avatar: ImageInput
|
||||||
|
$locationName: String
|
||||||
|
) {
|
||||||
|
UpdateGroup(
|
||||||
|
id: $id
|
||||||
|
name: $name
|
||||||
|
slug: $slug
|
||||||
|
about: $about
|
||||||
|
description: $description
|
||||||
|
actionRadius: $actionRadius
|
||||||
|
categoryIds: $categoryIds
|
||||||
|
avatar: $avatar
|
||||||
|
locationName: $locationName
|
||||||
|
) {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
slug
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
disabled
|
||||||
|
deleted
|
||||||
|
about
|
||||||
|
description
|
||||||
|
groupType
|
||||||
|
actionRadius
|
||||||
|
categories {
|
||||||
|
id
|
||||||
|
slug
|
||||||
|
name
|
||||||
|
icon
|
||||||
|
}
|
||||||
|
# avatar # test this as result
|
||||||
|
# locationName # test this as result
|
||||||
|
myRole
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
// ------ queries
|
// ------ queries
|
||||||
|
|
||||||
export const groupQuery = gql`
|
export const groupQuery = gql`
|
||||||
query(
|
query (
|
||||||
$isMember: Boolean
|
$isMember: Boolean
|
||||||
$id: ID
|
$id: ID
|
||||||
$name: String
|
$name: String
|
||||||
@ -90,6 +137,8 @@ export const groupQuery = gql`
|
|||||||
name
|
name
|
||||||
icon
|
icon
|
||||||
}
|
}
|
||||||
|
# avatar # test this as result
|
||||||
|
# locationName # test this as result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|||||||
@ -370,7 +370,11 @@
|
|||||||
"following": "Folge Ich"
|
"following": "Folge Ich"
|
||||||
},
|
},
|
||||||
"group": {
|
"group": {
|
||||||
"newGroup": "Erstelle eine neue Gruppe"
|
"newGroup": "Erstelle eine neue Gruppe",
|
||||||
|
"group-created": "Die Gruppe wurde angelegt.",
|
||||||
|
"group-updated": "Die Gruppendaten wurden geändert.",
|
||||||
|
"save":"neue Gruppe anlegen",
|
||||||
|
"update":"Änderung speichern"
|
||||||
},
|
},
|
||||||
"hashtags-filter": {
|
"hashtags-filter": {
|
||||||
"clearSearch": "Suche löschen",
|
"clearSearch": "Suche löschen",
|
||||||
@ -720,9 +724,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"groups": {
|
"myGroups": "Meine Gruppen",
|
||||||
"name": "Meine Gruppen"
|
|
||||||
},
|
|
||||||
"invites": {
|
"invites": {
|
||||||
"name": "Einladungen"
|
"name": "Einladungen"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -370,7 +370,11 @@
|
|||||||
"following": "Following"
|
"following": "Following"
|
||||||
},
|
},
|
||||||
"group": {
|
"group": {
|
||||||
"newGroup": "Create a new Group"
|
"newGroup": "Create a new Group",
|
||||||
|
"group-created": "The group was created.",
|
||||||
|
"group-updated": "The group data has been changed.",
|
||||||
|
"save":"Create new group",
|
||||||
|
"update":"Save change"
|
||||||
},
|
},
|
||||||
"hashtags-filter": {
|
"hashtags-filter": {
|
||||||
"clearSearch": "Clear search",
|
"clearSearch": "Clear search",
|
||||||
@ -720,9 +724,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"groups": {
|
"myGroups": "My Groups",
|
||||||
"name": "My Groups"
|
|
||||||
},
|
|
||||||
"invites": {
|
"invites": {
|
||||||
"name": "Invites"
|
"name": "Invites"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
|
<h2>Create Groupe</h2>
|
||||||
<ds-flex :width="{ base: '100%' }" gutter="base">
|
<ds-flex :width="{ base: '100%' }" gutter="base">
|
||||||
<ds-flex-item :width="{ base: '100%', md: 5 }">
|
<ds-flex-item :width="{ base: '100%', md: 5 }">
|
||||||
<group-form @createGroup="createGroup" />
|
<group-form @createGroup="createGroup" />
|
||||||
@ -12,8 +13,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import GroupForm from '~/components/GroupForm/GroupForm'
|
import GroupForm from '~/components/Group/GroupForm'
|
||||||
import GroupMember from '~/components/GroupMember/GroupMember.vue'
|
import GroupMember from '~/components/Group/GroupMember'
|
||||||
import { createGroupMutation } from '~/graphql/groups.js'
|
import { createGroupMutation } from '~/graphql/groups.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -28,9 +29,6 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async createGroup(form) {
|
async createGroup(form) {
|
||||||
console.log("createGroup", form)
|
|
||||||
console.log("createGroup form.categoryIds", form.categoryIds)
|
|
||||||
console.log("createGroup form.radius", form.radius)
|
|
||||||
try {
|
try {
|
||||||
await this.$apollo.mutate({
|
await this.$apollo.mutate({
|
||||||
mutation: createGroupMutation,
|
mutation: createGroupMutation,
|
||||||
@ -38,8 +36,8 @@ export default {
|
|||||||
name: form.name,
|
name: form.name,
|
||||||
about: form.about,
|
about: form.about,
|
||||||
description: form.description,
|
description: form.description,
|
||||||
groupType: form.status,
|
groupType: form.groupType,
|
||||||
actionRadius: form.radius,
|
actionRadius: form.actionRadius,
|
||||||
categoryIds: form.formData.categoryIds,
|
categoryIds: form.formData.categoryIds,
|
||||||
},
|
},
|
||||||
update: (_, { data: { createGroupData } }) => {
|
update: (_, { data: { createGroupData } }) => {
|
||||||
@ -48,7 +46,7 @@ export default {
|
|||||||
// ...this.createGroup,
|
// ...this.createGroup,
|
||||||
// sendNotificationEmails,
|
// sendNotificationEmails,
|
||||||
// })
|
// })
|
||||||
this.$toast.success(this.$t('settings.notifications.success-update'))
|
this.$toast.success(this.$t('group.group-created'))
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
112
webapp/pages/group/edit/_id.vue
Normal file
112
webapp/pages/group/edit/_id.vue
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
<template>
|
||||||
|
<ds-flex gutter="small">
|
||||||
|
{{$router}}
|
||||||
|
<ds-flex-item :width="{ base: '100%', md: '200px' }">
|
||||||
|
<ds-menu :routes="routes" :is-exact="() => true" />
|
||||||
|
</ds-flex-item>
|
||||||
|
<ds-flex-item :width="{ base: '100%', md: 1 }">
|
||||||
|
{{group}}
|
||||||
|
<transition name="slide-up" appear>
|
||||||
|
<group-form @updateGroup="updateGroup" :group="group" :update="true"/>
|
||||||
|
</transition>
|
||||||
|
</ds-flex-item>
|
||||||
|
</ds-flex>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import GroupForm from '~/components/Group/GroupForm'
|
||||||
|
import { groupQuery, updateGroupMutation } from '~/graphql/groups.js'
|
||||||
|
import { mapGetters } from 'vuex'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
GroupForm,
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
routes() {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
name: 'default',
|
||||||
|
path: ``,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'members',
|
||||||
|
path: ``,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'social media',
|
||||||
|
path: ``,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'invite link',
|
||||||
|
path: ``,
|
||||||
|
},
|
||||||
|
]},
|
||||||
|
...mapGetters({
|
||||||
|
user: 'auth/user',
|
||||||
|
}),
|
||||||
|
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
groupData: {},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async asyncData(context) {
|
||||||
|
console.log('asyncData start')
|
||||||
|
const {
|
||||||
|
app,
|
||||||
|
error,
|
||||||
|
params: { id },
|
||||||
|
} = context
|
||||||
|
const client = app.apolloProvider.defaultClient
|
||||||
|
const {
|
||||||
|
data: {
|
||||||
|
Group: [group],
|
||||||
|
},
|
||||||
|
} = await client.query({
|
||||||
|
query: groupQuery,
|
||||||
|
variables: { id },
|
||||||
|
})
|
||||||
|
console.log('asyncData group', group)
|
||||||
|
console.log('asyncData id', id)
|
||||||
|
if (group.myRole !== 'owner') {
|
||||||
|
error({ statusCode: 403, message: 'NONONNNO' })
|
||||||
|
}
|
||||||
|
return { group }
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
async updateGroup(form, context) {
|
||||||
|
const {
|
||||||
|
params: { id },
|
||||||
|
} = context
|
||||||
|
try {
|
||||||
|
await this.$apollo.mutate({
|
||||||
|
mutation: updateGroupMutation,
|
||||||
|
variables: {
|
||||||
|
id: params,
|
||||||
|
name: form.name,
|
||||||
|
about: form.about,
|
||||||
|
description: form.description,
|
||||||
|
// groupType: form.groupType,
|
||||||
|
actionRadius: form.actionRadius,
|
||||||
|
categoryIds: form.categoryIds,
|
||||||
|
// locationName: ''
|
||||||
|
},
|
||||||
|
update: (_, { data: { updateGroupData } }) => {
|
||||||
|
// const { sendNotificationEmails } = createGroup
|
||||||
|
// this.setCreateGroup({
|
||||||
|
// ...this.createGroup,
|
||||||
|
// sendNotificationEmails,
|
||||||
|
// })
|
||||||
|
this.$toast.success(this.$t('group.group-updated'))
|
||||||
|
},
|
||||||
|
})
|
||||||
|
} catch (error) {
|
||||||
|
// this.notifyByEmail = !this.notifyByEmail
|
||||||
|
this.$toast.error(error.message)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@ -9,9 +9,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import GroupTeaser from '~/components/GroupTeaser/GroupTeaser.vue'
|
import GroupTeaser from '~/components/Group/GroupTeaser.vue'
|
||||||
import GroupList from '~/components/GroupList/GroupList.vue'
|
import GroupList from '~/components/Group/GroupList.vue'
|
||||||
import GroupCard from '~/components/GroupList/GroupCard.vue'
|
import GroupCard from '~/components/Group/GroupCard.vue'
|
||||||
import { groupQuery } from '~/graphql/groups.js'
|
import { groupQuery } from '~/graphql/groups.js'
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -30,7 +30,7 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
responseGroupListQuery: [],
|
responseGroupListQuery: [],
|
||||||
fields: ['delete', 'name', 'about', 'categories', 'edit'],
|
fields: ['delete', 'name', 'about', 'categories', 'edit', 'unfollow'],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -40,8 +40,8 @@ export default {
|
|||||||
path: `/settings/my-social-media`,
|
path: `/settings/my-social-media`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: this.$t('settings.groups.name'),
|
name: this.$t('settings.myGroups'),
|
||||||
path: `/my-groups`,
|
path: `/group/my-groups`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: this.$t('settings.muted-users.name'),
|
name: this.$t('settings.muted-users.name'),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user