- Timestamp:
- 10/27/21 21:29:11 (3 years ago)
- Branches:
- dev
- Children:
- 32cd040
- Parents:
- d2b1fa6
- Location:
- src/Clients/Angular/finki-chattery/src/app/modules/questioning
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Clients/Angular/finki-chattery/src/app/modules/questioning/components/ask-question/ask-question.component.html
rd2b1fa6 rc205cc4 1 1 <form class="example-container" [formGroup]="questionFormGroup"> 2 <mat-form-field class="full-width " appearance="standard" appHandleInputFormErrors>3 <mat-label> STAVI TRANSLATE</mat-label>2 <mat-form-field class="full-width margin-bottom-sm" appearance="fill" appHandleInputFormErrors> 3 <mat-label>{{ 'ask-question-question-title' | translate }}</mat-label> 4 4 <input matInput [formControl]="titleForm" /> 5 5 </mat-form-field> … … 7 7 <editor 8 8 matInput 9 class="margin-bottom-sm" 9 10 [formControl]="textForm" 10 11 [init]="{ 12 apiKey: 'fx28x0d64jeufa35u7mcd80fgveayg5c4ap9gnr6posehzny', 11 13 menubar: false, 12 14 plugins: [ … … 16 18 ], 17 19 toolbar: 18 'undo redo | formatselect | bold italic backcolor | \20 'undo redo | formatselect | bold italic backcolor | code | \ 19 21 alignleft aligncenter alignright alignjustify | \ 20 22 bullist numlist outdent indent | removeformat | help' … … 22 24 ></editor> 23 25 <mat-error *ngIf="textForm?.touched && textForm?.errors?.required">{{ 'not-found' | translate }}</mat-error> 24 <mat-error *ngIf="textForm?.touched && textForm?.errors?.maxlength">STAVI TRANSL ATE MAX LENGTH</mat-error> 26 <mat-error *ngIf="textForm?.touched && textForm?.errors?.maxlength">{{ 27 'error-message-max-length' | translate: { maxlength: textForm?.errors?.maxlength?.requiredLength } 28 }}</mat-error> 25 29 26 <mat-form-field class="full-width " appearance="standard" appHandleInputFormErrors>27 <mat-label> STAVI TRANSLATE</mat-label>30 <mat-form-field class="full-width margin-bottom-sm" appearance="fill" appHandleInputFormErrors> 31 <mat-label>{{ 'ask-question-categories' | translate }}</mat-label> 28 32 <mat-select [formControl]="categoriesForm" multiple> 29 <mat-option *ngFor="let category of categoriesList " [value]="category.uid">{{ category.name }}</mat-option>33 <mat-option *ngFor="let category of categoriesList$ | async" [value]="category.uid">{{ category.translatedName }}</mat-option> 30 34 </mat-select> 31 35 </mat-form-field> 32 36 33 37 <app-button [disabled]="questionFormGroup.invalid" [buttonType]="ButtonType.CallToAction" (action)="askQuestion()"> 34 {{ ' not-found' | translate }}38 {{ 'ask-question-ask-button' | translate }} 35 39 </app-button> 36 40 </form> -
src/Clients/Angular/finki-chattery/src/app/modules/questioning/components/ask-question/ask-question.component.scss
rd2b1fa6 rc205cc4 1 .full-width {2 width: 100%;3 } -
src/Clients/Angular/finki-chattery/src/app/modules/questioning/components/ask-question/ask-question.component.ts
rd2b1fa6 rc205cc4 1 1 import { Component, OnInit } from '@angular/core'; 2 2 import { FormControl, FormGroup, Validators } from '@angular/forms'; 3 import { Router } from '@angular/router'; 3 4 5 import { CategoryFacadeService } from 'src/app/core/state/category-facade.service'; 4 6 import { ButtonType } from 'src/app/shared-app/components/generic/button/button.models'; 5 import { CategoryViewModel } from 'src/app/shared-app/models';6 7 import { AskQuestionRequest } from '../../models/questioning-request.models'; 7 8 import { QuestioningApiService } from '../../services/questioning-api.service'; … … 16 17 public textForm = new FormControl('', [Validators.required, Validators.maxLength(4000)]); 17 18 public categoriesForm = new FormControl([]); 18 19 19 public questionFormGroup: FormGroup; 20 20 public ButtonType = ButtonType; 21 public categoriesList$ = this.categoriesFacade.getCategories(); 21 22 22 // TODO: PULL FROM ENDPOINT OR FROM STORE (BETTER FROM STORE) 23 public categoriesList: CategoryViewModel[] = [ 24 new CategoryViewModel('123', 'test'), 25 new CategoryViewModel('345', 'test 2'), 26 new CategoryViewModel('345', 'test 3'), 27 new CategoryViewModel('345', 'test 4'), 28 new CategoryViewModel('345', 'test 5') 29 ]; 30 31 constructor(private api: QuestioningApiService) { 23 constructor(private api: QuestioningApiService, private categoriesFacade: CategoryFacadeService, private router: Router) { 32 24 this.questionFormGroup = new FormGroup({ 33 25 title: this.titleForm, … … 41 33 public askQuestion(): void { 42 34 const body = new AskQuestionRequest(this.titleForm.value, this.textForm.value, this.categoriesForm.value); 43 this.api.askQuestion(body).subscribe(() => {}); 35 this.api.askQuestion(body).subscribe((questionUid) => { 36 this.router.navigateByUrl(`questioning/${questionUid}`); 37 }); 44 38 } 45 39 } -
src/Clients/Angular/finki-chattery/src/app/modules/questioning/components/questioning-general/questioning-general.component.ts
rd2b1fa6 rc205cc4 1 1 import { Component, OnInit } from '@angular/core'; 2 import { CategoryFacadeService } from 'src/app/core/state/category-facade.service'; 2 3 3 4 @Component({ … … 7 8 }) 8 9 export class QuestioningGeneralComponent implements OnInit { 9 constructor( ) {}10 constructor(private categoriesFacade: CategoryFacadeService) {} 10 11 11 ngOnInit(): void {} 12 ngOnInit(): void { 13 this.categoriesFacade.fetchCategories(); 14 } 12 15 } -
src/Clients/Angular/finki-chattery/src/app/modules/questioning/components/questions-preview-general/questions-preview-general.component.ts
rd2b1fa6 rc205cc4 17 17 questionsSortByForm = new FormControl(PreviewQuestionsOrderEnum.Latest); 18 18 19 constructor(private categoriesFacade: CategoryFacadeService, privatequestionFacade: QuestionFacadeService, private router: Router) {}19 constructor(private questionFacade: QuestionFacadeService, private router: Router) {} 20 20 21 21 ngOnInit(): void { 22 this.categoriesFacade.fetchCategories();23 22 this.questionFacade.fetchPreviewQuestions(PreviewQuestionsOrderEnum.Latest); 24 23 this.questionsSortByForm.valueChanges.subscribe((value: PreviewQuestionsOrderEnum) => { -
src/Clients/Angular/finki-chattery/src/app/modules/questioning/services/questioning-api.service.ts
rd2b1fa6 rc205cc4 13 13 } 14 14 15 askQuestion(body: AskQuestionRequest): Observable< void> {15 askQuestion(body: AskQuestionRequest): Observable<string> { 16 16 return this.post('v1/questions', body); 17 17 }
Note:
See TracChangeset
for help on using the changeset viewer.