Skip to content

Commit

Permalink
feat(TOP): se agrega opción eliminar elemento rup
Browse files Browse the repository at this point in the history
  • Loading branch information
maring0019 authored and silviroa committed Mar 6, 2024
1 parent f791572 commit 0b8a649
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@
<plex-button *ngSwitchDefault type="warning" icon="pencil" size="sm"
[routerLink]="['atomo', elemento.id]">
</plex-button>

</ng-container>

<plex-button type="danger" size="sm" icon="delete" tooltip="Eliminar"
(click)="removeElemento(elemento)">
</plex-button>
</plex-item>
</plex-list>
</plex-layout-main>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Observable } from 'rxjs';
import { IElementoRUP } from 'src/app/shared/IElementoRUP';
import { ElementosRupService } from '../../services/elementos-rup.service';
import { ElementosRupListadoService } from './elementos-rup-listado.service';

import { Plex } from '@andes/plex';
@Component({
selector: 'rup-elementos-rup-listado',
templateUrl: 'elementos-rup-listado.component.html',
Expand All @@ -17,7 +17,7 @@ export class RUPElementosRupListadoComponent implements OnInit {
private router: Router,
private listadoService: ElementosRupListadoService,
private elementosRupService: ElementosRupService,
private auth: Auth
private auth: Auth, private plex: Plex
) { }

public items = [
Expand All @@ -39,4 +39,24 @@ export class RUPElementosRupListadoComponent implements OnInit {
goto(url) {
this.router.navigate([url]);
}

removeElemento(elementoRup: IElementoRUP) {
if (elementoRup.activo) {
this.plex.confirm(' Ud. está por eliminar el/la ' + elementoRup.tipo + ' "' + elementoRup.nombre + '", está seguro?').then((resultado) => {
const rta = resultado;
if (rta) {
elementoRup.activo = false;
this.elementosRupService.save(elementoRup).subscribe(() => {
this.elementosRupService.refresh.next(null);
this.plex.toast('success', 'El elemento se borró correctamente', 'Información', 2000);
},
err => {
if (err) {
this.plex.toast('danger', 'No fue posible eliminar el elemento');
}
});
}
});
}
}
}
5 changes: 1 addition & 4 deletions src/app/rupers/services/elementos-rup.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@ import { BehaviorSubject, Subject } from 'rxjs';
@Injectable({ providedIn: 'root' })
export class ElementosRupService extends ResourceBaseHttp {
protected url = '/modules/rup/elementos-rup';


refresh = new BehaviorSubject(null);

public cache$ = this.refresh.pipe(
switchMap(() => this.search({ limit: 1000 })),
switchMap(() => this.search({ activo: true, limit: 1000 })),
tap(data => this.processData(data)),
cache()
);
Expand Down

0 comments on commit 0b8a649

Please sign in to comment.