Skip to content

Commit

Permalink
added the moment date display and parser to format YYYY-MM-DD #2
Browse files Browse the repository at this point in the history
  • Loading branch information
tmushayahama committed Apr 1, 2020
1 parent 365a0bb commit b0062f6
Showing 1 changed file with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,45 @@ import { NoctuaFormConfigService, NoctuaUserService, Group, Contributor, Organis
import { NoctuaLookupService } from 'noctua-form-base';
import { NoctuaSearchService } from './../../services/noctua-search.service';
import { NoctuaSearchMenuService } from '../../services/search-menu.service';
import { cloneDeep } from 'lodash';
import { MomentDateAdapter, MAT_MOMENT_DATE_ADAPTER_OPTIONS } from '@angular/material-moment-adapter';
import { DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE } from '@angular/material/core';


import * as _moment from 'moment';
// tslint:disable-next-line:no-duplicate-imports
import { default as _rollupMoment } from 'moment';

const moment = _rollupMoment || _moment;

export const MY_FORMATS = {
parse: {
dateInput: 'YYYY-MM-DD',
},
display: {
dateInput: 'YYYY-MM-DD',
monthYearLabel: 'MMMM YYYY',
dateA11yLabel: 'LL',
monthYearA11yLabel: 'MMMM YYYY',
},
};
@Component({
selector: 'noc-search-filter',
templateUrl: './search-filter.component.html',
styleUrls: ['./search-filter.component.scss'],
providers: [
{
provide: DateAdapter,
useClass: MomentDateAdapter,
deps: [MAT_DATE_LOCALE, MAT_MOMENT_DATE_ADAPTER_OPTIONS]
},

{ provide: MAT_DATE_FORMATS, useValue: MY_FORMATS },
],
})

export class SearchFilterComponent implements OnInit, OnDestroy {
searchCriteria: any = {};
dateSearchType = true;
dateSearchType = false;
filterForm: FormGroup;
selectedOrganism = {};
searchFormData: any = [];
Expand Down Expand Up @@ -60,10 +89,8 @@ export class SearchFilterComponent implements OnInit, OnDestroy {

ngOnInit(): void {


}


search() {
let searchCriteria = this.filterForm.value;

Expand Down

0 comments on commit b0062f6

Please sign in to comment.