Enable students to add room entries

This commit is contained in:
Ramon Wenger 2021-08-31 18:42:22 +02:00
parent 36c84c500c
commit 94a13f4a15
3 changed files with 31 additions and 2 deletions

View File

@ -211,4 +211,28 @@ describe('The Room Page', () => {
cy.getByDataCy('room-entry-actions').click(); cy.getByDataCy('room-entry-actions').click();
cy.getByDataCy('edit-room-entry').click(); cy.getByDataCy('edit-room-entry').click();
}); });
it('creates a room entry', () => {
const MeQuery = getMinimalMe({isTeacher: false});
const room = {
id: 'some-room',
roomEntries: {
edges: []
}
};
const operations = {
MeQuery,
RoomEntriesQuery: {
room
},
};
cy.mockGraphqlOps({
operations
});
cy.visit(`/room/${slug}`);
cy.getByDataCy('add-room-entry').click();
cy.getByDataCy('add-room-entry-modal').should('exist');
});
}); });

View File

@ -3,6 +3,7 @@
:content-block="entry" :content-block="entry"
:show-task-selection="false" :show-task-selection="false"
:disable-save="saving" :disable-save="saving"
data-cy="add-room-entry-modal"
block-type="RoomEntry" block-type="RoomEntry"
@save="saveEntry" @save="saveEntry"
@hide="hideModal" @hide="hideModal"

View File

@ -30,7 +30,8 @@
<div class="room__content"> <div class="room__content">
<add-room-entry-button <add-room-entry-button
:parent="room" :parent="room"
v-if="room.id && canEdit"> data-cy="add-room-entry"
v-if="room.id && !isReadOnly">
<!-- <!--
the v-if is there for the case where the room hasn't loaded yet, but there is already an attempt to create the v-if is there for the case where the room hasn't loaded yet, but there is already an attempt to create
a new room entry. mainly happens during cypress testing, but could also happen on a very slow connection a new room entry. mainly happens during cypress testing, but could also happen on a very slow connection
@ -58,8 +59,11 @@
computed: { computed: {
canEdit() { canEdit() {
return this.me.isTeacher && !this.me.readOnly && !this.me.selectedClass.readOnly; return this.me.isTeacher && !this.isReadOnly;
}, },
isReadOnly() {
return this.me.readOnly || this.me.selectedClass.readOnly;
}
}, },
apollo: { apollo: {