File

assets/angular/export/export-form.component.ts

Description

Main Export component

Author: Shilo Banihit

Extends

LoadableComponent

Metadata

moduleId module.id
providers Location { : , : }
selector export-form
templateUrl ./export-form.html

Index

Properties
Methods

Constructor

constructor(elm: ElementRef, LocationService: Location, translationService: TranslationService)
Parameters :
Name Type Optional Description
elm ElementRef
LocationService Location
translationService TranslationService

Methods

download
download()
Returns : void

Properties

criticalError
criticalError: any
Type : any
datePickerOpts
datePickerOpts: any
Type : any
hasClearButton
hasClearButton: boolean
Type : boolean
initSubs
initSubs: any
Type : any
modAfter
modAfter: any
Type : any
modBefore
modBefore: any
Type : any
timePickerOpts
timePickerOpts: any
Type : any
import { Component, Inject, Input, ElementRef } from '@angular/core';
import { Location, LocationStrategy, PathLocationStrategy } from '@angular/common';
import { LoadableComponent } from '../shared/loadable.component';
import moment from 'moment-es6';
import { TranslationService } from '../shared/translation-service';

/**
 * Main Export component
 *
 * Author: <a href='https://github.com/shilob' target='_blank'>Shilo Banihit</a>
 *
 */
@Component({
  moduleId: module.id,
  selector: 'export-form',
  templateUrl: './export-form.html',
  providers: [Location, {provide: LocationStrategy, useClass: PathLocationStrategy}]
})

export class ExportFormComponent extends LoadableComponent {
  criticalError: any;
  modBefore: any;
  modAfter: any;
  initSubs: any;
  datePickerOpts: any;
  timePickerOpts: any;
  hasClearButton: boolean;

  constructor(
    elm: ElementRef,
    @Inject(Location) protected LocationService: Location,
    translationService:TranslationService
  ) {
    super();
    this.timePickerOpts = false;
    this.hasClearButton = false;
    this.datePickerOpts = {placeholder: 'dd/mm/yyyy', format: 'dd/mm/yyyy', icon: 'fa fa-calendar'};
    this.initTranslator(translationService);
    translationService.isReady(tService => {
      this.checkIfHasLoaded();
    });
  }

  download() {
    const before = this.modBefore ? moment(this.modBefore).format('YYYY-MM-DD') : '';
    const after = this.modAfter ? moment(this.modAfter).format('YYYY-MM-DD') : '';
    const url = this.LocationService.prepareExternalUrl(`export/record/download/csv?before=${before}&after=${after}`);
    window.open(url, '_blank');
  }

}
<div class="row" *ngIf="!isLoading">
  <div class="col-xs-1">
  </div>
  <div class="col-xs-10">
    <div class="form-horizontal">
      <div class="form-group">
        <label class="col-xs-2 control-label">{{ 'export-modified-after' | translate }} </label>
        <span class="col-xs-10">
          <datetime id="after" [(ngModel)]="modAfter" [datepicker]="datePickerOpts" [timepicker]="timePickerOpts" [hasClearButton]="hasClearButton"></datetime>
        </span>
      </div>
      <div class="form-group">
        <label class="col-xs-2 control-label">{{ 'export-modified-before' | translate }} </label>
        <span class="col-xs-10">
          <datetime id="before" [(ngModel)]="modBefore" [datepicker]="datePickerOpts" [timepicker]="timePickerOpts" [hasClearButton]="hasClearButton"></datetime>
        </span>
      </div>
      <div class="form-group">
        <div class="col-xs-offset-2 col-xs-10">
          <button (click)="download()" class="btn btn-primary">{{ 'export-download' | translate }}</button>
        </div>
      </div>
    </div>
  </div>
  <div class="col-xs-1">
  </div>
</div>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""