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

#791 #1027

Merged
merged 24 commits into from
Apr 19, 2022
Merged

#791 #1027

Show file tree
Hide file tree
Changes from 15 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
<mat-icon>edit</mat-icon>
</button>
</a>
<div class="del-icon" (click)="onDelete()" >
<button mat-button class="del-button">
<mat-icon>delete</mat-icon>
</button>
</div>
</ng-container>

<div class="details">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
color: #3849F9;
text-align: center;
text-decoration: none;
a {
a span{
display: flex;
justify-content: center;
align-items: center;
Expand All @@ -40,7 +40,24 @@
.config_edit-icon {
position: absolute;
top: 12px;
right: 16px;
right: 32px;
z-index: 2;
color : #3849F9;
.mat-icon {
font-size: 16px;
width: 16px;
height: 16px;
}
.mat-button {
padding: 0px;
min-width:auto;
line-height: 16px;
}
}
.del-icon {
position: absolute;
top: 12px;
right: 12px;
z-index: 2;
color : #3849F9;
.mat-icon {
Expand All @@ -57,4 +74,4 @@

.config-support p {
margin: 0;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input, OnInit } from '@angular/core';
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { Store } from '@ngxs/store';
import { CategoryIcons } from '../../enum/category-icons';
import { Direction } from '../../models/category.model';
Expand All @@ -14,6 +14,7 @@ export class CategoryCardComponent implements OnInit {
@Input() isEditMode: boolean;
@Input() direction: Direction;
@Input() icons: {};
@Output() deleteDirection = new EventEmitter<Direction>();
public categoryIcons = CategoryIcons;

constructor(private store: Store) {
Expand All @@ -22,6 +23,10 @@ export class CategoryCardComponent implements OnInit {
ngOnInit(): void {
Copy link
Contributor

Choose a reason for hiding this comment

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

you can delete it as well

}

onDelete(): void {
this.deleteDirection.emit(this.direction);
}

selectDirection(direction: Direction): void {
this.store.dispatch(new SetDirections([direction]));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
</mat-grid-tile>
</mat-grid-list>
</div>
</form>
</form>
4 changes: 3 additions & 1 deletion src/app/shared/components/paginator/paginator.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export class PaginatorComponent implements OnInit, OnChanges {

@Input() currentPage: PaginationElement;
@Input() totalEntities: number;
@Input() totalEntitiesDir: number;
Copy link
Contributor

Choose a reason for hiding this comment

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

use the same input ad it was before totalEntities
there is no sense in the new one


@Output() pageChange = new EventEmitter<PaginationElement>();

carouselPageList: PaginationElement[] = [];
Expand Down Expand Up @@ -57,7 +59,7 @@ export class PaginatorComponent implements OnInit, OnChanges {
}

private getTotalPageAmount(): number {
return Math.ceil(this.totalEntities / Constants.ITEMS_PER_PAGE);
return Math.ceil(this.totalEntities / Constants.ITEMS_PER_PAGE) || Math.ceil(this.totalEntitiesDir / Constants.ITEMS_PER_PAGE_DIR);
Copy link
Contributor

Choose a reason for hiding this comment

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

just as an idea, maybe for getTotalPageAmount method will be good to receive from parent component flag like isDirections and then check and if yes use Constants.ITEMS_PER_PAGE_DIR

}

private createDisplayedPageList(): PaginationElement[] {
Expand Down
5 changes: 3 additions & 2 deletions src/app/shared/constants/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Input } from '@angular/core';
import { MatDateFormats } from '@angular/material/core';
import { WorkingDays } from '../enum/enumUA/working-hours';
import { City } from '../models/city.model';
Expand Down Expand Up @@ -25,7 +26,7 @@ export class Constants {
static readonly PHONE_PREFIX = '+380';
static readonly PROVIDER_ENTITY_TYPE = 1;
static readonly WORKSHOP_ENTITY_TYPE = 2;

static readonly ITEMS_PER_PAGE_DIR =10;
static readonly ITEMS_PER_PAGE = 2 * Math.floor(window.innerWidth / (332));
Copy link
Contributor

Choose a reason for hiding this comment

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

what do you think is it make sense to use the same approach as with ITEMS_PER_PAGE constant? I mean "2 * Math.floor(window.innerWidth / (332))"


static readonly RATE_ONE_STAR = 1;
Expand Down Expand Up @@ -106,4 +107,4 @@ export const WorkingDaysValues: WorkingDaysToggleValue[] = [

export class NotificationsConstants {
static readonly NO_MESSAGE = 'У вас немає нових повідомлень';
}
}
15 changes: 14 additions & 1 deletion src/app/shared/enum/modal-confirmation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
export enum ModalConfirmationType {
delete = 'delete',

Copy link
Contributor

Choose a reason for hiding this comment

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

remove empty line

deleteDirection = 'deleteDirection',
deleteTeacher = 'deleteTeacher',
deleteProviderAdmin = 'deleteProviderAdmin',
deleteProviderAdminDeputy = 'deleteProviderAdminDeputy',
Expand All @@ -12,11 +14,18 @@ export enum ModalConfirmationType {
createApplication = 'createApplication',
approveApplication = 'approveApplication',
rejectApplication = 'rejectApplication',
createDirection = 'createDirection',
createDepartment = 'createDepartment',
createClass = 'createClass',
createProviderAdmin = 'createProviderAdmin',
createProviderAdminDeputy = 'createProviderAdminDeputy',
}
export enum ModalConfirmationTitle {
delete = 'ВИДАЛИТИ ГУРТОК',
delete = 'ВИДАЛИТИ ГУРТОК?',
deleteDirection = 'ВИДАЛИТИ НАПРЯМОК?',
createDirection = 'CТВОРИТИ НАПРЯМОК?',
createDepartment = 'CТВОРИТИ ВІДДІЛЕННЯ?',
createClass = 'CТВОРИТИ КЛАС?',
deleteChild = 'ВИЛУЧИТИ ДАНІ ПРО ДИТИНУ?',
deleteTeacher = 'ВИЛУЧИТИ ДАНІ ПРО ВЧИТЕЛЯ',
deleteProviderAdmin = 'ВИДАЛИТИ АДМІНІСТРАТОРА ГУРТКА',
Expand All @@ -34,6 +43,10 @@ export enum ModalConfirmationTitle {

export enum ModalConfirmationText {
delete = 'Ви впевнені, що хочете видалити гурток',
deleteDirection = 'Ви впевнені, що хочете видалити напрямок',
createDirection = 'Ви впевнені, що хочете створити напрямок?',
createDepartment = 'Ви впевнені, що хочете створити відділення?',
createClass = 'Ви впевнені, що хочете створити клас?',
deleteChild = 'Ви впевнені, що хочете вилучити дані про дитину',
deleteTeacher = 'Ви впевнені, що хочете вилучити дані про вчителя ?',
deleteProviderAdmin = 'Ви впевнені, що хочете видалити адміністратора гуртка',
Expand Down
1 change: 1 addition & 0 deletions src/app/shared/enum/navigation-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export enum NavBarName {
EditInformationAboutChild = 'Редагувати дані про дитину',
EditInstitutions = 'Редагувати заклад',
EditInformationAbout = 'Редагування особистої інформації',
EditDirection = 'Редагування напрямку',
Platform = 'Портал',
NewWorkshop = 'Новий гурток',
EditWorkshop = 'Редагування гуртка',
Expand Down
3 changes: 2 additions & 1 deletion src/app/shared/enum/no-results.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export enum NoResultsTitle {
noApplication = 'Заявок поки немає',
noResultWorkshops = 'За результатами нічого не знайдено',
noParentWorkshops = 'Тут буде відображатися інформація про гуртки, секцію або школу для навчання. Ще жодної заяви на гурток не подано.',
noParentWorkshops = 'Тут буде відображатися інформація про гуртки, секцію фбо школу для навчання. Ще жодної заяви на гурток не подано.',
Copy link
Contributor

Choose a reason for hiding this comment

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

mistake

noFavoriteWorkshops = 'Улюблених гуртків поки немає',
noDirections = 'За результатами нічого не знайдено',
noProviderAdmins = 'Користувачів поки немає',
}
5 changes: 5 additions & 0 deletions src/app/shared/enum/provider-admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@ export enum ProviderAdminIcons {
Accepted = 'fas fa-user-check',
Blocked = 'fas fa-user-times',
}
export enum createDirectionSteps {
'direction',
'department',
'class'
}
1 change: 1 addition & 0 deletions src/app/shared/enum/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ export enum createProviderSteps {
'contacts',
'description'
}

35 changes: 31 additions & 4 deletions src/app/shared/models/category.model.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,45 @@
export interface Direction {
export class Direction {
id: number;
title: string;
description: string;

constructor(info, id?) {
this.id = id;
this.title = info.title;
this.description = info.title;

Copy link
Contributor

Choose a reason for hiding this comment

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

empty line

}
}
export interface Department {

export class Department {
id: number;
directionId: number;
title: string;
description: string;

constructor(info, directionId, id?) {
this.id = id;
this.directionId = directionId;
this.title = info.title;
this.description = info.title;
}
}

export interface IClass {
export class IClass {
id: number;
departmentId: number;
title: string;
description: string;
departmentId: number;

constructor(info, departmentId, id?) {
this.id = id,
this.departmentId = departmentId,
this.title = info.title,
this.description = info.title
}
}

export interface DirectionsFilter {
totalAmount: number;
entities: Direction[];
}
49 changes: 46 additions & 3 deletions src/app/shared/services/categories/categories.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { HttpClient } from '@angular/common/http';
import { HttpClient, HttpParams } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { IClass, Department, Direction } from '../../models/category.model';
import { Constants } from '../../constants/constants';
import { IClass, Department, Direction, DirectionsFilter } from '../../models/category.model';
import { AdminStateModel } from '../../store/admin.state';

@Injectable({
providedIn: 'root'
Expand All @@ -10,19 +12,60 @@ export class CategoriesService {

constructor(private http: HttpClient) { }

private setParams(filters: AdminStateModel): HttpParams {
let params = new HttpParams();

if (filters.searchQuery) {
params = params.set('Name', filters.searchQuery);
}

if (filters.currentPage) {
const size: number = Constants.ITEMS_PER_PAGE_DIR;
const from: number = size * (+filters.currentPage.element - 1);

params = params.set('Size', size.toString());
params = params.set('From', from.toString());
}
return params;
}

getFilteredDirections(filters: AdminStateModel): Observable<DirectionsFilter> {
const options = { params: this.setParams(filters) };
return this.http.get<DirectionsFilter>('/api/v1/Direction/GetByFilter', options);
}

getDirections(): Observable<Direction[]> {
return this.http.get<Direction[]>('/api/v1/Direction/Get');
}

getTopDirections(): Observable<Direction[]> {
return this.http.get<Direction[]>(`/api/v1/Statistic/GetDirections`);
}
createDirection(direction: Direction): Observable<Direction> {
return this.http.post<Direction>('/api/v1/Direction/Create', direction);
}
createDepartment(department: Department): Observable<Department> {
return this.http.post<Department>('/api/v1/Department/Create', department);
}
updateDirection(direction: Direction): Observable<object> {
return this.http.put('/api/v1/Direction/Update', direction);
}
deleteDirection(id: number): Observable<object> {
return this.http.delete(`/api/v1/Direction/Delete/${id}`);
}

getDepartmentsBytDirectionId(id: number): Observable<Department[]> {
getDepartmentsByDirectionId(id: number): Observable<Department[]> {
return this.http.get<Department[]>(`/api/v1/Department/GetByDirectionId/${id}`);
}

getClassByDepartmentId(id: number): Observable<IClass[]> {
return this.http.get<IClass[]>(`/api/v1/Class/GetByDepartmentId/${id}`);
}

getDirectionById(id: number): Observable<Direction> {
return this.http.get<Direction>(`/api/v1/Direction/GetById/${id}`);
}
createClass(classes: IClass[]): Observable<IClass[]> {
return this.http.post<IClass[]>('/api/v1/Class/CreateMultiple', classes);
}
}
Loading