From f7b87d3b7fb80fda846ac78777ca46ba2495d1b3 Mon Sep 17 00:00:00 2001 From: Max Dvorak Date: Tue, 27 Aug 2024 15:10:54 +0300 Subject: [PATCH 1/2] first commit --- .../tag-workshop/tag-workshop.service.spec.ts | 16 +++++++++++ .../tag-workshop/tag-workshop.service.ts | 23 ++++++++++++++++ .../create-description-form.component.html | 27 +++++++++++++++++++ .../create-description-form.component.scss | 9 +++++++ .../create-description-form.component.ts | 23 +++++++++++++++- 5 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 src/app/shared/services/workshops/tag-workshop/tag-workshop.service.spec.ts create mode 100644 src/app/shared/services/workshops/tag-workshop/tag-workshop.service.ts diff --git a/src/app/shared/services/workshops/tag-workshop/tag-workshop.service.spec.ts b/src/app/shared/services/workshops/tag-workshop/tag-workshop.service.spec.ts new file mode 100644 index 0000000000..23e7653853 --- /dev/null +++ b/src/app/shared/services/workshops/tag-workshop/tag-workshop.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { TagService } from './tag-workshop.service'; + +describe('DirectionService', () => { + let service: TagService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(TagService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/shared/services/workshops/tag-workshop/tag-workshop.service.ts b/src/app/shared/services/workshops/tag-workshop/tag-workshop.service.ts new file mode 100644 index 0000000000..f6244df38d --- /dev/null +++ b/src/app/shared/services/workshops/tag-workshop/tag-workshop.service.ts @@ -0,0 +1,23 @@ +import { Injectable } from '@angular/core'; +import { Direction } from '../../../../shared/models/category.model'; // Шлях до моделі + +@Injectable({ + providedIn: 'root' +}) +export class TagService { + constructor() {} + + getDirections(): Direction[] { + return [ + { id: 1, title: 'Спорт', description: 'Фізичні активності та види спорту' }, + { id: 2, title: "Комп'ютери", description: 'Інформаційні технології та програмування' }, + { id: 3, title: 'Розваги', description: 'Ігри, музика, танці та інші розваги' }, + { id: 4, title: 'Наука', description: 'Наукові дисципліни та дослідження' }, + { id: 5, title: 'Фільми', description: 'Кіномистецтво та відеопродукція' }, + { id: 6, title: 'Діти', description: 'Заняття для дітей дошкільного та молодшого віку' }, + { id: 7, title: 'Підлітки', description: 'Заняття для підлітків середнього шкільного віку' }, + { id: 8, title: 'Молодь', description: 'Заняття для молоді та студентів' }, + { id: 9, title: 'Пенсіонери', description: 'Гуртки для пенсійного фонду' } + ]; + } +} diff --git a/src/app/shell/personal-cabinet/provider/create-workshop/create-description-form/create-description-form.component.html b/src/app/shell/personal-cabinet/provider/create-workshop/create-description-form/create-description-form.component.html index 70c304e5c8..a0e543e9a6 100644 --- a/src/app/shell/personal-cabinet/provider/create-workshop/create-description-form/create-description-form.component.html +++ b/src/app/shell/personal-cabinet/provider/create-workshop/create-description-form/create-description-form.component.html @@ -51,6 +51,33 @@ [provider]="provider"> + + + + + + + + + {{ direction.title }} + cancel + + + + + {{ direction.title }} + + + + +
diff --git a/src/app/shell/personal-cabinet/provider/create-workshop/create-description-form/create-description-form.component.scss b/src/app/shell/personal-cabinet/provider/create-workshop/create-description-form/create-description-form.component.scss index 756b62197e..73d1aaca96 100644 --- a/src/app/shell/personal-cabinet/provider/create-workshop/create-description-form/create-description-form.component.scss +++ b/src/app/shell/personal-cabinet/provider/create-workshop/create-description-form/create-description-form.component.scss @@ -26,3 +26,12 @@ position: absolute; top: 5px; } + +.min-logo { + width: 20px; + height: 20px; +} + +.list-of-tags { + margin: 10px 0 0 0; +} diff --git a/src/app/shell/personal-cabinet/provider/create-workshop/create-description-form/create-description-form.component.ts b/src/app/shell/personal-cabinet/provider/create-workshop/create-description-form/create-description-form.component.ts index 9d77878fd9..8aba7c8f73 100644 --- a/src/app/shell/personal-cabinet/provider/create-workshop/create-description-form/create-description-form.component.ts +++ b/src/app/shell/personal-cabinet/provider/create-workshop/create-description-form/create-description-form.component.ts @@ -4,10 +4,12 @@ import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; import { CropperConfigurationConstants } from 'shared/constants/constants'; +import { Direction } from '../../../../../shared/models/category.model'; import { MUST_CONTAIN_LETTERS } from 'shared/constants/regex-constants'; import { ValidationConstants } from 'shared/constants/validation'; import { Provider } from 'shared/models/provider.model'; import { Workshop, WorkshopDescriptionItem } from 'shared/models/workshop.model'; +import { TagService } from 'shared/services/workshops/tag-workshop/tag-workshop.service'; @Component({ selector: 'app-create-description-form', @@ -42,13 +44,30 @@ export class CreateDescriptionFormComponent implements OnInit, OnDestroy { public keyWords: string[] = []; public keyWord: string; + public directions: Direction[] = []; public disabilityOptionRadioBtn: FormControl = new FormControl(false); public disabledKeyWordsInput = false; + public directionsControl: FormControl = new FormControl([]); + + public compareItems(item1: Direction, item2: Direction): boolean { + return item1.id === item2.id; + } + + public onRemoveItem(direction: Direction): void { + const index = this.directionsControl.value.indexOf(direction); + if (index >= 0) { + this.directionsControl.value.splice(index, 1); + } + } + private destroy$: Subject = new Subject(); - constructor(private formBuilder: FormBuilder) { + constructor( + private formBuilder: FormBuilder, + private tagService: TagService + ) { this.DescriptionFormGroup = this.formBuilder.group({ imageFiles: new FormControl(''), imageIds: new FormControl(''), @@ -72,6 +91,8 @@ export class CreateDescriptionFormComponent implements OnInit, OnDestroy { this.onAddForm(); } + this.directions = this.tagService.getDirections(); + this.passDescriptionFormGroup.emit(this.DescriptionFormGroup); this.keyWordsListener(); } From 895d3dd0dc60abcba71efcec9b4e275150f8f78e Mon Sep 17 00:00:00 2001 From: Max Dvorak Date: Mon, 18 Nov 2024 19:25:12 +0200 Subject: [PATCH 2/2] Tags added to the container --- src/app/shared/models/tag.model.ts | 4 +++ .../tag-workshop/tag-workshop.service.ts | 25 ++++++++----------- .../create-description-form.component.html | 12 ++++----- .../create-description-form.component.ts | 22 ++++++++++------ src/assets/i18n/en.json | 1 + src/assets/i18n/uk.json | 1 + src/environments/environment.ts | 4 +-- 7 files changed, 40 insertions(+), 29 deletions(-) create mode 100644 src/app/shared/models/tag.model.ts diff --git a/src/app/shared/models/tag.model.ts b/src/app/shared/models/tag.model.ts new file mode 100644 index 0000000000..58d1707ecd --- /dev/null +++ b/src/app/shared/models/tag.model.ts @@ -0,0 +1,4 @@ +export interface Tag { + id: string; + name: string; +} diff --git a/src/app/shared/services/workshops/tag-workshop/tag-workshop.service.ts b/src/app/shared/services/workshops/tag-workshop/tag-workshop.service.ts index f6244df38d..74a59258f2 100644 --- a/src/app/shared/services/workshops/tag-workshop/tag-workshop.service.ts +++ b/src/app/shared/services/workshops/tag-workshop/tag-workshop.service.ts @@ -1,23 +1,20 @@ import { Injectable } from '@angular/core'; -import { Direction } from '../../../../shared/models/category.model'; // Шлях до моделі +import { HttpClient } from '@angular/common/http'; +import { Observable } from 'rxjs'; +import { Tag } from 'shared/models/tag.model'; +import { Util } from 'shared/utils/utils'; @Injectable({ providedIn: 'root' }) export class TagService { - constructor() {} + constructor(private http: HttpClient) {} - getDirections(): Direction[] { - return [ - { id: 1, title: 'Спорт', description: 'Фізичні активності та види спорту' }, - { id: 2, title: "Комп'ютери", description: 'Інформаційні технології та програмування' }, - { id: 3, title: 'Розваги', description: 'Ігри, музика, танці та інші розваги' }, - { id: 4, title: 'Наука', description: 'Наукові дисципліни та дослідження' }, - { id: 5, title: 'Фільми', description: 'Кіномистецтво та відеопродукція' }, - { id: 6, title: 'Діти', description: 'Заняття для дітей дошкільного та молодшого віку' }, - { id: 7, title: 'Підлітки', description: 'Заняття для підлітків середнього шкільного віку' }, - { id: 8, title: 'Молодь', description: 'Заняття для молоді та студентів' }, - { id: 9, title: 'Пенсіонери', description: 'Гуртки для пенсійного фонду' } - ]; + getDirections(): Observable { + return this.http.get('/api/v1/Tag/Get', { + params: { + localization: Util.getCurrentLocalization() + } + }); } } diff --git a/src/app/shell/personal-cabinet/provider/create-workshop/create-description-form/create-description-form.component.html b/src/app/shell/personal-cabinet/provider/create-workshop/create-description-form/create-description-form.component.html index a0e543e9a6..ea6facae23 100644 --- a/src/app/shell/personal-cabinet/provider/create-workshop/create-description-form/create-description-form.component.html +++ b/src/app/shell/personal-cabinet/provider/create-workshop/create-description-form/create-description-form.component.html @@ -53,7 +53,7 @@ - + + [formControl]="tagsControl"> - + - {{ direction.title }} + {{ tag.name }} cancel - - {{ direction.title }} + + {{ tag.name }} diff --git a/src/app/shell/personal-cabinet/provider/create-workshop/create-description-form/create-description-form.component.ts b/src/app/shell/personal-cabinet/provider/create-workshop/create-description-form/create-description-form.component.ts index 8aba7c8f73..4169ae809f 100644 --- a/src/app/shell/personal-cabinet/provider/create-workshop/create-description-form/create-description-form.component.ts +++ b/src/app/shell/personal-cabinet/provider/create-workshop/create-description-form/create-description-form.component.ts @@ -1,15 +1,18 @@ import { Component, ElementRef, EventEmitter, Input, OnDestroy, OnInit, Output, ViewChild } from '@angular/core'; import { FormArray, FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; -import { Subject } from 'rxjs'; -import { takeUntil } from 'rxjs/operators'; +import { Observable, Subject } from 'rxjs'; +import { take, takeUntil } from 'rxjs/operators'; import { CropperConfigurationConstants } from 'shared/constants/constants'; import { Direction } from '../../../../../shared/models/category.model'; import { MUST_CONTAIN_LETTERS } from 'shared/constants/regex-constants'; import { ValidationConstants } from 'shared/constants/validation'; +import { Select } from '@ngxs/store'; import { Provider } from 'shared/models/provider.model'; import { Workshop, WorkshopDescriptionItem } from 'shared/models/workshop.model'; import { TagService } from 'shared/services/workshops/tag-workshop/tag-workshop.service'; +import { MetaDataState } from '../../../../../shared/store/meta-data.state'; +import { Tag } from 'shared/models/tag.model'; @Component({ selector: 'app-create-description-form', @@ -44,21 +47,21 @@ export class CreateDescriptionFormComponent implements OnInit, OnDestroy { public keyWords: string[] = []; public keyWord: string; - public directions: Direction[] = []; + public tags: Tag[] = []; public disabilityOptionRadioBtn: FormControl = new FormControl(false); public disabledKeyWordsInput = false; - public directionsControl: FormControl = new FormControl([]); + public tagsControl: FormControl = new FormControl([]); public compareItems(item1: Direction, item2: Direction): boolean { return item1.id === item2.id; } public onRemoveItem(direction: Direction): void { - const index = this.directionsControl.value.indexOf(direction); + const index = this.tagsControl.value.indexOf(direction); if (index >= 0) { - this.directionsControl.value.splice(index, 1); + this.tagsControl.value.splice(index, 1); } } @@ -91,7 +94,12 @@ export class CreateDescriptionFormComponent implements OnInit, OnDestroy { this.onAddForm(); } - this.directions = this.tagService.getDirections(); + this.tagService + .getDirections() + .pipe(take(1)) + .subscribe((tags) => { + this.tags = tags; + }); this.passDescriptionFormGroup.emit(this.DescriptionFormGroup); this.keyWordsListener(); diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index eaa714ce06..2565783da4 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -406,6 +406,7 @@ "REGION": "Region", "MINISTRY_SUBMISSION": "Ministry of submission", "USER_DIRECTIONS": "Directions for user", + "USER_TAGS": "Tags", "TERRITORIAL_COMMUNITY": "Territorial community", "SHORT_TITLE": "Short title" }, diff --git a/src/assets/i18n/uk.json b/src/assets/i18n/uk.json index 858d156bcf..f36e3921dc 100644 --- a/src/assets/i18n/uk.json +++ b/src/assets/i18n/uk.json @@ -406,6 +406,7 @@ "REGION": "Область", "MINISTRY_SUBMISSION": "Підпорядкування (Міністерство)", "USER_DIRECTIONS": "Напрямки для користувача", + "USER_TAGS": "Теги", "TERRITORIAL_COMMUNITY": "Територіальна громада", "SHORT_TITLE": "Скорочена назва" }, diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 8750a762e2..e96ad4782b 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -4,8 +4,8 @@ // The list of file replacements can be found in `angular.json`. export const environment = { production: false, - stsServer: 'https://auth.oos.dmytrominochkin.cloud', - serverUrl: 'https://api.oos.dmytrominochkin.cloud', + stsServer: 'https://pozashkillia-test.iea.gov.ua/auth', + serverUrl: 'https://pozashkillia-test.iea.gov.ua/web', storageUrl: 'https://storage.googleapis.com/oos-images-63325/' }; /*