mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
#726 required validator for 'attach' widget
This commit is contained in:
@@ -35,7 +35,8 @@ export class RequiredFieldValidator implements FormFieldValidator {
|
||||
FormFieldTypes.DROPDOWN,
|
||||
FormFieldTypes.PEOPLE,
|
||||
FormFieldTypes.FUNCTIONAL_GROUP,
|
||||
FormFieldTypes.RADIO_BUTTONS
|
||||
FormFieldTypes.RADIO_BUTTONS,
|
||||
FormFieldTypes.UPLOAD
|
||||
];
|
||||
|
||||
isSupported(field: FormFieldModel): boolean {
|
||||
@@ -60,6 +61,10 @@ export class RequiredFieldValidator implements FormFieldValidator {
|
||||
return !!option;
|
||||
}
|
||||
|
||||
if (field.type === FormFieldTypes.UPLOAD) {
|
||||
return field.value && field.value.length > 0;
|
||||
}
|
||||
|
||||
if (!field.value) {
|
||||
return false;
|
||||
}
|
||||
|
@@ -15,3 +15,19 @@
|
||||
float: left;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.upload-widget__invalid .upload-widget__label {
|
||||
color: #d50000;
|
||||
}
|
||||
|
||||
.upload-widget__invalid .upload-widget__label:after {
|
||||
background-color: #d50000;
|
||||
}
|
||||
|
||||
.upload-widget__invalid .upload-widget__file {
|
||||
color: #d50000;
|
||||
}
|
||||
|
||||
.upload-widget__invalid .mdl-textfield__error {
|
||||
visibility: visible !important;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<div class="upload-widget">
|
||||
|
||||
<label [attr.for]="field.id">{{field.name}}</label>
|
||||
<div class="upload-widget"
|
||||
[class.upload-widget__invalid]="!field.isValid">
|
||||
<label class="upload-widget__label" [attr.for]="field.id">{{field.name}}</label>
|
||||
<div>
|
||||
<i *ngIf="hasFile" class="material-icons upload-widget__icon">attachment</i>
|
||||
<span *ngIf="hasFile" class="upload-widget__file">{{getUploadedFileName()}}</span>
|
||||
@@ -12,4 +12,5 @@
|
||||
(change)="onFileChanged($event)">
|
||||
<button *ngIf="hasFile" (click)="reset(file);" class="upload-widget__reset">X</button>
|
||||
</div>
|
||||
<span *ngIf="field.validationSummary" class="mdl-textfield__error">{{field.validationSummary}}</span>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user