Skip to content

Commit e5eeee6

Browse files
CSimoesJranderson-gregorio-totvs
authored andcommitted
feat(upload): repassa propriedade showThumbnail ao dynamic-form
1 parent cc66ea6 commit e5eeee6

File tree

4 files changed

+12
-26
lines changed

4 files changed

+12
-26
lines changed

projects/ui/src/lib/components/po-dynamic/po-dynamic-form/interfaces/po-dynamic-form-field.interface.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,15 @@ export interface PoDynamicFormField extends PoDynamicField {
750750
*/
751751
showRequired?: boolean;
752752

753+
/**
754+
* Exibe a pré-visualização de imagens ao anexá-las.
755+
*
756+
* > Propriedade funciona apenas em arquivos de formato de imagem (`.png`, `.jpg`, `.jpeg` e `.gif`).
757+
*
758+
* **Componente compatível**: `po-upload`
759+
*/
760+
showThumbnail?: boolean;
761+
753762
/**
754763
* Define uma ação personalizada no componente `po-upload`, adicionando um botão no canto inferior direito
755764
* de cada barra de progresso associada aos arquivos enviados ou em envio.

projects/ui/src/lib/components/po-dynamic/po-dynamic-form/po-dynamic-form-fields/po-dynamic-form-fields.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@
539539
[p-optional]="field.optional"
540540
[p-required]="field.required"
541541
[p-show-required]="field.showRequired"
542+
[p-show-thumbnail]="field.showThumbnail ?? true"
542543
[p-size]="field.size || componentsSize"
543544
(p-additional-help)="field.additionalHelp?.($event)"
544545
(p-change)="onChangeField(field)"

projects/ui/src/lib/components/po-field/po-upload/po-upload.component.spec.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -457,21 +457,6 @@ describe('PoUploadComponent:', () => {
457457
expect(spySetPrimary).toHaveBeenCalled();
458458
});
459459

460-
it('ngOnDestroy: should revoke all thumbnail URLs', () => {
461-
const spyRevoke = spyOn(URL, 'revokeObjectURL');
462-
component.currentFiles = [
463-
{ thumbnailUrl: 'blob:url1' },
464-
{ thumbnailUrl: 'blob:url2' },
465-
{ thumbnailUrl: undefined }
466-
] as any;
467-
468-
component.ngOnDestroy();
469-
470-
expect(spyRevoke).toHaveBeenCalledTimes(2);
471-
expect(spyRevoke).toHaveBeenCalledWith('blob:url1');
472-
expect(spyRevoke).toHaveBeenCalledWith('blob:url2');
473-
});
474-
475460
describe('ngAfterViewInit:', () => {
476461
let inputFocus: jasmine.Spy;
477462

projects/ui/src/lib/components/po-field/po-upload/po-upload.component.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
Component,
66
ElementRef,
77
OnChanges,
8-
OnDestroy,
98
Renderer2,
109
SimpleChanges,
1110
ViewChild,
@@ -17,7 +16,7 @@ import { NG_VALIDATORS, NG_VALUE_ACCESSOR } from '@angular/forms';
1716
import { PoI18nPipe } from '../../../services/po-i18n/po-i18n.pipe';
1817
import { PoLanguageService } from '../../../services/po-language/po-language.service';
1918
import { PoNotificationService } from '../../../services/po-notification/po-notification.service';
20-
import { formatBytes, isMobile, setHelperSettings, isTypeof, uuid } from '../../../utils/util';
19+
import { formatBytes, isMobile, isTypeof, setHelperSettings, uuid } from '../../../utils/util';
2120
import { PoProgressStatus } from '../../po-progress/enums/po-progress-status.enum';
2221
import { PoButtonComponent } from './../../po-button/po-button.component';
2322

@@ -83,7 +82,7 @@ import { PoUploadService } from './po-upload.service';
8382
],
8483
standalone: false
8584
})
86-
export class PoUploadComponent extends PoUploadBaseComponent implements AfterViewInit, OnChanges, OnDestroy {
85+
export class PoUploadComponent extends PoUploadBaseComponent implements AfterViewInit, OnChanges {
8786
renderer = inject(Renderer2);
8887
private i18nPipe = inject(PoI18nPipe);
8988
private notification = inject(PoNotificationService);
@@ -227,14 +226,6 @@ export class PoUploadComponent extends PoUploadBaseComponent implements AfterVie
227226
}
228227
}
229228

230-
ngOnDestroy() {
231-
this.currentFiles?.forEach(file => {
232-
if (file.thumbnailUrl) {
233-
URL.revokeObjectURL(file.thumbnailUrl);
234-
}
235-
});
236-
}
237-
238229
/** Método responsável por **limpar** o(s) arquivo(s) selecionado(s). */
239230
clear() {
240231
this.currentFiles = undefined;

0 commit comments

Comments
 (0)