Skip to content

Commit

Permalink
now can search by date with correc format #2
Browse files Browse the repository at this point in the history
  • Loading branch information
tmushayahama committed Apr 1, 2020
1 parent b0062f6 commit 576f5b7
Show file tree
Hide file tree
Showing 7 changed files with 8,887 additions and 7,183 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,16 +201,16 @@
Date
</div>
<span fxFlex></span>
<mat-radio-group fxFlex="200px" formControlName="dateSearchType" fxLayout="row" fxLayoutAlign="end center">
<mat-radio-button checked class="noc-radio-button-rounded noc-xs mr-8" [value]="true"> Date Range
<mat-radio-group fxFlex="200px" formControlName="isExactDate" fxLayout="row" fxLayoutAlign="end center">
<mat-radio-button checked class="noc-radio-button-rounded noc-xs mr-8" [value]="true">Exact Date
</mat-radio-button>
<mat-radio-button class="noc-radio-button-rounded noc-xs mr-8" [value]="false"> Exact Date
<mat-radio-button class="noc-radio-button-rounded noc-xs mr-8" [value]="false"> Date Range
</mat-radio-button>
</mat-radio-group>
</div>
<div class="noc-section-body" fxLayout="column" fxLayoutAlign="start stretch">
<div class="noc-annoton-group-row" fxLayout="column">
<mat-form-field *ngIf="dateSearchType" appearance="outline" class="noc-sm w-100-p">
<mat-form-field *ngIf="isExactDate" appearance="outline" class="noc-sm w-100-p">
<mat-label>Filter by Exact Date</mat-label>
<mat-chip-list #dateChipList>
<mat-chip *ngFor="let date of noctuaSearchService.searchCriteria.exactdates" [selectable]="true"
Expand All @@ -226,7 +226,7 @@
<mat-datepicker-toggle matSuffix [for]="exactDatePicker"></mat-datepicker-toggle>
<mat-datepicker #exactDatePicker></mat-datepicker>
</mat-form-field>
<div *ngIf="!dateSearchType" class="noc-sm w-100-p" fxLayout="column" fxLayoutAlign="start stretch">
<div *ngIf="!isExactDate" class="noc-sm w-100-p" fxLayout="column" fxLayoutAlign="start stretch">
<mat-form-field appearance="outline" class="noc-sm">
<mat-label>Start Date</mat-label>
<mat-chip-list #startDateChipList>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const MY_FORMATS = {

export class SearchFilterComponent implements OnInit, OnDestroy {
searchCriteria: any = {};
dateSearchType = false;
isExactDate = true;
filterForm: FormGroup;
selectedOrganism = {};
searchFormData: any = [];
Expand Down Expand Up @@ -78,11 +78,9 @@ export class SearchFilterComponent implements OnInit, OnDestroy {
EntityDefinition.GoAnatomicalEntity,
EntityDefinition.GoCellTypeEntity
]);

this.filterForm = this.createAnswerForm();

this.unsubscribeAll = new Subject();

this.filterForm = this.createAnswerForm();
this.searchFormData = this.noctuaFormConfigService.createSearchFormData();
this._onValueChanges();
}
Expand All @@ -108,7 +106,7 @@ export class SearchFilterComponent implements OnInit, OnDestroy {
organisms: new FormControl(),
titles: new FormControl(),
states: new FormControl(),
dateSearchType: new FormControl(),
isExactDate: new FormControl(),
exactdates: new FormControl(),
startdates: new FormControl(),
enddates: new FormControl(),
Expand Down Expand Up @@ -234,11 +232,11 @@ export class SearchFilterComponent implements OnInit, OnDestroy {
map(group => group ? this.noctuaUserService.filterGroups(group) : this.noctuaUserService.groups.slice())
);

this.filterForm.get('dateSearchType').valueChanges.pipe(
this.filterForm.get('isExactDate').valueChanges.pipe(
distinctUntilChanged(),
debounceTime(400)
).subscribe(value => {
this.dateSearchType = value;
this.isExactDate = value;
});

this.filteredStates = this.filterForm.controls.states.valueChanges
Expand Down
4 changes: 2 additions & 2 deletions src/@noctua.search/models/search-criteria.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ export class SearchCriteria {
});

each(self.exactdates, (date) => {
query.push(`date=${date}`);
query.push(`exactdate=${date}`);
});

each(self.startdates, (date) => {
query.push(`startdate=${date}`);
});

each(self.enddates, (date) => {
query.push(`enddate=${date}`);
query.push(`dateend=${date}`);
});

each(self.organisms, (organism: Organism) => {
Expand Down
19 changes: 1 addition & 18 deletions src/@noctua.search/services/noctua-search.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ export class NoctuaSearchService {
return;
}



this.getCams(searchCriteria).subscribe((response: any) => {
this.cams = response;
this.onCamsChanged.next(this.cams);
Expand Down Expand Up @@ -369,20 +367,5 @@ export class NoctuaSearchService {
return this.states.filter(state => state.name.toLowerCase().indexOf(filterValue) === 0);
}

get dateSearchType() {
const options = [
{
name: 'daterange',
label: 'Date Range'
}, {
name: 'exactdate',
label: 'Exact Date'
},
];

return {
options: options,
selected: options[0]
}
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { DataSource, CollectionViewer } from '@angular/cdk/collections';
import { Observable, BehaviorSubject, Subject, Subscription } from 'rxjs';
import { Subject } from 'rxjs';

import { noctuaAnimations } from '@noctua/animations';

Expand Down
16,012 changes: 8,864 additions & 7,148 deletions workbenches/noctua-landing-page/public/main.js

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion workbenches/noctua-landing-page/public/main.js.map

Large diffs are not rendered by default.

0 comments on commit 576f5b7

Please sign in to comment.