Merge branch 'feature/US-35' into feature/US-66

This commit is contained in:
Mariela Bonilla 2021-08-05 23:05:02 -06:00
commit a336d41277
10 changed files with 142 additions and 29 deletions

View File

@ -1,21 +1,20 @@
<form *ngIf="plantilla" name="deleteForm" (ngSubmit)="confirmDelete(plantilla.id!)">
<div class="modal-header">
<h4 class="modal-title" data-cy="plantillaDeleteDialogHeading" jhiTranslate="entity.delete.title">Confirm delete operation</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" (click)="cancel()">&times;</button>
</div>
<form class="ds-form" *ngIf="plantilla" name="deleteForm" (ngSubmit)="confirmDelete(plantilla)">
<div class="modal-body">
<jhi-alert-error></jhi-alert-error>
<p id="jhi-delete-plantilla-heading" jhiTranslate="dataSurveyApp.plantilla.delete.question" [translateValues]="{ id: plantilla.id }">
<p class="ds-title--small">Eliminar plantilla</p>
<p
class="ds-subtitle"
id="jhi-delete-plantilla-heading"
jhiTranslate="dataSurveyApp.plantilla.delete.question"
[translateValues]="{ id: plantilla.id }"
>
Are you sure you want to delete this Plantilla?
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal" (click)="cancel()">
<fa-icon icon="ban"></fa-icon>&nbsp;<span jhiTranslate="entity.action.cancel">Cancel</span>
<button type="button" class="ds-btn ds-btn--secondary" data-dismiss="modal" (click)="cancel()">
<fa-icon icon="arrow-left"></fa-icon>&nbsp;<span jhiTranslate="entity.action.cancel">Cancel</span>
</button>
<button id="jhi-confirm-delete-plantilla" data-cy="entityConfirmDeleteButton" type="submit" class="btn btn-danger">

View File

