Commit 64cd1428 authored by lauraMon's avatar lauraMon

Refactors and brings back boolean_to_icon in form

parent c25b1a43
......@@ -2,8 +2,10 @@
.col-lg-3
%h4.prepend-top-0
= @service.title
= boolean_to_icon @service.activated?
- [true, false].each do | value |
- hide_class = 'd-none' if @service.activated? != value
%span.js-service-active-status{ class: hide_class, data: { value: value.to_s } }
= boolean_to_icon value
%p= #{@service.description}.
- if @service.respond_to?(:detailed_description)
......
......@@ -82,14 +82,19 @@ export default {
},
watch: {
activated() {
const inactive = document.querySelector('.fa-power-off');
const active = document.querySelector('.fa-circle');
this.activated
? inactive && inactive.setAttribute('class', 'fa fa-circle cgreen')
: active && active.setAttribute('class', 'fa fa-power-off clgray');
this.updateIcon();
},
},
methods: {
updateIcon() {
return document.querySelectorAll('.js-service-active-status').forEach(icon => {
if (icon.dataset.value === this.activated.toString()) {
icon.classList.remove('d-none');
} else {
icon.classList.add('d-none');
}
});
},
resetKey() {
return axios
.put(this.formPath, { service: { token: '' } })
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment