import { Component , OnInit , Input , Output , EventEmitter } from '@angular/core' ; import { FormControl } from "@angular/forms" ; import { UsersService } from "../../services/users/users.service" ; import { GroupService } from "../../services/groups/group.service" ; import { ContextService } from "../../services/context.service" ; import { UtilsService } from "../../services/utils.service" ; @ Component ( { selector : 'app-add-member-modal' , templateUrl : './add-member-modal.component.html' , styleUrls : [ './add-member-modal.component.scss' ] } ) export class AddMemberModalComponent { private _show ; public users ; public addMemberForm = new FormControl ( ) ; @ Input ( ) group ; @ Output ( ) onAdd = new EventEmitter ( ) ; @ Output ( ) showChange = new EventEmitter ( ) ; @ Input ( ) set show ( value ) { this . _show = value ; this . showChange . emit ( this . _show ) ; } get show ( ) { return this . _show ; } constructor ( private usersService , private utils , private context , private groupService ) { this . users = context . getAllUsers ( ) ; } close ( ) { this . show = false ; } addMember ( ) { this . groupService . addMemberToGroup ( this . group . id , this . addMemberForm . value ) . then ( ( response ) => { this . onAdd . emit ( this . addMemberForm . value ) ; this . close ( ) ; this . utils . defaultSnackBar ( 'Request Sent' ) ; } ) ; } display ( user ) { return user && user . name ; } }