params.joinOp = [];
params.matchOp = [];
- if (ts.format) {
- params.format = ts.format;
- }
-
- if (ts.available) {
- params.available = ts.available;
- }
-
- if (ts.hasBrowseEntry) {
- params.hasBrowseEntry = ts.hasBrowseEntry;
- }
+ ['format', 'available', 'hasBrowseEntry', 'date1', 'date2', 'dateOp']
+ .forEach(field => {
+ if (ts[field]) {
+ params[field] = ts[field];
+ }
+ });
ts.query.forEach((val, idx) => {
if (val !== '') {
const ts = context.termSearch;
if (params.has('hasBrowseEntry')) {
+
+ // Browse entry display is (currently) a standalone filter.
+ // Other filters could be applied if needed.
ts.hasBrowseEntry = params.get('hasBrowseEntry');
} else if (params.has('query')) {
- if (params.has('format')) {
- ts.format = params.get('format');
- }
-
- if (params.get('available')) {
- ts.available = Boolean(params.get('available'));
- }
+ // Scalars
+ ['format', 'available', 'date1', 'date2', 'dateOp']
+ .forEach(field => {
+ if (params.has(field)) {
+ ts[field] = params.get(field);
+ }
+ });
+ // Arrays
['query', 'fieldClass', 'joinOp', 'matchOp'].forEach(field => {
const arr = params.getAll(field);
if (params.has(field)) {
- ts[field] = params.getAll(field); // array
+ ts[field] = params.getAll(field);
}
});
copyLocations: string[]; // ID's, but treated as strings in the UI.
isMetarecord: boolean; // TODO
hasBrowseEntry: string; // "entryId,fieldId"
+ date1: number;
+ date2: number;
+ dateOp: string; // before, after, between, is
reset() {
this.query = [''];
this.copyLocations = [''];
this.format = '';
this.hasBrowseEntry = '';
+ this.date1 = null;
+ this.date2 = null;
+ this.dateOp = 'is';
}
isSearchable(): boolean {
this.facetFilters.push(facet);
}
}
-
}
str += ' sort(' + parts[0] + ')';
}
+ if (ts.date1 && ts.dateOp) {
+ switch (ts.dateOp) {
+ case 'is':
+ str += ` date1(${ts.date1})`;
+ break;
+ case 'before':
+ str += ` before(${ts.date1})`;
+ break;
+ case 'after':
+ str += ` after(${ts.date1})`;
+ break;
+ case 'between':
+ if (ts.date2) {
+ str += ` between(${ts.date1},${ts.date2})`;
+ }
+ }
+ }
+
// -------
// Compile boolean sub-query components
if (str.length) { str += ' '; }
this.searchForm.searchTab = 'browse';
}
-
- ngAfterViewInit() {
}
</select>
</div>
</div>
+ <div class="row mt-3" *ngIf="showFilters()">
+ <div class="col-lg-12">
+ <div class="form-inline" i18n>
+ <label for="pub-date1-input">Publication Year is</label>
+ <select class="form-control ml-2" [(ngModel)]="context.termSearch.dateOp">
+ <option value='is'>Is</option>
+ <option value='before'>Before</option>
+ <option value='after'>After</option>
+ <option value='between'>Between</option>
+ </select>
+ <input class="form-control ml-2" type="number"
+ [(ngModel)]="context.termSearch.date1"/>
+ <input class="form-control ml-2" type="number"
+ *ngIf="context.termSearch.dateOp == 'between'"
+ [(ngModel)]="context.termSearch.date2"/>
+ </div>
+ </div>
+ </div>
</ng-template>
</ngb-tab>
<ngb-tab title="Numeric Search" i18n-title id="ident">