mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-26 02:54:20 +00:00
Improve delete button behavior
This commit is contained in:
parent
93b66d980d
commit
85d9816aaa
@ -263,7 +263,13 @@ a:not(.button) {
|
|||||||
&.btn-red {
|
&.btn-red {
|
||||||
background-color: #fc8181;
|
background-color: #fc8181;
|
||||||
color: black;
|
color: black;
|
||||||
border: #fc8181 1px solid;
|
&:not(:disabled):hover {
|
||||||
|
background-color: darken(#fc8181, 15%);
|
||||||
|
}
|
||||||
|
&:disabled {
|
||||||
|
background-color: lighten(#fc8181, 15%);
|
||||||
|
color: grey;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
i {
|
i {
|
||||||
|
@ -49,11 +49,14 @@
|
|||||||
{%- if form[field_name] -%}
|
{%- if form[field_name] -%}
|
||||||
<div>
|
<div>
|
||||||
{{ form[field_name] }}
|
{{ form[field_name] }}
|
||||||
{%- if user.is_root and form.instance[field_name] -%}
|
<button class="btn btn-red" @click.prevent="delete_picture()"
|
||||||
<button class="btn btn-red" @click.prevent="window.open('{{ url('core:file_delete', file_id=form.instance[field_name].id, popup='') }}', '_self')">
|
{%- if not (user.is_root and form.instance[field_name]) -%}
|
||||||
|
:disabled="picture == null"
|
||||||
|
{%- endif -%}
|
||||||
|
x-cloak
|
||||||
|
>
|
||||||
{%- trans -%}Delete{%- endtrans -%}
|
{%- trans -%}Delete{%- endtrans -%}
|
||||||
</button>
|
</button>
|
||||||
{%- endif -%}
|
|
||||||
</div>
|
</div>
|
||||||
<p>
|
<p>
|
||||||
{{ form[field_name].label }}
|
{{ form[field_name].label }}
|
||||||
@ -107,6 +110,28 @@
|
|||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
delete_picture() {
|
||||||
|
|
||||||
|
{# Only remove currently displayed picture #}
|
||||||
|
if (this.picture != null){
|
||||||
|
let list = new DataTransfer();
|
||||||
|
this.picture_form.files = list.files;
|
||||||
|
this.picture_form.dispatchEvent(new Event("change"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
{# Remove user picture if correct rights are available #}
|
||||||
|
{%- if user.is_root and form.instance[field_name] -%}
|
||||||
|
window.open(
|
||||||
|
'{{ url(
|
||||||
|
'core:file_delete',
|
||||||
|
file_id=form.instance[field_name].id,
|
||||||
|
popup=''
|
||||||
|
) }}',
|
||||||
|
'_self');
|
||||||
|
{%- endif -%}
|
||||||
|
},
|
||||||
|
|
||||||
enable_camera() {
|
enable_camera() {
|
||||||
this.picture = null;
|
this.picture = null;
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user