-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/#156-configure-map-in-'create-act…
…ivity'
- Loading branch information
Showing
125 changed files
with
1,430 additions
and
748 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/app/shared/components/hobby-select/category-select.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<form> | ||
<!-- select reffers to selectedCategory object in component (selectedCategory.value === selected option) --> | ||
<mat-select class="custom-select" [formControl]="selectedCategory" name="category" (selectionChange)="handleCategorySelect($event.value)"> | ||
<mat-option value="">Оберіть напрямок</mat-option> | ||
<!-- reffers to direction field for options --> | ||
<mat-option *ngFor="let option of category" [value]="option"> | ||
{{ option }} | ||
</mat-option> | ||
</mat-select> | ||
<!-- select reffers to selectedSubcategory object in component (selectedSubcategory.value === selected option) --> | ||
<mat-select *ngIf="selectedCategory.value !== ''" class="custom-select" [formControl]="selectedSubcategory" name="subcategory" (selectionChange)="handleSubcategorySelect($event.value)"> | ||
<mat-option value="">Оберіть напрямок</mat-option> | ||
<!-- reffers to faculty field for options (will update after field change) --> | ||
<mat-option *ngFor="let option of subcategories" [value]="option"> | ||
{{ option }} | ||
</mat-option> | ||
</mat-select> | ||
<!-- select reffers to selectedStudy object in component (selectedStudy.value === selected option) --> | ||
<mat-select *ngIf="selectedSubcategory.value !== ''" class="custom-select" [formControl]="selectedStudy" name="study" (selectionChange)="handleStudySelect($event.value)"> | ||
<mat-option value="">Оберіть напрямок</mat-option> | ||
<!-- reffers to study field for options (will update after field change) --> | ||
<mat-option *ngFor="let option of study" [value]="option"> | ||
{{ option }} | ||
</mat-option> | ||
</mat-select> | ||
</form> |
File renamed without changes.
10 changes: 5 additions & 5 deletions
10
...bby-select/hobby-select.component.spec.ts → ...-select/category-select.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
src/app/shared/components/hobby-select/category-select.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import { Component, OnInit, Output, EventEmitter } from '@angular/core'; | ||
import { FormBuilder, FormControl, FormGroup } from '@angular/forms'; | ||
import { CategorySelect } from '../../models/category-select.model'; | ||
import { CategorySelectService } from '../../services/category-select/category-select.service'; | ||
|
||
@Component({ | ||
selector: 'app-category-select', | ||
templateUrl: './category-select.component.html', | ||
styleUrls: ['./category-select.component.scss'] | ||
}) | ||
export class CategorySelectComponent implements OnInit { | ||
@Output() categoriesSelect = new EventEmitter<FormGroup>(); | ||
//lists of options in dropdowns | ||
data: CategorySelect[] = []; | ||
category: object = {}; | ||
subcategories: string[] = []; | ||
study: string[] = []; | ||
selectedCategory = new FormControl(''); //contains current state (which direction was selected) | ||
selectedSubcategory = new FormControl(''); | ||
selectedStudy = new FormControl(''); | ||
CategoryFormGroup: FormGroup; | ||
|
||
constructor(private formBuilder: FormBuilder, private service: CategorySelectService) { | ||
this.CategoryFormGroup = this.formBuilder.group({ | ||
id: new FormControl(''), | ||
title: new FormControl(''), | ||
subcategories: [ | ||
{ | ||
id: new FormControl(''), | ||
title: new FormControl(''), | ||
study: [ | ||
{ | ||
id: new FormControl(''), | ||
title: new FormControl('') | ||
} | ||
] | ||
} | ||
] | ||
}); | ||
} | ||
|
||
ngOnInit(): void { | ||
this.service.getCategories().subscribe(categories => { | ||
this.data = categories; | ||
this.getCategories(this.data); | ||
}); | ||
|
||
this.categoriesSelect.emit(this.CategoryFormGroup); | ||
} | ||
|
||
getCategories(data: CategorySelect[]): void { | ||
this.category = data.map(el => el.title); | ||
} | ||
|
||
handleCategorySelect(value: string): void { | ||
//sets selected option in current "state" | ||
this.selectedCategory.setValue(value); | ||
//clears selected faculty and study (all dropdowns should be consistant) | ||
this.selectedSubcategory.setValue(''); | ||
this.selectedStudy.setValue(''); | ||
//finds faculties, related to selected direction | ||
const targetCategory = this.data.find(el => el.title === value); | ||
//creates list of options for 2d dropdown | ||
const subcategoriesList = targetCategory?.subcategories?.map(el => el.title); | ||
//sets list of options in this.faculty | ||
this.subcategories = subcategoriesList; | ||
//sets output data | ||
this.CategoryFormGroup.get('title').setValue(value); | ||
this.CategoryFormGroup.get('id').setValue(targetCategory?.id); | ||
this.CategoryFormGroup.get('subcategories').setValue([{ | ||
id: null, | ||
title: null, | ||
study: [{ | ||
id: null, | ||
title: null | ||
}] | ||
}]); | ||
} | ||
|
||
handleSubcategorySelect(value: string): void { | ||
//the same logic as for handleDirectionSelect | ||
this.selectedSubcategory.setValue(value); | ||
this.selectedStudy.setValue(''); | ||
const targetCategory = this.data.find(el => el.title === this.selectedCategory.value); | ||
const targetSubcategory = targetCategory?.subcategories?.find(el => el.title === value); | ||
const studyList = targetSubcategory?.study; | ||
this.study = studyList?.map(el => el.title); | ||
//sets output data | ||
this.CategoryFormGroup.get('subcategories').setValue([{ | ||
id: targetSubcategory?.id, | ||
title: value, | ||
study: [{ | ||
id: null, | ||
title: null | ||
}] | ||
}]); | ||
} | ||
|
||
handleStudySelect(value: string): void { | ||
this.selectedStudy.setValue(value); | ||
const targetCategory = this.data.find(el => el.title === this.selectedCategory.value); | ||
const targetSubcategory = targetCategory?.subcategories.find(el => el.title === this.selectedSubcategory.value); | ||
const targetStudy = targetSubcategory?.study.find(el => el.title === value); | ||
//sets output data | ||
this.CategoryFormGroup.get('subcategories').setValue([{ | ||
id: targetSubcategory?.id, | ||
title: targetSubcategory.title, | ||
study: [ | ||
{ | ||
id: targetStudy?.id, | ||
title: value, | ||
} | ||
] | ||
}]); | ||
} | ||
} |
26 changes: 0 additions & 26 deletions
26
src/app/shared/components/hobby-select/hobby-select.component.html
This file was deleted.
Oops, something went wrong.
63 changes: 0 additions & 63 deletions
63
src/app/shared/components/hobby-select/hobby-select.component.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
src/app/shared/components/organization-card/organization-card.component.spec.ts
This file was deleted.
Oops, something went wrong.
File renamed without changes.
Oops, something went wrong.