From: Kohei Yoshino Date: Fri, 5 Jul 2019 22:49:10 +0000 (-0400) Subject: Bug 1557799 - Search By Change History: date range is ignored when field is not specified X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b8b90dadd1d3ccf29b2338fb668f3478d0849b63;p=thirdparty%2Fbugzilla.git Bug 1557799 - Search By Change History: date range is ignored when field is not specified --- diff --git a/extensions/BMO/web/js/advanced-search.js b/extensions/BMO/web/js/advanced-search.js index 3e5662453..9fa341ef0 100644 --- a/extensions/BMO/web/js/advanced-search.js +++ b/extensions/BMO/web/js/advanced-search.js @@ -11,10 +11,16 @@ */ var Bugzilla = Bugzilla || {}; // eslint-disable-line no-var +/** + * Reference or define the BMO extension namespace. + * @namespace + */ +Bugzilla.BMO = Bugzilla.BMO || {}; + /** * Implement Advanced Search page features. */ -Bugzilla.AdvancedSearch = class AdvancedSearch { +Bugzilla.BMO.AdvancedSearch = class AdvancedSearch { /** * Initialize a new AdvancedSearch instance. */ @@ -44,4 +50,4 @@ Bugzilla.AdvancedSearch = class AdvancedSearch { } }; -window.addEventListener('DOMContentLoaded', () => new Bugzilla.AdvancedSearch(), { once: true }); +window.addEventListener('DOMContentLoaded', () => new Bugzilla.BMO.AdvancedSearch(), { once: true }); diff --git a/js/advanced-search.js b/js/advanced-search.js index 50e673046..8f3214815 100644 --- a/js/advanced-search.js +++ b/js/advanced-search.js @@ -11,6 +11,48 @@ */ var Bugzilla = Bugzilla || {}; // eslint-disable-line no-var +Bugzilla.AdvancedSearch = {}; + +/** + * Implement features in the Search By Change History section. + */ +Bugzilla.AdvancedSearch.HistoryFilter = class HistoryFilter { + /** + * Initialize a new HistoryFilter instance. + */ + constructor() { + this.$chfield = document.querySelector('#chfield'); + this.$chfieldfrom = document.querySelector('#chfieldfrom'); + this.$chfieldfrom_button = document.querySelector('#chfieldfrom + button'); + this.$chfieldto = document.querySelector('#chfieldto'); + this.$chfieldto_button = document.querySelector('#chfieldto + button'); + + this.$chfieldfrom.addEventListener('input', event => this.on_date_change(event)); + this.$chfieldto.addEventListener('input', event => this.on_date_change(event)); + + // Use on-event handler because `field.js` will update it + this.$chfieldfrom_button.onclick = () => showCalendar('chfieldfrom'); + this.$chfieldto_button.onclick = () => showCalendar('chfieldto'); + + createCalendar('chfieldfrom'); + createCalendar('chfieldto'); + } + + /** + * Called whenever the date field value is updated. + * @param {InputEvent} event `input` event fired on date fields. + */ + on_date_change(event) { + // Update the calendar when the user enters a date manually + if (event.isTrusted) { + updateCalendarFromField(event.target); + } + + // Mark ` -
(comma-separated list)
+ (comma-separated list) should be - - and -
- - -
- (YYYY-MM-DD or relative dates) - + + + and +
+ + +
+ (YYYY-MM-DD or relative dates)