@ -3,6 +3,7 @@ import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { IPlantilla } from '../plantilla.model';
import { PlantillaService } from '../service/plantilla.service';
import { EstadoPlantilla } from '../../enumerations/estado-plantilla.model';
@Component({
templateUrl: './plantilla-delete-dialog.component.html',
@ -16,8 +17,9 @@ export class PlantillaDeleteDialogComponent {
this.activeModal.dismiss();
}
confirmDelete(id: number): void {
this.plantillaService.delete(id).subscribe(() => {
confirmDelete(pPlantilla: IPlantilla): void {
pPlantilla.estado = EstadoPlantilla.DELETED;
this.plantillaService.update(pPlantilla).subscribe(() => {
this.activeModal.close('deleted');
});
}

View File

@ -39,7 +39,6 @@
<thead>
<tr>
<th scope="col"><span jhiTranslate="dataSurveyApp.plantilla.nombre">Nombre</span></th>
<th scope="col"><span jhiTranslate="dataSurveyApp.plantilla.descripcion">Descripcion</span></th>
<!-- <th scope="col"><span jhiTranslate="dataSurveyApp.plantilla.fechaCreacion">Fecha Creacion</span></th> -->
<th scope="col"><span jhiTranslate="dataSurveyApp.plantilla.fechaPublicacionTienda">Fecha Publicacion Tienda</span></th>
<th scope="col"><span jhiTranslate="dataSurveyApp.plantilla.estado">Estado</span></th>
@ -51,7 +50,6 @@
<tbody>
<tr *ngFor="let plantilla of plantillas; trackBy: trackId" data-cy="entityTable">
<td>{{ plantilla.nombre }}</td>
<td>{{ plantilla.descripcion }}</td>
<!-- <td>{{ plantilla.fechaCreacion | formatMediumDatetime }}</td> -->
<td *ngIf="plantilla.fechaPublicacionTienda">{{ plantilla.fechaPublicacionTienda | formatShortDatetime | titlecase }}</td>
<td *ngIf="!plantilla.fechaPublicacionTienda">No establecida</td>
@ -61,16 +59,6 @@
<td>{{ plantilla.categoria?.nombre }}</td>
<td class="text-right">
<div class="btn-group">
<button
type="submit"
[routerLink]="['/plantilla', plantilla.id, 'view']"
class="ds-btn ds-btn--secondary btn-sm"
data-cy="entityDetailsButton"
>
<fa-icon icon="eye"></fa-icon>
<span class="d-none d-md-inline">Vista previa</span>
</button>
<button
type="submit"
[routerLink]="['/plantilla', plantilla.id, 'edit']"
@ -79,7 +67,10 @@
>
<span class="d-none d-md-inline" jhiTranslate="entity.action.edit">Edit</span>
</button>
<button type="submit" (click)="cambiarEstado(plantilla)" class="ds-btn btn-warning btn-sm" data-cy="entityDeleteButton">
<fa-icon [icon]="faExchangeAlt"></fa-icon>
<span class="d-none d-md-inline" jhiTranslate="dataSurveyApp.plantilla.updated.buttonChangeEstado">Change status</span>
</button>
<button type="submit" (click)="delete(plantilla)" class="ds-btn ds-btn--danger btn-sm" data-cy="entityDeleteButton">
<fa-icon icon="times"></fa-icon>
<span class="d-none d-md-inline" jhiTranslate="entity.action.delete">Delete</span>

View File

@ -17,6 +17,9 @@ import { CategoriaService } from 'app/entities/categoria/service/categoria.servi
import * as dayjs from 'dayjs';
import { DATE_TIME_FORMAT } from 'app/config/input.constants';
import { PlantillaChangeStatusDialogComponent } from '../plantilla-change-status-dialog/plantilla-change-status-dialog.component';
import { faExchangeAlt } from '@fortawesome/free-solid-svg-icons';
@Component({
selector: 'jhi-plantilla',
@ -39,6 +42,7 @@ export class PlantillaComponent implements OnInit {
categoria: [null, [Validators.required]],
});
faExchangeAlt = faExchangeAlt;
constructor(
protected plantillaService: PlantillaService,
protected modalService: NgbModal,
@ -53,7 +57,8 @@ export class PlantillaComponent implements OnInit {
this.plantillaService.query().subscribe(
(res: HttpResponse<IPlantilla[]>) => {
this.isLoading = false;
this.plantillas = res.body ?? [];
const tempPlantillas = res.body ?? [];
this.plantillas = tempPlantillas.filter(p => p.estado !== EstadoPlantilla.DELETED);
},
() => {
this.isLoading = false;
@ -81,6 +86,17 @@ export class PlantillaComponent implements OnInit {
});
}
cambiarEstado(plantilla: IPlantilla): void {
const modalRef = this.modalService.open(PlantillaChangeStatusDialogComponent, { size: 'lg', backdrop: 'static' });
modalRef.componentInstance.plantilla = plantilla;
// unsubscribe not needed because closed completes on modal close
modalRef.closed.subscribe(reason => {
if (reason === 'updated') {
this.loadAll();
}
});
}
isAdmin(): boolean {
return this.accountService.hasAnyAuthority('ROLE_ADMIN');
}

View File

@ -0,0 +1,32 @@
<form *ngIf="plantilla" class="ds-form" name="changeStatusForm" (ngSubmit)="confirmChangeStatus(plantilla)">
<div class="modal-body">
<p class="ds-title--small">Cambiar estado</p>
<p
*ngIf="plantilla.estado != 'DISABLED'"
class="ds-subtitle"
id="jhi-inactive-plantilla-heading"
jhiTranslate="dataSurveyApp.plantilla.desactivar.question"
>
Are you sure you want to delete this option?
</p>
<p
*ngIf="plantilla.estado == 'DISABLED'"
class="ds-subtitle"
id="jhi-active-plantilla-heading"
jhiTranslate="dataSurveyApp.plantilla.activar.question"
>
Are you sure you want to delete this option?
</p>
</div>
<div class="modal-footer">
<button type="button" class="ds-btn ds-btn--secondary" data-dismiss="modal" (click)="cancel()">
<fa-icon icon="arrow-left"></fa-icon>&nbsp;<span jhiTranslate="entity.action.cancel">Cancel</span>
</button>
<button id="jhi-confirm-change-status-option" data-cy="entityConfirmChangeButton" type="submit" class="ds-btn btn-warning">
<fa-icon [icon]="faExchangeAlt"></fa-icon
><span class="d-none d-md-inline" jhiTranslate="dataSurveyApp.plantilla.updated.buttonChangeEstado">Cambiar estado</span>
</button>
</div>
</form>

View File

@ -0,0 +1,24 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { PlantillaChangeStatusDialogComponent } from './plantilla-change-status-dialog.component';
describe('PlantillaChangeStatusDialogComponent', () => {
let component: PlantillaChangeStatusDialogComponent;
let fixture: ComponentFixture<PlantillaChangeStatusDialogComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [PlantillaChangeStatusDialogComponent],
}).compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(PlantillaChangeStatusDialogComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,36 @@
import { Component } from '@angular/core';
import { PlantillaService } from '../service/plantilla.service';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { EstadoPlantilla } from '../../enumerations/estado-plantilla.model';
import { IPlantilla } from '../plantilla.model';
import { faExchangeAlt } from '@fortawesome/free-solid-svg-icons';
@Component({
selector: 'jhi-plantilla-change-status-dialog',
templateUrl: './plantilla-change-status-dialog.component.html',
styleUrls: ['./plantilla-change-status-dialog.component.scss'],
})
export class PlantillaChangeStatusDialogComponent {
plantilla?: IPlantilla;
faExchangeAlt = faExchangeAlt;
constructor(protected plantillaService: PlantillaService, protected activeModal: NgbActiveModal) {}
cancel(): void {
this.activeModal.dismiss();
}
confirmChangeStatus(pPlantilla: IPlantilla) {
if (this.plantilla) {
if (pPlantilla.estado === EstadoPlantilla.DISABLED) {
this.plantilla.estado = EstadoPlantilla.DRAFT;
} else {
this.plantilla.estado = EstadoPlantilla.DISABLED;
}
this.plantillaService.update(this.plantilla).subscribe(() => {
this.activeModal.close('updated');
});
}
}
}

View File

@ -10,6 +10,7 @@ import { PlantillaDeleteQuestionDialogComponent } from './plantilla-delete-quest
import { PlantillaDeleteOptionDialogComponent } from './plantilla-delete-option-dialog/plantilla-delete-option-dialog.component';
import { PlantillaPublishStoreDialogComponent } from './plantilla-publish-store-dialog/plantilla-publish-store-dialog.component';
import { PlantillaDeleteStoreDialogComponent } from './plantilla-delete-store-dialog/plantilla-delete-store-dialog.component';
import { PlantillaChangeStatusDialogComponent } from './plantilla-change-status-dialog/plantilla-change-status-dialog.component';
@NgModule({
imports: [SharedModule, PlantillaRoutingModule, FontAwesomeModule],
@ -22,6 +23,7 @@ import { PlantillaDeleteStoreDialogComponent } from './plantilla-delete-store-di
PlantillaDeleteOptionDialogComponent,
PlantillaPublishStoreDialogComponent,
PlantillaDeleteStoreDialogComponent,
PlantillaChangeStatusDialogComponent,
],
entryComponents: [PlantillaDeleteDialogComponent],
})

View File

@ -9,10 +9,13 @@
"notFound": "No se encontró ninguna plantilla"
},
"created": "Una nueva plantilla ha sido creada con el identificador {{ param }}",
"updated": "Una plantilla ha sido actualizada con el identificador {{ param }}",
"updated": {
"detail": "Una plantilla ha sido actualizada con el identificador {{ param }}",
"buttonChangeEstado": "Cambiar estado"
},
"deleted": "Una plantilla ha sido eliminada con el identificador {{ param }}",
"delete": {
"question": "¿Seguro que quiere eliminar Plantilla {{ id }}?",
"question": "¿Seguro que quiere eliminar esta plantilla?",
"deletefromstore": "¿Seguro que quiere eliminar esta plantilla de la tienda?"
},
"publish": {
@ -21,6 +24,14 @@
"detail": {
"title": "Plantilla"
},
"desactivar": {
"titulo": "Desactivar plantilla",
"question": "¿Seguro que quiere desactivar la plantilla?"
},
"activar": {
"titulo": "Activar plantilla",
"question": "¿Seguro que quiere activar la plantilla?. Esta será activada en estado de 'Borrador'"
},
"id": "ID",
"nombre": "Nombre",
"descripcion": "Descripción",