From ce4de62c9d4d6a1604c881303bab5b6a3b0772df Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 13 Jul 2018 15:19:19 -0400 Subject: [PATCH] Add members to teams (fixes #1629) (#1658) --- .../view-meetups/meetups-view.component.ts | 11 +---- .../shared/dialogs/dialogs-list.service.ts | 20 ++++++++- src/app/teams/teams-view.component.html | 3 ++ src/app/teams/teams-view.component.ts | 44 ++++++++++++++++++- 4 files changed, 65 insertions(+), 13 deletions(-) diff --git a/src/app/meetups/view-meetups/meetups-view.component.ts b/src/app/meetups/view-meetups/meetups-view.component.ts index 068b6df182..7a21ab6029 100644 --- a/src/app/meetups/view-meetups/meetups-view.component.ts +++ b/src/app/meetups/view-meetups/meetups-view.component.ts @@ -91,16 +91,7 @@ export class MeetupsViewComponent implements OnInit, OnDestroy { } openInviteMemberDialog() { - this.dialogsListService.getListAndColumns('_users', { - '$nor': [ - { '_id': this.userService.get()._id }, - { '_id': 'org.couchdb.user:satellite' } - ], - '$or': [ - { 'roles': { '$in': [ 'learner', 'leader' ] } }, - { 'isUserAdmin': true } - ] - }).subscribe((res) => { + this.dialogsListService.getListAndColumns('_users').subscribe((res) => { res.tableData = res.tableData.filter(tableValue => this.members.indexOf(tableValue.name) === -1); const data = { okClick: this.sendInvitations.bind(this), diff --git a/src/app/shared/dialogs/dialogs-list.service.ts b/src/app/shared/dialogs/dialogs-list.service.ts index 36e756055d..334bb17dfd 100644 --- a/src/app/shared/dialogs/dialogs-list.service.ts +++ b/src/app/shared/dialogs/dialogs-list.service.ts @@ -2,6 +2,7 @@ import { Injectable } from '@angular/core'; import { CouchService } from '../couchdb.service'; import { map } from 'rxjs/operators'; import { findDocuments } from '../mangoQueries'; +import { UserService } from '../user.service'; const listColumns = { 'resources': [ 'title' ], @@ -13,11 +14,26 @@ const listColumns = { @Injectable() export class DialogsListService { + defaultSelectors = { + '_users': { + '$nor': [ + { '_id': this.userService.get()._id }, + { '_id': 'org.couchdb.user:satellite' } + ], + '$or': [ + { 'roles': { '$in': [ 'learner', 'leader' ] } }, + { 'isUserAdmin': true } + ] + } + }; + constructor( - private couchService: CouchService + private couchService: CouchService, + private userService: UserService ) {} - getListAndColumns(db: string, selector: any = {}, opts: any = {}) { + getListAndColumns(db: string, selector?: any, opts: any = {}) { + selector = selector || this.defaultSelectors[db] || {}; return this.couchService.post(db + '/_find', findDocuments(selector), opts).pipe(map((res) => { return { tableData: res.docs, columns: listColumns[db] }; })); diff --git a/src/app/teams/teams-view.component.html b/src/app/teams/teams-view.component.html index c2df03ea47..a5a4c4c4ff 100644 --- a/src/app/teams/teams-view.component.html +++ b/src/app/teams/teams-view.component.html @@ -6,6 +6,9 @@

{{team?.name}}

+