@eqproject/eqp-attachments 0.1.11 → 0.1.14

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
  */
@@ -318,6 +324,10 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
318
324
  * Restituisce la lista aggiornata degli allegati.
319
325
  */
320
326
  this.localEditedAttachments = new EventEmitter();
327
+ /**
328
+ * Evento scatenato alla pressione del pulsante ESCI della modale di caricamento file.
329
+ */
330
+ this.abortAddAttachment = new EventEmitter();
321
331
  /**
322
332
  * Evento di output che restituisce l'IAttachmentDTO selezionato per il download nel caso FileDataBase64, FileContentType o FileName non fossero specificati.
323
333
  */
@@ -329,8 +339,10 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
329
339
  //#endregion
330
340
  //#region Proprietà per gestione caricamento nuovo allegato
331
341
  this.newAttachment = {};
342
+ this.newMultipleAttachments = [];
332
343
  this.attachmentType = AttachmentType;
333
344
  this.selectedFile = null;
345
+ this.selectedFiles = null;
334
346
  this.showCropImage = false;
335
347
  //#endregion
336
348
  //#region Proprietà per gestione ridimensionamento file di tipo image
@@ -361,8 +373,6 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
361
373
  if (this.attachmentsList == null)
362
374
  this.attachmentsList = new Array();
363
375
  this.checkAttachmentImage();
364
- // if (!this.compressionOptions || !this.compressionOptions.maxSizeMB || !this.compressionOptions.maxWidthOrHeight)
365
- // this.compressionOptions = { maxSizeMB: 0.5, maxWidthOrHeight: 1920, useWebWorker: true };
366
376
  }
