Changeset 32cd040
- Timestamp:
- 10/27/21 21:37:43 (3 years ago)
- Branches:
- dev
- Children:
- 15a34a3
- Parents:
- c205cc4
- Location:
- src/Clients/Angular/finki-chattery/src/app
- Files:
-
- 4 added
- 5 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
src/Clients/Angular/finki-chattery/src/app/core/guards/authorized-student.guard.ts
rc205cc4 r32cd040 1 1 import { Injectable } from '@angular/core'; 2 2 import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; 3 import { ApplicationUserType } from 'src/app/shared-app/models';4 3 import { AuthService } from '../services'; 5 4 … … 11 10 12 11 canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean { 13 return this.auth. user?.userType === ApplicationUserType.Student;12 return this.auth.isStudent(); 14 13 } 15 14 } -
src/Clients/Angular/finki-chattery/src/app/modules/questioning/components/ask-question/ask-question.component.html
rc205cc4 r32cd040 1 <form class="example-container" [formGroup]="questionFormGroup"> 2 <mat-form-field class="full-width margin-bottom-sm" appearance="fill" appHandleInputFormErrors> 3 <mat-label>{{ 'ask-question-question-title' | translate }}</mat-label> 4 <input matInput [formControl]="titleForm" /> 5 </mat-form-field> 6 7 <editor 8 matInput 9 class="margin-bottom-sm" 10 [formControl]="textForm" 11 [init]="{ 12 apiKey: 'fx28x0d64jeufa35u7mcd80fgveayg5c4ap9gnr6posehzny', 13 menubar: false, 14 plugins: [ 15 'advlist autolink lists link image charmap print preview anchor', 16 'searchreplace visualblocks code fullscreen', 17 'insertdatetime media table paste code help wordcount' 18 ], 19 toolbar: 20 'undo redo | formatselect | bold italic backcolor | code | \ 21 alignleft aligncenter alignright alignjustify | \ 22 bullist numlist outdent indent | removeformat | help' 23 }" 24 ></editor> 25 <mat-error *ngIf="textForm?.touched && textForm?.errors?.required">{{ 'not-found' | translate }}</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> 29 30 <mat-form-field class="full-width margin-bottom-sm" appearance="fill" appHandleInputFormErrors> 31 <mat-label>{{ 'ask-question-categories' | translate }}</mat-label> 32 <mat-select [formControl]="categoriesForm" multiple> 33 <mat-option *ngFor="let category of categoriesList$ | async" [value]="category.uid">{{ category.translatedName }}</mat-option> 34 </mat-select> 35 </mat-form-field> 36 37 <app-button [disabled]="questionFormGroup.invalid" [buttonType]="ButtonType.CallToAction" (action)="askQuestion()"> 38 {{ 'ask-question-ask-button' | translate }} 39 </app-button> 40 </form> 1 <app-ask-question-shared (askQuestion)="askQuestionAsStudent($event)"></app-ask-question-shared> -
src/Clients/Angular/finki-chattery/src/app/modules/questioning/components/ask-question/ask-question.component.ts
rc205cc4 r32cd040 1 1 import { Component, OnInit } from '@angular/core'; 2 import { FormControl, FormGroup, Validators } from '@angular/forms';3 2 import { Router } from '@angular/router'; 4 3 5 import { CategoryFacadeService } from 'src/app/core/state/category-facade.service'; 6 import { ButtonType } from 'src/app/shared-app/components/generic/button/button.models'; 7 import { AskQuestionRequest } from '../../models/questioning-request.models'; 4 import { AskQuestionRequest } from 'src/app/shared-app/models'; 8 5 import { QuestioningApiService } from '../../services/questioning-api.service'; 9 6 … … 14 11 }) 15 12 export class AskQuestionComponent implements OnInit { 16 public titleForm = new FormControl('', [Validators.required, Validators.maxLength(500)]); 17 public textForm = new FormControl('', [Validators.required, Validators.maxLength(4000)]); 18 public categoriesForm = new FormControl([]); 19 public questionFormGroup: FormGroup; 20 public ButtonType = ButtonType; 21 public categoriesList$ = this.categoriesFacade.getCategories(); 22 23 constructor(private api: QuestioningApiService, private categoriesFacade: CategoryFacadeService, private router: Router) { 24 this.questionFormGroup = new FormGroup({ 25 title: this.titleForm, 26 text: this.textForm, 27 categories: this.categoriesForm 28 }); 29 } 13 constructor(private api: QuestioningApiService, private router: Router) {} 30 14 31 15 ngOnInit(): void {} 32 16 33 public askQuestion(): void { 34 const body = new AskQuestionRequest(this.titleForm.value, this.textForm.value, this.categoriesForm.value); 17 public askQuestionAsStudent(body: AskQuestionRequest): void { 35 18 this.api.askQuestion(body).subscribe((questionUid) => { 36 19 this.router.navigateByUrl(`questioning/${questionUid}`); -
src/Clients/Angular/finki-chattery/src/app/shared-app/components/components.ts
rc205cc4 r32cd040 4 4 import { HeaderComponent } from './generic/header/header.component'; 5 5 import { VoteComponent } from './generic/vote/vote.component'; 6 import { AskQuestionSharedComponent } from './question/ask-question-shared/ask-question-shared.component'; 6 7 import { PreviewQuestionDisplayComponent } from './question/preview-question-display/preview-question-display.component'; 7 8 import { QuestionPreviewComponent } from './question/question-preview/question-preview.component'; … … 18 19 HeaderComponent, 19 20 SearchQuestionComponent, 20 PreviewQuestionDisplayComponent 21 PreviewQuestionDisplayComponent, 22 AskQuestionSharedComponent 21 23 ]; -
src/Clients/Angular/finki-chattery/src/app/shared-app/models/index.ts
rc205cc4 r32cd040 4 4 export * from './category-state-view-models.models'; 5 5 export * from './question-state-enums.models'; 6 export * from './questioning-request.models';
Note:
See TracChangeset
for help on using the changeset viewer.