From f912b2ee3c41814f50f4c4b49e9338b03d142856 Mon Sep 17 00:00:00 2001 From: Cesc Date: Thu, 27 Jun 2024 13:12:19 +0200 Subject: [PATCH 1/7] user solution captured and seen in console --- .../send-solution-modal.component.ts | 1 + src/app/services/solution.service.ts | 11 ++++++++--- .../shared/components/shared-components.module.ts | 4 +++- .../components/solution/solution.component.html | 11 ++++++----- .../shared/components/solution/solution.component.ts | 12 ++++++++++++ 5 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/app/modules/modals/send-solution-modal/send-solution-modal.component.ts b/src/app/modules/modals/send-solution-modal/send-solution-modal.component.ts index 08439202..dd66b462 100755 --- a/src/app/modules/modals/send-solution-modal/send-solution-modal.component.ts +++ b/src/app/modules/modals/send-solution-modal/send-solution-modal.component.ts @@ -15,6 +15,7 @@ export class SendSolutionModalComponent { acceptSolution (): void { this.solutionService.updateSolutionSentState(true) + this.solutionService.sendSolutionText(true) this.closeModal() } diff --git a/src/app/services/solution.service.ts b/src/app/services/solution.service.ts index 7dd4a54c..d77d2bcd 100755 --- a/src/app/services/solution.service.ts +++ b/src/app/services/solution.service.ts @@ -1,18 +1,19 @@ import { HttpClient } from '@angular/common/http' import { Injectable, inject } from '@angular/core' -import { BehaviorSubject, type Observable } from 'rxjs' +import { BehaviorSubject, Subject, type Observable } from 'rxjs' @Injectable({ providedIn: 'root' }) export class SolutionService { private readonly http = inject(HttpClient) - // subject = new BehaviorSubject(1); - // obs$ = this.subject.asObservable(); private readonly solutionSentSubject = new BehaviorSubject(false) solutionSent$ = this.solutionSentSubject.asObservable() + private readonly submitSolutionSubject = new Subject() + public sendSolutionText$ = this.submitSolutionSubject.asObservable() + solutionSent: boolean = false updateSolutionSentState (value: boolean): void { @@ -27,4 +28,8 @@ export class SolutionService { public getSolutions (filePath: string): Observable { return this.http.get(filePath) } + + public sendSolutionText (solution: boolean): void { + this.submitSolutionSubject.next(solution) + } } diff --git a/src/app/shared/components/shared-components.module.ts b/src/app/shared/components/shared-components.module.ts index 3eee6728..d63b16a0 100755 --- a/src/app/shared/components/shared-components.module.ts +++ b/src/app/shared/components/shared-components.module.ts @@ -10,6 +10,7 @@ import { BreadcrumbComponent } from './breadcrumb/breadcrumb.component' import { TranslateModule } from '@ngx-translate/core' import { FormatDatePipe } from 'src/app/pipes/format-date.pipe' import { DynamicTranslatePipe } from 'src/app/pipes/dynamic-translate.pipe' +import { ReactiveFormsModule } from '@angular/forms' @NgModule({ declarations: [ @@ -25,7 +26,8 @@ import { DynamicTranslatePipe } from 'src/app/pipes/dynamic-translate.pipe' TranslateModule, NgbTooltipModule, DynamicTranslatePipe, - FormatDatePipe + FormatDatePipe, + ReactiveFormsModule ], exports: [ PaginationComponent, diff --git a/src/app/shared/components/solution/solution.component.html b/src/app/shared/components/solution/solution.component.html index 4ff7e8c1..646732f1 100755 --- a/src/app/shared/components/solution/solution.component.html +++ b/src/app/shared/components/solution/solution.component.html @@ -1,21 +1,22 @@
{{ "modules.challenge.info.solution" | translate }} {{ number }}
-
-
+
{{ solution.solution_text }}
-
+ diff --git a/src/app/shared/components/solution/solution.component.ts b/src/app/shared/components/solution/solution.component.ts index fbd762a5..fb1da7ed 100755 --- a/src/app/shared/components/solution/solution.component.ts +++ b/src/app/shared/components/solution/solution.component.ts @@ -8,6 +8,7 @@ import { php } from '@codemirror/lang-php' import { minimalSetup } from 'codemirror' import { TranslateService } from '@ngx-translate/core' import { SolutionService } from 'src/app/services/solution.service' +import { FormControl, FormGroup } from '@angular/forms' type Language = 'javascript' | 'java' | 'python' | 'php' @@ -38,6 +39,10 @@ export class SolutionComponent { /* code added by valerio */ private textRemoved = false + public solutionTextForm: FormGroup = new FormGroup({ + solution_text_field: new FormControl('') + }) + handleClick (event: MouseEvent): void { if (!this.textRemoved) { // Check if the text has not been removed yet @@ -67,6 +72,9 @@ export class SolutionComponent { this.solutionService.getSolutions('../assets/dummy/challenge.json').subscribe(data => { this.solutions = data.solutions }) + this.solutionService.sendSolutionText$.subscribe(() => { + this.onSubmitSolution() + }) } ngAfterViewInit (): void { @@ -115,4 +123,8 @@ export class SolutionComponent { } this.editor = new EditorView({ state, parent: this.editorSolution.nativeElement }) } + + onSubmitSolution (): void { + console.log('Solution submitted:', this.solutionTextForm.controls['solution_text_field'].value) + } } From 512fdb83eac37a91d37b27a25b56b7ed0c36fa5f Mon Sep 17 00:00:00 2001 From: Cesc Date: Thu, 4 Jul 2024 13:05:27 +0200 Subject: [PATCH 2/7] testing added --- src/app/services/solution.service.spec.ts | 28 +++++++++++++++++------ src/app/services/solution.service.ts | 2 +- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/app/services/solution.service.spec.ts b/src/app/services/solution.service.spec.ts index 97b533f6..362a5c1a 100755 --- a/src/app/services/solution.service.spec.ts +++ b/src/app/services/solution.service.spec.ts @@ -1,17 +1,31 @@ -import { TestBed, inject } from '@angular/core/testing' +import { TestBed } from '@angular/core/testing' import { SolutionService } from './solution.service' -import { provideHttpClientTesting } from '@angular/common/http/testing' -import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http' +// import { environment } from 'src/environments/environment' + +describe('SolutionService', () => { + let service: SolutionService + // let httpMock: HttpTestingController -describe('Service: SendSolution', () => { beforeEach(() => { TestBed.configureTestingModule({ imports: [], - providers: [SolutionService, provideHttpClient(withInterceptorsFromDi()), provideHttpClientTesting()] + providers: [SolutionService] }) + + service = TestBed.inject(SolutionService) + // httpMock = TestBed.inject(HttpTestingController) }) - it('should ...', inject([SolutionService], (service: SolutionService) => { + it('should be created', () => { expect(service).toBeTruthy() - })) + }) + + it('sendSolutionText should emit the provided solution', (done) => { + const testSolution = true + service.submitSolutionSubject.subscribe(value => { + expect(value).toBe(testSolution) + done() + }) + service.sendSolutionText(testSolution) + }) }) diff --git a/src/app/services/solution.service.ts b/src/app/services/solution.service.ts index d77d2bcd..048ae6a0 100755 --- a/src/app/services/solution.service.ts +++ b/src/app/services/solution.service.ts @@ -11,7 +11,7 @@ export class SolutionService { private readonly solutionSentSubject = new BehaviorSubject(false) solutionSent$ = this.solutionSentSubject.asObservable() - private readonly submitSolutionSubject = new Subject() + submitSolutionSubject = new Subject() public sendSolutionText$ = this.submitSolutionSubject.asObservable() solutionSent: boolean = false From 2099af7ab5ca8065e759ecb8a608ee28616abb2c Mon Sep 17 00:00:00 2001 From: Cesc Date: Tue, 9 Jul 2024 12:30:51 +0200 Subject: [PATCH 3/7] feature#386 --- src/app/services/solution.service.spec.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/app/services/solution.service.spec.ts b/src/app/services/solution.service.spec.ts index 362a5c1a..cfb388a9 100755 --- a/src/app/services/solution.service.spec.ts +++ b/src/app/services/solution.service.spec.ts @@ -1,19 +1,17 @@ import { TestBed } from '@angular/core/testing' import { SolutionService } from './solution.service' -// import { environment } from 'src/environments/environment' +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('SolutionService', () => { let service: SolutionService - // let httpMock: HttpTestingController beforeEach(() => { TestBed.configureTestingModule({ - imports: [], + imports: [HttpClientTestingModule], providers: [SolutionService] }) service = TestBed.inject(SolutionService) - // httpMock = TestBed.inject(HttpTestingController) }) it('should be created', () => { From db1512a91de9ac5f4448aa85e2d206980026b1ef Mon Sep 17 00:00:00 2001 From: Cesc Date: Mon, 22 Jul 2024 12:41:02 +0200 Subject: [PATCH 4/7] textarea error solved --- src/app/services/solution.service.ts | 2 +- .../solution/solution.component.html | 16 ++++++------- .../components/solution/solution.component.ts | 24 +++++++++---------- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/app/services/solution.service.ts b/src/app/services/solution.service.ts index 048ae6a0..a0d2ac45 100755 --- a/src/app/services/solution.service.ts +++ b/src/app/services/solution.service.ts @@ -17,7 +17,7 @@ export class SolutionService { solutionSent: boolean = false updateSolutionSentState (value: boolean): void { - this.solutionSentSubject.next(value) + // this.solutionSentSubject.next(value) this.solutionSent = value } diff --git a/src/app/shared/components/solution/solution.component.html b/src/app/shared/components/solution/solution.component.html index 646732f1..9832f0fa 100755 --- a/src/app/shared/components/solution/solution.component.html +++ b/src/app/shared/components/solution/solution.component.html @@ -1,22 +1,22 @@
{{ "modules.challenge.info.solution" | translate }} {{ number }}
-
- +
{{ solution.solution_text }}
- + diff --git a/src/app/shared/components/solution/solution.component.ts b/src/app/shared/components/solution/solution.component.ts index fb1da7ed..5e3b2a1d 100755 --- a/src/app/shared/components/solution/solution.component.ts +++ b/src/app/shared/components/solution/solution.component.ts @@ -5,10 +5,9 @@ import { javascript } from '@codemirror/lang-javascript' import { python } from '@codemirror/lang-python' import { java } from '@codemirror/lang-java' import { php } from '@codemirror/lang-php' -import { minimalSetup } from 'codemirror' +import { basicSetup } from 'codemirror' import { TranslateService } from '@ngx-translate/core' import { SolutionService } from 'src/app/services/solution.service' -import { FormControl, FormGroup } from '@angular/forms' type Language = 'javascript' | 'java' | 'python' | 'php' @@ -39,9 +38,7 @@ export class SolutionComponent { /* code added by valerio */ private textRemoved = false - public solutionTextForm: FormGroup = new FormGroup({ - solution_text_field: new FormControl('') - }) + public currentSolution: string = '' handleClick (event: MouseEvent): void { if (!this.textRemoved) { @@ -62,10 +59,10 @@ export class SolutionComponent { ngOnInit (): void { this.solutionService.solutionSent$.subscribe((value) => { // if (this.editor && this.isUserSolution) { - const currentSolution = this.editor.state.doc.toString() - if (currentSolution !== this.lastSentSolution) { - this.solutionService.sendSolution(currentSolution) - this.lastSentSolution = currentSolution + this.currentSolution = this.editor.state.doc.toString() + if (this.currentSolution !== this.lastSentSolution) { + this.solutionService.sendSolution(this.currentSolution) + this.lastSentSolution = this.currentSolution } // } }) @@ -105,9 +102,9 @@ export class SolutionComponent { let state: EditorState if (this.isUserSolution) { state = EditorState.create({ - // doc: comment, + // doc: 'comment', extensions: [ - minimalSetup, + basicSetup, languageExtension ] }) @@ -115,7 +112,7 @@ export class SolutionComponent { state = EditorState.create({ // doc: 'Respuesta de ejemplo, no se puede modificar', extensions: [ - minimalSetup, + basicSetup, languageExtension, EditorView.editable.of(false) ] @@ -125,6 +122,7 @@ export class SolutionComponent { } onSubmitSolution (): void { - console.log('Solution submitted:', this.solutionTextForm.controls['solution_text_field'].value) + console.log('Solution submitted:', this.editor.state.doc.toString()) + console.log('currentSolution: ', this.currentSolution) } } From 6937a58128d21ef77b012148d23cacd18656c008 Mon Sep 17 00:00:00 2001 From: Cesc Date: Tue, 23 Jul 2024 11:31:55 +0200 Subject: [PATCH 5/7] textarea and code written resalted fixed --- .../solution/solution.component.html | 27 +-- .../components/solution/solution.component.ts | 181 +++++++++--------- 2 files changed, 102 insertions(+), 106 deletions(-) diff --git a/src/app/shared/components/solution/solution.component.html b/src/app/shared/components/solution/solution.component.html index 9832f0fa..d2a4089e 100755 --- a/src/app/shared/components/solution/solution.component.html +++ b/src/app/shared/components/solution/solution.component.html @@ -1,22 +1,15 @@
- {{ "modules.challenge.info.solution" | translate }} {{ number }} + {{ "modules.challenge.info.solution" | translate }} {{ number }}
- - {{ "modules.challenge.info.solutionCode" | translate }} - + + {{ "modules.challenge.info.solutionCode" | translate }} + -
-
-
- - -
{{ solution.solution_text }}
- -
+
+
+ + +
{{ solution.solution_text }}
+
diff --git a/src/app/shared/components/solution/solution.component.ts b/src/app/shared/components/solution/solution.component.ts index 5e3b2a1d..06c1825c 100755 --- a/src/app/shared/components/solution/solution.component.ts +++ b/src/app/shared/components/solution/solution.component.ts @@ -1,128 +1,131 @@ -import { Component, type ElementRef, Input, ViewChild, inject } from '@angular/core' -import { EditorState } from '@codemirror/state' -import { EditorView } from '@codemirror/view' -import { javascript } from '@codemirror/lang-javascript' -import { python } from '@codemirror/lang-python' -import { java } from '@codemirror/lang-java' -import { php } from '@codemirror/lang-php' -import { basicSetup } from 'codemirror' -import { TranslateService } from '@ngx-translate/core' -import { SolutionService } from 'src/app/services/solution.service' - -type Language = 'javascript' | 'java' | 'python' | 'php' +import { + Component, + type ElementRef, + Input, + ViewChild, + inject, +} from "@angular/core"; +import { TranslateService } from "@ngx-translate/core"; + +import { EditorState } from "@codemirror/state"; +import { EditorView } from "@codemirror/view"; +import { java } from "@codemirror/lang-java"; +import { javascript } from "@codemirror/lang-javascript"; +import { minimalSetup } from "codemirror"; +import { php } from "@codemirror/lang-php"; +import { python } from "@codemirror/lang-python"; + +import { SolutionService } from "src/app/services/solution.service"; + +type Language = "javascript" | "java" | "python" | "php"; @Component({ - selector: 'app-solution', - templateUrl: './solution.component.html', - styleUrls: ['./solution.component.scss'] + selector: "app-solution", + templateUrl: "./solution.component.html", + styleUrls: ["./solution.component.scss"], }) export class SolutionComponent { - @ViewChild('editorSolution') editorSolution!: ElementRef - editor: EditorView = new EditorView() + @ViewChild("editorSolution") editorSolution!: ElementRef; - @Input() set number (value: number | undefined) { + @Input() set number(value: number | undefined) { setTimeout(() => { - this._number = value - }, 0) + this._number = value; + }, 0); } + @Input() languageExt: Language = "javascript"; - get number (): number | undefined { - return this._number - } - - private _number?: number - @Input() languageExt: Language = 'javascript' - - @Input() isUserSolution = false - - /* code added by valerio */ - private textRemoved = false + @Input() isUserSolution = false; - public currentSolution: string = '' - - handleClick (event: MouseEvent): void { - if (!this.textRemoved) { - // Check if the text has not been removed yet - const div = event.target as HTMLDivElement - div.textContent = '' // Remove the text - this.textRemoved = true // Set the flag to indicate that the text has been removed - } + get number(): number | undefined { + return this._number; } - solutions: any[] = [] + public editor: EditorView = new EditorView(); + public currentSolution: string = ""; + public solutions: any[] = []; - private readonly solutionService = inject(SolutionService) - private readonly translateService = inject(TranslateService) + private _number?: number; + private textRemoved = false; + private readonly solutionService = inject(SolutionService); + private readonly translateService = inject(TranslateService); + private lastSentSolution: string = ""; - private lastSentSolution: string = '' - - ngOnInit (): void { + ngOnInit(): void { this.solutionService.solutionSent$.subscribe((value) => { // if (this.editor && this.isUserSolution) { - this.currentSolution = this.editor.state.doc.toString() + this.currentSolution = this.editor.state.doc.toString(); if (this.currentSolution !== this.lastSentSolution) { - this.solutionService.sendSolution(this.currentSolution) - this.lastSentSolution = this.currentSolution + this.solutionService.sendSolution(this.currentSolution); + this.lastSentSolution = this.currentSolution; } // } - }) - this.solutionService.getSolutions('../assets/dummy/challenge.json').subscribe(data => { - this.solutions = data.solutions - }) + }); + this.solutionService + .getSolutions("../assets/dummy/challenge.json") + .subscribe((data) => { + this.solutions = data.solutions; + }); this.solutionService.sendSolutionText$.subscribe(() => { - this.onSubmitSolution() - }) + this.onSubmitSolution(); + }); } - ngAfterViewInit (): void { - this.createEditor() + ngAfterViewInit(): void { + this.createEditor(); } - // nota para equipo front end : tuve que eliminar la variable comment porque sino el handleclick no me funcionaba - createEditor (): void { - let languageExtension + handleClick(event: MouseEvent): void { + if (!this.textRemoved) { + // Check if the text has not been removed yet + const div = event.target as HTMLDivElement; + div.textContent = ""; // Remove the text + this.textRemoved = true; // Set the flag to indicate that the text has been removed + } + } + + createEditor(): void { + let languageExtension; switch (this.languageExt) { - case 'javascript': - languageExtension = javascript({ typescript: true }) - break - case 'python': - languageExtension = python() - break - case 'java': - languageExtension = java() - break - case 'php': - languageExtension = php() - break + case "javascript": + languageExtension = javascript({ typescript: true }); + break; + case "python": + languageExtension = python(); + break; + case "java": + languageExtension = java(); + break; + case "php": + languageExtension = php(); + break; default: - return + return; } - let state: EditorState + let state: EditorState; if (this.isUserSolution) { state = EditorState.create({ - // doc: 'comment', - extensions: [ - basicSetup, - languageExtension - ] - }) + doc: "", + extensions: [minimalSetup, languageExtension], + }); } else { state = EditorState.create({ - // doc: 'Respuesta de ejemplo, no se puede modificar', + doc: "Respuesta de ejemplo, no se puede modificar", extensions: [ - basicSetup, + minimalSetup, languageExtension, - EditorView.editable.of(false) - ] - }) + EditorView.editable.of(false), + ], + }); } - this.editor = new EditorView({ state, parent: this.editorSolution.nativeElement }) + this.editor = new EditorView({ + state, + parent: this.editorSolution.nativeElement, + }); } - onSubmitSolution (): void { - console.log('Solution submitted:', this.editor.state.doc.toString()) - console.log('currentSolution: ', this.currentSolution) + onSubmitSolution(): void { + console.log("Solution submitted:", this.editor.state.doc.toString()); } } From b61d2496ac96656f383f6296253b3d62ff135fe5 Mon Sep 17 00:00:00 2001 From: Cesc Date: Tue, 23 Jul 2024 11:50:15 +0200 Subject: [PATCH 6/7] RELEASE-3.1.1 --- src/app/services/solution.service.spec.ts | 2 +- .../components/shared-components.module.ts | 1 - .../components/solution/solution.component.ts | 151 +++++++++--------- 3 files changed, 75 insertions(+), 79 deletions(-) diff --git a/src/app/services/solution.service.spec.ts b/src/app/services/solution.service.spec.ts index cfb388a9..afb8a55f 100755 --- a/src/app/services/solution.service.spec.ts +++ b/src/app/services/solution.service.spec.ts @@ -1,6 +1,6 @@ import { TestBed } from '@angular/core/testing' import { SolutionService } from './solution.service' -import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { HttpClientTestingModule } from '@angular/common/http/testing' describe('SolutionService', () => { let service: SolutionService diff --git a/src/app/shared/components/shared-components.module.ts b/src/app/shared/components/shared-components.module.ts index 729f3ace..1ab54d34 100755 --- a/src/app/shared/components/shared-components.module.ts +++ b/src/app/shared/components/shared-components.module.ts @@ -9,7 +9,6 @@ import { SolutionComponent } from './solution/solution.component' import { BreadcrumbComponent } from './breadcrumb/breadcrumb.component' import { TranslateModule } from '@ngx-translate/core' import { DynamicTranslatePipe } from 'src/app/pipes/dynamic-translate.pipe' -import { ReactiveFormsModule } from '@angular/forms' @NgModule({ declarations: [ diff --git a/src/app/shared/components/solution/solution.component.ts b/src/app/shared/components/solution/solution.component.ts index 06c1825c..bea730db 100755 --- a/src/app/shared/components/solution/solution.component.ts +++ b/src/app/shared/components/solution/solution.component.ts @@ -3,129 +3,126 @@ import { type ElementRef, Input, ViewChild, - inject, -} from "@angular/core"; -import { TranslateService } from "@ngx-translate/core"; + inject +} from '@angular/core' +import { EditorState } from '@codemirror/state' +import { EditorView } from '@codemirror/view' +import { java } from '@codemirror/lang-java' +import { javascript } from '@codemirror/lang-javascript' +import { minimalSetup } from 'codemirror' +import { php } from '@codemirror/lang-php' +import { python } from '@codemirror/lang-python' -import { EditorState } from "@codemirror/state"; -import { EditorView } from "@codemirror/view"; -import { java } from "@codemirror/lang-java"; -import { javascript } from "@codemirror/lang-javascript"; -import { minimalSetup } from "codemirror"; -import { php } from "@codemirror/lang-php"; -import { python } from "@codemirror/lang-python"; +import { SolutionService } from 'src/app/services/solution.service' -import { SolutionService } from "src/app/services/solution.service"; - -type Language = "javascript" | "java" | "python" | "php"; +type Language = 'javascript' | 'java' | 'python' | 'php' @Component({ - selector: "app-solution", - templateUrl: "./solution.component.html", - styleUrls: ["./solution.component.scss"], + selector: 'app-solution', + templateUrl: './solution.component.html', + styleUrls: ['./solution.component.scss'] }) export class SolutionComponent { - @ViewChild("editorSolution") editorSolution!: ElementRef; + @ViewChild('editorSolution') editorSolution!: ElementRef - @Input() set number(value: number | undefined) { - setTimeout(() => { - this._number = value; - }, 0); + private _number?: number + get number (): number | undefined { + return this._number } - @Input() languageExt: Language = "javascript"; - - @Input() isUserSolution = false; - get number(): number | undefined { - return this._number; + @Input() set number (value: number | undefined) { + setTimeout(() => { + this._number = value + }, 0) } - public editor: EditorView = new EditorView(); - public currentSolution: string = ""; - public solutions: any[] = []; + @Input() languageExt: Language = 'javascript' + @Input() isUserSolution = false + + public editor: EditorView = new EditorView() + public currentSolution: string = '' + public solutions: any[] = [] - private _number?: number; - private textRemoved = false; - private readonly solutionService = inject(SolutionService); - private readonly translateService = inject(TranslateService); - private lastSentSolution: string = ""; + private textRemoved = false + private readonly solutionService = inject(SolutionService) + private lastSentSolution: string = '' - ngOnInit(): void { + ngOnInit (): void { this.solutionService.solutionSent$.subscribe((value) => { // if (this.editor && this.isUserSolution) { - this.currentSolution = this.editor.state.doc.toString(); + this.currentSolution = this.editor.state.doc.toString() if (this.currentSolution !== this.lastSentSolution) { - this.solutionService.sendSolution(this.currentSolution); - this.lastSentSolution = this.currentSolution; + this.solutionService.sendSolution(this.currentSolution) + this.lastSentSolution = this.currentSolution } // } - }); + }) this.solutionService - .getSolutions("../assets/dummy/challenge.json") + .getSolutions('../assets/dummy/challenge.json') .subscribe((data) => { - this.solutions = data.solutions; - }); + this.solutions = data.solutions + }) this.solutionService.sendSolutionText$.subscribe(() => { - this.onSubmitSolution(); - }); + this.onSubmitSolution() + }) } - ngAfterViewInit(): void { - this.createEditor(); + ngAfterViewInit (): void { + this.createEditor() } - handleClick(event: MouseEvent): void { + handleClick (event: MouseEvent): void { if (!this.textRemoved) { // Check if the text has not been removed yet - const div = event.target as HTMLDivElement; - div.textContent = ""; // Remove the text - this.textRemoved = true; // Set the flag to indicate that the text has been removed + const div = event.target as HTMLDivElement + div.textContent = '' // Remove the text + this.textRemoved = true // Set the flag to indicate that the text has been removed } } - createEditor(): void { - let languageExtension; + createEditor (): void { + let languageExtension switch (this.languageExt) { - case "javascript": - languageExtension = javascript({ typescript: true }); - break; - case "python": - languageExtension = python(); - break; - case "java": - languageExtension = java(); - break; - case "php": - languageExtension = php(); - break; + case 'javascript': + languageExtension = javascript({ typescript: true }) + break + case 'python': + languageExtension = python() + break + case 'java': + languageExtension = java() + break + case 'php': + languageExtension = php() + break default: - return; + return } - let state: EditorState; + let state: EditorState if (this.isUserSolution) { state = EditorState.create({ - doc: "", - extensions: [minimalSetup, languageExtension], - }); + doc: '', + extensions: [minimalSetup, languageExtension] + }) } else { state = EditorState.create({ - doc: "Respuesta de ejemplo, no se puede modificar", + doc: 'Respuesta de ejemplo, no se puede modificar', extensions: [ minimalSetup, languageExtension, - EditorView.editable.of(false), - ], - }); + EditorView.editable.of(false) + ] + }) } this.editor = new EditorView({ state, - parent: this.editorSolution.nativeElement, - }); + parent: this.editorSolution.nativeElement + }) } - onSubmitSolution(): void { - console.log("Solution submitted:", this.editor.state.doc.toString()); + onSubmitSolution (): void { + console.log('Solution submitted:', this.editor.state.doc.toString()) } } From 628583dce3f1437de0e2849dc6a65295d1ec81ac Mon Sep 17 00:00:00 2001 From: Cesc Date: Wed, 24 Jul 2024 10:03:58 +0200 Subject: [PATCH 7/7] fixed library compatibility problems --- package-lock.json | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index a7f7dc57..384a123d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ita-challenges-frontend", - "version": "3.0.3-RELEASE", + "version": "3.0.5-RELEASE", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ita-challenges-frontend", - "version": "3.0.3-RELEASE", + "version": "3.0.5-RELEASE", "dependencies": { "@angular/animations": "^18.0.2", "@angular/cdk": "^18.0.2", @@ -64,7 +64,7 @@ "eslint-plugin-n": "^16.6.2", "eslint-plugin-promise": "^6.1.1", "jest": "^29.5.0", - "typescript": "^5.4.4" + "typescript": "^5.4.5" } }, "node_modules/@aduh95/viz.js": { @@ -21404,10 +21404,9 @@ } }, "node_modules/typescript": { - "version": "5.4.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.4.tgz", - "integrity": "sha512-dGE2Vv8cpVvw28v8HCPqyb08EzbBURxDpuhJvTrusShUfGnhHBafDsLdS1EhhxyL6BJQE+2cT3dDPAv+MQ6oLw==", - "license": "Apache-2.0", + "version": "5.5.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz", + "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver"