Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/app/apps/gestor-usuarios/views/usuarios-edit.view.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
<plex-layout [main]="4">
<plex-layout-main>
<header>

<plex-title [titulo]="orgName" size="md">
<plex-button label="VOLVER" (click)="volver()" type="danger"></plex-button>
</plex-title>

<div class="fecha-vencimiento" *ngIf="canEditAccount">
<plex-badge size="sm" [type]="isExpired ? 'danger' : 'warning'">
VENCIMIENTO
<span dato>
{{ (fechaVencimiento | date: 'dd/MM/yyyy') || 'Sin fecha' }}
</span>
</plex-badge>

<plex-datetime type="date" [(ngModel)]="fechaVencimiento" (change)="onEditarFechaVencimiento()"
tooltip="Agregar fecha" name="fechaVencimiento" [min]="hoy" [btnOnly]="true" size="sm">
</plex-datetime>
<plex-button icon="clock" type="danger" size="sm" (click)="onEliminarFechaVencimiento()"
tooltip="Eliminar fecha" tooltipPosition="right"></plex-button>
</div>
<ng-container *ngIf="user$ | async as user">
<gestor-usuarios-usuario-detalle [usuario]="user"></gestor-usuarios-usuario-detalle>

</ng-container>
</header>
<ng-container *ngIf="arbolPermisos.length && perfiles.length">
Expand All @@ -20,6 +37,7 @@
</div>
</ng-container>
</div>

</ng-container>
</plex-layout-main>
<plex-layout-sidebar>
Expand All @@ -42,4 +60,5 @@
[organizacion]="organizacionId">
</arbol-permisos>
</plex-layout-sidebar>

</plex-layout>
7 changes: 7 additions & 0 deletions src/app/apps/gestor-usuarios/views/usuarios-edit.view.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.fecha-vencimiento {
display: flex;
align-items: center;
gap: 4px;
margin-left: 10px;
margin-top: 30px;
}
34 changes: 32 additions & 2 deletions src/app/apps/gestor-usuarios/views/usuarios-edit.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ import { Auth } from '@andes/auth';

@Component({
selector: 'gestor-usarios-usuarios-edit',
templateUrl: 'usuarios-edit.view.html'
templateUrl: 'usuarios-edit.view.html',
styleUrls: ['usuarios-edit.view.scss']
})
export class UsuariosEditComponent implements OnInit, OnDestroy {
destroy$: Subject<boolean> = new Subject<boolean>();

@ViewChild(ArbolPermisosComponent, { static: true }) arbol: ArbolPermisosComponent;

private userId = '';
private _permisos = new BehaviorSubject([]);

Expand All @@ -29,6 +31,17 @@ export class UsuariosEditComponent implements OnInit, OnDestroy {
public perfiles = [];
public arbolPermisos = [];
public habilitados = {};
public fechaVencimiento: Date;
public canEditAccount = this.auth.check('usuarios:cuenta');
public hoy = new Date();
public get isExpired() {
if (!this.fechaVencimiento) {
return false;
}
const today = new Date();
today.setHours(0, 0, 0, 0);
return new Date(this.fechaVencimiento) < today;
}

get permisos() {
return this._permisos.getValue();
Expand Down Expand Up @@ -100,6 +113,7 @@ export class UsuariosEditComponent implements OnInit, OnDestroy {
if (orgPermisos) {
this.orgName = orgPermisos.nombre;
this.permisos = orgPermisos.permisos;
this.fechaVencimiento = orgPermisos.fechaVencimiento;
}
})
),
Expand All @@ -122,7 +136,9 @@ export class UsuariosEditComponent implements OnInit, OnDestroy {
_id: p.id,
nombre: p.nombre
};
})
}),
fechaVencimiento: this.fechaVencimiento,
activo: !this.isExpired
};

if (
Expand Down Expand Up @@ -182,6 +198,20 @@ export class UsuariosEditComponent implements OnInit, OnDestroy {
}
}

onEliminarFechaVencimiento() {
this.fechaVencimiento = null;
this.onEditarFechaVencimiento();
}
onEditarFechaVencimiento() {
this.usuariosHttp.updateOrganizacion(this.userId, this.organizacionId, {
id: this.organizacionId,
fechaVencimiento: this.fechaVencimiento,
activo: !this.isExpired
}).subscribe(() => {
this.plex.toast('success', 'Usuario modificado exitosamente');
});
}

copy() {
this.permisosService.copy(this.permisos);
}
Expand Down