source: src/Clients/Angular/finki-chattery/src/app/shared-app/components/question/ask-question-shared/ask-question-shared.component.ts@ 32cd040

dev
Last change on this file since 32cd040 was 32cd040, checked in by Стојков Марко <mst@…>, 3 years ago

Added generic component for asking questions

  • Property mode set to 100644
File size: 1.5 KB
Line 
1import { Component, EventEmitter, OnInit, Output } from '@angular/core';
2import { FormControl, FormGroup, Validators } from '@angular/forms';
3import { Router } from '@angular/router';
4
5import { CategoryFacadeService } from 'src/app/core/state/category-facade.service';
6import { ButtonType } from 'src/app/shared-app/components/generic/button/button.models';
7import { AskQuestionRequest } from 'src/app/shared-app/models';
8
9@Component({
10 selector: 'app-ask-question-shared',
11 templateUrl: './ask-question-shared.component.html',
12 styleUrls: ['./ask-question-shared.component.scss']
13})
14export class AskQuestionSharedComponent implements OnInit {
15 @Output() askQuestion = new EventEmitter<AskQuestionRequest>();
16
17 public titleForm = new FormControl('', [Validators.required, Validators.maxLength(500)]);
18 public textForm = new FormControl('', [Validators.required, Validators.maxLength(4000)]);
19 public categoriesForm = new FormControl([]);
20 public questionFormGroup: FormGroup;
21 public ButtonType = ButtonType;
22 public categoriesList$ = this.categoriesFacade.getCategories();
23
24 constructor(private categoriesFacade: CategoryFacadeService, private router: Router) {
25 this.questionFormGroup = new FormGroup({
26 title: this.titleForm,
27 text: this.textForm,
28 categories: this.categoriesForm
29 });
30 }
31
32 ngOnInit(): void {}
33
34 public askQuestionEmit(): void {
35 const body = new AskQuestionRequest(this.titleForm.value, this.textForm.value, this.categoriesForm.value);
36 this.askQuestion.emit(body);
37 }
38}
Note: See TracBrowser for help on using the repository browser.