diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2017-03-04 14:04:00 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2017-03-04 14:10:16 +0300 |
commit | 8a910ba297b229171a64794b8958401431354b4a (patch) | |
tree | 24e7c6c66d85cc3a058e006f3a4ce10015874e66 /app/assets | |
parent | 1d49d065ed168fcc3653d0d4681485edd524043e (diff) |
Improve projects/groups list js code
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/assets')
-rw-r--r-- | app/assets/javascripts/filterable_list.js | 2 | ||||
-rw-r--r-- | app/assets/javascripts/groups_list.js | 11 | ||||
-rw-r--r-- | app/assets/javascripts/projects_list.js | 11 |
3 files changed, 14 insertions, 10 deletions
diff --git a/app/assets/javascripts/filterable_list.js b/app/assets/javascripts/filterable_list.js index f498c3ea973..47a40e28461 100644 --- a/app/assets/javascripts/filterable_list.js +++ b/app/assets/javascripts/filterable_list.js @@ -7,8 +7,6 @@ export default class FilterableList { this.filterForm = form; this.listFilterElement = filter; this.listHolderElement = holder; - - this.initSearch(); } initSearch() { diff --git a/app/assets/javascripts/groups_list.js b/app/assets/javascripts/groups_list.js index 49b29affaa5..56a8cbf6d03 100644 --- a/app/assets/javascripts/groups_list.js +++ b/app/assets/javascripts/groups_list.js @@ -6,10 +6,13 @@ import FilterableList from './filterable_list'; */ export default class GroupsList { constructor() { - var form = document.querySelector('form#group-filter-form'); - var filter = document.querySelector('.js-groups-list-filter'); - var holder = document.querySelector('.js-groups-list-holder'); + const form = document.querySelector('form#group-filter-form'); + const filter = document.querySelector('.js-groups-list-filter'); + const holder = document.querySelector('.js-groups-list-holder'); - new FilterableList(form, filter, holder); + if (form && filter && holder) { + const list = new FilterableList(form, filter, holder); + list.initSearch(); + } } } diff --git a/app/assets/javascripts/projects_list.js b/app/assets/javascripts/projects_list.js index 383c2815457..c67d59d2be5 100644 --- a/app/assets/javascripts/projects_list.js +++ b/app/assets/javascripts/projects_list.js @@ -6,10 +6,13 @@ import FilterableList from './filterable_list'; */ export default class ProjectsList { constructor() { - var form = document.querySelector('form#project-filter-form'); - var filter = document.querySelector('.js-projects-list-filter'); - var holder = document.querySelector('.js-projects-list-holder'); + const form = document.querySelector('form#project-filter-form'); + const filter = document.querySelector('.js-projects-list-filter'); + const holder = document.querySelector('.js-projects-list-holder'); - new FilterableList(form, filter, holder); + if (form && filter && holder) { + const list = new FilterableList(form, filter, holder); + list.initSearch(); + } } } |