367
377
  reloadData() {
368
378
  if (this.attachmentTable)
@@ -473,9 +483,25 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
473
483
  * Apre la modale per la definizione dei parametri del nuovo file
474
484
  */
475
485
  openModalAddAttachment(attachmentType) {
486
+ //Se è stato richiesto il caricamento di un LINK o è impostato il caricamento di FILE SINGOLO allora apre la modale per
487
+ //il caricamento singolo del file altrimenti apre quella per il caricamento multiplo
488
+ // if (attachmentType == AttachmentType.LINK || (attachmentType == AttachmentType.FILE && this.loadMultipleFiles != true)) {
476
489
  this.newAttachment = {};
477
490
  this.newAttachment.IsImage = false;
478
491
  this.newAttachment.AttachmentType = attachmentType;
492
+ this.newMultipleAttachments = new Array();
493
+ if (attachmentType == AttachmentType.LINK)
494
+ this.newMultipleAttachments.push(this.newAttachment);
495
+ this.createAttachmentForm();
496
+ //Apre la modale
497
+ this.dialofRefAddAttachment = this.dialog.open(this.dialogAddAttachment, {
498
+ disableClose: true,
499
+ hasBackdrop: true,
500
+ width: '60%',
501
+ maxHeight: '80%'
502
+ });
503
+ }
504
+ createAttachmentForm() {
479
505
  //Crea la form per la validazione dei campi
480
506
  this.newAttachmentForm = this.formBuilder.group({
481
507
  type: [this.newAttachment.AttachmentType, Validators.required],
@@ -484,19 +510,16 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
484
510
  customHeight: [this.customHeight],
485
511
  customWidth: [this.customWidth]
486
512
  });
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
513
  }
495
- close() {
514
+ close(emitCloseEvent = true) {
496
515
  this.newAttachment = {};
516
+ this.newMultipleAttachments = new Array();
497
517
  this.abortFile();
498
- this.newAttachmentForm.reset();
518
+ if (this.newAttachmentForm)
519
+ this.newAttachmentForm.reset();
499
520
  this.dialofRefAddAttachment.close();
521
+ if (emitCloseEvent == true && this.abortAddAttachment)
522
+ this.abortAddAttachment.emit();
500
523
  }
501
524
  /**
502
525
  * In base al tipo di allegato controlla se disabilitare o meno il pulsante per salvare.
@@ -504,23 +527,37 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
504
527
  * @returns
505
528
  */
506
529
  disableSave() {
507
- if (this.newAttachment.AttachmentType == AttachmentType.FILE) {
508
- return !this.newAttachment.FileDataBase64;
530
+ if (this.loadMultipleFiles != true) {
531
+ if (this.newAttachment.AttachmentType == AttachmentType.FILE) {
532
+ return !this.newAttachment.FileDataBase64;
533
+ }
534
+ else {
535
+ return !this.newAttachment.FilePath;
536
+ }
509
537
  }
510
538
  else {
511
- return !this.newAttachment.FilePath;
539
+ return this.newMultipleAttachments.filter(p => (p.AttachmentType == AttachmentType.FILE && !p.FileDataBase64) || (p.AttachmentType == AttachmentType.LINK && !p.FilePath)).length > 0;
512
540
  }
513
541
  }
514
542
  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);
543
+ if (this.loadMultipleFiles != true) {
544
+ if (this.newAttachment.AttachmentType == AttachmentType.LINK && !this.newAttachment.FileName)
545
+ this.newAttachment.FileName = this.newAttachment.FilePath;
546
+ if (this.attachmentsList == null)
547
+ this.attachmentsList = new Array();
548
+ this.attachmentsList.push(this.newAttachment);
549
+ }
550
+ else {
551
+ if (this.newMultipleAttachments == null || this.newMultipleAttachments.length == 0)
552
+ return;
553
+ if (this.attachmentsList == null)
554
+ this.attachmentsList = new Array();
555
+ this.attachmentsList = this.attachmentsList.concat(this.newMultipleAttachments);
556
+ }
520
557
  if (this.attachmentTable)
521
558
  this.attachmentTable.reloadDatatable();
522
559
  this.localEditedAttachments.emit(this.attachmentsList);
523
- this.dialofRefAddAttachment.close();
560
+ this.close(false);
524
561
  }
525
562
  /**
526
563
  * Apre il dialog per l'anteprima dell'allegato selezionato.
@@ -578,68 +615,140 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
578
615
  }
579
616
  //#region Gestione caricamento file
580
617
  /**
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
618
+ * Evento scatenato alla selezione del file (o dei file).
619
+ * 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
620
+ * mostrare le funzionalità del croppie (per ritagliare l'immagine) oppure no.
621
+ * Se il file caricato non è un immagine allora genera direttamente il base64 e lo associa all'allegato da salvare.
622
+ * Se invece il caricamento dei file è MULTIPLO e sono presenti più file allora esegue le stesse operazioni ignorando però il contrllo
623
+ * immagine per il croppie (in caso di caricamento multiplo le funzionalità del croppie sono disabilitate).
583
624
  */
584
625
  onFileInputChange(event) {
585
626
  return __awaiter(this, void 0, void 0, function* () {
586
627
  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;
628
+ //Se è stato richiesto il caricamento SINGOLO oppure se il caricamento è MULTIPLO ma è stato selezionato un solo file
629
+ //allora verifica se il file è un immagine (per mostrare il CROPPIE)
630
+ if ([...event.target.files].length == 1 || this.loadMultipleFiles != true) {
631
+ this.selectedFile = event.target.files[0];
632
+ this.selectedFiles = event.target.files;
633
+ if (!this.selectedFile)
634
+ return;
635
+ //Memorizza i dati per l'allegato
636
+ this.newAttachment = yield this.createAttachmentFromUploadedFile(this.selectedFile, false);
637
+ this.newMultipleAttachments = new Array();
638
+ this.newMultipleAttachments.push(this.newAttachment);
639
+ //Se è stata richiesta la gestione delle sole immagini ma per errore è stato selezionato un file che non è un immagine
640
+ let checkOnlyImage = this.checkAllowOnlyImageFile(this.newAttachment);
641
+ if (checkOnlyImage == false)
642
+ return;
643
+ if (this.loadMultipleFiles == true && [...event.target.files].length == 1)
644
+ this.createAttachmentForm();
645
+ //Verifica se il file caricato è un'immagine oppure no. Se è un immagine, prima di caricarla mostra il croppie per il resize.
646
+ //Se non è un immagine allora genera il Base64
647
+ if (this.newAttachment.IsImage == true) {
648
+ this.getImageDimensions(event.target.files[0]);
649
+ //Mostra il croppie e disabilita la form finchè non termina la modifica dell'immagine
650
+ this.newAttachmentForm.disable();
651
+ this.newAttachmentForm.controls["customWidth"].enable();
652
+ this.newAttachmentForm.controls["customHeight"].enable();
653
+ this.showCropImage = true;
654
+ this.imageChangedEvent = event;
655
+ }
656
+ else {
657
+ this.showCropImage = false;
658
+ let base64Result = yield this.getBase64FromFile(this.selectedFile);
659
+ this.newAttachment.FileDataBase64 = base64Result.Base64File;
660
+ this.newAttachment.FileContentType = base64Result.ContentType;
661
+ }
616
662
  }
617
663
  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];
664
+ this.selectedFiles = event.target.files;
665
+ if (!this.selectedFiles || this.selectedFiles.length == 0)
666
+ return;
667
+ this.newMultipleAttachments = new Array();
668
+ for (let i = 0; i < this.selectedFiles.length; i++) {
669
+ let newAttachment = yield this.createAttachmentFromUploadedFile(this.selectedFiles[i], true);
670
+ //Se è stata richiesta la gestione delle sole immagini ma per errore è stato selezionato un file che non è un immagine
671
+ let checkOnlyImage = this.checkAllowOnlyImageFile(newAttachment);
672
+ if (checkOnlyImage == false)
673
+ return;
674
+ this.newMultipleAttachments.push(newAttachment);
628
675
  }
629
676
  }
630
677
  });
