mirror of
				https://github.com/ae-utbm/sith.git
				synced 2025-11-04 11:03:04 +00:00 
			
		
		
		
	Improve delete button behavior
This commit is contained in:
		@@ -263,7 +263,13 @@ a:not(.button) {
 | 
			
		||||
    &.btn-red {
 | 
			
		||||
      background-color: #fc8181;
 | 
			
		||||
      color: black;
 | 
			
		||||
      border: #fc8181 1px solid;
 | 
			
		||||
      &:not(:disabled):hover {
 | 
			
		||||
        background-color: darken(#fc8181, 15%);
 | 
			
		||||
      }
 | 
			
		||||
      &:disabled {
 | 
			
		||||
        background-color: lighten(#fc8181, 15%);
 | 
			
		||||
        color: grey;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    i {
 | 
			
		||||
 
 | 
			
		||||
@@ -49,11 +49,14 @@
 | 
			
		||||
      {%- if form[field_name] -%}
 | 
			
		||||
        <div>
 | 
			
		||||
          {{ form[field_name] }}
 | 
			
		||||
          {%- if user.is_root and form.instance[field_name] -%}
 | 
			
		||||
            <button class="btn btn-red" @click.prevent="window.open('{{ url('core:file_delete', file_id=form.instance[field_name].id, popup='') }}', '_self')">
 | 
			
		||||
              {%- trans -%}Delete{%- endtrans -%}
 | 
			
		||||
            </button>
 | 
			
		||||
          {%- endif -%}
 | 
			
		||||
          <button class="btn btn-red" @click.prevent="delete_picture()"
 | 
			
		||||
                  {%- if not (user.is_root and form.instance[field_name]) -%}
 | 
			
		||||
                    :disabled="picture == null"
 | 
			
		||||
                  {%- endif -%}
 | 
			
		||||
                  x-cloak
 | 
			
		||||
          >
 | 
			
		||||
            {%- trans -%}Delete{%- endtrans -%}
 | 
			
		||||
          </button>
 | 
			
		||||
        </div>
 | 
			
		||||
        <p>
 | 
			
		||||
          {{ form[field_name].label }}
 | 
			
		||||
@@ -107,6 +110,28 @@
 | 
			
		||||
          {%- 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() {
 | 
			
		||||
          this.picture = null;
 | 
			
		||||
          this.loading = true;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user