Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

feat: close confirmation modal #1654

Merged
merged 25 commits into from
Feb 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8763f52
wip
dav1app Feb 7, 2020
a4d0a97
wip
dav1app Feb 7, 2020
39d6280
fix: expose modal inside index
dav1app Feb 9, 2020
8f3934c
fix: prevent click bubbling on child elements
dav1app Feb 9, 2020
3edb859
test: close confirmation tests
dav1app Feb 9, 2020
053577a
fix: include major class on component
dav1app Feb 9, 2020
1070c4b
test: modal window tests
dav1app Feb 9, 2020
8db6097
test: prevet closing when button clicked
dav1app Feb 9, 2020
acf6371
feat: check for state change to close
dav1app Feb 10, 2020
f74a7fc
refactor: tests
dav1app Feb 10, 2020
5cbb1d6
fix: change eventbus on menu dropdown
dav1app Feb 10, 2020
14b8c35
Merge branch 'develop' into feat/close-confirmation-modal
dav1app Feb 10, 2020
fbc02f2
fix: class selection.
dav1app Feb 12, 2020
0e08fa3
Merge branch 'develop' into feat/close-confirmation-modal
dav1app Feb 12, 2020
0a6d3d4
fix: remove modal confirmation reference
dav1app Feb 12, 2020
2f9bd37
Merge branch 'develop' into feat/close-confirmation-modal
dav1app Feb 13, 2020
2db2b17
fix: remove mousedown event
dav1app Feb 14, 2020
0329f44
Merge branch 'feat/close-confirmation-modal' of https://github.com/Ar…
dav1app Feb 14, 2020
4f42df6
Merge branch 'develop' into feat/close-confirmation-modal
alexbarnsley Feb 14, 2020
3ed31f8
Merge branch 'develop' into feat/close-confirmation-modal
alexbarnsley Feb 18, 2020
eee985a
Merge branch 'develop' into feat/close-confirmation-modal
faustbrian Feb 20, 2020
0b2d12d
Merge branch 'develop' into feat/close-confirmation-modal
dav1app Feb 20, 2020
b9f83b8
fix: mousedown events
dav1app Feb 20, 2020
55ebf55
refactor: close confirm modal buttons
alexbarnsley Feb 24, 2020
82c576f
Merge branch 'develop' into feat/close-confirmation-modal
alexbarnsley Feb 24, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions __tests__/unit/components/Modal/ModalCloseConfirmation.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { shallowMount } from '@vue/test-utils'
import useI18nGlobally from '../../__utils__/i18n'
import { ModalCloseConfirmation } from '@/components/Modal'

const i18n = useI18nGlobally()

let wrapper
beforeEach(() => {
wrapper = shallowMount(ModalCloseConfirmation, {
i18n
})
})

describe('ModalCloseConfirmation', () => {
describe('render popup', () => {
it('should render the close confirmation modal', () => {
expect(wrapper.isVueInstance()).toBeTrue()
})
})

describe('close modal capabilities', () => {
describe('cancel event', () => {
it('should emit a cancel event when clicks the cancel buttom', () => {
const mask = wrapper.find('.ModalCloseConfirmation__cancel-button')
mask.trigger('click')
expect(wrapper.emitted('cancel')).toBeTruthy()
})

it('should emit a cancel event when clicks the mask', () => {
const mask = wrapper.find('.ModalCloseConfirmation__mask')
mask.trigger('click')
expect(wrapper.emitted('cancel')).toBeTruthy()
})

it('should not emit a cancel event when pressing inside the modal', () => {
const modal = wrapper.find('.ModalCloseConfirmation__container')
modal.trigger('click')
expect(wrapper.emitted('cancel')).toBeFalsy()
})
})

describe('confirm event', () => {
it('should emit a confirm event when clicks the confirm buttom', () => {
const mask = wrapper.find('.ModalCloseConfirmation__confirm-button')
mask.trigger('click')
expect(wrapper.emitted('confirm')).toBeTruthy()
})
})
})
})
101 changes: 101 additions & 0 deletions __tests__/unit/components/Modal/ModalWindow.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { mount } from '@vue/test-utils'
import ModalWindow from '@/components/Modal'
import useI18nGlobally from '../../__utils__/i18n'

const i18n = useI18nGlobally()

const stubs = {
Portal: '<div><slot/></div>'
Expand Down Expand Up @@ -63,6 +66,104 @@ describe('ModalWindow', () => {
})
})