631
678
  }
679
+ /**
680
+ * A partire dal FILE ricevuto in input ricostruisce l'oggetto IAttachmentDTO e lo restituisce.
681
+ * Se il parametro getBase64 viene passato a TRUE allora, sempre a partire dal file,genera il base64 e
682
+ * ricava il ContentType da associare all'oggetto IAttachmentDTO da restituire
683
+ * @param currentFile Oggetto FILE da processare
684
+ * @param getBase64 Se TRUE allora calcola base64 e ContentType del file passato in input
685
+ * @returns Restituisce un oggetto di tipo IAttachmentDTO
686
+ */
687
+ createAttachmentFromUploadedFile(currentFile, getBase64 = true) {
688
+ return __awaiter(this, void 0, void 0, function* () {
689
+ let newAttachment = {};
690
+ //Memorizza i dati per l'allegato
691
+ newAttachment.AttachmentType = AttachmentType.FILE;
692
+ newAttachment.FileContentType = currentFile.type;
693
+ newAttachment.FileName = currentFile.name;
694
+ newAttachment.FileExtension = currentFile.name.substr(currentFile.name.lastIndexOf('.') + 1);
695
+ newAttachment.IsImage = AttachmentHelperService.checkImageFromMimeType(currentFile.type);
696
+ if (getBase64 == true) {
697
+ let base64Result = yield this.getBase64FromFile(currentFile);
698
+ newAttachment.FileDataBase64 = base64Result.Base64File;
699
+ newAttachment.FileContentType = base64Result.ContentType;
700
+ }
701
+ return newAttachment;
702
+ });
703
+ }
704
+ /**
705
+ * A partire dal file passato in input restituisce un oggetto
706
+ * contenente il base64 del file e il suo contentType
707
+ * @param currentFile Oggetto File da cui estrapolare base64 e contentType
708
+ * @returns Restituisce un oggetto avente le proprietà Base64File e ContentType
709
+ */
710
+ getBase64FromFile(currentFile) {
711
+ return __awaiter(this, void 0, void 0, function* () {
712
+ let base64File = yield toBase64(currentFile);
713
+ let contentType = null;
714
+ if (base64File) {
715
+ // Loris 20/01/2022: PROBLEMA - Quando eseguo l'upload di un file .sql non viene salvato/scaricato correttamente.
716
+ // Questo succede perchè non viene popolato il FileContentType. Per risolvere il problema
717
+ // faccio un controllo e se non esiste il FileContentType allora lo recupero dal base64 ottenuto.
718
+ contentType = base64File.split(",")[0].split(":")[1].split(";")[0];
719
+ // Un altro metodo per leggere il ccontent type del file è tramite una regular expression:
720
+ base64File = base64File.split(",")[1];
721
+ }
722
+ let result = {
723
+ Base64File: base64File,
724
+ ContentType: contentType
725
+ };
726
+ return result;
727
+ });
728
+ }
632
729
  /**
633
730
  * Controlla se il file che si sta caricando è supportato dal sistema.
634
731
  * @returns
635
732
  */
