-
Notifications
You must be signed in to change notification settings - Fork 12
Daterange #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Daterange #47
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -476,7 +476,7 @@ function initEngine() { | |
|
|
||
| resultListController = buildResultList( headlessEngine, { | ||
| options: { | ||
| fieldsToInclude: [ "author", "date", "language", "urihash", "objecttype", "collection", "source", "permanentid", "displaynavlabel", "hostname" ] | ||
| fieldsToInclude: [ "author", "date", "language", "urihash", "objecttype", "collection", "source", "permanentid", "displaynavlabel", "hostname", "declared_type" ] | ||
| } | ||
| } ); | ||
| querySummaryController = buildQuerySummary( headlessEngine ); | ||
|
|
@@ -485,7 +485,7 @@ function initEngine() { | |
| statusController = buildSearchStatus( headlessEngine ); | ||
|
|
||
| if ( urlParams.allq || urlParams.exctq || urlParams.anyq || urlParams.noneq || urlParams.fqupdate || | ||
| urlParams.dmn || urlParams.fqocct || urlParams.elctn_cat || urlParams.filetype || urlParams.site || urlParams.year ) { | ||
| urlParams.dmn || urlParams.fqocct || urlParams.elctn_cat || urlParams.filetype || urlParams.site || urlParams.year || urlParams.declaredtype || urlParams.startdate || urlParams.enddate ) { | ||
| let q = []; | ||
| let qString = ""; | ||
| if ( urlParams.allq ) { | ||
|
|
@@ -622,6 +622,28 @@ function initEngine() { | |
| let site = urlParams.site.toLowerCase().replace( '*', '' ); | ||
| aqString += ' @canadagazettesite==' + site; | ||
| } | ||
|
|
||
| if ( urlParams.startdate && urlParams.enddate ) { | ||
| aqString += ' @date = "' + urlParams.startdate.replaceAll('-','/') + '..' + urlParams.enddate.replaceAll('-','/') + '"'; | ||
| } | ||
|
Comment on lines
+626
to
+628
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ipaksc Can you also include the cases where there would only be a startdate provided, and when there is only an enddate provided?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
with
|
||
|
|
||
| if ( urlParams.startdate ) { | ||
| aqString += ' @date = "' + urlParams.startdate.replaceAll('-','/') + '..' + currentDate() + '"'; | ||
| } | ||
|
|
||
| if ( urlParams.enddate ) { | ||
| aqString += ' @date < "' + urlParams.enddate.replaceAll('-','/') + '"'; | ||
| } | ||
|
|
||
| if ( urlParams.dprtmnt ) { | ||
| aqString += ' @author = "' + urlParams.dprtmnt + '"'; | ||
|
|
||
| } | ||
|
|
||
| if ( urlParams.declaredtype ) { | ||
| aqString += ' @declared_type="' + urlParams.declaredtype.replaceAll( /'/g, ''' ) + '"'; | ||
|
|
||
| } | ||
|
|
||
| if ( aqString ) { | ||
| const action = loadAdvancedSearchQueryActions( headlessEngine ).updateAdvancedSearchQueries( { | ||
|
|
@@ -1151,6 +1173,10 @@ function updatePagerState( newState ) { | |
|
|
||
| buttonNode.onclick = () => { | ||
| pagerController.previousPage(); | ||
|
|
||
| if ( params.isAdvancedSearch ) { | ||
| updateUrlParameter( pagerState.currentPage ); | ||
| } | ||
| }; | ||
|
|
||
| pagerComponentElement.appendChild( liNode ); | ||
|
|
@@ -1178,6 +1204,10 @@ function updatePagerState( newState ) { | |
|
|
||
| buttonNode.onclick = () => { | ||
| pagerController.selectPage( pageNo ); | ||
|
|
||
| if ( params.isAdvancedSearch ) { | ||
| updateUrlParameter( pagerState.currentPage ); | ||
| } | ||
| }; | ||
|
|
||
| pagerComponentElement.appendChild( liNode ); | ||
|
|
@@ -1192,11 +1222,40 @@ function updatePagerState( newState ) { | |
|
|
||
| buttonNode.onclick = () => { | ||
| pagerController.nextPage(); | ||
|
|
||
| if ( params.isAdvancedSearch ) { | ||
| updateUrlParameter( pagerState.currentPage ); | ||
| } | ||
| }; | ||
|
|
||
| pagerComponentElement.appendChild( liNode ); | ||
| } | ||
| } | ||
|
|
||
| function currentDate() { | ||
| var today = new Date(); | ||
| var dd = String(today.getDate()).padStart(2, '0'); | ||
| var mm = String(today.getMonth() + 1).padStart(2, '0'); | ||
| var yyyy = today.getFullYear(); | ||
|
|
||
| today = yyyy + "/" + mm + "/" + dd; | ||
|
|
||
| return today; | ||
| } | ||
|
|
||
| function updateUrlParameter(curtPage) { | ||
|
|
||
| const urlParams = new URLSearchParams(window.location.search); | ||
| const paramName = 'firstResult'; | ||
| const pageNum = (curtPage - 1) * 10; | ||
|
|
||
| // Set the value of the parameter. If it doesn't exist, it will be added. | ||
| urlParams.set(paramName, pageNum); | ||
|
|
||
| const newSearch = urlParams.toString(); | ||
| window.history.replaceState({}, '', `${window.location.pathname}?${newSearch}${window.location.hash}`); | ||
|
|
||
| } | ||
|
|
||
| // Run Search UI | ||
| initSearchUI(); | ||
Uh oh!
There was an error while loading. Please reload this page.