Properly handle justificatif_motivation case

This commit is contained in:
Paul Chavard 2019-05-22 12:00:05 +02:00
parent 6a3413018a
commit 6797c01b69
7 changed files with 27 additions and 11 deletions

View file

@ -1,4 +1,4 @@
import Rails from 'rails-ujs';
import { ajax, delegate } from '@utils';
addEventListener('turbolinks:load', () => {
checker.deactivate();
@ -14,6 +14,11 @@ addEventListener('attachment:update', ({ detail: { url } }) => {
checker.add(url);
});
delegate('click', '[data-attachment-refresh]', event => {
event.preventDefault();
checker.check();
});
class AttachmentChecker {
urls = new Set();
timeout;
@ -41,13 +46,19 @@ class AttachmentChecker {
}
}
check() {
let urls = this.urls;
this.reset();
for (let url of urls) {
ajax({ url, type: 'get' });
}
}
activate() {
clearTimeout(this.timeout);
this.timeout = setTimeout(() => {
for (let url of this.urls) {
Rails.ajax({ url, type: 'get' });
}
this.checks++;
this.reset();
this.check();
}, this.interval);
}

View file

@ -3,7 +3,7 @@ import $ from 'jquery';
import debounce from 'debounce';
export { debounce };
export const { fire } = Rails;
export const { fire, ajax } = Rails;
export function show({ classList }) {
classList.remove('hidden');

View file

@ -60,7 +60,7 @@
- if dossier.motivation.present?
%h4 Motivation
%p.dossier-motivation= dossier.motivation
= render partial: 'new_user/dossiers/show/download_justificatif', locals: { dossier: dossier }
= render partial: 'users/dossiers/show/download_justificatif', locals: { dossier: dossier }
- if dossier.attestation.present?
%h4 Attestation

View file

@ -1,2 +1,7 @@
<%= render_flash %>
<%= render_to_element('.state-button', partial: "state_button", locals: { dossier: dossier }) %>
<% attachment = dossier.justificatif_motivation.attachment %>
<% if attachment && attachment.virus_scanner.pending? %>
<%= fire_event('attachment:update', { url: attachment_url(attachment.id, { signed_id: attachment.blob.signed_id }) }.to_json ) %>
<% end %>

View file

@ -17,7 +17,7 @@
= attachment.filename.to_s
- if attachment.virus_scanner.pending?
(analyse antivirus en cours
= link_to "rafraichir", request.path
= link_to "rafraichir", request.path, data: { 'attachment-refresh': true }
)
- elsif attachment.virus_scanner.infected?
- if user_can_upload

View file

@ -50,7 +50,7 @@
%h3 Motif de lacceptation
%blockquote= dossier.motivation
= render partial: 'new_user/dossiers/show/download_justificatif', locals: { dossier: dossier }
= render partial: 'users/dossiers/show/download_justificatif', locals: { dossier: dossier }
- if dossier.attestation.present?
.action
@ -71,7 +71,7 @@
%h3 Motif du refus
%blockquote= dossier.motivation
= render partial: 'new_user/dossiers/show/download_justificatif', locals: { dossier: @dossier }
= render partial: 'users/dossiers/show/download_justificatif', locals: { dossier: dossier }
.action
= link_to 'Envoyer un message à ladministration', messagerie_dossier_url(dossier, anchor: 'new_commentaire'), class: 'button'
@ -83,7 +83,7 @@
= succeed '.' do
%strong sans suite
= render partial: 'new_user/dossiers/show/download_justificatif', locals: { dossier: @dossier }
= render partial: 'users/dossiers/show/download_justificatif', locals: { dossier: dossier }
- if dossier.motivation.present?
%h3 Motif du classement sans suite