root/resilient#2 Change the User selection control to a 'on type' combo.
Also restricted the user list to only users that have NO association to org yet
This commit is contained in:
parent
4890950952
commit
2aa75f0e13
8 changed files with 174 additions and 82 deletions
|
@ -186,12 +186,36 @@
|
|||
<!-- User property applies only to OrganizationNature.PERSON -->
|
||||
<div class="mb-3" *ngIf="editForm.get('organizationType')?.value?.nature === organizationNature.PERSON">
|
||||
<label class="form-label" for="field_user" jhiTranslate="resilientApp.organization.user">User</label>
|
||||
<select class="form-control" id="field_user" data-cy="user" name="user" formControlName="user" [compareWith]="compareUser">
|
||||
<!--
|
||||
<select
|
||||
class="form-control"
|
||||
id="field_user"
|
||||
data-cy="user"
|
||||
name="user"
|
||||
formControlName="user"
|
||||
[compareWith]="compareUser">
|
||||
<option [ngValue]="null"></option>
|
||||
@for (userOption of usersSharedCollection; track $index) {
|
||||
<option [ngValue]="userOption">{{ userOption.login }}</option>
|
||||
}
|
||||
</select>
|
||||
-->
|
||||
|
||||
<ng-select
|
||||
class="form-control drop-down-panel"
|
||||
formControlName="user"
|
||||
[items]="usersSharedCollection"
|
||||
[compareWith]="compareUser"
|
||||
[clearable]="true"
|
||||
[searchFn]="userSearchFn"
|
||||
>
|
||||
<ng-template ng-label-tmp let-item="item">
|
||||
{{ item.login }} ( {{ item.email }} )
|
||||
</ng-template>
|
||||
<ng-template ng-option-tmp let-item="item">
|
||||
{{ item.login }} ( {{ item.email }} )
|
||||
</ng-template>
|
||||
</ng-select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import { finalize, map } from 'rxjs/operators';
|
|||
|
||||
import SharedModule from 'app/shared/shared.module';
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { NgSelectModule } from '@ng-select/ng-select';
|
||||
|
||||
import { AlertError } from 'app/shared/alert/alert-error.model';
|
||||
import { EventManager, EventWithContent } from 'app/core/util/event-manager.service';
|
||||
|
@ -23,7 +24,7 @@ import { OrganizationNature } from 'app/entities/enumerations/organization-natur
|
|||
standalone: true,
|
||||
selector: 'jhi-organization-update',
|
||||
templateUrl: './organization-update.component.html',
|
||||
imports: [SharedModule, FormsModule, ReactiveFormsModule],
|
||||
imports: [SharedModule, FormsModule, ReactiveFormsModule, NgSelectModule],
|
||||
})
|
||||
export class OrganizationUpdateComponent implements OnInit {
|
||||
// Properties with defaults by router
|
||||
|
@ -181,7 +182,7 @@ export class OrganizationUpdateComponent implements OnInit {
|
|||
|
||||
protected loadRelationshipsOptionsUser(): void {
|
||||
this.userService
|
||||
.query()
|
||||
.queryForOrganization()
|
||||
.pipe(map((res: HttpResponse<IUser[]>) => res.body ?? []))
|
||||
.pipe(map((users: IUser[]) => this.userService.addUserToCollectionIfMissing<IUser>(users, this.organization?.user)))
|
||||
.subscribe((users: IUser[]) => (this.usersSharedCollection = users));
|
||||
|
@ -227,4 +228,9 @@ export class OrganizationUpdateComponent implements OnInit {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
userSearchFn = (term: string, item: any) => {
|
||||
term = term.toLowerCase();
|
||||
return (item.login + "( " + item.email + " )").toLowerCase().includes(term);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -26,6 +26,11 @@ export class UserService {
|
|||
return this.http.get<IUser[]>(this.resourceUrl, { params: options, observe: 'response' });
|
||||
}
|
||||
|
||||
queryForOrganization(req?: any): Observable<EntityArrayResponseType> {
|
||||
const options = createRequestOption(req);
|
||||
return this.http.get<IUser[]>(`${this.resourceUrl}/for/organization`, { params: options, observe: 'response' });
|
||||
}
|
||||
|
||||
getUserIdentifier(user: Pick<IUser, 'id'>): number {
|
||||
return user.id;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
export interface IUser {
|
||||
id: number;
|
||||
login?: string | null;
|
||||
email?: string | null;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue