Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Workshop Admin/ Deputy] - personal cabinet functionality #1173 #1233

Merged
merged 46 commits into from
Jun 19, 2022
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
acb54cd
Merge pull request #879 from ita-social-projects/develop
DmyMi Feb 4, 2022
23fe589
fix
Olya-web7 May 25, 2022
fb355e6
fix
Olya-web7 May 25, 2022
9fff452
fix
Olya-web7 May 25, 2022
90bca96
add ProviderDeputy
Olya-web7 May 26, 2022
4de70fc
add conditioan for administruvannia
Olya-web7 May 26, 2022
ae3c984
add condition for administruvannia
Olya-web7 May 26, 2022
4f597be
fix
Olya-web7 May 26, 2022
81bbd0b
add btn accept to the gurtok zalysheno
Olya-web7 May 26, 2022
5d34662
add btn accept to the gurtok zalysheno
Olya-web7 May 26, 2022
6b9ca24
add possibility to return child only for admin
Olya-web7 May 27, 2022
43cefa7
add possibility to return child only for admin
Olya-web7 May 27, 2022
a53ff65
add possibility to return child only for admin
Olya-web7 May 27, 2022
9eb544d
delete administruvannia for all
Olya-web7 May 27, 2022
c6f2a2a
fix
Olya-web7 May 28, 2022
16b7bec
fix
Olya-web7 May 28, 2022
aead610
fix
Olya-web7 May 28, 2022
22d8efa
fix
Olya-web7 May 28, 2022
738a3b3
fix
Olya-web7 May 29, 2022
805e653
fix
Olya-web7 May 29, 2022
745a115
Merge branch 'develop' into Workshop-Admin-Deputy-personalcabinet-fun…
Olya-web7 May 30, 2022
939f5db
fix tests
Olya-web7 May 30, 2022
21977f4
Merge branch 'Workshop-Admin-Deputy-personalcabinet-functionality' of…
Olya-web7 May 30, 2022
06b50ae
fix
Olya-web7 May 30, 2022
d362808
fix
Olya-web7 May 30, 2022
a2f72a9
Merge pull request #1244 from ita-social-projects/develop
DmyMi May 31, 2022
61b6afd
Merge pull request #1246 from ita-social-projects/develop
DmyMi May 31, 2022
6f05bdc
work on comments
Olya-web7 Jun 2, 2022
bd45226
work on comments
Olya-web7 Jun 2, 2022
e071a7c
work on comments
Olya-web7 Jun 2, 2022
570d328
delete administruvannia in header for providerAdmin
Olya-web7 Jun 2, 2022
076ae20
Merge branch 'develop' into Workshop-Admin-Deputy-personalcabinet-fun…
Olya-web7 Jun 3, 2022
d5ae7c9
limit the ability to delete and block deputy for deputy
Olya-web7 Jun 5, 2022
44487c5
fix
Olya-web7 Jun 5, 2022
436d8cf
deputy cannot create new deputy and admins
Olya-web7 Jun 5, 2022
867743f
fix
Olya-web7 Jun 5, 2022
3b64a4c
Merge branch 'develop' into Workshop-Admin-Deputy-personalcabinet-fun…
Olya-web7 Jun 5, 2022
b66f822
fix
Olya-web7 Jun 5, 2022
c0a7d23
Merge branch 'Workshop-Admin-Deputy-personalcabinet-functionality' of…
Olya-web7 Jun 5, 2022
3728674
fix
Olya-web7 Jun 5, 2022
4ef63ef
fix
Olya-web7 Jun 5, 2022
efbd35f
fix
Olya-web7 Jun 5, 2022
5c4615d
Merge branch 'develop', remote-tracking branch 'origin' into Workshop…
litvinets Jun 19, 2022
b8b2c74
Merge branch 'develop' into Workshop-Admin-Deputy-personalcabinet-fun…
litvinets Jun 19, 2022
fa32be1
Update users-list.component.html
litvinets Jun 19, 2022
a980842
rounting
litvinets Jun 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/header/header.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ <h2 class="header_descr">
</ng-template>
<ng-template #AdminView>
<a [routerLink]="'./personal-cabinet/config'"><button mat-menu-item>Особиста інформація</button></a>
<a [routerLink]="'./admin-tools/platform/AboutPortal'"> <button mat-menu-item>Адміністрування</button></a>
<a *ngIf="subrole !== 'ProviderAdmin'" [routerLink]="'./admin-tools/platform/AboutPortal'"> <button mat-menu-item>Адміністрування</button></a>
<button mat-menu-item (click)="logout()">Вийти</button>
</ng-template>
</mat-menu>
Expand Down
36 changes: 21 additions & 15 deletions src/app/header/header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ import { AdminState } from '../shared/store/admin.state';
@Component({
selector: 'app-header',
templateUrl: './header.component.html',
styleUrls: ['./header.component.scss']
styleUrls: ['./header.component.scss'],
})
export class HeaderComponent implements OnInit, OnDestroy {

readonly Languages: typeof Languages = Languages;
readonly Role: typeof Role = Role;
readonly roles: typeof RoleLinks = RoleLinks;
Expand Down Expand Up @@ -63,16 +62,19 @@ export class HeaderComponent implements OnInit, OnDestroy {

private destroy$: Subject<boolean> = new Subject<boolean>();

constructor(
private store: Store,
private router: Router) {
}
constructor(private store: Store, private router: Router) {}

changeView(): void {
this.store.dispatch(new SidenavToggle());
}

ngOnInit(): void {
combineLatest([
this.isLoadingResultPage$,
this.isLoadingMetaData$,
this.isLoadingCabinet$,
])

combineLatest([this.isLoadingResultPage$, this.isLoadingMetaData$, this.isLoadingCabinet$, this.isLoadingAdminData$])
.pipe(takeUntil(this.destroy$), delay(0))
.subscribe(([isLoadingResult, isLoadingMeta, isLoadingCabinet, isLoadingAdminData]) => {
Expand All @@ -87,21 +89,25 @@ export class HeaderComponent implements OnInit, OnDestroy {
.subscribe(([isMobile, navigationPaths]) => {
this.isMobile = isMobile;
this.navigationPaths = navigationPaths;
})
});

this.store.dispatch(new CheckAuth());

this.user$.pipe(
filter((user) => !!user),
takeUntil(this.destroy$)
).subscribe((user: User) => {
this.userShortName = this.getFullName(user);
this.user = user;
});
this.user$
.pipe(
filter((user) => !!user),
takeUntil(this.destroy$)
)
.subscribe((user: User) => {
this.userShortName = this.getFullName(user);
this.user = user;
});
}

private getFullName(user: User): string {
return `${user.lastName} ${(user.firstName).slice(0, 1)}.${(user.middleName) ? (user.middleName).slice(0, 1) + '.' : ''}`;
return `${user.lastName} ${user.firstName.slice(0, 1)}.${
user.middleName ? user.middleName.slice(0, 1) + '.' : ''
}`;
}

logout(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
<a class="more-details" [routerLink]="['#']">
<span class="Cancel"> Скасувати </span>
</a>
<button mat-icon-button [matMenuTriggerFor]="actions">
<button mat-icon-button [matMenuTriggerFor]="actions" [disabled]="subrole === Role.deputy && user.isDeputy">
<mat-icon>more_vert</mat-icon>
</button>
<button mat-icon-button [matMenuTriggerFor]="email">
Expand All @@ -105,7 +105,7 @@
<button mat-menu-item (click)="onDelete(user)">
Видалити користувача
</button>
</mat-menu>
</mat-menu>
<mat-menu #email="matMenu" class="header_menu">
<button mat-menu-item (click)="sendInvitation()">
Надіслати запрошення
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { MatIconModule } from '@angular/material/icon';
import { MatMenuModule } from '@angular/material/menu';
import { MatTableModule } from '@angular/material/table';
import { RouterTestingModule } from '@angular/router/testing';
import { NgxsModule } from '@ngxs/store';
import { UsersListComponent } from './users-list.component';

describe('UsersListComponent', () => {
Expand All @@ -15,6 +16,7 @@ describe('UsersListComponent', () => {
MatTableModule,
RouterTestingModule,
MatMenuModule,
NgxsModule.forRoot([]),
MatIconModule,
],
declarations: [ UsersListComponent ]
Expand All @@ -26,6 +28,7 @@ describe('UsersListComponent', () => {
fixture = TestBed.createComponent(UsersListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
component.subrole = '' as string;
});

it('should create', () => {
Expand Down
57 changes: 40 additions & 17 deletions src/app/shared/components/users-list/users-list.component.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,40 @@
import { LiveAnnouncer } from '@angular/cdk/a11y';
import { AfterViewInit, Component, EventEmitter, Input, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core';
import {
AfterViewInit,
Component,
EventEmitter,
Input,
OnInit,
Output,
SimpleChanges,
ViewChild,
} from '@angular/core';
import { MatSort, Sort } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table';
import { providerAdminRoleUkr, ProviderAdminTitles } from '../../enum/enumUA/provider-admin';
import { Select } from '@ngxs/store';
import { Observable } from 'rxjs';
import { Constants } from 'src/app/shared/constants/constants';
import {
providerAdminRoleUkr,
ProviderAdminTitles,
} from '../../enum/enumUA/provider-admin';

import { Role } from '../../enum/role';
import { ProviderAdminIcons, ProviderAdminStatus } from '../../enum/provider-admin';
import { ProviderAdminTable } from '../../models/providerAdmin.model';
import { RegistrationState } from '../../store/registration.state';

/**
* @title Table with sorting
*/
@Component({
selector: 'app-users-list',
templateUrl: './users-list.component.html',
styleUrls: ['./users-list.component.scss']
styleUrls: ['./users-list.component.scss'],
})
export class UsersListComponent implements OnInit, AfterViewInit {
@Select(RegistrationState.subrole)
subrole$: Observable<string>;

@Input() users: Array<object>;
@Input() filterValue: string;
Expand All @@ -25,32 +45,35 @@ export class UsersListComponent implements OnInit, AfterViewInit {
readonly providerAdminTitles = ProviderAdminTitles;
readonly providerAdminStatus = ProviderAdminStatus;
readonly providerAdminIcons = ProviderAdminIcons;
subrole: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add empty row between readonly and public values

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add empty row between readonly and public values

Role = Role;
displayedColumns: string[];
dataSource: MatTableDataSource<object> = new MatTableDataSource([{}]);

constructor(private _liveAnnouncer: LiveAnnouncer) {}

@ViewChild(MatSort) sort: MatSort;

ngOnInit(): void {
this.displayedColumns = ['pib', 'email', 'phone', 'place', 'role', 'status', 'actions'];
this.dataSource = new MatTableDataSource(this.users);
ngOnInit(): void {
this.subrole$.subscribe((subrole) => (this.subrole = subrole));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

takeUntil

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add typo

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

takeUntil

this.displayedColumns = ['pib', 'email', 'phone', 'place', 'role', 'status', 'actions'];
this.dataSource = new MatTableDataSource(this.users);
}

ngAfterViewInit() {
this.dataSource.sort = this.sort;
}

ngOnChanges(changes: SimpleChanges) {
if (changes.filterValue && changes.filterValue.currentValue) {
let filter = changes.filterValue.currentValue;
this.dataSource.filter = filter.trim().toLowerCase();
} else this.dataSource.filter = "";
if (changes.users && changes.users.currentValue) {
const users = changes.users.currentValue;
this.dataSource = new MatTableDataSource(users);
}
if (changes.filterValue && changes.filterValue.currentValue) {
let filter = changes.filterValue.currentValue;
this.dataSource.filter = filter.trim().toLowerCase();
} else this.dataSource.filter = '';

if (changes.users && changes.users.currentValue) {
const users = changes.users.currentValue;
this.dataSource = new MatTableDataSource(users);
}
}

/** Announce the change in sort state for assistive technology. */
Expand All @@ -62,10 +85,10 @@ export class UsersListComponent implements OnInit, AfterViewInit {
}
}

onDelete(user: ProviderAdminTable): void {
onDelete(user: ProviderAdminTable): void {
this.deleteAdmin.emit(user);
}

onBlock(user: ProviderAdminTable): void {
this.blockAdmin.emit(user);
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/shared/enum/enumUA/provider-admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export enum PersonalCabinetTitle {
None = 'КАБІНЕТ НАДАВАЧА',
admin = 'КАБІНЕТ ТЕХ. АДМІНА',
user = 'КАБІНЕТ КОРИСТУВАЧА',
deputy = 'КАБІНЕТ ЗАСТУПНИКА ДИРЕКТОРА',
ProviderDeputy = 'КАБІНЕТ ЗАСТУПНИКА ДИРЕКТОРА',
ProviderAdmin = 'КАБІНЕТ АДМІНІСТРАТОРА ГУРТКА',
}

2 changes: 2 additions & 0 deletions src/app/shared/enum/role.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ export enum Role {
parent = 'parent',
unauthorized = 'unauthorized',
techAdmin = 'admin',
deputy = 'ProviderDeputy',
admin = 'ProviderAdmin',
all = 'all',
child = 'child'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,13 @@
<th
mat-header-cell
*matHeaderCellDef
mat-sort-header
mat-sort-header
sortActionDescription="Sort by city"
>
Населений пункт
</th>
<td mat-cell *matCellDef="let element">
{{ element.legalAddress.city }}
{{ element.legalAddress.city || ""}}
</td>
</ng-container>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ <h4 class="name title">{{ application.child.lastName }} {{ application.child.fir

<mat-card-content class="card-block card-block-buttons" *ngIf="userRole === role.provider">
<div fxLayout="column" fxLayoutAlign="start start"
[ngClass]="(application.status === applicationStatus.Approved || application.status === applicationStatus.Left) && 'hidden'">
[ngClass]="application.status === applicationStatus.Approved && 'hidden'">
<button class="btn btn-blue" (click)="onApprove(application)">
<p>ПРИЙНЯТИ</p>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ p {
row-gap: 1rem;
}
.hidden {
display: none!important;
display: none !important;
}
}

Expand Down
Loading