@eqproject/eqp-attachments 0.1.12 → 0.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import { __decorate, __awaiter } from 'tslib';
2
- import { ɵɵdefineInjectable, Injectable, EventEmitter, Input, Output, ViewChild, Component, NgModule } from '@angular/core';
2
+ import { ɵɵdefineInjectable, Injectable, EventEmitter, ChangeDetectorRef, Input, Output, ViewChild, Component, NgModule } from '@angular/core';
3
3
  import { Validators, FormBuilder, FormsModule, ReactiveFormsModule } from '@angular/forms';
4
4
  import { base64ToFile, ImageCropperComponent, ImageCropperModule } from 'ngx-image-cropper';
5
5
  import imageCompression from 'browser-image-compression';
@@ -211,11 +211,12 @@ const toBase64 = file => new Promise((resolve, reject) => {
211
211
  });
212
212
  const ɵ0 = toBase64;
213
213
  let EqpAttachmentsComponent = class EqpAttachmentsComponent {
214
- constructor(dialog, formBuilder, sanitizer, http) {
214
+ constructor(dialog, formBuilder, sanitizer, http, cd) {
215
215
  this.dialog = dialog;
216
216
  this.formBuilder = formBuilder;
217
217
  this.sanitizer = sanitizer;
218
218
  this.http = http;
219
+ this.cd = cd;
219
220
  //#region @Input del componente
220
221
  /**
221
222
  * Se TRUE allora nasconde la colonna per le azioni sull'allegato (nel caso "multipleAttachment" è TRUE).
@@ -242,6 +243,11 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
242
243
  * Se TRUE allora il componente mostra l'elenco di tutti gli allegati ricevuto nel parametro "attachmentsList".
243
244
  */
244
245
  this.multipleAttachment = true;
246
+ /**
247
+ * Se assume il valore TRUE allora sarà possibile caricare più file per volta. Questa funzionalità è attiva
248
+ * SOLO se si gestiscono allegati multipli, quindi se l'input 'multipleAttachment' assume il valore TRUE, altrimenti è sempre disabilitata.
249
+ */
250
+ this.loadMultipleFiles = false;
245
251
  /**
246
252
  * Configurazione delle colonne della eqp-table per la visualizzazione degli allegati (caso "multipleAttachment" è TRUE).
247
253
  */
@@ -287,9 +293,20 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
287
293
  */
288
294
  this.allowedTypes = [AttachmentType.FILE, AttachmentType.LINK];
289
295
  /**
290
- * Booleano per impostare la eqp-table nella modalità multilingua
296
+ * Permette di stabilire se la eqp-table contenente l'elenco degli allegati utilizza
297
+ * il multilingua oppure no
291
298
  */
292
299
  this.isEqpTableMultiLanguage = false;
300
+ /**
301
+ * Permette di stabilire, in caso di gestione allegati multipli, se la tabella contenente l'elenco
302
+ * degli allegati deve essere paginata oppure no
303
+ */
304
+ this.tablePaginatorVisible = true;
305
+ /**
306
+ * In caso di gestione allegati multipli, permette di stabilire la dimensione pagina di default
307
+ * per la tabella contenente l'elenco degli allegati
308
+ */
309
+ this.tablePaginatorSize = null;
293
310
  /**
294
311
  * Input per definire le label da usare nel componente
295
312
  */
@@ -318,6 +335,10 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
318
335
  * Restituisce la lista aggiornata degli allegati.
319
336
  */
320
337
  this.localEditedAttachments = new EventEmitter();
338
+ /**
339
+ * Evento scatenato alla pressione del pulsante ESCI della modale di caricamento file.
340
+ */
341
+ this.abortAddAttachment = new EventEmitter();
321
342
  /**
322
343
  * Evento di output che restituisce l'IAttachmentDTO selezionato per il download nel caso FileDataBase64, FileContentType o FileName non fossero specificati.
323
344
  */
@@ -329,8 +350,10 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
329
350
  //#endregion
330
351
  //#region Proprietà per gestione caricamento nuovo allegato
331
352
  this.newAttachment = {};
353
+ this.newMultipleAttachments = [];
332
354
  this.attachmentType = AttachmentType;
333
355
  this.selectedFile = null;
356
+ this.selectedFiles = null;
334
357
  this.showCropImage = false;
335
358
  //#endregion
336
359
  //#region Proprietà per gestione ridimensionamento file di tipo image
@@ -361,8 +384,6 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
361
384
  if (this.attachmentsList == null)
362
385
  this.attachmentsList = new Array();
363
386
  this.checkAttachmentImage();
364
- // if (!this.compressionOptions || !this.compressionOptions.maxSizeMB || !this.compressionOptions.maxWidthOrHeight)
365
- // this.compressionOptions = { maxSizeMB: 0.5, maxWidthOrHeight: 1920, useWebWorker: true };
366
387
  }
367
388
  reloadData() {
368
389
  if (this.attachmentTable)
@@ -473,9 +494,25 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
473
494
  * Apre la modale per la definizione dei parametri del nuovo file
474
495
  */
475
496
  openModalAddAttachment(attachmentType) {
497
+ //Se è stato richiesto il caricamento di un LINK o è impostato il caricamento di FILE SINGOLO allora apre la modale per
498
+ //il caricamento singolo del file altrimenti apre quella per il caricamento multiplo
499
+ // if (attachmentType == AttachmentType.LINK || (attachmentType == AttachmentType.FILE && this.loadMultipleFiles != true)) {
476
500
  this.newAttachment = {};
477
501
  this.newAttachment.IsImage = false;
478
502
  this.newAttachment.AttachmentType = attachmentType;
503
+ this.newMultipleAttachments = new Array();
504
+ if (attachmentType == AttachmentType.LINK)
505
+ this.newMultipleAttachments.push(this.newAttachment);
506
+ this.createAttachmentForm();
507
+ //Apre la modale
508
+ this.dialofRefAddAttachment = this.dialog.open(this.dialogAddAttachment, {
509
+ disableClose: true,
510
+ hasBackdrop: true,
511
+ width: '60%',
512
+ maxHeight: '80%'
513
+ });
514
+ }
515
+ createAttachmentForm() {
479
516
  //Crea la form per la validazione dei campi
480
517
  this.newAttachmentForm = this.formBuilder.group({
481
518
  type: [this.newAttachment.AttachmentType, Validators.required],
@@ -484,19 +521,16 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
484
521
  customHeight: [this.customHeight],
485
522
  customWidth: [this.customWidth]
486
523
  });
487
- //Apre la modale
488
- this.dialofRefAddAttachment = this.dialog.open(this.dialogAddAttachment, {
489
- disableClose: true,
490
- hasBackdrop: true,
491
- width: '60%',
492
- maxHeight: '80%'
493
- });
494
524
  }
495
- close() {
525
+ close(emitCloseEvent = true) {
496
526
  this.newAttachment = {};
527
+ this.newMultipleAttachments = new Array();
497
528
  this.abortFile();
498
- this.newAttachmentForm.reset();
529
+ if (this.newAttachmentForm)
530
+ this.newAttachmentForm.reset();
499
531
  this.dialofRefAddAttachment.close();
532
+ if (emitCloseEvent == true && this.abortAddAttachment)
533
+ this.abortAddAttachment.emit();
500
534
  }
501
535
  /**
502
536
  * In base al tipo di allegato controlla se disabilitare o meno il pulsante per salvare.
@@ -504,23 +538,37 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
504
538
  * @returns
505
539
  */
506
540
  disableSave() {
507
- if (this.newAttachment.AttachmentType == AttachmentType.FILE) {
508
- return !this.newAttachment.FileDataBase64;
541
+ if (this.loadMultipleFiles != true) {
542
+ if (this.newAttachment.AttachmentType == AttachmentType.FILE) {
543
+ return !this.newAttachment.FileDataBase64;
544
+ }
545
+ else {
546
+ return !this.newAttachment.FilePath;
547
+ }
509
548
  }
510
549
  else {
511
- return !this.newAttachment.FilePath;
550
+ return this.newMultipleAttachments.filter(p => (p.AttachmentType == AttachmentType.FILE && !p.FileDataBase64) || (p.AttachmentType == AttachmentType.LINK && !p.FilePath)).length > 0;
512
551
  }
513
552
  }
514
553
  confirmAddAttachment() {
515
- if (this.newAttachment.AttachmentType == AttachmentType.LINK && !this.newAttachment.FileName)
516
- this.newAttachment.FileName = this.newAttachment.FilePath;
517
- if (this.attachmentsList == null)
518
- this.attachmentsList = new Array();
519
- this.attachmentsList.push(this.newAttachment);
554
+ if (this.loadMultipleFiles != true) {
555
+ if (this.newAttachment.AttachmentType == AttachmentType.LINK && !this.newAttachment.FileName)
556
+ this.newAttachment.FileName = this.newAttachment.FilePath;
557
+ if (this.attachmentsList == null)
558
+ this.attachmentsList = new Array();
559
+ this.attachmentsList.push(this.newAttachment);
560
+ }
561
+ else {
562
+ if (this.newMultipleAttachments == null || this.newMultipleAttachments.length == 0)
563
+ return;
564
+ if (this.attachmentsList == null)
565
+ this.attachmentsList = new Array();
566
+ this.attachmentsList = this.attachmentsList.concat(this.newMultipleAttachments);
567
+ }
520
568
  if (this.attachmentTable)
521
569
  this.attachmentTable.reloadDatatable();
522
570
  this.localEditedAttachments.emit(this.attachmentsList);
523
- this.dialofRefAddAttachment.close();
571
+ this.close(false);
524
572
  }
525
573
  /**
526
574
  * Apre il dialog per l'anteprima dell'allegato selezionato.
@@ -578,68 +626,140 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
578
626
  }
579
627
  //#region Gestione caricamento file
580
628
  /**
581
- * Se il file caricato è un immagine allora mostra le funzionalità del croppie per ritagliare l'immagine altrimenti
582
- * converte il file in base64 e lo associa all'allegato da salvare
629
+ * Evento scatenato alla selezione del file (o dei file).
630
+ * Se il caricamento è SINGOLO o se comunque è stato selezionato un solo file allora si occupa di controllare se si tratta di un immagine in modo da
631
+ * mostrare le funzionalità del croppie (per ritagliare l'immagine) oppure no.
632
+ * Se il file caricato non è un immagine allora genera direttamente il base64 e lo associa all'allegato da salvare.
633
+ * Se invece il caricamento dei file è MULTIPLO e sono presenti più file allora esegue le stesse operazioni ignorando però il contrllo
634
+ * immagine per il croppie (in caso di caricamento multiplo le funzionalità del croppie sono disabilitate).
583
635
  */
584
636
  onFileInputChange(event) {
585
637
  return __awaiter(this, void 0, void 0, function* () {
586
638
  this.showCropImage = false;
587
- this.selectedFile = event.target.files[0];
588
- if (!this.selectedFile)
589
- return;
590
- //Memorizza i dati per l'allegato
591
- this.newAttachment.FileContentType = this.selectedFile.type;
592
- this.newAttachment.FileName = this.selectedFile.name;
593
- this.newAttachment.FileExtension = this.selectedFile.name.substr(this.selectedFile.name.lastIndexOf('.') + 1);
594
- this.newAttachment.IsImage = AttachmentHelperService.checkImageFromMimeType(this.selectedFile.type);
595
- //Se è stata richiesta la gestione delle sole immagini ma per errore è stato selezionato un file che non è un immagine
596
- if (this.allowOnlyImages == true && this.newAttachment.IsImage != true) {
597
- EqpAttachmentDialogService.Error(this.noImageSelectedErrorMessage);
598
- this.abortFile();
599
- return;
600
- }
601
- else if (!this.checkAcceptedFiles()) {
602
- EqpAttachmentDialogService.Error(this.wrongTypeSelectedErrorMessage);
603
- this.abortFile();
604
- return;
605
- }
606
- //Verifica se il file caricato è un'immagine oppure no. Se è un immagine, prima di caricarla mostra il croppie per il resize.
607
- //Se non è un immagine allora genera il Base64
608
- if (this.newAttachment.IsImage == true) {
609
- this.getImageDimensions(event.target.files[0]);
610
- //Mostra il croppie e disabilita la form finchè non termina la modifica dell'immagine
611
- this.newAttachmentForm.disable();
612
- this.newAttachmentForm.controls["customWidth"].enable();
613
- this.newAttachmentForm.controls["customHeight"].enable();
614
- this.showCropImage = true;
615
- this.imageChangedEvent = event;
639
+ //Se è stato richiesto il caricamento SINGOLO oppure se il caricamento è MULTIPLO ma è stato selezionato un solo file
640
+ //allora verifica se il file è un immagine (per mostrare il CROPPIE)
641
+ if ([...event.target.files].length == 1 || this.loadMultipleFiles != true) {
642
+ this.selectedFile = event.target.files[0];
643
+ this.selectedFiles = event.target.files;
644
+ if (!this.selectedFile)
645
+ return;
646
+ //Memorizza i dati per l'allegato
647
+ this.newAttachment = yield this.createAttachmentFromUploadedFile(this.selectedFile, false);
648
+ this.newMultipleAttachments = new Array();
649
+ this.newMultipleAttachments.push(this.newAttachment);
650
+ //Se è stata richiesta la gestione delle sole immagini ma per errore è stato selezionato un file che non è un immagine
651
+ let checkOnlyImage = this.checkAllowOnlyImageFile(this.newAttachment);
652
+ if (checkOnlyImage == false)
653
+ return;
654
+ if (this.loadMultipleFiles == true && [...event.target.files].length == 1)
655
+ this.createAttachmentForm();
656
+ //Verifica se il file caricato è un'immagine oppure no. Se è un immagine, prima di caricarla mostra il croppie per il resize.
657
+ //Se non è un immagine allora genera il Base64
658
+ if (this.newAttachment.IsImage == true) {
659
+ this.getImageDimensions(event.target.files[0]);
660
+ //Mostra il croppie e disabilita la form finchè non termina la modifica dell'immagine
661
+ this.newAttachmentForm.disable();
662
+ this.newAttachmentForm.controls["customWidth"].enable();
663
+ this.newAttachmentForm.controls["customHeight"].enable();
664
+ this.showCropImage = true;
665
+ this.imageChangedEvent = event;
666
+ }
667
+ else {
668
+ this.showCropImage = false;
669
+ let base64Result = yield this.getBase64FromFile(this.selectedFile);
670
+ this.newAttachment.FileDataBase64 = base64Result.Base64File;
671
+ this.newAttachment.FileContentType = base64Result.ContentType;
672
+ }
616
673
  }
617
674
  else {
618
- this.showCropImage = false;
619
- let base64File = yield toBase64(this.selectedFile);
620
- if (base64File) {
621
- // Loris 20/01/2022: PROBLEMA - Quando eseguo l'upload di un file .sql non viene salvato/scaricato correttamente.
622
- // Questo succede perchè non viene popolato il FileContentType. Per risolvere il problema
623
- // faccio un controllo e se non esiste il FileContentType allora lo recupero dal base64 ottenuto.
624
- this.newAttachment.FileContentType = !this.newAttachment.FileContentType ? base64File.split(",")[0].split(":")[1].split(";")[0] : this.newAttachment.FileContentType;
625
- // Un altro metodo per leggere il ccontent type del file è tramite una regular expression:
626
- // this.newAttachment.FileContentType = !this.newAttachment.FileContentType ? base64File.match(/[^:]\w+\/[\w-+\d.]+(?=;|,)/)[0] : this.newAttachment.FileContentType;
627
- this.newAttachment.FileDataBase64 = base64File.split(",")[1];
675
+ this.selectedFiles = event.target.files;
676
+ if (!this.selectedFiles || this.selectedFiles.length == 0)
677
+ return;
678
+ this.newMultipleAttachments = new Array();
679
+ for (let i = 0; i < this.selectedFiles.length; i++) {
680
+ let newAttachment = yield this.createAttachmentFromUploadedFile(this.selectedFiles[i], true);
681
+ //Se è stata richiesta la gestione delle sole immagini ma per errore è stato selezionato un file che non è un immagine
682
+ let checkOnlyImage = this.checkAllowOnlyImageFile(newAttachment);
683
+ if (checkOnlyImage == false)
684
+ return;
685
+ this.newMultipleAttachments.push(newAttachment);
628
686
  }
629
687
  }
630
688
  });
631
689
  }
690
+ /**
691
+ * A partire dal FILE ricevuto in input ricostruisce l'oggetto IAttachmentDTO e lo restituisce.
692
+ * Se il parametro getBase64 viene passato a TRUE allora, sempre a partire dal file,genera il base64 e
693
+ * ricava il ContentType da associare all'oggetto IAttachmentDTO da restituire
694
+ * @param currentFile Oggetto FILE da processare
695
+ * @param getBase64 Se TRUE allora calcola base64 e ContentType del file passato in input
696
+ * @returns Restituisce un oggetto di tipo IAttachmentDTO
697
+ */
698
+ createAttachmentFromUploadedFile(currentFile, getBase64 = true) {
699
+ return __awaiter(this, void 0, void 0, function* () {
700
+ let newAttachment = {};
701
+ //Memorizza i dati per l'allegato
702
+ newAttachment.AttachmentType = AttachmentType.FILE;
703
+ newAttachment.FileContentType = currentFile.type;
704
+ newAttachment.FileName = currentFile.name;
705
+ newAttachment.FileExtension = currentFile.name.substr(currentFile.name.lastIndexOf('.') + 1);
706
+ newAttachment.IsImage = AttachmentHelperService.checkImageFromMimeType(currentFile.type);
707
+ if (getBase64 == true) {
708
+ let base64Result = yield this.getBase64FromFile(currentFile);
709
+ newAttachment.FileDataBase64 = base64Result.Base64File;
710
+ newAttachment.FileContentType = base64Result.ContentType;
711
+ }
712
+ return newAttachment;
713
+ });
714
+ }
715
+ /**
716
+ * A partire dal file passato in input restituisce un oggetto
717
+ * contenente il base64 del file e il suo contentType
718
+ * @param currentFile Oggetto File da cui estrapolare base64 e contentType
719
+ * @returns Restituisce un oggetto avente le proprietà Base64File e ContentType
720
+ */
721
+ getBase64FromFile(currentFile) {
722
+ return __awaiter(this, void 0, void 0, function* () {
723
+ let base64File = yield toBase64(currentFile);
724
+ let contentType = null;
725
+ if (base64File) {
726
+ // Loris 20/01/2022: PROBLEMA - Quando eseguo l'upload di un file .sql non viene salvato/scaricato correttamente.
727
+ // Questo succede perchè non viene popolato il FileContentType. Per risolvere il problema
728
+ // faccio un controllo e se non esiste il FileContentType allora lo recupero dal base64 ottenuto.
729
+ contentType = base64File.split(",")[0].split(":")[1].split(";")[0];
730
+ // Un altro metodo per leggere il ccontent type del file è tramite una regular expression:
731
+ base64File = base64File.split(",")[1];
732
+ }
733
+ let result = {
734
+ Base64File: base64File,
735
+ ContentType: contentType
736
+ };
737
+ return result;
738
+ });
739
+ }
632
740
  /**
633
741
  * Controlla se il file che si sta caricando è supportato dal sistema.
634
742
  * @returns
635
743
  */
636
744
  checkAcceptedFiles() {
637
- if (this.selectedFile.type.startsWith("video"))
745
+ if ((this.loadMultipleFiles != true && this.selectedFile.type.startsWith("video"))
746
+ || (this.loadMultipleFiles == true && [...this.selectedFiles].filter(p => p.type.startsWith("video")).length > 0))
638
747
  return false;
639
748
  if (this.acceptedFileTypes == "*")
640
749
  return true;
641
- let accepted = this.acceptedFileTypes.includes(this.selectedFile.type);
642
- if (!accepted) {
750
+ //Verifica che i tipi del file (o dei file) caricati siano coerenti con quelli accettati dalla direttiva
751
+ let accepted = true;
752
+ if (this.loadMultipleFiles != true)
753
+ accepted = this.acceptedFileTypes.includes(this.selectedFile.type);
754
+ else {
755
+ let uploadedFileTypes = [...this.selectedFiles].map(p => p.type);
756
+ uploadedFileTypes.forEach(type => {
757
+ if (!this.acceptedFileTypes.includes(type))
758
+ accepted = false;
759
+ });
760
+ }
761
+ //Questo controllo permette di gestire le casistiche per cui vengono indicati come tipi validi, ad esempio, 'image/*'
762
+ if (!accepted && this.loadMultipleFiles != true) {
643
763
  for (let t of this.acceptedFileTypes.split(",").filter(t => t.includes("*"))) {
644
764
  accepted = this.selectedFile.type.startsWith(t.split("*")[0]);
645
765
  if (accepted)
@@ -648,6 +768,24 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
648
768
  }
649
769
  return accepted;
650
770
  }
771
+ /**
772
+ * Se eqp-attachments è stata configurata per il caricamento delle sole immagini allora verifica che il file passato in
773
+ * input sia effettivamente un immagine o no.
774
+ * Se il controllo va a buon fine restituisce TRUE altrimenti mostra un messaggio d'errore e restituisce FALSE
775
+ */
776
+ checkAllowOnlyImageFile(newAttachment) {
777
+ if (this.allowOnlyImages == true && newAttachment.IsImage != true) {
778
+ EqpAttachmentDialogService.Error(this.noImageSelectedErrorMessage);
779
+ this.abortFile();
780
+ return false;
781
+ }
782
+ else if (!this.checkAcceptedFiles()) {
783
+ EqpAttachmentDialogService.Error(this.wrongTypeSelectedErrorMessage);
784
+ this.abortFile();
785
+ return false;
786
+ }
787
+ return true;
788
+ }
651
789
  getImageDimensions(img) {
652
790
  const reader = new FileReader();
653
791
  reader.onload = (e) => {
@@ -715,12 +853,14 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
715
853
  if (this.imageInput)
716
854
  this.imageInput.nativeElement.value = '';
717
855
  this.selectedFile = null;
856
+ this.selectedFiles = null;
718
857
  this.showCropImage = false;
719
858
  this.newAttachment.IsImage = false;
720
859
  this.newAttachment.FileDataBase64 = null;
721
860
  this.newAttachment.FileName = null;
722
861
  this.newAttachment.FileExtension = null;
723
862
  this.newAttachment.FileContentType = null;
863
+ this.newMultipleAttachments = new Array();
724
864
  this.customHeight = null;
725
865
  this.customWidth = null;
726
866
  this.originalHeight = null;
@@ -731,7 +871,8 @@ EqpAttachmentsComponent.ctorParameters = () => [
731
871
  { type: MatDialog },
732
872
  { type: FormBuilder },
733
873
  { type: DomSanitizer },
734
- { type: HttpClient }
874
+ { type: HttpClient },
875
+ { type: ChangeDetectorRef }
735
876
  ];
736
877
  __decorate([
737
878
  Input("disableAction")
@@ -751,6 +892,9 @@ __decorate([
751
892
  __decorate([
752
893
  Input("multipleAttachment")
753
894
  ], EqpAttachmentsComponent.prototype, "multipleAttachment", void 0);
895
+ __decorate([
896
+ Input("loadMultipleFiles")
897
+ ], EqpAttachmentsComponent.prototype, "loadMultipleFiles", void 0);
754
898
  __decorate([
755
899
  Input("attachmentsColumns")
756
900
  ], EqpAttachmentsComponent.prototype, "attachmentsColumns", void 0);
@@ -784,6 +928,12 @@ __decorate([
784
928
  __decorate([
785
929
  Input("isEqpTableMultiLanguage")
786
930
  ], EqpAttachmentsComponent.prototype, "isEqpTableMultiLanguage", void 0);
931
+ __decorate([
932
+ Input("tablePaginatorVisible")
933
+ ], EqpAttachmentsComponent.prototype, "tablePaginatorVisible", void 0);
934
+ __decorate([
935
+ Input("tablePaginatorSize")
936
+ ], EqpAttachmentsComponent.prototype, "tablePaginatorSize", void 0);
787
937
  __decorate([
788
938
  Input("downloadTooltipPosition")
789
939
  ], EqpAttachmentsComponent.prototype, "downloadTooltipPosition", void 0);
@@ -844,6 +994,9 @@ __decorate([
844
994
  __decorate([
845
995
  Output()
846
996
  ], EqpAttachmentsComponent.prototype, "localEditedAttachments", void 0);
997
+ __decorate([
998
+ Output()
999
+ ], EqpAttachmentsComponent.prototype, "abortAddAttachment", void 0);
847
1000
  __decorate([
848
1001
  Output("downloadAttachment")
849
1002
  ], EqpAttachmentsComponent.prototype, "downloadAttachment", void 0);
@@ -853,6 +1006,9 @@ __decorate([
853
1006
  __decorate([
854
1007
  ViewChild('dialogAddAttachment', { static: true })
855
1008
  ], EqpAttachmentsComponent.prototype, "dialogAddAttachment", void 0);
1009
+ __decorate([
1010
+ ViewChild('dialogAddMultipleAttachment', { static: true })
1011
+ ], EqpAttachmentsComponent.prototype, "dialogAddMultipleAttachment", void 0);
856
1012
  __decorate([
857
1013
  ViewChild(ImageCropperComponent)
858
1014
  ], EqpAttachmentsComponent.prototype, "imageCropper", void 0);
@@ -871,7 +1027,7 @@ __decorate([
871
1027
  EqpAttachmentsComponent = __decorate([
872
1028
  Component({
873
1029
  selector: 'eqp-attachments',
874
- template: "<!-- Se richiesta la gestione multipla mostra il pulsante di aggiunta e la tabella con l'elenco allegati -->\r\n<div *ngIf=\"multipleAttachment == true\">\r\n <mat-card [ngStyle]=\"{ 'box-shadow': showMatCard == false ? 'none' : null }\">\r\n <mat-card-header>\r\n <div class=\"col-md-6\">\r\n <div class=\"text-nowrap eqp-attachments-header-title\" *ngIf=\"showHeader == true\">\r\n {{headerTitle}}\r\n </div>\r\n </div>\r\n <div class=\"col-md-6 text-right\">\r\n <div class=\"row justify-content-end\">\r\n <!-- Template del button per l'aggiunta di un allegato -->\r\n <ng-container *ngTemplateOutlet=\"addAttachmentButton\"></ng-container>\r\n </div>\r\n </div>\r\n </mat-card-header>\r\n <mat-card-content>\r\n <eqp-table #attachmentTable [createMatCard]=\"false\" #table [columns]=\"attachmentsColumns\" [isMultiLanguage]=\"isEqpTableMultiLanguage\"\r\n [data]=\"attachmentsList\" [emptyTableMessage]=\"emptyTableMessage\" [searchText]=\"eqpTableSearchText\">\r\n </eqp-table>\r\n </mat-card-content>\r\n </mat-card>\r\n</div>\r\n\r\n<!-- Se richiesta la gestione singola mostra il pulsante di caricamento di un singolo file -->\r\n<div *ngIf=\"multipleAttachment != true\">\r\n <!-- Template del button per l'aggiunta di un allegato -->\r\n <ng-container *ngTemplateOutlet=\"addAttachmentButton\"></ng-container>\r\n\r\n <button class=\"mb-2 mr-2 eqp-attachments-download-btn\" (click)=\"viewAttachment(attachmentsList[0])\" type=\"button\"\r\n mat-raised-button *ngIf=\"attachmentsList && attachmentsList.length > 0 && attachmentsList[0]\" color=\"primary\">\r\n <mat-icon *ngIf=\"attachmentsList[0].AttachmentType == AttachmentType.FILE\">download</mat-icon>\r\n <mat-icon *ngIf=\"attachmentsList[0].AttachmentType != AttachmentType.FILE\">open_in_new</mat-icon>\r\n {{attachmentsList[0].AttachmentType == AttachmentType.FILE ? downloadLabel : openLinkLabel}}\r\n </button>\r\n <button class=\"mb-2 mr-2 eqp-attachments-preview-btn\" (click)=\"openPreviewDialog(attachmentsList[0])\" type=\"button\"\r\n mat-raised-button color=\"primary\"\r\n *ngIf=\"attachmentsList && attachmentsList.length > 0 && attachmentsList[0] && (!attachmentsList[0].FileContentType || (!attachmentsList[0].FileContentType.startsWith('video') && !attachmentsList[0].FileContentType.startsWith('audio')))\">\r\n <mat-icon>visibility</mat-icon> {{previewLabel}}\r\n </button>\r\n <button class=\"mb-2 eqp-attachments-delete-btn\" (click)=\"deleteAttachment(attachmentsList[0])\" type=\"button\"\r\n mat-raised-button *ngIf=\"attachmentsList && attachmentsList.length > 0 && attachmentsList[0]\"\r\n [disabled]=\"isDisabled\">\r\n <mat-icon>delete</mat-icon> {{deleteLabel}}\r\n </button>\r\n\r\n <div class=\"row\" style=\"margin-top: 10px;\"\r\n *ngIf=\"attachmentsList.length > 0 && attachmentsList[0] && attachmentsList[0].FileDataBase64 && attachmentsList[0].IsImage == true\">\r\n <div class=\"col-sm-12\">\r\n <div class=\"single-attachment-inline-preview-container\">\r\n <img src=\"data:image/png;base64,{{attachmentsList[0].FileDataBase64}}\">\r\n </div>\r\n </div>\r\n </div>\r\n <div class=\"row\" *ngIf=\"attachmentsList.length > 0 && attachmentsList[0] && attachmentsList[0].IsImage != true\">\r\n <div class=\"col-sm-12\">\r\n <mat-form-field>\r\n <mat-label>{{fileNameLabel}}</mat-label>\r\n <input readonly matInput [(ngModel)]=\"attachmentsList[0].FileName\">\r\n </mat-form-field>\r\n </div>\r\n </div>\r\n</div>\r\n\r\n\r\n\r\n<ng-template #dialogAddAttachment>\r\n <div class=\"container-fluid eqp-attachments-dialog-add-container\"\r\n style=\"max-height: 70vh !important; overflow-x: hidden; overflow-y: auto;\">\r\n <form [formGroup]=\"newAttachmentForm\" (ngSubmit)=\"confirmAddAttachment()\" *ngIf=\"newAttachmentForm\">\r\n <div class=\"row\">\r\n <div class=\"header-title-standard\"> {{addButtonLabel}} {{ newAttachment.AttachmentType ==\r\n attachmentType.FILE ?\r\n 'File' : 'Link'}} </div>\r\n </div>\r\n <div class=\"row\" style=\"margin-top: 20px;\">\r\n <div class=\"col-sm-12\" *ngIf=\"newAttachment.AttachmentType == attachmentType.FILE\">\r\n <input #imageInput style=\"display:none;\" id=\"file_attachment\" name=\"file_attachment\" type=\"file\"\r\n (change)=\"onFileInputChange($event)\" [accept]=\"acceptedFileTypes\" />\r\n <button (click)=\"imageInput.click()\" type=\"button\" style=\"margin-left: 10px;\" id=\"file_attachment\"\r\n mat-raised-button color=\"primary\" [disabled]=\"showCropImage == true\"\r\n class=\"mb-2 btn btn-primary eqp-attachments-upload-btn\" *ngIf=\"!newAttachment.FileDataBase64\">\r\n <mat-icon>cloud_upload</mat-icon>\r\n {{uploadFileLabel}}\r\n </button>\r\n <button (click)=\"abortFile()\" type=\"button\" style=\"margin-left: 10px;\" mat-raised-button\r\n *ngIf=\"newAttachment.FileDataBase64\" class=\"mb-2 eqp-attachments-delete-btn\">\r\n <mat-icon>delete</mat-icon> {{deleteLabel}}\r\n </button>\r\n </div>\r\n <div class=\"col-sm-12\" *ngIf=\"newAttachment.AttachmentType == 2 || selectedFile\">\r\n <mat-form-field>\r\n <mat-label> {{fileNameLabel}} </mat-label>\r\n <input formControlName=\"name\" matInput [(ngModel)]=\"newAttachment.FileName\">\r\n </mat-form-field>\r\n </div>\r\n <div class=\"col-sm-12\" *ngIf=\"newAttachment.AttachmentType == 2\">\r\n <mat-form-field>\r\n <mat-label> Link </mat-label>\r\n <input formControlName=\"path\" required matInput [(ngModel)]=\"newAttachment.FilePath\">\r\n </mat-form-field>\r\n </div>\r\n </div>\r\n <div class=\"row\"\r\n *ngIf=\"showCropImage != true && newAttachment.FileDataBase64 && newAttachment.IsImage == true\"\r\n style=\"margin-top: 10px;\">\r\n <div class=\"col-4\">\r\n <div class=\"single-attachment-inline-preview-container\">\r\n <img src=\"data:image/png;base64,{{newAttachment.FileDataBase64}}\">\r\n </div>\r\n </div>\r\n </div>\r\n <div class=\"row mt-2 mb-2\" *ngIf=\"showCropImage == true\">\r\n <div class=\"col-md-12 d-flex align-items-center justify-content-center\">\r\n <span class=\"mr-1\">Max H(px):</span>\r\n <mat-form-field>\r\n <input formControlName=\"customHeight\" type=\"number\" matInput [(ngModel)]=\"customHeight\"\r\n (change)=\"onDimensionsChange('H')\">\r\n </mat-form-field>\r\n\r\n <span class=\"ml-2 mr-1\">Max W(px):</span>\r\n <mat-form-field>\r\n <input formControlName=\"customWidth\" type=\"number\" matInput [(ngModel)]=\"customWidth\"\r\n (change)=\"onDimensionsChange('W')\">\r\n </mat-form-field>\r\n\r\n <button class=\"btn btn-primary mat-raised-button ml-2\" (click)=\"restoreOriginalDimensions()\"\r\n [disabled]=\"customWidth == originalWidth && customHeight == originalHeight\">\r\n <mat-icon style=\"vertical-align: middle;\">replay</mat-icon>\r\n </button>\r\n </div>\r\n </div>\r\n <div class=\"row justify-content-center\" *ngIf=\"showCropImage == true\">\r\n <div style=\"max-height: 450px; max-width: 450px;\">\r\n <image-cropper [imageChangedEvent]=\"imageChangedEvent\" [maintainAspectRatio]=\"false\"\r\n [autoCrop]=\"false\" [containWithinAspectRatio]=\"false\" [aspectRatio]=\"4/3\"\r\n [cropperMinWidth]=\"128\" [onlyScaleDown]=\"true\" [roundCropper]=\"false\" [canvasRotation]=\"0\"\r\n [transform]=\"transform\" [alignImage]=\"'left'\" format=\"png\" (imageCropped)=\"imageCropped($event)\"\r\n [resizeToWidth]=\"customWidth\" [resizeToHeight]=\"customHeight\">\r\n </image-cropper>\r\n </div>\r\n </div>\r\n <div class=\"row justify-content-center mt-2\" *ngIf=\"showCropImage == true\">\r\n <div style=\"max-height: 450px; max-width: 450px;\">\r\n <button class=\"btn btn-primary mat-raised-button eqp-attachments-confirm-btn mr-2\" type=\"button\"\r\n (click)=\"confirmCrop()\">\r\n {{confirmLabel}}\r\n </button>\r\n <button class=\"btn mat-raised-button eqp-attachments-abort-btn\" type=\"button\" (click)=\"abortFile()\">\r\n {{abortLabel}}\r\n </button>\r\n </div>\r\n </div>\r\n\r\n <div class=\"row mt-2\">\r\n <div class=\"col-sm-12 text-right\">\r\n <button class=\"btn btn-primary mat-raised-button eqp-attachments-save-btn mr-2\" type=\"submit\"\r\n [disabled]=\"showCropImage == true || newAttachmentForm?.disabled == true || disableSave()\">\r\n {{saveLabel}}\r\n </button>\r\n <button class=\"btn mat-raised-button eqp-attachments-exit-btn\" (click)=\"close()\"\r\n [disabled]=\"showCropImage == true\" type=\"button\">\r\n {{exitLabel}}\r\n </button>\r\n </div>\r\n </div>\r\n </form>\r\n\r\n </div>\r\n</ng-template>\r\n\r\n<ng-template #inlinePreviewTemplate let-row=\"row\">\r\n <div class=\"inline-preview-container\" *ngIf=\"row.IsImage\" (click)=\"openPreviewDialog(row)\">\r\n <img src=\"data:image/png;base64,{{row.FileThumbnailBase64 ? row.FileThumbnailBase64 : row.FileDataBase64}}\">\r\n </div>\r\n <div class=\"inline-preview-container\" *ngIf=\"!row.IsImage\" (click)=\"openPreviewDialog(row)\">\r\n <i [ngClass]=\"getAttachmentIcon(row)\"></i>\r\n </div>\r\n</ng-template>\r\n\r\n\r\n<ng-template #dialogPreview>\r\n <div class=\"container-fluid\" style=\"max-height: 70vh !important;\" *ngIf=\"selectedAttachment\">\r\n <div class=\"row\">\r\n <div class=\"header-title-standard\">\r\n {{previewLabel}} {{ selectedAttachment?.AttachmentType == attachmentType.FILE ? 'File' : 'Link'}}\r\n </div>\r\n </div>\r\n\r\n <div class=\"row mt-2\">\r\n <!-- ANTEPRIMA IMMAGINE -->\r\n <div class=\"col-12 text-center preview-container\" *ngIf=\"selectedAttachment.IsImage\">\r\n <img class=\"image-preview\"\r\n src=\"data:image/png;base64,{{selectedAttachment.FileDataBase64 ? selectedAttachment.FileDataBase64 : selectedAttachment.FileThumbnailBase64}}\">\r\n </div>\r\n\r\n <!-- ANTEPRIMA LINK -->\r\n <div class=\"col-12 preview-container\" *ngIf=\"!selectedAttachment.IsImage\">\r\n <iframe class=\"link-preview\" [src]=\"selectedAttachment.TrustedUrl\"\r\n [title]=\"selectedAttachment.FileName\"></iframe>\r\n </div>\r\n </div>\r\n\r\n <div class=\"row mt-3\">\r\n <div class=\"col-sm-12 text-right\">\r\n <button class=\"btn btn-primary mat-raised-button eqp-attachments-save-btn mr-2\" type=\"submit\"\r\n (click)=\"viewAttachment(selectedAttachment)\"\r\n *ngIf=\"selectedAttachment.AttachmentType != AttachmentType.LINK\">\r\n {{downloadLabel}}\r\n </button>\r\n <button class=\"btn mat-raised-button eqp-attachments-exit-btn\" mat-dialog-close type=\"button\"\r\n (click)=\"selectedAttachment = null\">\r\n {{exitLabel}}\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n</ng-template>\r\n\r\n\r\n<!-- TEMPLATE PER IL PULSANTE DI AGGIUNTA NUOVO ALLEGATO -->\r\n<ng-template #addAttachmentButton>\r\n\r\n <!-- \r\n Pulsanti per l'aggiunta di un file o un link. Ne viene visualizzato uno se:\r\n - gli allowedTypes sono stati specificati, nell'array ne \u00E8 presente uno solo, quello inserito \u00E8 AttachmentType.FILE (o AttachmentType.LINK) \r\n e sono nella gestione di pi\u00F9 allegati (multipleAttachment == true)\r\n OPPURE\r\n - gli allowedTypes sono stati specificati, nell'array ne \u00E8 presente uno solo, quello inserito \u00E8 AttachmentType.FILE (o AttachmentType.LINK) \r\n e sono nella gestione di un singolo allegato (multipleAttachment == true) e non ne \u00E8 ancora stato selezionato uno (ovvero attachmentsList non esiste o non ha elementi)\r\n -->\r\n <button class=\"btn btn-primary mb-4 mr-5 eqp-attachments-add-btn\" mat-raised-button color=\"primary\" type=\"button\"\r\n *ngIf=\"allowedTypes && allowedTypes.length == 1 && (multipleAttachment == true || (!attachmentsList || attachmentsList.length == 0 || (attachmentsList.length > 0 && !attachmentsList[0])))\"\r\n (click)=\"openModalAddAttachment(allowedTypes[0])\" [disabled]=\"isDisabled\">\r\n <!-- Per l'aggiunta dei file mostro un'icona diversa dall'aggiunta dei link -->\r\n <mat-icon *ngIf=\"allowedTypes[0] == 1\">cloud_upload</mat-icon>\r\n <i class=\"fas fa-link\" *ngIf=\"allowedTypes[0] == 2\"></i>\r\n <span style=\"margin-left: 10px;\">{{addButtonLabel}} {{allowedTypes[0] == 1 ? \"file\" : \"link\"}}</span>\r\n </button>\r\n\r\n\r\n <!-- Pulsante per aprire il menu per la scelta del tipo di Attachment da creare -->\r\n <button class=\"btn btn-primary mb-4 mr-5 eqp-attachments-add-btn\" mat-raised-button color=\"primary\" type=\"button\"\r\n [matMenuTriggerFor]=\"attachmentTypeMenu\" [disabled]=\"isDisabled\"\r\n *ngIf=\"allowedTypes && allowedTypes.length > 1 && (multipleAttachment == true || (!attachmentsList || attachmentsList.length == 0 || (attachmentsList.length > 0 && !attachmentsList[0])))\">\r\n <mat-icon *ngIf=\"multipleAttachment != true\">cloud_upload</mat-icon>\r\n <mat-icon *ngIf=\"multipleAttachment == true\">add</mat-icon>\r\n <span style=\"margin-left: 0px;\"> {{addButtonLabel}} </span>\r\n </button>\r\n <mat-menu #attachmentTypeMenu=\"matMenu\">\r\n <button mat-menu-item (click)=\"openModalAddAttachment(1)\" class=\"eqp-attachments-file-btn\">\r\n <i class=\"fas fa-file\"></i>\r\n <span style=\"margin-left: 10px;\">File</span>\r\n </button>\r\n <button mat-menu-item (click)=\"openModalAddAttachment(2)\" class=\"eqp-attachments-link-btn\">\r\n <i class=\"fas fa-link\"></i>\r\n <span style=\"margin-left: 10px;\">Link</span>\r\n </button>\r\n </mat-menu>\r\n</ng-template>",
1030
+ template: "<!-- Se richiesta la gestione multipla mostra il pulsante di aggiunta e la tabella con l'elenco allegati -->\r\n<div *ngIf=\"multipleAttachment == true\">\r\n <mat-card [ngStyle]=\"{ 'box-shadow': showMatCard == false ? 'none' : null }\">\r\n <mat-card-header>\r\n <div class=\"col-md-6\">\r\n <div class=\"text-nowrap eqp-attachments-header-title\" *ngIf=\"showHeader == true\">\r\n {{headerTitle}}\r\n </div>\r\n </div>\r\n <div class=\"col-md-6 text-right\">\r\n <div class=\"row justify-content-end\">\r\n <!-- Template del button per l'aggiunta di un allegato -->\r\n <ng-container *ngTemplateOutlet=\"addAttachmentButton\"></ng-container>\r\n </div>\r\n </div>\r\n </mat-card-header>\r\n <mat-card-content>\r\n <eqp-table #attachmentTable [createMatCard]=\"false\" #table [columns]=\"attachmentsColumns\"\r\n [isMultiLanguage]=\"isEqpTableMultiLanguage\" [data]=\"attachmentsList\"\r\n [paginatorVisible]=\"tablePaginatorVisible\" [matPaginatorSize]=\"tablePaginatorSize\"\r\n [emptyTableMessage]=\"emptyTableMessage\" [searchText]=\"eqpTableSearchText\">\r\n </eqp-table>\r\n </mat-card-content>\r\n </mat-card>\r\n</div>\r\n\r\n<!-- Se richiesta la gestione singola mostra il pulsante di caricamento di un singolo file -->\r\n<div *ngIf=\"multipleAttachment != true\">\r\n <!-- Template del button per l'aggiunta di un allegato -->\r\n <ng-container *ngTemplateOutlet=\"addAttachmentButton\"></ng-container>\r\n\r\n <button class=\"mb-2 mr-2 eqp-attachments-download-btn\" (click)=\"viewAttachment(attachmentsList[0])\" type=\"button\"\r\n mat-raised-button *ngIf=\"attachmentsList && attachmentsList.length > 0 && attachmentsList[0]\" color=\"primary\">\r\n <mat-icon *ngIf=\"attachmentsList[0].AttachmentType == AttachmentType.FILE\">download</mat-icon>\r\n <mat-icon *ngIf=\"attachmentsList[0].AttachmentType != AttachmentType.FILE\">open_in_new</mat-icon>\r\n {{attachmentsList[0].AttachmentType == AttachmentType.FILE ? downloadLabel : openLinkLabel}}\r\n </button>\r\n <button class=\"mb-2 mr-2 eqp-attachments-preview-btn\" (click)=\"openPreviewDialog(attachmentsList[0])\" type=\"button\"\r\n mat-raised-button color=\"primary\"\r\n *ngIf=\"attachmentsList && attachmentsList.length > 0 && attachmentsList[0] && (!attachmentsList[0].FileContentType || (!attachmentsList[0].FileContentType.startsWith('video') && !attachmentsList[0].FileContentType.startsWith('audio')))\">\r\n <mat-icon>visibility</mat-icon> {{previewLabel}}\r\n </button>\r\n <button class=\"mb-2 eqp-attachments-delete-btn\" (click)=\"deleteAttachment(attachmentsList[0])\" type=\"button\"\r\n mat-raised-button *ngIf=\"attachmentsList && attachmentsList.length > 0 && attachmentsList[0]\"\r\n [disabled]=\"isDisabled\">\r\n <mat-icon>delete</mat-icon> {{deleteLabel}}\r\n </button>\r\n\r\n <div class=\"row\" style=\"margin-top: 10px;\"\r\n *ngIf=\"attachmentsList.length > 0 && attachmentsList[0] && attachmentsList[0].FileDataBase64 && attachmentsList[0].IsImage == true\">\r\n <div class=\"col-sm-12\">\r\n <div class=\"single-attachment-inline-preview-container\">\r\n <img src=\"data:image/png;base64,{{attachmentsList[0].FileDataBase64}}\">\r\n </div>\r\n </div>\r\n </div>\r\n <div class=\"row\" *ngIf=\"attachmentsList.length > 0 && attachmentsList[0] && attachmentsList[0].IsImage != true\">\r\n <div class=\"col-sm-12\">\r\n <mat-form-field>\r\n <mat-label>{{fileNameLabel}}</mat-label>\r\n <input readonly matInput [(ngModel)]=\"attachmentsList[0].FileName\">\r\n </mat-form-field>\r\n </div>\r\n </div>\r\n</div>\r\n\r\n\r\n\r\n<ng-template #dialogAddAttachment>\r\n <div class=\"container-fluid eqp-attachments-dialog-add-container\"\r\n style=\"max-height: 70vh !important; overflow-x: hidden; overflow-y: auto;\">\r\n <form [formGroup]=\"newAttachmentForm\" (ngSubmit)=\"confirmAddAttachment()\" *ngIf=\"newAttachmentForm\">\r\n <div class=\"row\">\r\n <div class=\"header-title-standard\"> {{addButtonLabel}} {{ newAttachment.AttachmentType ==\r\n attachmentType.FILE ?\r\n 'File' : 'Link'}} </div>\r\n </div>\r\n <div class=\"row\" style=\"margin-top: 20px;\">\r\n <div class=\"col-sm-12\" *ngIf=\"newAttachment.AttachmentType == attachmentType.FILE\">\r\n <input #imageInput style=\"display:none;\" id=\"file_attachment\"\r\n name=\"file_attachment\" type=\"file\" (change)=\"onFileInputChange($event)\"\r\n [accept]=\"acceptedFileTypes\" [multiple]=\"loadMultipleFiles\"/>\r\n <button (click)=\"imageInput.click()\" type=\"button\" style=\"margin-left: 10px;\" id=\"file_attachment\"\r\n mat-raised-button color=\"primary\" [disabled]=\"showCropImage == true\"\r\n class=\"mb-2 btn btn-primary eqp-attachments-upload-btn\" *ngIf=\"(loadMultipleFiles != true && !newAttachment.FileDataBase64) || (loadMultipleFiles == true && newMultipleAttachments && newMultipleAttachments.length == 0)\">\r\n <mat-icon>cloud_upload</mat-icon>\r\n {{uploadFileLabel}}\r\n </button>\r\n <button (click)=\"abortFile()\" type=\"button\" style=\"margin-left: 10px;\" mat-raised-button\r\n *ngIf=\"(loadMultipleFiles != true && newAttachment.FileDataBase64) || (loadMultipleFiles == true && newMultipleAttachments && newMultipleAttachments.length > 0)\" class=\"mb-2 eqp-attachments-delete-btn\">\r\n <mat-icon>delete</mat-icon> {{deleteLabel}}\r\n </button>\r\n </div>\r\n <div class=\"col-sm-12\" *ngIf=\"newAttachment.AttachmentType == 2 || (selectedFile && loadMultipleFiles != true)\">\r\n <mat-form-field style=\"width: 100%;\">\r\n <mat-label> {{fileNameLabel}} </mat-label>\r\n <input formControlName=\"name\" matInput [(ngModel)]=\"newAttachment.FileName\">\r\n </mat-form-field>\r\n </div>\r\n <div class=\"col-sm-12\" *ngIf=\"newAttachment.AttachmentType == 2\">\r\n <mat-form-field style=\"width: 100%;\">\r\n <mat-label> Link </mat-label>\r\n <input formControlName=\"path\" required matInput [(ngModel)]=\"newAttachment.FilePath\">\r\n </mat-form-field>\r\n </div>\r\n </div>\r\n\r\n <!-- Riporta l'elenco dei nomi dei file caricati contemporaneamente (visibile solo se loadMultipleFiles = TRUE e se ci sono realmente pi\u00F9 file senza link) -->\r\n <div class=\"row\" *ngIf=\"loadMultipleFiles == true && newMultipleAttachments && newMultipleAttachments.length > 0 && newMultipleAttachments[0].AttachmentType != attachmentType.LINK\">\r\n <div class=\"col-12\" *ngFor=\"let attach of newMultipleAttachments\">\r\n <mat-form-field style=\"width: 100%\">\r\n <mat-label> {{fileNameLabel}} </mat-label>\r\n <input disabled matInput [(ngModel)]=\"attach.FileName\" [ngModelOptions]=\"{standalone: true}\">\r\n </mat-form-field>\r\n </div>\r\n </div>\r\n\r\n <!-- Riporta la preview dell'immagine quando \u00E8 richiesto il caricamento MULTIPLO ma \u00E8 stata selezionata una sola immagine (quindi \u00E8 entrato in gioco anche il croppie) -->\r\n <div class=\"row\" *ngIf=\"loadMultipleFiles == true && showCropImage != true && newMultipleAttachments && newMultipleAttachments.length == 1 && newMultipleAttachments[0].IsImage == true\" style=\"margin-top: 10px;\">\r\n <div class=\"col-4\">\r\n <div class=\"single-attachment-inline-preview-container\">\r\n <img src=\"data:image/png;base64,{{newMultipleAttachments[0].FileDataBase64}}\">\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <!-- Riporta la preview dell'immagine quando \u00E8 richiesto il caricamento SINGOLO ed \u00E8 stata selezionata un'immagine -->\r\n <div class=\"row\" *ngIf=\"loadMultipleFiles != true && showCropImage != true && newAttachment.FileDataBase64 && newAttachment.IsImage == true\" style=\"margin-top: 10px;\">\r\n <div class=\"col-4\">\r\n <div class=\"single-attachment-inline-preview-container\">\r\n <img src=\"data:image/png;base64,{{newAttachment.FileDataBase64}}\">\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <!-- Richiama il template per le funzionalit\u00E0 del CROPPIE -->\r\n <ng-container [ngTemplateOutlet]=\"croppieTemplate\" [ngTemplateOutletContext]=\"{form: newAttachmentForm}\" *ngIf=\"showCropImage == true\"></ng-container>\r\n\r\n <div class=\"row mt-2\">\r\n <div class=\"col-sm-12 text-right\">\r\n <button class=\"btn btn-primary mat-raised-button eqp-attachments-save-btn mr-2\" type=\"submit\"\r\n [disabled]=\"showCropImage == true || (loadMultipleFiles != true && newAttachmentForm?.disabled == true) || disableSave()\">\r\n {{saveLabel}}\r\n </button>\r\n <button class=\"btn mat-raised-button eqp-attachments-exit-btn\" (click)=\"close()\"\r\n [disabled]=\"showCropImage == true\" type=\"button\">\r\n {{exitLabel}}\r\n </button>\r\n </div>\r\n </div>\r\n </form>\r\n </div>\r\n</ng-template>\r\n\r\n<ng-template #inlinePreviewTemplate let-row=\"row\">\r\n <div class=\"inline-preview-container\" *ngIf=\"row.AttachmentType != AttachmentType.LINK && row.IsImage\" (click)=\"openPreviewDialog(row)\">\r\n <img src=\"data:image/png;base64,{{row.FileThumbnailBase64 ? row.FileThumbnailBase64 : row.FileDataBase64}}\">\r\n </div>\r\n <div class=\"inline-preview-container\" *ngIf=\"row.AttachmentType != AttachmentType.LINK && !row.IsImage\" (click)=\"openPreviewDialog(row)\">\r\n <i [ngClass]=\"getAttachmentIcon(row)\"></i>\r\n </div>\r\n</ng-template>\r\n\r\n\r\n<ng-template #dialogPreview>\r\n <div class=\"container-fluid\" style=\"max-height: 70vh !important;\" *ngIf=\"selectedAttachment\">\r\n <div class=\"row\">\r\n <div class=\"header-title-standard\">\r\n {{previewLabel}} {{ selectedAttachment?.AttachmentType == attachmentType.FILE ? 'File' : 'Link'}}\r\n </div>\r\n </div>\r\n\r\n <div class=\"row mt-2\">\r\n <!-- ANTEPRIMA IMMAGINE -->\r\n <div class=\"col-12 text-center preview-container\" *ngIf=\"selectedAttachment.IsImage\">\r\n <img class=\"image-preview\"\r\n src=\"data:image/png;base64,{{selectedAttachment.FileDataBase64 ? selectedAttachment.FileDataBase64 : selectedAttachment.FileThumbnailBase64}}\">\r\n </div>\r\n\r\n <!-- ANTEPRIMA LINK -->\r\n <div class=\"col-12 preview-container\" *ngIf=\"!selectedAttachment.IsImage\">\r\n <iframe class=\"link-preview\" [src]=\"selectedAttachment.TrustedUrl\"\r\n [title]=\"selectedAttachment.FileName\"></iframe>\r\n </div>\r\n </div>\r\n\r\n <div class=\"row mt-3\">\r\n <div class=\"col-sm-12 text-right\">\r\n <button class=\"btn btn-primary mat-raised-button eqp-attachments-save-btn mr-2\" type=\"submit\"\r\n (click)=\"viewAttachment(selectedAttachment)\"\r\n *ngIf=\"selectedAttachment.AttachmentType != AttachmentType.LINK\">\r\n {{downloadLabel}}\r\n </button>\r\n <button class=\"btn mat-raised-button eqp-attachments-exit-btn\" mat-dialog-close type=\"button\"\r\n (click)=\"selectedAttachment = null\">\r\n {{exitLabel}}\r\n </button>\r\n </div>\r\n </div>\r\n </div>\r\n</ng-template>\r\n\r\n\r\n<!-- TEMPLATE PER IL PULSANTE DI AGGIUNTA NUOVO ALLEGATO -->\r\n<ng-template #addAttachmentButton>\r\n\r\n <!-- \r\n Pulsanti per l'aggiunta di un file o un link. Ne viene visualizzato uno se:\r\n - gli allowedTypes sono stati specificati, nell'array ne \u00E8 presente uno solo, quello inserito \u00E8 AttachmentType.FILE (o AttachmentType.LINK) \r\n e sono nella gestione di pi\u00F9 allegati (multipleAttachment == true)\r\n OPPURE\r\n - gli allowedTypes sono stati specificati, nell'array ne \u00E8 presente uno solo, quello inserito \u00E8 AttachmentType.FILE (o AttachmentType.LINK) \r\n e sono nella gestione di un singolo allegato (multipleAttachment == true) e non ne \u00E8 ancora stato selezionato uno (ovvero attachmentsList non esiste o non ha elementi)\r\n -->\r\n <button class=\"btn btn-primary mb-4 mr-5 eqp-attachments-add-btn\" mat-raised-button color=\"primary\" type=\"button\"\r\n *ngIf=\"allowedTypes && allowedTypes.length == 1 && (multipleAttachment == true || (!attachmentsList || attachmentsList.length == 0 || (attachmentsList.length > 0 && !attachmentsList[0])))\"\r\n (click)=\"openModalAddAttachment(allowedTypes[0])\" [disabled]=\"isDisabled\">\r\n <!-- Per l'aggiunta dei file mostro un'icona diversa dall'aggiunta dei link -->\r\n <mat-icon *ngIf=\"allowedTypes[0] == 1\">cloud_upload</mat-icon>\r\n <i class=\"fas fa-link\" *ngIf=\"allowedTypes[0] == 2\"></i>\r\n <span style=\"margin-left: 10px;\">{{addButtonLabel}} {{allowedTypes[0] == 1 ? \"file\" : \"link\"}}</span>\r\n </button>\r\n\r\n\r\n <!-- Pulsante per aprire il menu per la scelta del tipo di Attachment da creare -->\r\n <button class=\"btn btn-primary mb-4 mr-5 eqp-attachments-add-btn\" mat-raised-button color=\"primary\" type=\"button\"\r\n [matMenuTriggerFor]=\"attachmentTypeMenu\" [disabled]=\"isDisabled\"\r\n *ngIf=\"allowedTypes && allowedTypes.length > 1 && (multipleAttachment == true || (!attachmentsList || attachmentsList.length == 0 || (attachmentsList.length > 0 && !attachmentsList[0])))\">\r\n <mat-icon *ngIf=\"multipleAttachment != true\">cloud_upload</mat-icon>\r\n <mat-icon *ngIf=\"multipleAttachment == true\">add</mat-icon>\r\n <span style=\"margin-left: 0px;\"> {{addButtonLabel}} </span>\r\n </button>\r\n <mat-menu #attachmentTypeMenu=\"matMenu\">\r\n <button mat-menu-item (click)=\"openModalAddAttachment(1)\" class=\"eqp-attachments-file-btn\">\r\n <i class=\"fas fa-file\"></i>\r\n <span style=\"margin-left: 10px;\">File</span>\r\n </button>\r\n <button mat-menu-item (click)=\"openModalAddAttachment(2)\" class=\"eqp-attachments-link-btn\">\r\n <i class=\"fas fa-link\"></i>\r\n <span style=\"margin-left: 10px;\">Link</span>\r\n </button>\r\n </mat-menu>\r\n</ng-template>\r\n\r\n\r\n<ng-template #croppieTemplate let-form=\"form\">\r\n <div class=\"row mt-2 mb-2\" [formGroup]=\"form\">\r\n <div class=\"col-md-12 d-flex align-items-center justify-content-center\">\r\n <span class=\"mr-1\">Max H(px):</span>\r\n <mat-form-field>\r\n <input formControlName=\"customHeight\" type=\"number\" matInput [(ngModel)]=\"customHeight\"\r\n (change)=\"onDimensionsChange('H')\">\r\n </mat-form-field>\r\n\r\n <span class=\"ml-2 mr-1\">Max W(px):</span>\r\n <mat-form-field>\r\n <input formControlName=\"customWidth\" type=\"number\" matInput [(ngModel)]=\"customWidth\"\r\n (change)=\"onDimensionsChange('W')\">\r\n </mat-form-field>\r\n\r\n <button class=\"btn btn-primary mat-raised-button ml-2\" (click)=\"restoreOriginalDimensions()\"\r\n [disabled]=\"customWidth == originalWidth && customHeight == originalHeight\">\r\n <mat-icon style=\"vertical-align: middle;\">replay</mat-icon>\r\n </button>\r\n </div>\r\n </div>\r\n <div class=\"row justify-content-center\">\r\n <div style=\"max-height: 450px; max-width: 450px;\">\r\n <image-cropper [imageChangedEvent]=\"imageChangedEvent\" [maintainAspectRatio]=\"false\"\r\n [autoCrop]=\"false\" [containWithinAspectRatio]=\"false\" [aspectRatio]=\"4/3\"\r\n [cropperMinWidth]=\"128\" [onlyScaleDown]=\"true\" [roundCropper]=\"false\" [canvasRotation]=\"0\"\r\n [transform]=\"transform\" [alignImage]=\"'left'\" format=\"png\" (imageCropped)=\"imageCropped($event)\"\r\n [resizeToWidth]=\"customWidth\" [resizeToHeight]=\"customHeight\">\r\n </image-cropper>\r\n </div>\r\n </div>\r\n <div class=\"row justify-content-center mt-2\">\r\n <div style=\"max-height: 450px; max-width: 450px;\">\r\n <button class=\"btn btn-primary mat-raised-button eqp-attachments-confirm-btn mr-2\" type=\"button\"\r\n (click)=\"confirmCrop()\">\r\n {{confirmLabel}}\r\n </button>\r\n <button class=\"btn mat-raised-button eqp-attachments-abort-btn\" type=\"button\" (click)=\"abortFile()\">\r\n {{abortLabel}}\r\n </button>\r\n </div>\r\n </div>\r\n</ng-template>",
875
1031
  styles: [".eqp-attachments-header-title{font-weight:700;font-size:19px;line-height:24px;margin-bottom:auto}.single-attachment-inline-preview-container{max-height:400px;max-width:400px;display:flex;align-items:center}.single-attachment-inline-preview-container img{max-width:100%;max-height:120px}.inline-preview-container{max-height:100px;max-width:100px;display:flex;align-items:center;justify-content:center;width:100%;cursor:pointer}.inline-preview-container img{max-width:100%;max-height:100px}.inline-preview-container i{font-size:25px;margin:auto}.preview-container{max-height:60vh;max-width:100%}.preview-container .image-preview{max-width:100%;max-height:100%}.preview-container .link-preview{width:70vw;height:55vh}"]
876
1032
  })
877
1033
  ], EqpAttachmentsComponent);