Changes in / [74ad056:7e7cc4c]


Ignore:
Location:
src/Clients/Angular/finki-chattery/src
Files:
4 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • src/Clients/Angular/finki-chattery/src/app/core/state/question-facade.service.ts

    r74ad056 r7e7cc4c  
    1414import { AuthService } from '../services';
    1515import {
    16   AnswerQuestion,
    1716  EffectStartedWorking,
    1817  GetPreviewQuestionsLatest,
     
    10099  }
    101100
    102   public answerQuestion(questionUid: string, text: string): void {
    103     this.dispatchEffect(new AnswerQuestion(questionUid, text));
    104   }
    105 
    106101  private fetchPreviewQuestionsLatest(): void {
    107102    this.dispatchEffect(new GetPreviewQuestionsLatest());
  • src/Clients/Angular/finki-chattery/src/app/core/state/question-state/question-state-request.models.ts

    r74ad056 r7e7cc4c  
    88  constructor(public text: string) {}
    99}
    10 
    11 export class AnswerQuestionRequest {
    12   constructor(public text: string) {}
    13 }
  • src/Clients/Angular/finki-chattery/src/app/core/state/question-state/question.actions.ts

    r74ad056 r7e7cc4c  
    33
    44import {
    5   AnswerQuestionStateViewModel,
    65  AnswerResponseQuestionStateViewModel,
    76  PreviewQuestionViewModel,
     
    2726  VoteAnswer = '[Question] Vote answer',
    2827  VoteAnswerSuccess = '[Question] Vote answer Success',
    29   AnswerQuestion = '[Question] AnswerQuestion',
    30   AnswerQuestionSuccess = '[Question] AnswerQuestion Success',
    3128  EffectStartedWorking = '[Question] Effect Started Working',
    3229  EffectFinishedWorking = '[Question] Effect Finished Working',
    3330  EffectFinishedWorkingError = '[Question] Effect Finished Working error'
    34 }
    35 
    36 export class AnswerQuestion implements Action {
    37   readonly type = QuestionActionTypes.AnswerQuestion;
    38 
    39   constructor(public questionUid: string, public text: string) {}
    40 }
    41 
    42 export class AnswerQuestionSuccess implements Action {
    43   readonly type = QuestionActionTypes.AnswerQuestionSuccess;
    44 
    45   constructor(public payload: AnswerQuestionStateViewModel) {}
    4631}
    4732
     
    156141  | SetCorrectAnswerSuccess
    157142  | RespondToAnswerSuccess
    158   | AnswerQuestionSuccess
    159143  | EffectStartedWorking
    160144  | EffectFinishedWorking
  • src/Clients/Angular/finki-chattery/src/app/core/state/question-state/question.effects.ts

    r74ad056 r7e7cc4c  
    88import { NotificationService } from '../../services/notification.service';
    99import { QuestionFacadeService } from '../question-facade.service';
    10 import { AnswerQuestionRequest, RespondToAnswerRequest, VoteAnswerRequest } from './question-state-request.models';
     10import { RespondToAnswerRequest, VoteAnswerRequest } from './question-state-request.models';
    1111import {
    12   AnswerQuestionStateResponse,
    1312  AnswerResponseQuestionStateResponse,
    1413  PreviewQuestionResponse,
     
    1716} from './question-state-response.models';
    1817import {
    19   AnswerQuestion,
    20   AnswerQuestionSuccess,
    2118  EffectFinishedWorking,
    2219  EffectFinishedWorkingError,
     
    168165    );
    169166  });
    170 
    171   answerQuestion$ = createEffect(() => {
    172     return this.actions$.pipe(
    173       ofType<AnswerQuestion>(QuestionActionTypes.AnswerQuestion),
    174       mergeMap((action) => {
    175         return this.api
    176           .post<AnswerQuestionStateResponse>(`v1/questions/${action.questionUid}/answers`, new AnswerQuestionRequest(action.text))
    177           .pipe(
    178             tap((state) => this.notification.successNotification('success-answer')),
    179             switchMap((state) => [
    180               new AnswerQuestionSuccess(QuestionMapper.ToAnswerQuestionStateViewModel(state)),
    181               new EffectFinishedWorking()
    182             ]),
    183             catchError((err) => [new EffectFinishedWorkingError(err)])
    184           );
    185       })
    186     );
    187   });
    188167}
  • src/Clients/Angular/finki-chattery/src/app/core/state/question-state/question.mapper.ts

    r74ad056 r7e7cc4c  
    1515import { TranslateFromJsonService } from 'src/app/shared-app/services';
    1616import {
    17   AnswerQuestionStateResponse,
    1817  AnswerResponseQuestionStateResponse,
    1918  PreviewQuestionResponse,
     
    3029
    3130    if (questionStateResponse.answersResponse.length > 0) {
    32       answers = questionStateResponse.answersResponse.map((x) => QuestionMapper.ToAnswerQuestionStateViewModel(x));
     31      answers = questionStateResponse.answersResponse.map((x) => {
     32        let answerResponses: AnswerResponseQuestionStateViewModel[] = [];
     33
     34        if (x.answerResponsesResponse.length > 0) {
     35          answerResponses = x.answerResponsesResponse.map((y) => {
     36            const answerResponseStudent = new AnswerResponseStudentQuestionStateViewModel(
     37              y.studentResponse.uid,
     38              y.studentResponse.index,
     39              y.studentResponse.imageUrl,
     40              y.studentResponse.reputation
     41            );
     42
     43            return new AnswerResponseQuestionStateViewModel(y.uid, y.text, moment(y.createdOn), answerResponseStudent);
     44          });
     45        }
     46
     47        const answerStudent = new AnswerStudentQuestionStateViewModel(
     48          x.studentResponse.uid,
     49          x.studentResponse.index,
     50          x.studentResponse.imageUrl,
     51          x.studentResponse.reputation
     52        );
     53
     54        return new AnswerQuestionStateViewModel(
     55          x.uid,
     56          x.text,
     57          x.correctAnswer,
     58          moment(x.createdOn),
     59          x.votesCount,
     60          answerStudent,
     61          answerResponses
     62        );
     63      });
    3364    }
    3465
     
    105136    return new AnswerResponseQuestionStateViewModel(response.uid, response.text, moment(response.createdOn), answerResponseStudent);
    106137  }
    107 
    108   public static ToAnswerQuestionStateViewModel(response: AnswerQuestionStateResponse): AnswerQuestionStateViewModel {
    109     let answerResponses: AnswerResponseQuestionStateViewModel[] = [];
    110 
    111     if (response.answerResponsesResponse.length > 0) {
    112       answerResponses = response.answerResponsesResponse.map((y) => {
    113         const answerResponseStudent = new AnswerResponseStudentQuestionStateViewModel(
    114           y.studentResponse.uid,
    115           y.studentResponse.index,
    116           y.studentResponse.imageUrl,
    117           y.studentResponse.reputation
    118         );
    119 
    120         return new AnswerResponseQuestionStateViewModel(y.uid, y.text, moment(y.createdOn), answerResponseStudent);
    121       });
    122     }
    123 
    124     const answerStudent = new AnswerStudentQuestionStateViewModel(
    125       response.studentResponse.uid,
    126       response.studentResponse.index,
    127       response.studentResponse.imageUrl,
    128       response.studentResponse.reputation
    129     );
    130 
    131     return new AnswerQuestionStateViewModel(
    132       response.uid,
    133       response.text,
    134       response.correctAnswer,
    135       moment(response.createdOn),
    136       response.votesCount,
    137       answerStudent,
    138       answerResponses
    139     );
    140   }
    141138}
  • src/Clients/Angular/finki-chattery/src/app/core/state/question-state/question.reducers.ts

    r74ad056 r7e7cc4c  
    114114      };
    115115    }
    116     case QuestionActionTypes.AnswerQuestionSuccess: {
    117       if (state.question) {
    118         return {
    119           ...state,
    120           question: {
    121             ...state.question,
    122             answers: [...state.question.answers, action.payload]
    123           }
    124         };
    125       }
    126 
    127       return {
    128         ...state
    129       };
    130     }
    131116    case QuestionActionTypes.EffectStartedWorking: {
    132117      return {
  • src/Clients/Angular/finki-chattery/src/app/shared-app/components/components.ts

    r74ad056 r7e7cc4c  
    55import { TextEditorComponent } from './generic/text-editor/text-editor.component';
    66import { VoteComponent } from './generic/vote/vote.component';
    7 import { AnswerQuestionComponent } from './question/answer-question/answer-question.component';
    87import { AskQuestionSharedComponent } from './question/ask-question-shared/ask-question-shared.component';
    98import { PreviewQuestionDisplayComponent } from './question/preview-question-display/preview-question-display.component';
     
    2726  PreviewQuestionFullComponent,
    2827  TextEditorComponent,
    29   RespondToAnswerDialogComponent,
    30   AnswerQuestionComponent
     28  RespondToAnswerDialogComponent
    3129];
  • src/Clients/Angular/finki-chattery/src/app/shared-app/components/question/preview-question-full/preview-question-full.component.html

    r74ad056 r7e7cc4c  
    4040  </mat-card-content>
    4141  <mat-card-actions>
    42     <app-button (action)="scrollToBottom()" [buttonType]="ButtonType.CallToAction">{{
    43       'preview-question-full-answer' | translate
    44     }}</app-button>
    4542    <app-button appShareLink [buttonType]="ButtonType.Basic">{{ 'share-link' | translate }}</app-button>
    4643  </mat-card-actions>
  • src/Clients/Angular/finki-chattery/src/app/shared-app/components/question/preview-question-full/preview-question-full.component.ts

    r74ad056 r7e7cc4c  
    1414
    1515  ngOnInit(): void {}
    16 
    17   scrollToBottom(): void {
    18     window.scrollTo(0, document.body.scrollHeight);
    19   }
    2016}
  • src/Clients/Angular/finki-chattery/src/app/shared-app/components/question/question-preview/question-preview.component.html

    r74ad056 r7e7cc4c  
    5959    </mat-card>
    6060  </ng-container>
    61   <app-answer-question></app-answer-question>
    6261</div>
  • src/Clients/Angular/finki-chattery/src/assets/translations/en.json

    r74ad056 r7e7cc4c  
    6363  "submit-button": "Submit",
    6464  "header-student-questions": "Your questions",
    65   "success-answer": "Successfully answered question",
    66   "preview-question-full-answer": "Answer question",
    67   "answer-question-title": "Give your answer to the question",
    68   "answer-question-button": "Answer",
    69   "StudentDoesNotOwnQuestion": "You do not own this question",
    7065  "AnswerAlreadyUpvoted": "You have already upvoted this answer",
    7166  "AnswerAlreadyDownvoted": "You have already downvoted this answer",
Note: See TracChangeset for help on using the changeset viewer.