Changes in / [74ad056:7e7cc4c]
- 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 14 14 import { AuthService } from '../services'; 15 15 import { 16 AnswerQuestion,17 16 EffectStartedWorking, 18 17 GetPreviewQuestionsLatest, … … 100 99 } 101 100 102 public answerQuestion(questionUid: string, text: string): void {103 this.dispatchEffect(new AnswerQuestion(questionUid, text));104 }105 106 101 private fetchPreviewQuestionsLatest(): void { 107 102 this.dispatchEffect(new GetPreviewQuestionsLatest()); -
src/Clients/Angular/finki-chattery/src/app/core/state/question-state/question-state-request.models.ts
r74ad056 r7e7cc4c 8 8 constructor(public text: string) {} 9 9 } 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 3 3 4 4 import { 5 AnswerQuestionStateViewModel,6 5 AnswerResponseQuestionStateViewModel, 7 6 PreviewQuestionViewModel, … … 27 26 VoteAnswer = '[Question] Vote answer', 28 27 VoteAnswerSuccess = '[Question] Vote answer Success', 29 AnswerQuestion = '[Question] AnswerQuestion',30 AnswerQuestionSuccess = '[Question] AnswerQuestion Success',31 28 EffectStartedWorking = '[Question] Effect Started Working', 32 29 EffectFinishedWorking = '[Question] Effect Finished Working', 33 30 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) {}46 31 } 47 32 … … 156 141 | SetCorrectAnswerSuccess 157 142 | RespondToAnswerSuccess 158 | AnswerQuestionSuccess159 143 | EffectStartedWorking 160 144 | EffectFinishedWorking -
src/Clients/Angular/finki-chattery/src/app/core/state/question-state/question.effects.ts
r74ad056 r7e7cc4c 8 8 import { NotificationService } from '../../services/notification.service'; 9 9 import { QuestionFacadeService } from '../question-facade.service'; 10 import { AnswerQuestionRequest,RespondToAnswerRequest, VoteAnswerRequest } from './question-state-request.models';10 import { RespondToAnswerRequest, VoteAnswerRequest } from './question-state-request.models'; 11 11 import { 12 AnswerQuestionStateResponse,13 12 AnswerResponseQuestionStateResponse, 14 13 PreviewQuestionResponse, … … 17 16 } from './question-state-response.models'; 18 17 import { 19 AnswerQuestion,20 AnswerQuestionSuccess,21 18 EffectFinishedWorking, 22 19 EffectFinishedWorkingError, … … 168 165 ); 169 166 }); 170 171 answerQuestion$ = createEffect(() => {172 return this.actions$.pipe(173 ofType<AnswerQuestion>(QuestionActionTypes.AnswerQuestion),174 mergeMap((action) => {175 return this.api176 .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 });188 167 } -
src/Clients/Angular/finki-chattery/src/app/core/state/question-state/question.mapper.ts
r74ad056 r7e7cc4c 15 15 import { TranslateFromJsonService } from 'src/app/shared-app/services'; 16 16 import { 17 AnswerQuestionStateResponse,18 17 AnswerResponseQuestionStateResponse, 19 18 PreviewQuestionResponse, … … 30 29 31 30 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 }); 33 64 } 34 65 … … 105 136 return new AnswerResponseQuestionStateViewModel(response.uid, response.text, moment(response.createdOn), answerResponseStudent); 106 137 } 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.reputation118 );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.reputation129 );130 131 return new AnswerQuestionStateViewModel(132 response.uid,133 response.text,134 response.correctAnswer,135 moment(response.createdOn),136 response.votesCount,137 answerStudent,138 answerResponses139 );140 }141 138 } -
src/Clients/Angular/finki-chattery/src/app/core/state/question-state/question.reducers.ts
r74ad056 r7e7cc4c 114 114 }; 115 115 } 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 ...state129 };130 }131 116 case QuestionActionTypes.EffectStartedWorking: { 132 117 return { -
src/Clients/Angular/finki-chattery/src/app/shared-app/components/components.ts
r74ad056 r7e7cc4c 5 5 import { TextEditorComponent } from './generic/text-editor/text-editor.component'; 6 6 import { VoteComponent } from './generic/vote/vote.component'; 7 import { AnswerQuestionComponent } from './question/answer-question/answer-question.component';8 7 import { AskQuestionSharedComponent } from './question/ask-question-shared/ask-question-shared.component'; 9 8 import { PreviewQuestionDisplayComponent } from './question/preview-question-display/preview-question-display.component'; … … 27 26 PreviewQuestionFullComponent, 28 27 TextEditorComponent, 29 RespondToAnswerDialogComponent, 30 AnswerQuestionComponent 28 RespondToAnswerDialogComponent 31 29 ]; -
src/Clients/Angular/finki-chattery/src/app/shared-app/components/question/preview-question-full/preview-question-full.component.html
r74ad056 r7e7cc4c 40 40 </mat-card-content> 41 41 <mat-card-actions> 42 <app-button (action)="scrollToBottom()" [buttonType]="ButtonType.CallToAction">{{43 'preview-question-full-answer' | translate44 }}</app-button>45 42 <app-button appShareLink [buttonType]="ButtonType.Basic">{{ 'share-link' | translate }}</app-button> 46 43 </mat-card-actions> -
src/Clients/Angular/finki-chattery/src/app/shared-app/components/question/preview-question-full/preview-question-full.component.ts
r74ad056 r7e7cc4c 14 14 15 15 ngOnInit(): void {} 16 17 scrollToBottom(): void {18 window.scrollTo(0, document.body.scrollHeight);19 }20 16 } -
src/Clients/Angular/finki-chattery/src/app/shared-app/components/question/question-preview/question-preview.component.html
r74ad056 r7e7cc4c 59 59 </mat-card> 60 60 </ng-container> 61 <app-answer-question></app-answer-question>62 61 </div> -
src/Clients/Angular/finki-chattery/src/assets/translations/en.json
r74ad056 r7e7cc4c 63 63 "submit-button": "Submit", 64 64 "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",70 65 "AnswerAlreadyUpvoted": "You have already upvoted this answer", 71 66 "AnswerAlreadyDownvoted": "You have already downvoted this answer",
Note:
See TracChangeset
for help on using the changeset viewer.