Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@
<td></td>
<td>Helper text to be placed above the component.</td>
</tr>
<tr>
<td>buttonLabel: string</td>
<td>
<code></code>
</td>
<td>
Text to be placed inside the button.
</td>
</tr>
<tr>
<td>accept: string</td>
<td></td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
(callbackFile)="callback($event)"
[multiple]="false"
></dxc-file-input>
<dxc-file-input
label="Custom button label"
helperText="helperText"
buttonLabel="Custom button label"
[showPreview]="true"
margin="xsmall"
(callbackFile)="callback2($event)"
[multiple]="false"
></dxc-file-input>
<dxc-file-input
label="Label"
helperText="helperText"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/>
<dxc-button
*ngIf="mode === 'file'"
label="Select files"
[label]="buttonLabel"
mode="secondary"
[disabled]="disabled"
(onClick)="fileInput.click()"
Expand All @@ -27,7 +27,7 @@
(dragover)="dragOver($event)"
>
<dxc-button
label="Select"
[label]="buttonLabel"
mode="secondary"
[disabled]="disabled"
[tabIndexValue]="tabIndexValue"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,23 @@ describe("DxcFileInputComponent", () => {
expect(fileInput.getByText("Helper Text"));
});

test("should render dxc-file-input with custom buttonLabel", async () => {
const fileInput = await render(DxcFileInputComponent, {
componentProperties: {
label: "Label",
helperText: "Helper Text",
buttonLabel: "Custom Button Label",
},
excludeComponentDeclaration: true,
imports: [DxcFileInputModule],
});

expect(fileInput.getByText("Custom Button Label"));
expect(fileInput.getByText("Label"));
expect(fileInput.getByText("Helper Text"));
});


test("should render dxc-file-input in file drop mode", async () => {
const fileInput = await render(DxcFileInputComponent, {
componentProperties: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export class DxcFileInputComponent implements OnChanges, OnInit {
@Input() public name: string;
@Input() public mode: string = "file";
@Input() public label: string;
@Input() public buttonLabel: string;
@Input() public helperText: string;
@Input() public value: Array<FileData>;
@Input() public accept: any;
Expand Down Expand Up @@ -148,6 +149,21 @@ export class DxcFileInputComponent implements OnChanges, OnInit {
this.hasShowError = this.isErrorShow();
this.hasMultipleFiles = this.isMultipleFilesPrintables();
this.hasSingleFile = this.isSingleFilesPrintables();
if (!this.buttonLabel) {
console.log(
this.mode === "file"
? this.multiple
? "Select files"
: "Select file"
: "Select"
);
this.buttonLabel =
this.mode === "file"
? this.multiple
? "Select files"
: "Select file"
: "Select";
}
this.className = `${this.getDynamicStyle(this.defaultInputs.getValue())}`;
}

Expand Down