#726 required validator for group picker widget

This commit is contained in:
Denys Vuika
2016-09-14 18:49:59 +01:00
parent c1b2d0d7ab
commit 16eb825a51
5 changed files with 35 additions and 7 deletions

View File

@@ -33,7 +33,8 @@ export class RequiredFieldValidator implements FormFieldValidator {
FormFieldTypes.NUMBER,
FormFieldTypes.TYPEAHEAD,
FormFieldTypes.DROPDOWN,
FormFieldTypes.PEOPLE
FormFieldTypes.PEOPLE,
FormFieldTypes.FUNCTIONAL_GROUP
];
isSupported(field: FormFieldModel): boolean {

View File

@@ -27,3 +27,23 @@
.functional-group-widget--autocomplete > ul > li {
opacity: 1;
}
.people-widget--autocomplete > ul > li {
opacity: 1;
}
.functional-group-widget__invalid .mdl-textfield__input {
border-color: #d50000;
}
.functional-group-widget__invalid .mdl-textfield__label {
color: #d50000;
}
.functional-group-widget__invalid .mdl-textfield__label:after {
background-color: #d50000;
}
.functional-group-widget__invalid .mdl-textfield__error {
visibility: visible !important;
}

View File

@@ -1,4 +1,5 @@
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label functional-group-widget">
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label functional-group-widget"
[class.functional-group-widget__invalid]="!field.isValid">
<input class="mdl-textfield__input"
type="text"
[attr.id]="field.id"
@@ -8,8 +9,8 @@
(blur)="onBlur()"
[disabled]="field.readOnly">
<label class="mdl-textfield__label" [attr.for]="field.id">{{field.name}}</label>
<span *ngIf="field.validationSummary" class="mdl-textfield__error">{{field.validationSummary}}</span>
</div>
<div class="functional-group-widget--autocomplete mdl-shadow--2dp" *ngIf="popupVisible && groups.length > 0">
<ul>
<li *ngFor="let item of groups"

View File

@@ -54,6 +54,13 @@ export class FunctionalGroupWidget extends WidgetComponent implements OnInit {
let restrictWithGroup = <GroupModel> params['restrictWithGroup'];
this.groupId = restrictWithGroup.id;
}
// Load auto-completion for previously saved value
if (this.value) {
this.formService
.getWorkflowGroups(this.value, this.groupId)
.subscribe((result: GroupModel[]) => this.groups = result || []);
}
}
}

View File

@@ -58,10 +58,9 @@ export class PeopleWidget extends WidgetComponent implements OnInit {
// Load auto-completion for previously saved value
if (this.value) {
this.formService.getWorkflowUsers(this.value, this.groupId)
.subscribe((result: GroupUserModel[]) => {
this.users = result || [];
});
this.formService
.getWorkflowUsers(this.value, this.groupId)
.subscribe((result: GroupUserModel[]) => this.users = result || []);
}
}
}