636
733
  checkAcceptedFiles() {
637
- if (this.selectedFile.type.startsWith("video"))
734
+ if ((this.loadMultipleFiles != true && this.selectedFile.type.startsWith("video"))
735
+ || (this.loadMultipleFiles == true && [...this.selectedFiles].filter(p => p.type.startsWith("video")).length > 0))
638
736
  return false;
639
737
  if (this.acceptedFileTypes == "*")
640
738
  return true;
641
- let accepted = this.acceptedFileTypes.includes(this.selectedFile.type);
642
- if (!accepted) {
739
+ //Verifica che i tipi del file (o dei file) caricati siano coerenti con quelli accettati dalla direttiva
740
+ let accepted = true;
741
+ if (this.loadMultipleFiles != true)
742
+ accepted = this.acceptedFileTypes.includes(this.selectedFile.type);
743
+ else {
744
+ let uploadedFileTypes = [...this.selectedFiles].map(p => p.type);
745
+ uploadedFileTypes.forEach(type => {
746
+ if (!this.acceptedFileTypes.includes(type))
747
+ accepted = false;
748
+ });
749
+ }
750
+ //Questo controllo permette di gestire le casistiche per cui vengono indicati come tipi validi, ad esempio, 'image/*'
751
+ if (!accepted && this.loadMultipleFiles != true) {
643
752
  for (let t of this.acceptedFileTypes.split(",").filter(t => t.includes("*"))) {
644
753
  accepted = this.selectedFile.type.startsWith(t.split("*")[0]);
645
754
  if (accepted)
@@ -648,6 +757,24 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
648
757
  }
649
758
  return accepted;
650
759
  }
760
+ /**
761
+ * Se eqp-attachments è stata configurata per il caricamento delle sole immagini allora verifica che il file passato in
762
+ * input sia effettivamente un immagine o no.
763
+ * Se il controllo va a buon fine restituisce TRUE altrimenti mostra un messaggio d'errore e restituisce FALSE
764
+ */
765
+ checkAllowOnlyImageFile(newAttachment) {
766
+ if (this.allowOnlyImages == true && newAttachment.IsImage != true) {
767
+ EqpAttachmentDialogService.Error(this.noImageSelectedErrorMessage);
768
+ this.abortFile();
769
+ return false;
770
+ }
771
+ else if (!this.checkAcceptedFiles()) {
772
+ EqpAttachmentDialogService.Error(this.wrongTypeSelectedErrorMessage);
773
+ this.abortFile();
774
+ return false;
775
+ }
776
+ return true;
777
+ }
651
778
  getImageDimensions(img) {
652
779
  const reader = new FileReader();
653
780
  reader.onload = (e) => {
@@ -715,12 +842,14 @@ let EqpAttachmentsComponent = class EqpAttachmentsComponent {
715
842
  if (this.imageInput)
716
843
  this.imageInput.nativeElement.value = '';
717
844
  this.selectedFile = null;
845
+ this.selectedFiles = null;
718
846
  this.showCropImage = false;
719
847
  this.newAttachment.IsImage = false;
720
848
  this.newAttachment.FileDataBase64 = null;
721
849
  this.newAttachment.FileName = null;
722
850
  this.newAttachment.FileExtension = null;
723
851
  this.newAttachment.FileContentType = null;
852
+ this.newMultipleAttachments = new Array();
724
853
  this.customHeight = null;
725
854
  this.customWidth = null;
726
855
  this.originalHeight = null;
@@ -731,7 +860,8 @@ EqpAttachmentsComponent.ctorParameters = () => [
731
860
  { type: MatDialog },
732
861
  { type: FormBuilder },
733
862
  { type: DomSanitizer },
734
- { type: HttpClient }
863
+ { type: HttpClient },
864
+ { type: ChangeDetectorRef }
735
865
  ];
736
866
  __decorate([
737
867
  Input("disableAction")
@@ -751,6 +881,9 @@ __decorate([
751
881
  __decorate([
752
882
  Input("multipleAttachment")
753
883
  ], EqpAttachmentsComponent.prototype, "multipleAttachment", void 0);
884
+ __decorate([
885
+ Input("loadMultipleFiles")
886
+ ], EqpAttachmentsComponent.prototype, "loadMultipleFiles", void 0);
754
887
  __decorate([
755
888
  Input("attachmentsColumns")
756
889
  ], EqpAttachmentsComponent.prototype, "attachmentsColumns", void 0);
@@ -844,6 +977,9 @@ __decorate([
844
977
  __decorate([
845
978
  Output()
846
979
  ], EqpAttachmentsComponent.prototype, "localEditedAttachments", void 0);
980
+ __decorate([
981
+ Output()
982
+ ], EqpAttachmentsComponent.prototype, "abortAddAttachment", void 0);
847
983
  __decorate([
848
984
  Output("downloadAttachment")
849
985
  ], EqpAttachmentsComponent.prototype, "downloadAttachment", void 0);
@@ -853,6 +989,9 @@ __decorate([
853
989
  __decorate([
854
990
  ViewChild('dialogAddAttachment', { static: true })
855
991
  ], EqpAttachmentsComponent.prototype, "dialogAddAttachment", void 0);
992
+ __decorate([
993
+ ViewChild('dialogAddMultipleAttachment', { static: true })
994
+ ], EqpAttachmentsComponent.prototype, "dialogAddMultipleAttachment", void 0);
856
995
  __decorate([
857
996
  ViewChild(ImageCropperComponent)
858
997
  ], EqpAttachmentsComponent.prototype, "imageCropper", void 0);
@@ -871,7 +1010,7 @@ __decorate([
871
1010
  EqpAttachmentsComponent = __decorate([
872
1011
  Component({
873
1012
  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>",
1013
+ 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 [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
1014
  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
1015
  })
877
1016
  ], EqpAttachmentsComponent);