Add mutation to frontend
This commit is contained in:
parent
b0d4615c2b
commit
e368307d3d
|
|
@ -4,15 +4,18 @@ describe('The Room Page', () => {
|
||||||
const entryText = 'something should be here';
|
const entryText = 'something should be here';
|
||||||
const entryTitle = 'some title';
|
const entryTitle = 'some title';
|
||||||
const slug = 'ein-historisches-festival';
|
const slug = 'ein-historisches-festival';
|
||||||
|
const id = btoa('RoomNode:1');
|
||||||
|
const room = {
|
||||||
|
id,
|
||||||
|
slug,
|
||||||
|
restricted: false,
|
||||||
|
roomEntries: {
|
||||||
|
edges: [],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
const RoomEntriesQuery = {
|
const RoomEntriesQuery = {
|
||||||
room: {
|
room
|
||||||
slug,
|
|
||||||
restricted: false,
|
|
||||||
roomEntries: {
|
|
||||||
edges: [],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const operations = {
|
const operations = {
|
||||||
|
|
@ -68,7 +71,16 @@ describe('The Room Page', () => {
|
||||||
});
|
});
|
||||||
const operations = {
|
const operations = {
|
||||||
MeQuery,
|
MeQuery,
|
||||||
RoomEntriesQuery
|
RoomEntriesQuery,
|
||||||
|
UpdateRoomVisibility: {
|
||||||
|
updateRoomVisibility: {
|
||||||
|
success: true,
|
||||||
|
room: {
|
||||||
|
...room,
|
||||||
|
restricted: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
cy.mockGraphqlOps({
|
cy.mockGraphqlOps({
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,9 @@
|
||||||
import Ellipses from '@/components/icons/Ellipses.vue';
|
import Ellipses from '@/components/icons/Ellipses.vue';
|
||||||
import WidgetPopover from '@/components/ui/WidgetPopover';
|
import WidgetPopover from '@/components/ui/WidgetPopover';
|
||||||
|
|
||||||
import DELETE_ROOM_MUTATION from '@/graphql/gql/mutations/deleteRoom.gql';
|
import DELETE_ROOM_MUTATION from 'gql/mutations/rooms/deleteRoom.gql';
|
||||||
|
import UPDATE_ROOM_VISIBILITY_MUTATION from 'gql/mutations/rooms/updateRoomVisibility.gql';
|
||||||
|
|
||||||
import ROOMS_QUERY from '@/graphql/gql/queries/roomsQuery.gql';
|
import ROOMS_QUERY from '@/graphql/gql/queries/roomsQuery.gql';
|
||||||
import PenIcon from '@/components/icons/PenIcon';
|
import PenIcon from '@/components/icons/PenIcon';
|
||||||
import TrashIcon from '@/components/icons/TrashIcon';
|
import TrashIcon from '@/components/icons/TrashIcon';
|
||||||
|
|
@ -92,10 +94,17 @@
|
||||||
this.$router.push({name: 'edit-room', params: {id: this.id}});
|
this.$router.push({name: 'edit-room', params: {id: this.id}});
|
||||||
},
|
},
|
||||||
changeVisibility() {
|
changeVisibility() {
|
||||||
console.log('changeVisibility');
|
|
||||||
this.$modal.open('change-visibility', {restricted: false})
|
this.$modal.open('change-visibility', {restricted: false})
|
||||||
.then((res) => {
|
.then((restricted) => {
|
||||||
console.log('yay', res);
|
this.$apollo.mutate({
|
||||||
|
mutation: UPDATE_ROOM_VISIBILITY_MUTATION,
|
||||||
|
variables: {
|
||||||
|
input: {
|
||||||
|
id: this.id,
|
||||||
|
restricted
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
console.log('nay');
|
console.log('nay');
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,14 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="room-visibility-widget">
|
<div class="room-visibility-widget">
|
||||||
<template v-if="restricted">
|
<template v-if="restricted">
|
||||||
<eye-icon class="room-visibility-widget__icon"/>
|
|
||||||
<span class="room-visibility-widget__text">Raumeinträge sind für alle Lernenden sichtbar</span>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<closed-eye-icon class="room-visibility-widget__icon"/>
|
<closed-eye-icon class="room-visibility-widget__icon"/>
|
||||||
<span class="room-visibility-widget__text">Lernende sehen nur die eigenen Beiträge</span>
|
<span class="room-visibility-widget__text">Lernende sehen nur die eigenen Beiträge</span>
|
||||||
</template>
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<eye-icon class="room-visibility-widget__icon"/>
|
||||||
|
<span class="room-visibility-widget__text">Raumeinträge sind für alle Lernenden sichtbar</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
@ -18,7 +19,7 @@
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
visibility: {
|
restricted: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#import "../fragments/roomParts.gql"
|
#import "../../fragments/roomParts.gql"
|
||||||
mutation AddRoom($input: AddRoomInput!){
|
mutation AddRoom($input: AddRoomInput!){
|
||||||
addRoom(input: $input) {
|
addRoom(input: $input) {
|
||||||
room {
|
room {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#import "../fragments/roomEntryParts.gql"
|
#import "../../fragments/roomEntryParts.gql"
|
||||||
mutation AddRoomEntry($input: AddRoomEntryInput!){
|
mutation AddRoomEntry($input: AddRoomEntryInput!){
|
||||||
addRoomEntry(input: $input) {
|
addRoomEntry(input: $input) {
|
||||||
roomEntry {
|
roomEntry {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#import "../fragments/roomParts.gql"
|
#import "../../fragments/roomParts.gql"
|
||||||
mutation UpdateRoom($input: UpdateRoomInput!){
|
mutation UpdateRoom($input: UpdateRoomInput!){
|
||||||
updateRoom(input: $input) {
|
updateRoom(input: $input) {
|
||||||
room {
|
room {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#import "../fragments/roomEntryParts.gql"
|
#import "../../fragments/roomEntryParts.gql"
|
||||||
mutation UpdateRoomEntry($input: UpdateRoomEntryInput!){
|
mutation UpdateRoomEntry($input: UpdateRoomEntryInput!){
|
||||||
updateRoomEntry(input: $input) {
|
updateRoomEntry(input: $input) {
|
||||||
roomEntry {
|
roomEntry {
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ mutation UpdateRoomVisibility($input: UpdateRoomVisibilityInput!) {
|
||||||
success
|
success
|
||||||
room {
|
room {
|
||||||
id
|
id
|
||||||
|
slug
|
||||||
restricted
|
restricted
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="room">
|
<div class="room">
|
||||||
<div class="room__back">
|
<div class="room__back">
|
||||||
|
|
||||||
<back-link
|
<back-link
|
||||||
type="room"
|
type="room"
|
||||||
title="Zurück zur Übersicht"/>
|
title="Zurück zur Übersicht"/>
|
||||||
|
|
@ -20,7 +19,7 @@
|
||||||
<div class="room__meta">
|
<div class="room__meta">
|
||||||
<room-visibility-widget
|
<room-visibility-widget
|
||||||
:restricted="room.restricted"
|
:restricted="room.restricted"
|
||||||
data-cy="room-visibility-status" />
|
data-cy="room-visibility-status"/>
|
||||||
<room-group-widget v-bind="room.schoolClass"/>
|
<room-group-widget v-bind="room.schoolClass"/>
|
||||||
<entry-count-widget :entry-count="roomEntryCount"/>
|
<entry-count-widget :entry-count="roomEntryCount"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -441,6 +441,7 @@ type CustomMutation {
|
||||||
deleteRoomEntry(input: DeleteRoomEntryInput!): DeleteRoomEntryPayload
|
deleteRoomEntry(input: DeleteRoomEntryInput!): DeleteRoomEntryPayload
|
||||||
updateRoomEntry(input: UpdateRoomEntryInput!): UpdateRoomEntryPayload
|
updateRoomEntry(input: UpdateRoomEntryInput!): UpdateRoomEntryPayload
|
||||||
addComment(input: AddCommentInput!): AddCommentPayload
|
addComment(input: AddCommentInput!): AddCommentPayload
|
||||||
|
updateRoomVisibility(input: UpdateRoomVisibilityInput!): UpdateRoomVisibilityPayload
|
||||||
mutateContentBlock(input: MutateContentBlockInput!): MutateContentBlockPayload
|
mutateContentBlock(input: MutateContentBlockInput!): MutateContentBlockPayload
|
||||||
addContentBlock(input: AddContentBlockInput!): AddContentBlockPayload
|
addContentBlock(input: AddContentBlockInput!): AddContentBlockPayload
|
||||||
deleteContentBlock(input: DeleteContentBlockInput!): DeleteContentBlockPayload
|
deleteContentBlock(input: DeleteContentBlockInput!): DeleteContentBlockPayload
|
||||||
|
|
@ -1447,6 +1448,18 @@ type UpdateRoomPayload {
|
||||||
clientMutationId: String
|
clientMutationId: String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input UpdateRoomVisibilityInput {
|
||||||
|
id: ID!
|
||||||
|
restricted: Boolean!
|
||||||
|
clientMutationId: String
|
||||||
|
}
|
||||||
|
|
||||||
|
type UpdateRoomVisibilityPayload {
|
||||||
|
success: Boolean
|
||||||
|
room: RoomNode
|
||||||
|
clientMutationId: String
|
||||||
|
}
|
||||||
|
|
||||||
input UpdateSchoolClassInput {
|
input UpdateSchoolClassInput {
|
||||||
id: ID!
|
id: ID!
|
||||||
name: String
|
name: String
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue