Skip to content

Commit

Permalink
1) Update the RequestFieldCoordDialogComponent to pull the AGOLGroups…
Browse files Browse the repository at this point in the history
… that are set as is_auth_group - commit 2 (#55). 2) Update to tsconfig.spec.json.
  • Loading branch information
tommckennon committed Feb 18, 2021
1 parent 25027d5 commit 5cb6ed2
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def get_serializer_class(self):
return AccountSerializer


class AGOLGroupViewSet(ContentTypeListMixin, ReadOnlyModelViewSet):
class AGOLGroupViewSet(ReadOnlyModelViewSet):
queryset = AGOLGroup.objects.none()
serializer_class = AGOLGroupSerializer
ordering = ['title']
Expand Down
7 changes: 4 additions & 3 deletions ui/src/app/components/tag-input/tag-input.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {HttpClient} from '@angular/common/http';
import {COMMA, ENTER} from '@angular/cdk/keycodes';
import {Observable} from 'rxjs';
import {debounceTime, map, startWith, switchMap} from 'rxjs/operators';
import {isArray} from 'rxjs/internal-compatibility';

import {BaseService, Response} from '@services/base.service';
import {LoadingService} from '@services/loading.service';
Expand Down Expand Up @@ -55,11 +56,11 @@ export class TagInputComponent implements OnInit {
}
}),
map((response) => {
if (response.results) {
if (isArray(response)) {
if (this.tags && this.tags.length > 0) {
return response.results.filter(result => this.tags.indexOf(result.title) === -1);
return response.filter(result => this.tags.indexOf(result.title) === -1);
}
return response.results;
return response;
}
}),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ export class EditAccountPropsDialogComponent implements OnInit {
if (response) {
this.http.get<AgolGroup[]>('/v1/agol/groups',
{params: new HttpParams().set('response', response.toString())}).pipe(
tap(r => this.groups.next(r))
tap((res) => {
this.groups.next(res);
})
).subscribe();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {Component, Inject, OnInit} from '@angular/core';
import {FormControl, FormGroup, Validators} from '@angular/forms';
import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material/dialog';
import {HttpClient} from '@angular/common/http';
import {HttpClient, HttpParams} from '@angular/common/http';
import {ReplaySubject} from 'rxjs';
import {map} from 'rxjs/operators';
import {map, tap} from 'rxjs/operators';

import {BaseService} from '@services/base.service';
import {FieldCoordinator} from '../../field-coord-list/field-coord-list.component';
Expand All @@ -18,7 +18,6 @@ import {AgolGroup} from '../edit-account-props-dialog/edit-account-props-dialog.
styleUrls: ['./request-field-coord-dialog.component.css']
})
export class RequestFieldCoordDialogComponent implements OnInit {
groupsService: BaseService;
authGroupChoices: ReplaySubject<AgolGroup[]> = new ReplaySubject<AgolGroup[]>();
requestFieldCoordForm: FormGroup = new FormGroup({
first_name: new FormControl(null, [Validators.required]),
Expand All @@ -34,15 +33,15 @@ export class RequestFieldCoordDialogComponent implements OnInit {
constructor(public dialogRef: MatDialogRef<RequestFieldCoordDialogComponent>,
public http: HttpClient, public loadingService: LoadingService,
@Inject(MAT_DIALOG_DATA) public data: FieldCoordinator) {
this.groupsService = new BaseService('v1/agol/groups', this.http, this.loadingService);
}

async ngOnInit() {
await this.groupsService.getList<AgolGroup>({is_auth_group: true}).pipe(
map((response) => {
this.authGroupChoices.next(response.results);
this.http.get<AgolGroup[]>('/v1/agol/groups',
{params: new HttpParams().set('is_auth_group', String(true))}).pipe(
tap((res) => {
this.authGroupChoices.next(res);
})
).toPromise();
).subscribe();
}

submit() {
Expand Down
7 changes: 6 additions & 1 deletion ui/src/tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
"types": [
"jasmine",
"node"
]
],
"paths": {
"@services/*": ["src/app/services/*"],
"@components/*": ["src/app/components/*"],
"@environments/*": ["src/environments/*"]
}
},
"files": [
"test.ts",
Expand Down

0 comments on commit 5cb6ed2

Please sign in to comment.