implement share project button
This commit is contained in:
parent
d9f07c1adb
commit
2b39cc92dd
|
|
@ -1,11 +1,11 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="widget-footer">
|
<div class="widget-footer">
|
||||||
<a @click="showMenu = !showMenu" class="widget-footer__more-link">
|
<a @click="toggleMenu" class="widget-footer__more-link">
|
||||||
<ellipses></ellipses>
|
<ellipses></ellipses>
|
||||||
</a>
|
</a>
|
||||||
<widget-popover v-if="showMenu"
|
<widget-popover v-if="showMenu"
|
||||||
@hide-me="showMenu = false">
|
@hide-me="showMenu = false">
|
||||||
<slot></slot>
|
<slot :hide="toggleMenu"></slot>
|
||||||
</widget-popover>
|
</widget-popover>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -25,6 +25,12 @@
|
||||||
return {
|
return {
|
||||||
showMenu: false
|
showMenu: false
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
toggleMenu: function () {
|
||||||
|
this.showMenu = !this.showMenu
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -8,18 +8,16 @@
|
||||||
|
|
||||||
</router-link>
|
</router-link>
|
||||||
<widget-footer>
|
<widget-footer>
|
||||||
<li class="popover-links__link"><a @click="deleteProject()">Projekt löschen</a></li>
|
<template slot-scope="scope">
|
||||||
<li class="popover-links__link"><a @click="editProject()">Projekt bearbeiten</a></li>
|
<li class="popover-links__link"><a @click="$emit('delete', id)">Projekt löschen</a></li>
|
||||||
<li class="popover-links__link"><a @click="shareProject()">Projekt teilen</a></li>
|
<li class="popover-links__link"><a @click="$emit('edit', id)">Projekt bearbeiten</a></li>
|
||||||
|
<li class="popover-links__link"><a @click="share(scope)">Projekt teilen</a></li>
|
||||||
|
</template>
|
||||||
</widget-footer>
|
</widget-footer>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import DELETE_PROJECT_MUTATION from '@/graphql/gql/mutations/deleteProject.gql';
|
|
||||||
import PROJECTS_QUERY from '@/graphql/gql/allProjects.gql';
|
|
||||||
|
|
||||||
import OwnerWidget from '@/components/portfolio/OwnerWidget';
|
import OwnerWidget from '@/components/portfolio/OwnerWidget';
|
||||||
import EntryCountWidget from '@/components/rooms/EntryCountWidget';
|
import EntryCountWidget from '@/components/rooms/EntryCountWidget';
|
||||||
import WidgetFooter from '@/components/WidgetFooter';
|
import WidgetFooter from '@/components/WidgetFooter';
|
||||||
|
|
@ -38,33 +36,11 @@
|
||||||
return `project-widget--${this.appearance}`;
|
return `project-widget--${this.appearance}`;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
deleteProject() {
|
share: function (scope) {
|
||||||
const theId = this.id
|
scope.hide();
|
||||||
this.$apollo.mutate({
|
this.$emit('share', this.id);
|
||||||
mutation: DELETE_PROJECT_MUTATION,
|
|
||||||
variables: {
|
|
||||||
input: {
|
|
||||||
id: theId
|
|
||||||
}
|
|
||||||
},
|
|
||||||
update(store, {data: {deleteProject: {success}}}) {
|
|
||||||
if (success) {
|
|
||||||
const data = store.readQuery({query: PROJECTS_QUERY});
|
|
||||||
|
|
||||||
if (data) {
|
|
||||||
data.projects.edges.splice(data.projects.edges.findIndex(edge => edge.node.id === theId), 1);
|
|
||||||
store.writeQuery({query: PROJECTS_QUERY, data});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
editProject() {
|
|
||||||
this.$router.push({name: 'edit-room', params: {id: this.id}});
|
|
||||||
},
|
|
||||||
shareProject() {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,11 @@
|
||||||
|
|
||||||
<project-widget
|
<project-widget
|
||||||
v-for="project in projects"
|
v-for="project in projects"
|
||||||
v-bind="project" :key="project.id"
|
v-bind="project"
|
||||||
|
@delete="deleteProject"
|
||||||
|
@share="shareProject"
|
||||||
|
@edit="editProject"
|
||||||
|
:key="project.id"
|
||||||
class="portfolio__project"
|
class="portfolio__project"
|
||||||
></project-widget>
|
></project-widget>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -18,6 +22,8 @@
|
||||||
import AddProject from '@/components/portfolio/AddProject';
|
import AddProject from '@/components/portfolio/AddProject';
|
||||||
|
|
||||||
import PROJECTS_QUERY from '@/graphql/gql/allProjects.gql';
|
import PROJECTS_QUERY from '@/graphql/gql/allProjects.gql';
|
||||||
|
import DELETE_PROJECT_MUTATION from '@/graphql/gql/mutations/deleteProject.gql';
|
||||||
|
import UPDATE_PROJECT_MUTATION from '@/graphql/gql/mutations/updateProject.gql';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
|
|
@ -38,6 +44,49 @@
|
||||||
return {
|
return {
|
||||||
projects: []
|
projects: []
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
deleteProject(id) {
|
||||||
|
this.$apollo.mutate({
|
||||||
|
mutation: DELETE_PROJECT_MUTATION,
|
||||||
|
variables: {
|
||||||
|
input: {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
},
|
||||||
|
update(store, {data: {deleteProject: {success}}}) {
|
||||||
|
if (success) {
|
||||||
|
const data = store.readQuery({query: PROJECTS_QUERY});
|
||||||
|
|
||||||
|
if (data) {
|
||||||
|
data.projects.edges.splice(data.projects.edges.findIndex(edge => edge.node.id === id), 1);
|
||||||
|
store.writeQuery({query: PROJECTS_QUERY, data});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
editProject(id) {
|
||||||
|
this.$router.push({name: 'edit-project', params: { id }});
|
||||||
|
},
|
||||||
|
shareProject(id) {
|
||||||
|
const project = this.projects.filter(project => project.id === id)[0];
|
||||||
|
this.$apollo.mutate({
|
||||||
|
mutation: UPDATE_PROJECT_MUTATION,
|
||||||
|
variables: {
|
||||||
|
input: {
|
||||||
|
project: {
|
||||||
|
id: project.id,
|
||||||
|
title: project.title,
|
||||||
|
description: project.description,
|
||||||
|
appearance: project.appearance,
|
||||||
|
objectives: project.objectives,
|
||||||
|
final: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ class AddProjectArgument(ProjectInput):
|
||||||
|
|
||||||
class UpdateProjectArgument(ProjectInput):
|
class UpdateProjectArgument(ProjectInput):
|
||||||
id = graphene.ID(required=True)
|
id = graphene.ID(required=True)
|
||||||
|
final = graphene.Boolean()
|
||||||
|
|
||||||
|
|
||||||
class ProjectEntryInput(InputObjectType):
|
class ProjectEntryInput(InputObjectType):
|
||||||
|
|
@ -29,3 +30,4 @@ class AddProjectEntryArgument(ProjectEntryInput):
|
||||||
|
|
||||||
class UpdateProjectEntryArgument(ProjectEntryInput):
|
class UpdateProjectEntryArgument(ProjectEntryInput):
|
||||||
id = graphene.ID(required=True)
|
id = graphene.ID(required=True)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,10 @@ class MutateProject(relay.ClientIDMutation):
|
||||||
# serializer_class = ProjectSerializer
|
# serializer_class = ProjectSerializer
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def mutate_and_get_payload(cls, *args, **kwargs):
|
def mutate_and_get_payload(cls, root, info, **kwargs):
|
||||||
data = kwargs.get('project')
|
data = kwargs.get('project')
|
||||||
|
data['student'] = info.context.user.id
|
||||||
|
|
||||||
if data.get('id') is not None:
|
if data.get('id') is not None:
|
||||||
entity = get_object(Project, data['id'])
|
entity = get_object(Project, data['id'])
|
||||||
serializer = ProjectSerializer(entity, data=data)
|
serializer = ProjectSerializer(entity, data=data)
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ from portfolio.models import Project, ProjectEntry
|
||||||
class ProjectSerializer(serializers.ModelSerializer):
|
class ProjectSerializer(serializers.ModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Project
|
model = Project
|
||||||
fields = ('id', 'title', 'description', 'objectives', 'slug', 'appearance', 'student',)
|
fields = ('id', 'title', 'description', 'objectives', 'slug', 'appearance', 'student', 'final',)
|
||||||
read_only_fields = ('id', 'slug',)
|
read_only_fields = ('id', 'slug',)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue