mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
fix readonly attach file scenarios (#5365)
This commit is contained in:
@@ -26,6 +26,7 @@
|
|||||||
"REMOVE_FILE": "Remove",
|
"REMOVE_FILE": "Remove",
|
||||||
"UPLOAD": "UPLOAD",
|
"UPLOAD": "UPLOAD",
|
||||||
"REQUIRED": "*Required",
|
"REQUIRED": "*Required",
|
||||||
|
"NO_FILE_ATTACHED" : "No file attached",
|
||||||
"VALIDATOR": {
|
"VALIDATOR": {
|
||||||
"INVALID_NUMBER": "Use a different number format",
|
"INVALID_NUMBER": "Use a different number format",
|
||||||
"INVALID_DATE": "Use a different date format",
|
"INVALID_DATE": "Use a different date format",
|
||||||
|
@@ -28,7 +28,8 @@
|
|||||||
(click)="uploadFileFromCS()">
|
(click)="uploadFileFromCS()">
|
||||||
{{field.params?.fileSource?.name}}
|
{{field.params?.fileSource?.name}}
|
||||||
<mat-icon>
|
<mat-icon>
|
||||||
<img alt="alfresco" class="adf-attach-widget__image-logo" src="../assets/images/alfresco-flower.svg">
|
<img alt="alfresco" class="adf-attach-widget__image-logo"
|
||||||
|
src="../assets/images/alfresco-flower.svg">
|
||||||
</mat-icon>
|
</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -71,6 +72,10 @@
|
|||||||
</mat-menu>
|
</mat-menu>
|
||||||
</mat-list-item>
|
</mat-list-item>
|
||||||
</mat-list>
|
</mat-list>
|
||||||
|
<div *ngIf="!hasFile && field.readOnly" id="{{'adf-attach-empty-list-'+field.id}}">
|
||||||
|
{{ 'FORM.FIELD.NO_FILE_ATTACHED' | translate }}
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<error-widget [error]="field.validationSummary"></error-widget>
|
<error-widget [error]="field.validationSummary"></error-widget>
|
||||||
|
@@ -234,6 +234,56 @@ describe('AttachFileCloudWidgetComponent', () => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
describe('when is readonly', () => {
|
||||||
|
|
||||||
|
it('should show empty list message when there are no file', async(() => {
|
||||||
|
widget.field = new FormFieldModel(new FormModel(), {
|
||||||
|
type: FormFieldTypes.UPLOAD,
|
||||||
|
readOnly: true,
|
||||||
|
value: []
|
||||||
|
});
|
||||||
|
widget.field.id = 'empty-test';
|
||||||
|
widget.field.params = <FormFieldMetadata> onlyLocalParams;
|
||||||
|
fixture.detectChanges();
|
||||||
|
fixture.whenStable().then(() => {
|
||||||
|
expect(element.querySelector('#adf-attach-empty-list-empty-test')).not.toBeNull();
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should not show empty list message when there are files', async(() => {
|
||||||
|
widget.field = new FormFieldModel(new FormModel(), {
|
||||||
|
type: FormFieldTypes.UPLOAD,
|
||||||
|
readOnly: true,
|
||||||
|
value: [fakePngAnswer]
|
||||||
|
});
|
||||||
|
widget.field.id = 'fill-test';
|
||||||
|
widget.field.params = <FormFieldMetadata> onlyLocalParams;
|
||||||
|
fixture.detectChanges();
|
||||||
|
fixture.whenStable().then(() => {
|
||||||
|
expect(element.querySelector('#adf-attach-empty-list-fill-test')).toBeNull();
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should not show remove button when there are files attached', async(() => {
|
||||||
|
widget.field = new FormFieldModel(new FormModel(), {
|
||||||
|
type: FormFieldTypes.UPLOAD,
|
||||||
|
readOnly: true,
|
||||||
|
value: [fakePngAnswer]
|
||||||
|
});
|
||||||
|
widget.field.id = 'fill-test';
|
||||||
|
widget.field.params = <FormFieldMetadata> onlyLocalParams;
|
||||||
|
|
||||||
|
fixture.detectChanges();
|
||||||
|
const menuButton: HTMLButtonElement = <HTMLButtonElement> (
|
||||||
|
fixture.debugElement.query(By.css('#file-1155-option-menu'))
|
||||||
|
.nativeElement
|
||||||
|
);
|
||||||
|
menuButton.click();
|
||||||
|
fixture.detectChanges();
|
||||||
|
expect(fixture.debugElement.query(By.css('#file-1155-remove'))).toBeNull();
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
describe('when a file is uploaded', () => {
|
describe('when a file is uploaded', () => {
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
widget.field = new FormFieldModel(new FormModel(), {
|
widget.field = new FormFieldModel(new FormModel(), {
|
||||||
|
@@ -34,6 +34,11 @@
|
|||||||
(change)="onFileChanged($event)"/>
|
(change)="onFileChanged($event)"/>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div *ngIf="!hasFile && field.readOnly">
|
||||||
|
{{ 'FORM.FIELD.NO_FILE_ATTACHED' | translate }}
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<error-widget [error]="field.validationSummary"></error-widget>
|
<error-widget [error]="field.validationSummary"></error-widget>
|
||||||
<error-widget *ngIf="isInvalidFieldRequired()" required="{{ 'FORM.FIELD.REQUIRED' | translate }}"></error-widget>
|
<error-widget *ngIf="isInvalidFieldRequired()" required="{{ 'FORM.FIELD.REQUIRED' | translate }}"></error-widget>
|
||||||
|
Reference in New Issue
Block a user