From d509b246668e85de236a6dc6015eb4f9d28c1102 Mon Sep 17 00:00:00 2001 From: Ramon Wenger Date: Tue, 31 Aug 2021 17:49:40 +0200 Subject: [PATCH] Update change visibility modal --- .../frontend/rooms/room-page.spec.js | 20 +++++++++++++++++++ .../src/components/rooms/ChangeVisibility.vue | 11 +++++++++- client/src/components/rooms/RoomActions.vue | 16 ++++++++++++--- client/src/components/rooms/RoomWidget.vue | 6 ++++-- client/src/components/ui/BaseInput.vue | 6 ++++-- client/src/pages/room.vue | 1 + 6 files changed, 52 insertions(+), 8 deletions(-) diff --git a/client/cypress/integration/frontend/rooms/room-page.spec.js b/client/cypress/integration/frontend/rooms/room-page.spec.js index f458ee48..499e73d0 100644 --- a/client/cypress/integration/frontend/rooms/room-page.spec.js +++ b/client/cypress/integration/frontend/rooms/room-page.spec.js @@ -44,6 +44,10 @@ describe('The Room Page', () => { }, }; + const checkRadioButton = () => { + cy.get('.base-input-container__input:checked + .base-input-container__radiobutton svg').should('have.length', 1); + }; + beforeEach(() => { cy.setup(); }); @@ -107,8 +111,24 @@ describe('The Room Page', () => { cy.getByDataCy('toggle-room-actions-menu').click(); cy.getByDataCy('change-visibility').click(); cy.getByDataCy('modal-title').should('contain', 'Sichtbarkeit anpassen'); + cy.get('.change-visibility__radio').should('have.length', 2); + cy.get('.change-visibility__radio--selected').should('have.length', 1); + checkRadioButton(); + cy.get('.change-visibility__radio--selected').should('have.length', 1).should('contain', 'alle Lernenden'); + checkRadioButton(); + cy.getByDataCy('select-option').eq(0).click(); + cy.get('.change-visibility__radio--selected').should('have.length', 1); + checkRadioButton(); cy.getByDataCy('select-option').eq(1).click(); + cy.getByDataCy('select-option').eq(1).click(); + cy.get('.change-visibility__radio--selected').should('have.length', 1).should('contain', 'eigenen Beiträge'); + checkRadioButton(); cy.getByDataCy('modal-save-button').click(); cy.getByDataCy('room-visibility-status').should('contain', 'eigenen Beiträge'); + cy.getByDataCy('toggle-room-actions-menu').click(); + cy.getByDataCy('change-visibility').click(); + cy.getByDataCy('modal-title').should('contain', 'Sichtbarkeit anpassen'); + cy.get('.change-visibility__radio--selected').should('have.length', 1).should('contain', 'eigenen Beiträge'); + checkRadioButton(); }); }); diff --git a/client/src/components/rooms/ChangeVisibility.vue b/client/src/components/rooms/ChangeVisibility.vue index 8dc8bf60..cb2ba046 100644 --- a/client/src/components/rooms/ChangeVisibility.vue +++ b/client/src/components/rooms/ChangeVisibility.vue @@ -10,12 +10,16 @@
@@ -44,7 +48,7 @@ data() { return { - restricted: undefined + restricted: false }; }, @@ -77,6 +81,11 @@ &__content { display: flex; flex-direction: column; + padding: $medium-spacing 0; + } + + &__radio:first-of-type { + margin-bottom: $medium-spacing; } } diff --git a/client/src/components/rooms/RoomActions.vue b/client/src/components/rooms/RoomActions.vue index 7580a408..02cc58e5 100644 --- a/client/src/components/rooms/RoomActions.vue +++ b/client/src/components/rooms/RoomActions.vue @@ -49,7 +49,16 @@ import PopoverLink from '@/components/ui/PopoverLink'; export default { - props: ['id'], + props: { + id: { + type: String, + default: '', + }, + restricted: { + type: Boolean, + default: false + } + }, components: { PopoverLink, @@ -94,7 +103,8 @@ this.$router.push({name: 'edit-room', params: {id: this.id}}); }, changeVisibility() { - this.$modal.open('change-visibility', {restricted: false}) + this.showMenu = false; + this.$modal.open('change-visibility', {restricted: this.restricted}) .then((restricted) => { this.$apollo.mutate({ mutation: UPDATE_ROOM_VISIBILITY_MUTATION, @@ -107,7 +117,7 @@ }); }) .catch(() => { - console.log('nay'); + }); } }, diff --git a/client/src/components/rooms/RoomWidget.vue b/client/src/components/rooms/RoomWidget.vue index cbc204a1..80b57a4e 100644 --- a/client/src/components/rooms/RoomWidget.vue +++ b/client/src/components/rooms/RoomWidget.vue @@ -13,7 +13,9 @@ - + @@ -28,7 +30,7 @@ import {meQuery} from '@/graphql/queries'; export default { - props: ['slug', 'title', 'entryCount', 'appearance', 'schoolClass', 'id'], + props: ['slug', 'title', 'entryCount', 'appearance', 'schoolClass', 'id', 'restricted'], components: { EntryCountWidget, diff --git a/client/src/components/ui/BaseInput.vue b/client/src/components/ui/BaseInput.vue index b13a226f..c9ef5756 100644 --- a/client/src/components/ui/BaseInput.vue +++ b/client/src/components/ui/BaseInput.vue @@ -4,13 +4,15 @@ :checked="checked" type="checkbox" class="base-input-container__input" - @change.prevent="$emit('input', $event.target.checked, item)" + @click.prevent="$emit('input', $event.target.checked, item)" > - +