-
Notifications
You must be signed in to change notification settings - Fork 1
/
871.0d69499270f6ae57.js
1 lines (1 loc) · 7.78 KB
/
871.0d69499270f6ae57.js
1
"use strict";(self.webpackChunkyurii_hrebeniuk_quiz=self.webpackChunkyurii_hrebeniuk_quiz||[]).push([[871],{4871:(E,g,r)=>{r.r(g),r.d(g,{QuizMakerModule:()=>k});var a=r(6814),f=r(157),d=r(7394),t=r(5879),m=r(7797),y=r(4716),s=r(95),u=(()=>((u=u||{}).EASY="easy",u.MEDIUM="medium",u.HARD="hard",u))(),h=r(2296),p=r(1941),q=r(3224),z=r(3680);let v=(()=>{class e{constructor(i){this.element=i,this.buttonLabel=""}ngAfterViewInit(){this.buttonLabel=this.element.nativeElement.innerText}ngOnChanges(i){i.isFetching.firstChange||(!0===i.isFetching.currentValue?(this.element.nativeElement.setAttribute("disabled","true"),this.element.nativeElement.innerText="Fetching..."):(this.element.nativeElement.removeAttribute("disabled"),this.element.nativeElement.innerText=this.buttonLabel))}}return e.\u0275fac=function(i){return new(i||e)(t.Y36(t.SBq))},e.\u0275dir=t.lG2({type:e,selectors:[["","appFetchingButton",""]],inputs:{isFetching:"isFetching"},features:[t.TTD]}),e})();function Q(e,n){if(1&e&&(t.TgZ(0,"mat-option",9),t._uU(1),t.qZA()),2&e){const i=n.$implicit;t.Q6J("value",i.id),t.xp6(1),t.hij(" ",i.name," ")}}function C(e,n){1&e&&(t.TgZ(0,"mat-error"),t._uU(1," * This field is required "),t.qZA())}function b(e,n){if(1&e&&(t.TgZ(0,"mat-option",9),t._uU(1),t.qZA()),2&e){const i=n.$implicit;t.Q6J("value",i),t.xp6(1),t.hij(" ",i," ")}}function F(e,n){1&e&&(t.TgZ(0,"mat-error"),t._uU(1," * This field is required "),t.qZA())}let T=(()=>{class e{constructor(i){this.quizService=i,this.categoryForm=new s.cw({category:new s.NI(null,[s.kI.required]),difficulty:new s.NI(null,[s.kI.required])}),this.difficulty=[u.EASY,u.MEDIUM,u.HARD],this.isDataFetching=!1,this.subscription=new d.w0}get categoryField(){return this.categoryForm.get("category")}get difficultyField(){return this.categoryForm.get("difficulty")}onFormSubmit(){this.categoryForm.markAllAsTouched(),!this.categoryForm.invalid&&(this.isDataFetching=!0,this.quizService.questionsList.next([]),this.subscription.add(this.quizService.createQuiz(this.categoryField.value,this.difficultyField.value).pipe((0,y.x)(()=>this.isDataFetching=!1)).subscribe()))}ngOnDestroy(){this.subscription.unsubscribe()}}return e.\u0275fac=function(i){return new(i||e)(t.Y36(m.v))},e.\u0275cmp=t.Xpm({type:e,selectors:[["app-quiz-category-selector"]],inputs:{categoryList:"categoryList"},decls:18,vars:8,consts:[[1,"w-100"],[1,"row","w-100","align-items-start",3,"formGroup","submit"],["appearance","outline",1,"col-5"],["id","categorySelect","formControlName","category","required","","disableOptionCentering",""],[3,"value",4,"ngFor","ngForOf"],[4,"ngIf"],["id","difficultySelect","formControlName","difficulty","required","","disableOptionCentering",""],["mat-raised-button","","id","createBtn","color","primary","appFetchingButton","",1,"col-2",2,"height","56px",3,"isFetching"],[1,"button-text"],[3,"value"]],template:function(i,o){1&i&&(t.TgZ(0,"div",0)(1,"form",1),t.NdJ("submit",function(){return o.onFormSubmit()}),t.TgZ(2,"mat-form-field",2)(3,"mat-label"),t._uU(4,"Select category"),t.qZA(),t.TgZ(5,"mat-select",3),t.YNc(6,Q,2,2,"mat-option",4),t.ALo(7,"async"),t.qZA(),t.YNc(8,C,2,0,"mat-error",5),t.qZA(),t.TgZ(9,"mat-form-field",2)(10,"mat-label"),t._uU(11,"Select difficulty"),t.qZA(),t.TgZ(12,"mat-select",6),t.YNc(13,b,2,2,"mat-option",4),t.qZA(),t.YNc(14,F,2,0,"mat-error",5),t.qZA(),t.TgZ(15,"button",7)(16,"span",8),t._uU(17,"Create"),t.qZA()()()()),2&i&&(t.xp6(1),t.Q6J("formGroup",o.categoryForm),t.xp6(5),t.Q6J("ngForOf",t.lcZ(7,6,o.categoryList)),t.xp6(2),t.Q6J("ngIf",o.categoryField.hasError("required")),t.xp6(5),t.Q6J("ngForOf",o.difficulty),t.xp6(1),t.Q6J("ngIf",o.difficultyField.invalid),t.xp6(1),t.Q6J("isFetching",o.isDataFetching))},dependencies:[a.sg,a.O5,s._Y,s.JJ,s.JL,s.Q7,s.sg,s.u,h.lW,p.KE,p.hX,p.TO,q.gD,z.ey,v,a.Ov],encapsulation:2}),e})();var _=r(5446),A=r(5054);function x(e,n){if(1&e){const i=t.EpF();t.TgZ(0,"app-quiz-answer-button",7),t.NdJ("click",function(){const l=t.CHM(i).$implicit,D=t.oxw().index,U=t.oxw();return t.KtG(U.markAsAnswer(D,l))}),t.qZA()}if(2&e){const i=n.$implicit,o=t.oxw().index,c=t.oxw();t.Q6J("answerText",i)("isSelectedAnswer",c.isSelectedAnswer(o,i))}}function Z(e,n){if(1&e&&(t.TgZ(0,"div",4),t._UZ(1,"span",5),t.ALo(2,"sanitizer"),t.YNc(3,x,1,2,"app-quiz-answer-button",6),t.qZA()),2&e){const i=n.$implicit;t.xp6(1),t.Q6J("innerHTML",t.lcZ(2,2,i.question),t.oJD),t.xp6(2),t.Q6J("ngForOf",i.allAnswers)}}function w(e,n){1&e&&(t.TgZ(0,"button",8)(1,"span",9),t._uU(2," Submit"),t.qZA()())}let S=(()=>{class e{constructor(i){this.quizService=i,this.qustionsGroup=new s.cw([]),this.isSubmitButtonVisible=!1}ngOnInit(){for(let i=0;i<this.questionsList.length;i++)this.qustionsGroup.addControl(`question${i}`,new s.NI(null,[s.kI.required]))}markAsAnswer(i,o){this.qustionsGroup.get(`question${i}`)?.patchValue(o)}isSelectedAnswer(i,o){return this.qustionsGroup.get(`question${i}`)?.value===o}onSubmit(){this.qustionsGroup.valid&&this.quizService.validateQuiz(Object.values(this.qustionsGroup.value),this.questionsList)}}return e.\u0275fac=function(i){return new(i||e)(t.Y36(m.v))},e.\u0275cmp=t.Xpm({type:e,selectors:[["app-quiz-questions"]],inputs:{questionsList:"questionsList"},decls:4,vars:3,consts:[[1,"quiz-questions-container"],[3,"formGroup","submit"],["class","mb-4",4,"ngFor","ngForOf"],["mat-raised-button","","color","primary","class","mt-4 py-4 w-100",4,"ngIf"],[1,"mb-4"],[1,"quiz-question",3,"innerHTML"],["class","me-3",3,"answerText","isSelectedAnswer","click",4,"ngFor","ngForOf"],[1,"me-3",3,"answerText","isSelectedAnswer","click"],["mat-raised-button","","color","primary",1,"mt-4","py-4","w-100"],[1,"button-text"]],template:function(i,o){1&i&&(t.TgZ(0,"div",0)(1,"form",1),t.NdJ("submit",function(){return o.onSubmit()}),t.YNc(2,Z,4,4,"div",2),t.YNc(3,w,3,0,"button",3),t.qZA()()),2&i&&(t.xp6(1),t.Q6J("formGroup",o.qustionsGroup),t.xp6(1),t.Q6J("ngForOf",o.questionsList),t.xp6(1),t.Q6J("ngIf",o.qustionsGroup.valid))},dependencies:[a.sg,a.O5,s._Y,s.JL,s.sg,h.lW,_.q,A.M],styles:[".quiz-questions-container[_ngcontent-%COMP%]{display:flex;flex-direction:column;padding-left:48px}"]}),e})();function M(e,n){if(1&e&&t._UZ(0,"app-quiz-category-selector",4),2&e){const i=t.oxw();t.Q6J("categoryList",i.categoryList)}}function L(e,n){if(1&e&&t._UZ(0,"app-quiz-questions",5),2&e){const i=t.oxw();t.Q6J("questionsList",i.questions)}}function J(e,n){1&e&&(t.TgZ(0,"span"),t._uU(1,"Initializing... Please, wait"),t.qZA())}const I=[{path:"",pathMatch:"full",component:(()=>{class e{constructor(i){this.quizService=i,this.questions=[],this.subscription=new d.w0,this.categoryList=this.quizService.getQuizCategoryList()}ngOnInit(){this.subscription.add(this.quizService.questionsList.subscribe({next:i=>this.questions=i}))}ngOnDestroy(){this.subscription.unsubscribe()}}return e.\u0275fac=function(i){return new(i||e)(t.Y36(m.v))},e.\u0275cmp=t.Xpm({type:e,selectors:[["app-quiz-maker"]],decls:8,vars:5,consts:[[1,"d-flex","flex-column","align-items-center","w-100"],["class","w-100",3,"categoryList",4,"ngIf","ngIfElse"],["class","w-100",3,"questionsList",4,"ngIf"],["initializing",""],[1,"w-100",3,"categoryList"],[1,"w-100",3,"questionsList"]],template:function(i,o){if(1&i&&(t.TgZ(0,"div",0)(1,"h1"),t._uU(2,"Quiz maker"),t.qZA(),t.YNc(3,M,1,1,"app-quiz-category-selector",1),t.ALo(4,"async"),t.YNc(5,L,1,1,"app-quiz-questions",2),t.qZA(),t.YNc(6,J,2,0,"ng-template",null,3,t.W1O)),2&i){const c=t.MAs(7);let l;t.xp6(3),t.Q6J("ngIf",null==(l=t.lcZ(4,3,o.categoryList))?null:l.length)("ngIfElse",c),t.xp6(2),t.Q6J("ngIf",0!==o.questions.length)}},dependencies:[a.O5,T,S,a.Ov],encapsulation:2}),e})()}];let O=(()=>{class e{}return e.\u0275fac=function(i){return new(i||e)},e.\u0275mod=t.oAB({type:e}),e.\u0275inj=t.cJS({imports:[f.Bz.forChild(I),f.Bz]}),e})();var N=r(9099),Y=r(6208);let k=(()=>{class e{}return e.\u0275fac=function(i){return new(i||e)},e.\u0275mod=t.oAB({type:e}),e.\u0275inj=t.cJS({imports:[a.ez,O,s.UX,N.$,Y.m]}),e})()}}]);