Commit 57ce386197479e20007a25c5b7dd9c434b2f0202
1 parent
5b61bc60ed
Exists in
master
and in
1 other branch
Creado componente de configuracion
Showing
5 changed files
with
186 additions
and
2 deletions
Show diff stats
src/app/app.module.ts
| 1 | //#region MODULES | 1 | //#region MODULES |
| 2 | import { BrowserModule } from '@angular/platform-browser'; | 2 | import { BrowserModule } from '@angular/platform-browser'; |
| 3 | import { NgModule } from '@angular/core'; | 3 | import { NgModule } from '@angular/core'; |
| 4 | import { AppRoutingModule } from './app-routing.module'; | 4 | import { AppRoutingModule } from './app-routing.module'; |
| 5 | import { HttpClientModule } from '@angular/common/http'; | 5 | import { HttpClientModule } from '@angular/common/http'; |
| 6 | import { FormsModule, ReactiveFormsModule } from '@angular/forms'; | 6 | import { FormsModule, ReactiveFormsModule } from '@angular/forms'; |
| 7 | import { TooltipModule } from 'ngx-bootstrap/tooltip'; | 7 | import { TooltipModule } from 'ngx-bootstrap/tooltip'; |
| 8 | import { PopoverModule } from 'ngx-bootstrap/popover'; | 8 | import { PopoverModule } from 'ngx-bootstrap/popover'; |
| 9 | import { CarouselModule } from 'ngx-bootstrap/carousel'; | 9 | import { CarouselModule } from 'ngx-bootstrap/carousel'; |
| 10 | import { PaginationModule } from 'ngx-bootstrap/pagination'; | 10 | import { PaginationModule } from 'ngx-bootstrap/pagination'; |
| 11 | import { ModalModule } from 'ngx-bootstrap/modal'; | 11 | import { ModalModule } from 'ngx-bootstrap/modal'; |
| 12 | //#endregion | 12 | //#endregion |
| 13 | 13 | ||
| 14 | //#region Keyboard | 14 | //#region Keyboard |
| 15 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; | 15 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; |
| 16 | import { MatButtonModule } from '@angular/material/button'; | 16 | import { MatButtonModule } from '@angular/material/button'; |
| 17 | import { MatKeyboardModule } from '@ngx-material-keyboard/core'; | 17 | import { MatKeyboardModule } from '@ngx-material-keyboard/core'; |
| 18 | //#endregion | 18 | //#endregion |
| 19 | 19 | ||
| 20 | //#region COMPONENTS | 20 | //#region COMPONENTS |
| 21 | import { AppComponent } from './app.component'; | 21 | import { AppComponent } from './app.component'; |
| 22 | import { HeaderComponent } from './components/header/header.component'; | 22 | import { HeaderComponent } from './components/header/header.component'; |
| 23 | import { SidebarComponent } from './components/sidebar/sidebar.component'; | 23 | import { SidebarComponent } from './components/sidebar/sidebar.component'; |
| 24 | import { HomeComponent } from './components/home/home.component'; | 24 | import { HomeComponent } from './components/home/home.component'; |
| 25 | import { InicioComponent } from './components/inicio/inicio.component'; | 25 | import { InicioComponent } from './components/inicio/inicio.component'; |
| 26 | import { BusquedaProductosComponent } from './components/busqueda-productos/busqueda-productos.component'; | 26 | import { BusquedaProductosComponent } from './components/busqueda-productos/busqueda-productos.component'; |
| 27 | import { ConfirmacionCarritoComponent } from './components/confirmacion-carrito/confirmacion-carrito.component'; | 27 | import { ConfirmacionCarritoComponent } from './components/confirmacion-carrito/confirmacion-carrito.component'; |
| 28 | import { MasterComponent } from './components/master/master.component'; | 28 | import { MasterComponent } from './components/master/master.component'; |
| 29 | import { PopoverPromosComponent } from './components/popover-promos/popover-promos.component'; | 29 | import { PopoverPromosComponent } from './components/popover-promos/popover-promos.component'; |
| 30 | import { PopoverSinonimosComponent } from './components/popover-sinonimos/popover-sinonimos.component'; | 30 | import { PopoverSinonimosComponent } from './components/popover-sinonimos/popover-sinonimos.component'; |
| 31 | import { CancelarCompraComponent } from './components/cancelar-compra/cancelar-compra.component'; | 31 | import { CancelarCompraComponent } from './components/cancelar-compra/cancelar-compra.component'; |
| 32 | import { MensajeFinalComponent } from './components/mensaje-final/mensaje-final.component'; | 32 | import { MensajeFinalComponent } from './components/mensaje-final/mensaje-final.component'; |
| 33 | import { ComandaComponent } from './components/comanda/comanda.component'; | 33 | import { ComandaComponent } from './components/comanda/comanda.component'; |
| 34 | import { PedidosSalientesComponent } from './components/pedidos-salientes/pedidos-salientes.component'; | 34 | import { PedidosSalientesComponent } from './components/pedidos-salientes/pedidos-salientes.component'; |
| 35 | import { PagoConTarjetaComponent } from './components/pago-con-tarjeta/pago-con-tarjeta.component'; | 35 | import { PagoConTarjetaComponent } from './components/pago-con-tarjeta/pago-con-tarjeta.component'; |
| 36 | import { ConfiguracionComponent } from './components/configuracion/configuracion.component'; | ||
| 36 | //#endregion | 37 | //#endregion |
| 37 | 38 | ||
| 38 | @NgModule({ | 39 | @NgModule({ |
| 39 | declarations: [ | 40 | declarations: [ |
| 40 | AppComponent, | 41 | AppComponent, |
| 41 | HeaderComponent, | 42 | HeaderComponent, |
| 42 | SidebarComponent, | 43 | SidebarComponent, |
| 43 | HomeComponent, | 44 | HomeComponent, |
| 44 | InicioComponent, | 45 | InicioComponent, |
| 45 | BusquedaProductosComponent, | 46 | BusquedaProductosComponent, |
| 46 | ConfirmacionCarritoComponent, | 47 | ConfirmacionCarritoComponent, |
| 47 | MasterComponent, | 48 | MasterComponent, |
| 48 | PopoverPromosComponent, | 49 | PopoverPromosComponent, |
| 49 | PopoverSinonimosComponent, | 50 | PopoverSinonimosComponent, |
| 50 | CancelarCompraComponent, | 51 | CancelarCompraComponent, |
| 51 | MensajeFinalComponent, | 52 | MensajeFinalComponent, |
| 52 | ComandaComponent, | 53 | ComandaComponent, |
| 53 | PedidosSalientesComponent, | 54 | PedidosSalientesComponent, |
| 54 | PagoConTarjetaComponent | 55 | PagoConTarjetaComponent, |
| 56 | ConfiguracionComponent | ||
| 55 | ], | 57 | ], |
| 56 | imports: [ | 58 | imports: [ |
| 57 | BrowserModule, | 59 | BrowserModule, |
| 58 | AppRoutingModule, | 60 | AppRoutingModule, |
| 59 | HttpClientModule, | 61 | HttpClientModule, |
| 60 | FormsModule, | 62 | FormsModule, |
| 61 | ReactiveFormsModule, | 63 | ReactiveFormsModule, |
| 62 | ReactiveFormsModule.withConfig({ warnOnNgModelWithFormControl: 'never' }), | 64 | ReactiveFormsModule.withConfig({ warnOnNgModelWithFormControl: 'never' }), |
| 63 | TooltipModule.forRoot(), | 65 | TooltipModule.forRoot(), |
| 64 | PopoverModule.forRoot(), | 66 | PopoverModule.forRoot(), |
| 65 | BrowserAnimationsModule, | 67 | BrowserAnimationsModule, |
| 66 | MatKeyboardModule, | 68 | MatKeyboardModule, |
| 67 | MatButtonModule, | 69 | MatButtonModule, |
| 68 | CarouselModule.forRoot(), | 70 | CarouselModule.forRoot(), |
| 69 | PaginationModule.forRoot(), | 71 | PaginationModule.forRoot(), |
| 70 | ModalModule.forRoot(), | 72 | ModalModule.forRoot(), |
| 71 | ], | 73 | ], |
| 72 | providers: [], | 74 | providers: [], |
| 73 | bootstrap: [AppComponent], | 75 | bootstrap: [AppComponent], |
| 74 | entryComponents: [PagoConTarjetaComponent] | 76 | entryComponents: [PagoConTarjetaComponent, ConfiguracionComponent] |
| 75 | }) | 77 | }) |
| 76 | export class AppModule { } | 78 | export class AppModule { } |
| 77 | 79 |
src/app/components/configuracion/configuracion.component.html
| File was created | 1 | <form [formGroup]="form" class="modal-body" id="modal-body"> | |
| 2 | |||
| 3 | <div class="row"> | ||
| 4 | <div class="col-12"> | ||
| 5 | |||
| 6 | <p>¿Este punto de venta trabaja con planilla propia?</p> | ||
| 7 | |||
| 8 | <!-- RADIO BUTTONS --> | ||
| 9 | <div class="text-center"> | ||
| 10 | <div class="disabled form-check form-check-inline"> | ||
| 11 | <input | ||
| 12 | class="form-check-input" | ||
| 13 | type="radio" | ||
| 14 | id="radio1" | ||
| 15 | formControlName="usePlanillaPropia" | ||
| 16 | [value]="true"> | ||
| 17 | |||
| 18 | <label class="form-check-label" for="radio1">Si</label> | ||
| 19 | </div> | ||
| 20 | <div class="form-check form-check-inline"> | ||
| 21 | <input | ||
| 22 | class="form-check-input" | ||
| 23 | type="radio" | ||
| 24 | id="radio2" | ||
| 25 | formControlName="usePlanillaPropia" | ||
| 26 | [value]="false"> | ||
| 27 | <label class="form-check-label" for="radio2">No</label> | ||
| 28 | </div> | ||
| 29 | </div> | ||
| 30 | <div *ngIf="form.get('usePlanillaPropia').value === false" class="form-group"> | ||
| 31 | <select | ||
| 32 | formControlName="puntoVenta" | ||
| 33 | class="form-control form-control-sm w-50 mx-auto mt-2"> | ||
| 34 | <option [ngValue]="null" disabled>Seleccione una opción</option> | ||
| 35 | <option | ||
| 36 | *ngFor="let ptoVenta of puntosVenta" | ||
| 37 | [ngValue]="ptoVenta.ID"> | ||
| 38 | {{ptoVenta.ID}} {{ptoVenta.NOM}} | ||
| 39 | </option> | ||
| 40 | </select> | ||
| 41 | </div> | ||
| 42 | </div> | ||
| 43 | </div> | ||
| 44 | |||
| 45 | <div *ngIf="impresoras.length > 0" class="row"> | ||
| 46 | <div class="col-12"> | ||
| 47 | <p>Salida de impresión de comprobantes</p> | ||
| 48 | <select | ||
| 49 | formControlName="impresora" | ||
| 50 | class="form-control form-control-sm w-50 mx-auto mt-2"> | ||
| 51 | <option [ngValue]="null" disabled>Seleccione una opción</option> | ||
| 52 | <option | ||
| 53 | *ngFor="let imp of impresoras" | ||
| 54 | [ngValue]="imp.PVE"> | ||
| 55 | {{imp.PVE}} {{imp.DES}} | ||
| 56 | </option> | ||
| 57 | </select> | ||
| 58 | </div> | ||
| 59 | </div> | ||
| 60 | |||
| 61 | </form> | ||
| 62 | |||
| 63 | <div class="modal-footer py-1"> | ||
| 64 | <button | ||
| 65 | class="btn btn-sm btn-secondary" | ||
| 66 | type="button" | ||
| 67 | (click)="close()">Cancelar | ||
| 68 | </button> | ||
| 69 | <button | ||
| 70 | class="btn btn-sm btn-primary" | ||
| 71 | type="button" | ||
| 72 | (click)="acept()" | ||
| 73 | >Aceptar | ||
| 74 | </button> | ||
| 75 | </div> | ||
| 76 |
src/app/components/configuracion/configuracion.component.scss
| File was created | 1 | .disabled { | |
| 2 | pointer-events: none; | ||
| 3 | opacity: 0.5; | ||
| 4 | } | ||
| 5 |
src/app/components/configuracion/configuracion.component.spec.ts
| File was created | 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | |
| 2 | |||
| 3 | import { ConfiguracionComponent } from './configuracion.component'; | ||
| 4 | |||
| 5 | describe('ConfiguracionComponent', () => { | ||
| 6 | let component: ConfiguracionComponent; | ||
| 7 | let fixture: ComponentFixture<ConfiguracionComponent>; | ||
| 8 | |||
| 9 | beforeEach(async(() => { | ||
| 10 | TestBed.configureTestingModule({ | ||
| 11 | declarations: [ ConfiguracionComponent ] | ||
| 12 | }) | ||
| 13 | .compileComponents(); | ||
| 14 | })); | ||
| 15 | |||
| 16 | beforeEach(() => { | ||
| 17 | fixture = TestBed.createComponent(ConfiguracionComponent); | ||
| 18 | component = fixture.componentInstance; | ||
| 19 | fixture.detectChanges(); | ||
| 20 | }); | ||
| 21 | |||
| 22 | it('should create', () => { | ||
| 23 | expect(component).toBeTruthy(); | ||
| 24 | }); | ||
| 25 | }); | ||
| 26 |
src/app/components/configuracion/configuracion.component.ts
| File was created | 1 | import { Component, OnInit } from '@angular/core'; | |
| 2 | import { BsModalRef } from 'ngx-bootstrap'; | ||
| 3 | import { PuntoVentaService } from 'src/app/services/punto-venta.service'; | ||
| 4 | import { PuntoVenta } from 'src/app/wrappers/puntoVenta'; | ||
| 5 | import { ImpresoraService } from 'src/app/services/impresora.service'; | ||
| 6 | import { Impresora } from 'src/app/wrappers/impresora'; | ||
| 7 | import { FormGroup, FormControl } from '@angular/forms'; | ||
| 8 | |||
| 9 | @Component({ | ||
| 10 | selector: 'app-configuracion', | ||
| 11 | templateUrl: './configuracion.component.html', | ||
| 12 | styleUrls: ['./configuracion.component.scss'] | ||
| 13 | }) | ||
| 14 | export class ConfiguracionComponent implements OnInit { | ||
| 15 | |||
| 16 | puntosVenta: PuntoVenta[] = []; | ||
| 17 | impresoras: Impresora[] = []; | ||
| 18 | form: FormGroup; | ||
| 19 | |||
| 20 | constructor( | ||
| 21 | private activeModal: BsModalRef, | ||
| 22 | private puntoVentaService: PuntoVentaService, | ||
| 23 | private impresoraService: ImpresoraService, | ||
| 24 | ) { } | ||
| 25 | |||
| 26 | ngOnInit() { | ||
| 27 | |||
| 28 | this.form = new FormGroup({ | ||
| 29 | usePlanillaPropia: new FormControl(false, []), | ||
| 30 | puntoVenta: new FormControl(null, []), | ||
| 31 | impresora: new FormControl(null, []), | ||
| 32 | }) | ||
| 33 | |||
| 34 | this.puntoVentaService.getAll() | ||
| 35 | .subscribe((res: PuntoVenta[]) => { | ||
| 36 | |||
| 37 | this.puntosVenta = res; | ||
| 38 | this.setPuntoVenta(); | ||
| 39 | }, console.error); | ||
| 40 | |||
| 41 | this.impresoraService.getAll() | ||
| 42 | .subscribe((res: Impresora[]) => { | ||
| 43 | |||
| 44 | this.impresoras = res; | ||
| 45 | this.setImpresora(); | ||
| 46 | }, console.error); | ||
| 47 | |||
| 48 | } | ||
| 49 | |||
| 50 | close() { | ||
| 51 | |||
| 52 | this.activeModal.hide(); | ||
| 53 | } | ||
| 54 | |||
| 55 | acept() { | ||
| 56 | |||
| 57 | let auxPuntoVenta = this.puntosVenta.find(p => p.ID === this.form.get('puntoVenta').value); | ||
| 58 | let auxImpresora = this.impresoras.find(p => p.PVE === this.form.get('impresora').value); | ||
| 59 | localStorage.setItem('pve', auxPuntoVenta ? auxPuntoVenta.ID.toString() : null); | ||
| 60 | localStorage.setItem('impresoraPVE', auxImpresora ? auxImpresora.PVE.toString() : null); | ||
| 61 | this.close(); | ||
| 62 | } | ||
| 63 | |||
| 64 | setPuntoVenta() { | ||
| 65 | |||
| 66 | let pve = parseInt(localStorage.getItem('pve')); | ||
| 67 | let auxPuntoVenta = this.puntosVenta.find(x => x.ID === pve); | ||
| 68 | this.form.get('puntoVenta').setValue(auxPuntoVenta ? auxPuntoVenta.ID : null); | ||
| 69 | } | ||
| 70 | |||
| 71 | setImpresora() { | ||
| 72 | |||
| 73 | let impresoraPVE = parseInt(localStorage.getItem('impresoraPVE')); | ||
| 74 | let auxImpresora = this.impresoras.find(x => x.PVE === impresoraPVE); | ||
| 75 | this.form.get('impresora').setValue(auxImpresora ? auxImpresora.PVE : null); | ||
| 76 | } | ||
| 77 | |||
| 78 | } | ||
| 79 |