From cdad2c4eceeceb0944e7249d725d70f1bb480132 Mon Sep 17 00:00:00 2001 From: ncamera <nico_camera98@hotmail.com> Date: Tue, 8 Nov 2022 23:31:55 -0300 Subject: [PATCH] Arreglar traducciones en archivos.component --- .../app/layout/archivos/archivos.component.ts | 106 ++++++++---------- 1 file changed, 45 insertions(+), 61 deletions(-) diff --git a/Frontend Angular 4/src/app/layout/archivos/archivos.component.ts b/Frontend Angular 4/src/app/layout/archivos/archivos.component.ts index 718241f..5df6677 100755 --- a/Frontend Angular 4/src/app/layout/archivos/archivos.component.ts +++ b/Frontend Angular 4/src/app/layout/archivos/archivos.component.ts @@ -316,9 +316,7 @@ export class ArchivosComponent { // Si el archivo es del alumno, se puede eliminar. // No se controla por creador, dado que los compartidos mantienen este atributo if (!this.archivos.some((arch) => arch.id == this.archivoSeleccionado.id)) { - this.notifService.warning( - this.translateService.get("i18n.warning.file.noPermissionDelete").value - ); + this.showNotification("warning", "i18n.warning.file.noPermissionDelete"); return; } @@ -334,18 +332,14 @@ export class ArchivosComponent { seleccionarDirectorioAMover() { if (!this.archivoSeleccionado) { - this.notifService.warning( - this.translateService.get("i18n.warning.file.noSelected").value - ); + this.showNotification("warning", "i18n.warning.file.noSelected"); return; } // Si el archivo es del alumno, se puede mover. // No se controla por creador, dado que los compartidos mantienen este atributo if (!this.archivos.some((arch) => arch.id == this.archivoSeleccionado.id)) { - this.notifService.warning( - this.translateService.get("i18n.warning.file.noPermissionMove").value - ); + this.showNotification("warning", "i18n.warning.file.noPermissionMove"); return; } @@ -447,51 +441,47 @@ export class ArchivosComponent { }; cargarArchivo() { - if (this.archivoSeleccionado) { - if (this.archivoSeleccionado.directorio) { - this.notifService.warning( - this.translateService.get("i18n.warning.file.noSelected").value, - false - ); + if (!this.archivoSeleccionado) { + this.showNotification("warning", "i18n.warning.file.noSelected"); + return; + } + + if (this.archivoSeleccionado.directorio) { + this.translateService + .get("i18n.warning.file.noSelected") + .subscribe((res) => this.notifService.warning(res, false)); + return; + } + + // Si el archivo es compartido con el grupo, editabe y no lo he editado, lo voy a buscar al servidor. + if ( + this.archivosCompartidos.some( + (arch) => arch.id == this.archivoSeleccionado.id + ) && + this.archivoSeleccionado.editable && + this.archivoSeleccionado.archivoOrigenId == -1 + ) { + if (this.hayArchivoMio()) { + this.seleccionarArchivoMio(); + this.sessionService.setArchivo(this.archivoSeleccionado); + this.router.navigate(["/matefun"]); } else { - //Si el archivo es compartido con el grupo, editabe y no lo he editado, lo voy a buscar al servidor. - if ( - this.archivosCompartidos.some( - (arch) => arch.id == this.archivoSeleccionado.id - ) && - this.archivoSeleccionado.editable && - this.archivoSeleccionado.archivoOrigenId == -1 - ) { - if (this.hayArchivoMio()) { - this.seleccionarArchivoMio(); - this.sessionService.setArchivo(this.archivoSeleccionado); - this.router.navigate(["/matefun"]); - } else { - let cedula = this.authService.getUser().cedula; - this.haskellService - .getCopiaArchivoCompartidoGrupo( - cedula, - this.archivoSeleccionado.id - ) - .subscribe( - (archivo) => { - this.sessionService.setArchivo(archivo); - this.router.navigate(["/matefun"]); - }, - (error) => { - console.log(error); - } - ); - } - } else { - this.sessionService.setArchivo(this.archivoSeleccionado); - this.router.navigate(["/matefun"]); - } + let cedula = this.authService.getUser().cedula; + this.haskellService + .getCopiaArchivoCompartidoGrupo(cedula, this.archivoSeleccionado.id) + .subscribe( + (archivo) => { + this.sessionService.setArchivo(archivo); + this.router.navigate(["/matefun"]); + }, + (error) => { + console.log(error); + } + ); } } else { - this.notifService.warning( - this.translateService.get("i18n.warning.file.noSelected").value - ); + this.sessionService.setArchivo(this.archivoSeleccionado); + this.router.navigate(["/matefun"]); } } @@ -631,7 +621,7 @@ export class ArchivosComponent { // Antes que nada, se chequea que empiece con mayúscula if (!STARTS_WITH_CAPITAL_LETTER_REGEX.test(nombre)) { - alert(this.translateService.get("i18n.warning.file.capitalLetter").value); + this.showNotification("warning", "i18n.warning.file.capitalLetter"); return; } @@ -760,9 +750,7 @@ export class ArchivosComponent { const selectedGroup = event.detail; if (!selectedGroup) { - this.notifService.error( - this.translateService.get("i18n.warning.group.select").value - ); + this.showNotification("error", "i18n.warning.group.select"); return; } @@ -770,9 +758,7 @@ export class ArchivosComponent { .compartirArchivoGrupo(selectedGroup, this.archivoSeleccionado.id) .subscribe( () => { - this.notifService.success( - this.translateService.get("i18n.msg.file.shared").value - ); + this.showNotification("success", "i18n.msg.file.shared"); // Cerrar el modal en caso de éxito this.modalShareFileOpened = false; @@ -848,9 +834,7 @@ export class ArchivosComponent { compartirArchivo() { if (!this.archivoSeleccionado) { - this.notifService.warning( - this.translateService.get("i18n.warning.file.noSelected").value - ); + this.showNotification("warning", "i18n.warning.file.noSelected"); return; } -- GitLab