-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(progress): adiciona suporte a ações customizadas
Adiciona suporte a ações customizadas no componente `po-progress` por meio das novas propriedades `p-custom-action` e `p-custom-action-click`. Permite configurar ícone, label, tipo, visibilidade e estado de desabilitado do botão customizado. Integra a funcionalidade aos componentes `po-upload` e `po-dynamic-form`, garantindo que a propriedade `p-custom-action-click` retorne o arquivo associado à ação. Fixes DTHFUI-10272
- Loading branch information
1 parent
0b12f25
commit d9f46ee
Showing
22 changed files
with
900 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...ield/po-upload/samples/sample-po-upload-download/sample-po-upload-download.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<po-upload | ||
name="upload" | ||
p-url="https://po-sample-api.onrender.com/v1/uploads/addFile" | ||
[p-custom-action]="customAction" | ||
(p-custom-action-click)="onCustomActionClick($event)" | ||
[p-multiple]="true" | ||
(p-success)="uploadSuccess()" | ||
></po-upload> |
46 changes: 46 additions & 0 deletions
46
...-field/po-upload/samples/sample-po-upload-download/sample-po-upload-download.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { PoProgressAction } from '@po-ui/ng-components'; | ||
|
||
@Component({ | ||
selector: 'sample-po-upload-download', | ||
templateUrl: 'sample-po-upload-download.component.html' | ||
}) | ||
export class SamplePoUploadDownloadComponent { | ||
customAction: PoProgressAction = { | ||
icon: 'ph ph-download', | ||
type: 'default', | ||
visible: false | ||
}; | ||
|
||
uploadSuccess() { | ||
this.customAction.visible = true; | ||
} | ||
|
||
onCustomActionClick(file: { rawFile: File }) { | ||
if (!file.rawFile) { | ||
console.error('Arquivo inválido ou não encontrado.'); | ||
return; | ||
} | ||
|
||
this.downloadFile(file.rawFile); | ||
} | ||
|
||
downloadFile(rawFile: File) { | ||
// Cria uma URL temporária para o arquivo | ||
const url = URL.createObjectURL(rawFile); | ||
|
||
// Cria um link <a> temporário para iniciar o download | ||
const anchor = document.createElement('a'); | ||
anchor.href = url; | ||
anchor.download = rawFile.name; // Define o nome do arquivo para o download | ||
anchor.style.display = 'none'; | ||
|
||
// Adiciona o link ao DOM, aciona o clique e remove o link | ||
document.body.appendChild(anchor); | ||
anchor.click(); | ||
document.body.removeChild(anchor); | ||
|
||
// Libera a memória utilizada pela URL temporária | ||
URL.revokeObjectURL(url); | ||
} | ||
} |
Oops, something went wrong.