describe('close confirmation modal', () => {
const options = {
stubs,
i18n,
propsData: {
confirmClose: true
}
}

describe('render', () => {
describe('without changes', () => {
it('should not render when click on mask', () => {
const wrapper = mount(ModalWindow, options)
const mask = wrapper.find('.ModalWindow')
mask.trigger('click')
expect(wrapper.contains('.ModalCloseConfirmation')).toBeFalsy()
})
it('should not render when click on close button', () => {
const wrapper = mount(ModalWindow, options)
const mask = wrapper.find('.ModalWindow__close-button')
mask.trigger('click')
expect(wrapper.contains('.ModalCloseConfirmation')).toBeFalsy()
})
})
describe('with changes', () => {
it('should render when click on mask', () => {
const wrapper = mount(ModalWindow, options)
wrapper.setData({ showConfirmationModal: true })
const mask = wrapper.find('.ModalWindow')
mask.trigger('click')
expect(wrapper.contains('.ModalCloseConfirmation')).toBeTruthy()
})

it('should render when click on close button', () => {
const wrapper = mount(ModalWindow, options)
wrapper.setData({ showConfirmationModal: true })
const mask = wrapper.find('.ModalWindow__close-button')
mask.trigger('click')
expect(wrapper.contains('.ModalCloseConfirmation')).toBeTruthy()
})
})
})

describe('events', () => {
describe('close', () => {
it('should emit on confirm', () => {
const wrapper = mount(ModalWindow, options)
wrapper.setData({ showConfirmationModal: true })
const confirmButton = wrapper.find('.ModalCloseConfirmation__confirm-button')
confirmButton.trigger('click')
expect(wrapper.emitted('close')).toBeTruthy()
})

it('should not emit on cancel', () => {
const wrapper = mount(ModalWindow, options)
wrapper.setData({ showConfirmationModal: true })
const cancelButton = wrapper.find('.ModalCloseConfirmation__cancel-button')
cancelButton.trigger('click')
expect(wrapper.emitted('close')).toBeFalsy()
})
})

describe('confirm', () => {
it('should close the confirmation modal', () => {
const wrapper = mount(ModalWindow, options)
wrapper.setData({ showConfirmationModal: true })
const confirmButton = wrapper.find('.ModalCloseConfirmation__confirm-button')
confirmButton.trigger('click')
expect(wrapper.contains('.ModalCloseConfirmation')).toBeFalsy()
})
it('should close the modal window', () => {
const wrapper = mount(ModalWindow, options)
wrapper.setData({ showConfirmationModal: true })
const confirmButton = wrapper.find('.ModalCloseConfirmation__confirm-button')
confirmButton.trigger('click')
expect(wrapper.contains('.ModalCloseConfirmation')).toBeFalsy()
})
})

describe('cancel', () => {
it('should close the confirmation modal', () => {
const wrapper = mount(ModalWindow, options)
wrapper.setData({ showConfirmationModal: true })
const cancelButton = wrapper.find('.ModalCloseConfirmation__cancel-button')
cancelButton.trigger('click')
expect(wrapper.contains('.ModalCloseConfirmation')).toBeFalsy()
})
it('should not close the modal window', () => {
const wrapper = mount(ModalWindow, options)
wrapper.setData({ showConfirmationModal: true })
const cancelButton = wrapper.find('.ModalCloseConfirmation__cancel-button')
cancelButton.trigger('click')
expect(wrapper.contains('.ModalWindow')).toBeTruthy()
})
})
})
})

describe('close popup', () => {
it('should emit a close event when clicks the close button', () => {
const wrapper = mount(ModalWindow, { stubs })
Expand Down
3 changes: 3 additions & 0 deletions src/renderer/components/Input/InputAddress.vue
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,9 @@ export default {

updateInputValue (value) {
this.inputValue = value

this.$eventBus.emit('change')

// Inform Vuelidate that the value changed
this.$v.model.$touch()
},
Expand Down
146 changes: 146 additions & 0 deletions src/renderer/components/Modal/ModalCloseConfirmation.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
<template>
<div
dav1app marked this conversation as resolved.
Show resolved Hide resolved
class="ModalCloseConfirmation ModalCloseConfirmation__mask"
@click="onBackdropClick"
>
<div
class="ModalCloseConfirmation__container"
@click.stop="void 0"
>
<section class="ModalCloseConfirmation__container__content">
<div class="mb-6">
<h3
v-if="question"
class="font-semibold"
>
{{ question }}
</h3>

<div
v-if="note"
class="mt-3 text-grey-darker text-lg"
:class="{ 'mb-8': note }"
>
{{ note }}
</div>
</div>

<slot />

<div class="mt-4 flex flex-row">
<div class="flex-1">
<button
class="ModalCloseConfirmation__cancel-button blue-button m-1"
@click="emitCancel"
>
{{ cancelButton }}
</button>
</div>

<div class="flex-1 text-right">
<button
class="ModalCloseConfirmation__confirm-button action-button m-1 px-8 py-4"
@click="emitConfirm"
>
{{ confirmButton }}
</button>
</div>
</div>
</section>
</div>
</div>
</template>

<script>

export default {
name: 'ModalCloseConfirmation',

props: {
cancelButton: {
type: String,
required: false,
default () {
return this.$t('MODAL_CLOSE_CONFIRMATION.CANCEL')
}
},
confirmButton: {
type: String,
required: false,
default () {
return this.$t('MODAL_CLOSE_CONFIRMATION.CONFIRM')
}
},
containerClasses: {
type: String,
required: false,
default: 'ModalConfirmationClose'
},
footer: {
type: String,
required: false,
default: ''
},
note: {
type: String,
required: false,
default: null
},
question: {
type: String,
required: false,
default () {
return this.$t('MODAL_CLOSE_CONFIRMATION.QUESTION')
}
},
title: {
type: String,
required: false,
default () {
return this.$t('MODAL_CONFIRMATION.TITLE')
}
},
portalTarget: {
type: String,
required: false,
default: 'modal'
}
},

methods: {
emitCancel () {
this.$emit('cancel')
},

emitConfirm () {
this.$emit('confirm')
},

onBackdropClick () {
this.$emit('cancel')
}
}
}
</script>

<style lang="postcss" scoped>
.ModalCloseConfirmation-enter,
.ModalCloseConfirmation-leave-active {
opacity: 0;
transform: scale(1.1);
}

.ModalCloseConfirmation__mask {
@apply overflow-hidden p-16 pt-16 bg-theme-modal shadow rounded-lg w-full h-full flex items-center justify-center absolute;
position: fixed;
z-index: 60;
top: 0;
left: 0;
background-color: rgba(0, 0, 0, .5);
transition: opacity .3s ease;
}

.ModalCloseConfirmation__container__content{
@apply overflow-hidden p-12 bg-theme-modal shadow rounded-lg flex flex-col inline-block w-auto
}
</style>
Loading