Add generic edit modal

This commit is contained in:
Ramon Wenger 2021-03-25 17:44:14 +01:00
parent f6eaecb571
commit 0f59cf1b99
4 changed files with 56 additions and 29 deletions

View File

@ -230,7 +230,7 @@ describe('Teacher Class Management', () => {
cy.visit('/me/my-class'); cy.visit('/me/my-class');
cy.get('[data-cy=edit-group-name-link]').click(); cy.get('[data-cy=edit-group-name-link]').click();
cy.get('[data-cy=edit-class-name-input] input').type('{selectall}{backspace}').type(className); cy.get('[data-cy=edit-name-input] input').type('{selectall}{backspace}').type(className);
cy.get('[data-cy=modal-save-button]').click(); cy.get('[data-cy=modal-save-button]').click();
cy.get('[data-cy=school-class-name]').should('contain', className); cy.get('[data-cy=school-class-name]').should('contain', className);
}); });

View File

@ -0,0 +1,46 @@
<template>
<modal
:hide-header="false"
:small="true">
<h4 slot="header">{{ type }} bearbeiten</h4>
<modal-input
:value="name"
placeholder="Klassenname"
data-cy="edit-name-input"
@input="$emit('input', $event)"
/>
<div slot="footer">
<a
class="button button--primary"
data-cy="modal-save-button"
@click="$emit('save')">Speichern</a>
<a
class="button"
@click="$emit('hide')">Abbrechen</a>
</div>
</modal>
</template>
<script>
import Modal from '@/components/Modal';
import ModalInput from '@/components/ModalInput';
export default {
props: {
name: {
type: String,
default: ''
},
type: {
type: String,
default: ''
}
},
components: {
Modal,
ModalInput
},
};
</script>

View File

@ -1,39 +1,20 @@
<template> <template>
<modal <edit-name-wizard
:hide-header="false" :name="name"
:small="true" type="Klasse"
title="Hello"> @input="name = $event"
<h4 slot="header">Klasse bearbeiten</h4> @hide="hide"
<modal-input @save="save" />
:value="name"
placeholder="Klassenname"
data-cy="edit-class-name-input"
@input="name = $event"
/>
<div slot="footer">
<a
class="button button--primary"
data-cy="modal-save-button"
@click="save">Speichern</a>
<a
class="button"
@click="hide">Abbrechen</a>
</div>
</modal>
</template> </template>
<script> <script>
import Modal from '@/components/Modal';
import ModalInput from '@/components/ModalInput';
import MY_SCHOOL_CLASS_QUERY from '@/graphql/gql/mySchoolClass.gql'; import MY_SCHOOL_CLASS_QUERY from '@/graphql/gql/mySchoolClass.gql';
import UPDATE_SCHOOL_CLASS_MUTATION from '@/graphql/gql/mutations/updateSchoolClass.gql'; import UPDATE_SCHOOL_CLASS_MUTATION from '@/graphql/gql/mutations/updateSchoolClass.gql';
import EditNameWizard from '@/components/profile/EditNameWizard';
export default { export default {
components: { components: {
Modal, EditNameWizard,
ModalInput
}, },
data() { data() {

View File

@ -87,7 +87,7 @@
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@import "@/styles/_variables.scss"; @import "~styles/helpers";
.my-class { .my-class {
display: grid; display: grid;