controller
This commit is contained in:
parent
bc101b34cd
commit
f5e4c28fc1
2 changed files with 39 additions and 0 deletions
|
@ -244,6 +244,11 @@ module Instructeurs
|
||||||
redirect_to instructeur_procedure_path(@procedure)
|
redirect_to instructeur_procedure_path(@procedure)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def administrateurs
|
||||||
|
@procedure = procedure
|
||||||
|
@administrateurs = procedure.administrateurs
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def create_bulk_message_mail(dossier_count, dossier_state)
|
def create_bulk_message_mail(dossier_count, dossier_state)
|
||||||
|
|
34
app/javascript/controllers/clipboard_controller.ts
Normal file
34
app/javascript/controllers/clipboard_controller.ts
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
import { Controller } from '@hotwired/stimulus';
|
||||||
|
|
||||||
|
const SUCCESS_MESSAGE_TIMEOUT = 1000;
|
||||||
|
|
||||||
|
export class ClipboardController extends Controller {
|
||||||
|
static values = { text: String };
|
||||||
|
static targets = ['success'];
|
||||||
|
|
||||||
|
declare readonly textValue: string;
|
||||||
|
declare readonly successTarget: HTMLElement;
|
||||||
|
declare readonly hasSuccessTarget: boolean;
|
||||||
|
|
||||||
|
#timer?: ReturnType<typeof setTimeout>;
|
||||||
|
|
||||||
|
disconnect(): void {
|
||||||
|
clearTimeout(this.#timer);
|
||||||
|
}
|
||||||
|
|
||||||
|
copy() {
|
||||||
|
navigator.clipboard
|
||||||
|
.writeText(this.textValue)
|
||||||
|
.then(() => this.displayCopyConfirmation());
|
||||||
|
}
|
||||||
|
|
||||||
|
private displayCopyConfirmation() {
|
||||||
|
if (this.hasSuccessTarget) {
|
||||||
|
this.successTarget.classList.remove('hidden');
|
||||||
|
clearTimeout(this.#timer);
|
||||||
|
this.#timer = setTimeout(() => {
|
||||||
|
this.successTarget.classList.add('hidden');
|
||||||
|
}, SUCCESS_MESSAGE_TIMEOUT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue