Add user group to room form
This commit is contained in:
parent
b4a3699aa3
commit
5b8eb36cbb
|
|
@ -28,7 +28,7 @@
|
||||||
title: room.title,
|
title: room.title,
|
||||||
appearance: room.appearance,
|
appearance: room.appearance,
|
||||||
description: room.description,
|
description: room.description,
|
||||||
userGroup: room.userGroup.id
|
userGroup: room.userGroup
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
appearance: defaultColor,
|
appearance: defaultColor,
|
||||||
title: '',
|
title: '',
|
||||||
description: '',
|
description: '',
|
||||||
userGroup: 'VXNlckdyb3VwTm9kZToxMw=='
|
userGroup: {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,25 @@
|
||||||
<div class="room-form__content">
|
<div class="room-form__content">
|
||||||
<h1 class="room-form__heading">Neues Board</h1>
|
<h1 class="room-form__heading">Neues Board</h1>
|
||||||
|
|
||||||
<h2 class="room-form__property-heading">Titel</h2>
|
<label class="room-form__property-heading" for="room-title">Titel</label>
|
||||||
<input class="skillbox-input room-form__input" v-model="localRoom.title">
|
<input class="skillbox-input room-form__input" v-model="localRoom.title" id="room-title">
|
||||||
<h2 class="room-form__property-heading">Beschreibung</h2>
|
<label class="room-form__property-heading" for="room-description">Beschreibung</label>
|
||||||
<textarea class="skillbox-textarea room-form__textarea" v-model="localRoom.description"></textarea>
|
<textarea class="skillbox-textarea room-form__textarea" v-model="localRoom.description"
|
||||||
|
id="room-description"></textarea>
|
||||||
|
<label class="room-form__property-heading" for="room-class">Klasse</label>
|
||||||
|
<select
|
||||||
|
class="skillbox-input room-form__input"
|
||||||
|
id="room-class"
|
||||||
|
v-model="localRoom.userGroup"
|
||||||
|
>
|
||||||
|
<option disabled value="">-</option>
|
||||||
|
<option
|
||||||
|
v-for="userGroup in userGroups"
|
||||||
|
:key="userGroup.id"
|
||||||
|
v-bind:value="userGroup"
|
||||||
|
>{{userGroup.name}}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
<h2 class="room-form__property-heading">Farbe</h2>
|
<h2 class="room-form__property-heading">Farbe</h2>
|
||||||
<room-colors
|
<room-colors
|
||||||
:selected-color="localRoom.appearance"
|
:selected-color="localRoom.appearance"
|
||||||
|
|
@ -19,7 +34,7 @@
|
||||||
@click="$emit('save', localRoom)"
|
@click="$emit('save', localRoom)"
|
||||||
>Speichern
|
>Speichern
|
||||||
</button>
|
</button>
|
||||||
<button class="button">Abbrechen</button>
|
<router-link to="/rooms" tag="button" class="button">Abbrechen</router-link>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -27,6 +42,8 @@
|
||||||
<script>
|
<script>
|
||||||
import RoomColors from '@/components/rooms/RoomColors';
|
import RoomColors from '@/components/rooms/RoomColors';
|
||||||
|
|
||||||
|
import {userGroupsQuery} from '@/helpers/user-groups'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: ['room'],
|
props: ['room'],
|
||||||
|
|
||||||
|
|
@ -36,7 +53,8 @@
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
localRoom: Object.assign({}, this.room)
|
localRoom: Object.assign({}, this.room),
|
||||||
|
userGroups: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -47,6 +65,10 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
apollo: {
|
||||||
|
userGroupsQuery: userGroupsQuery
|
||||||
|
},
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
this.$store.dispatch('setSpecialContainerClass', this.localRoom.appearance);
|
this.$store.dispatch('setSpecialContainerClass', this.localRoom.appearance);
|
||||||
},
|
},
|
||||||
|
|
@ -63,13 +85,13 @@
|
||||||
|
|
||||||
.room-form {
|
.room-form {
|
||||||
width: 710px;
|
width: 710px;
|
||||||
height: 760px;
|
min-height: 760px;
|
||||||
max-height: 100%;
|
max-height: 100%;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
background-color: $color-white;
|
background-color: $color-white;
|
||||||
border-radius: $default-border-radius;
|
border-radius: $default-border-radius;
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-rows: auto 65px;
|
grid-template-rows: 1fr 65px;
|
||||||
|
|
||||||
&__heading {
|
&__heading {
|
||||||
font-size: toRem(35px);
|
font-size: toRem(35px);
|
||||||
|
|
@ -85,8 +107,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
&__property-heading {
|
&__property-heading {
|
||||||
|
display: block;
|
||||||
font-size: toRem(21px);
|
font-size: toRem(21px);
|
||||||
font-weight: 800;
|
font-weight: 800;
|
||||||
|
margin-bottom: 24px;
|
||||||
|
font-family: $sans-serif-font-family;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__input,
|
&__input,
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ const httpLink = new HttpLink({
|
||||||
headers: {
|
headers: {
|
||||||
'X-CSRFToken': document.cookie.replace(/(?:(?:^|.*;\s*)csrftoken\s*=\s*([^;]*).*$)|^.*$/, '$1')
|
'X-CSRFToken': document.cookie.replace(/(?:(?:^|.*;\s*)csrftoken\s*=\s*([^;]*).*$)|^.*$/, '$1')
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
const consoleLink = new ApolloLink((operation, forward) => {
|
const consoleLink = new ApolloLink((operation, forward) => {
|
||||||
// console.log(`starting request for ${operation.operationName}`);
|
// console.log(`starting request for ${operation.operationName}`);
|
||||||
|
|
@ -21,9 +21,22 @@ const consoleLink = new ApolloLink((operation, forward) => {
|
||||||
|
|
||||||
return data
|
return data
|
||||||
})
|
})
|
||||||
})
|
});
|
||||||
|
|
||||||
const composedLink = ApolloLink.from([consoleLink, httpLink]);
|
// from https://github.com/apollographql/apollo-client/issues/1564#issuecomment-357492659
|
||||||
|
const omitTypename = (key, value) => {
|
||||||
|
return key === '__typename' ? undefined : value
|
||||||
|
};
|
||||||
|
|
||||||
|
const createOmitTypenameLink = new ApolloLink((operation, forward) => {
|
||||||
|
if (operation.variables) {
|
||||||
|
operation.variables = JSON.parse(JSON.stringify(operation.variables), omitTypename)
|
||||||
|
}
|
||||||
|
|
||||||
|
return forward(operation)
|
||||||
|
});
|
||||||
|
|
||||||
|
const composedLink = ApolloLink.from([createOmitTypenameLink, consoleLink, httpLink]);
|
||||||
|
|
||||||
const cache = new InMemoryCache({
|
const cache = new InMemoryCache({
|
||||||
cacheRedirects: {
|
cacheRedirects: {
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
border: 1px solid $color-lightgrey;
|
border: 1px solid $color-lightgrey;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
|
background-color: $color-white;
|
||||||
}
|
}
|
||||||
|
|
||||||
.skillbox-input {
|
.skillbox-input {
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
import graphene
|
import graphene
|
||||||
from graphene import InputObjectType
|
from graphene import InputObjectType
|
||||||
|
|
||||||
|
from user.inputs import UserGroupInput
|
||||||
|
|
||||||
|
|
||||||
class RoomInput(InputObjectType):
|
class RoomInput(InputObjectType):
|
||||||
title = graphene.String()
|
title = graphene.String()
|
||||||
description = graphene.String()
|
description = graphene.String()
|
||||||
user_group = graphene.ID()
|
user_group = UserGroupInput()
|
||||||
appearance = graphene.String()
|
appearance = graphene.String()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ class MutateRoom(relay.ClientIDMutation):
|
||||||
@classmethod
|
@classmethod
|
||||||
def mutate_and_get_payload(cls, *args, **kwargs):
|
def mutate_and_get_payload(cls, *args, **kwargs):
|
||||||
room_data = kwargs.get('room')
|
room_data = kwargs.get('room')
|
||||||
user_group = get_object(UserGroup, room_data.get('user_group'))
|
user_group = get_object(UserGroup, room_data.get('user_group').get('id'))
|
||||||
room_data['user_group'] = user_group.id
|
room_data['user_group'] = user_group.id
|
||||||
if room_data.get('id') is not None:
|
if room_data.get('id') is not None:
|
||||||
room = get_object(Room, room_data['id'])
|
room = get_object(Room, room_data['id'])
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
import graphene
|
||||||
|
from graphene import InputObjectType
|
||||||
|
|
||||||
|
|
||||||
|
class UserGroupInput(InputObjectType):
|
||||||
|
id = graphene.ID()
|
||||||
|
name = graphene.String()
|
||||||
|
year = graphene.Int()
|
||||||
Loading…
Reference in New Issue