Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Maxence Bothorel
funkwhale
Commits
32dc18ed
Verified
Commit
32dc18ed
authored
Mar 20, 2018
by
Eliot Berriot
Browse files
Added dangerous-button component, smarter modal
parent
16f631af
Changes
3
Hide whitespace changes
Inline
Side-by-side
front/src/components/common/DangerousButton.vue
0 → 100644
View file @
32dc18ed
<
template
>
<div
@
click=
"showModal = true"
class=
"ui red button"
>
<slot></slot>
<modal
class=
"small"
:show.sync=
"showModal"
>
<div
class=
"header"
>
<slot
name=
"modal-header"
>
Do you want to confirm this action?
</slot>
</div>
<div
class=
"scrolling content"
>
<div
class=
"description"
>
<slot
name=
"modal-content"
></slot>
</div>
</div>
<div
class=
"actions"
>
<div
class=
"ui cancel button"
>
Cancel
</div>
<div
class=
"ui confirm red button"
@
click=
"confirm"
>
<slot
name=
"modal-confirm"
>
Confirm
</slot>
</div>
</div>
</modal>
</div>
</
template
>
<
script
>
import
Modal
from
'
@/components/semantic/Modal
'
export
default
{
props
:
[
'
action
'
],
components
:
{
Modal
},
data
()
{
return
{
showModal
:
false
}
},
methods
:
{
confirm
()
{
this
.
showModal
=
false
this
.
action
()
}
}
}
</
script
>
front/src/components/globals.js
View file @
32dc18ed
...
...
@@ -8,4 +8,8 @@ import Username from '@/components/common/Username'
Vue
.
component
(
'
username
'
,
Username
)
import
DangerousButton
from
'
@/components/common/DangerousButton
'
Vue
.
component
(
'
dangerous-button
'
,
DangerousButton
)
export
default
{}
front/src/components/semantic/Modal.vue
View file @
32dc18ed
...
...
@@ -2,7 +2,7 @@
<div
:class=
"['ui',
{'active': show}, 'modal']">
<i
class=
"close icon"
></i>
<slot>
</slot>
</div>
</
template
>
...
...
@@ -19,26 +19,38 @@ export default {
control
:
null
}
},
mounted
()
{
this
.
control
=
$
(
this
.
$el
).
modal
({
onApprove
:
function
()
{
this
.
$emit
(
'
approved
'
)
}.
bind
(
this
),
onDeny
:
function
()
{
this
.
$emit
(
'
deny
'
)
}.
bind
(
this
),
onHidden
:
function
()
{
this
.
$emit
(
'
update:show
'
,
false
)
}.
bind
(
this
)
})
beforeDestroy
()
{
if
(
this
.
control
)
{
this
.
control
.
remove
()
}
},
methods
:
{
initModal
()
{
this
.
control
=
$
(
this
.
$el
).
modal
({
duration
:
100
,
onApprove
:
function
()
{
this
.
$emit
(
'
approved
'
)
}.
bind
(
this
),
onDeny
:
function
()
{
this
.
$emit
(
'
deny
'
)
}.
bind
(
this
),
onHidden
:
function
()
{
this
.
$emit
(
'
update:show
'
,
false
)
}.
bind
(
this
)
})
}
},
watch
:
{
show
:
{
handler
(
newValue
)
{
if
(
newValue
)
{
this
.
initModal
()
this
.
control
.
modal
(
'
show
'
)
}
else
{
this
.
control
.
modal
(
'
hide
'
)
if
(
this
.
control
)
{
this
.
control
.
modal
(
'
hide
'
)
this
.
control
.
remove
()
}
}
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment