Clean up code
This commit is contained in:
parent
f3eb6ded51
commit
cabbceb843
|
|
@ -11,8 +11,6 @@
|
||||||
import NEW_ROOM_ENTRY_MUTATION from '@/graphql/gql/mutations/addRoomEntry.gql';
|
import NEW_ROOM_ENTRY_MUTATION from '@/graphql/gql/mutations/addRoomEntry.gql';
|
||||||
import ROOM_ENTRIES_QUERY from '@/graphql/gql/roomEntriesQuery.gql';
|
import ROOM_ENTRIES_QUERY from '@/graphql/gql/roomEntriesQuery.gql';
|
||||||
|
|
||||||
import store from '@/store/index';
|
|
||||||
|
|
||||||
import ContentsForm from '@/components/content-block-form/ContentsForm';
|
import ContentsForm from '@/components/content-block-form/ContentsForm';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
@ -30,6 +28,12 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
room() {
|
||||||
|
return this.$store.state.parentRoom;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
saveEntry(entry) {
|
saveEntry(entry) {
|
||||||
this.$apollo.mutate({
|
this.$apollo.mutate({
|
||||||
|
|
@ -37,14 +41,14 @@
|
||||||
variables: {
|
variables: {
|
||||||
input: {
|
input: {
|
||||||
roomEntry: Object.assign({}, entry, {
|
roomEntry: Object.assign({}, entry, {
|
||||||
room: store.state.parentRoom.id
|
room: this.room.id
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
update: (store, {data: {addRoomEntry: {roomEntry}}}) => {
|
update: (store, {data: {addRoomEntry: {roomEntry}}}) => {
|
||||||
try {
|
try {
|
||||||
const query = ROOM_ENTRIES_QUERY;
|
const query = ROOM_ENTRIES_QUERY;
|
||||||
const variables = {slug: this.$store.state.parentRoom.slug};
|
const variables = {slug: this.room.slug};
|
||||||
const data = store.readQuery({query, variables});
|
const data = store.readQuery({query, variables});
|
||||||
if (data.room && data.room.roomEntries) {
|
if (data.room && data.room.roomEntries) {
|
||||||
data.room.roomEntries.edges.push({
|
data.room.roomEntries.edges.push({
|
||||||
|
|
@ -54,7 +58,6 @@
|
||||||
store.writeQuery({query, variables, data});
|
store.writeQuery({query, variables, data});
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
|
||||||
// Query did not exist in the cache, and apollo throws a generic Error. Do nothing
|
// Query did not exist in the cache, and apollo throws a generic Error. Do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue