app/js/component/ui/issues_filter.js
/*
* Copyright 2014 Thoughtworks Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
define([
'flight/lib/component',
'component/templates/issue_filter_template',
'config/config_bootstrap'
],
function (defineComponent, issueFilterTemplate, config) {
var repoNames = config.getReposNames();
return defineComponent(issuesFilter, issueFilterTemplate);
function issuesFilter() {
this.addFilters = function() {
repoNames.forEach(function (name, idx) {
var renderedFilter = $(this.renderFilter({name: name, index: idx}));
this.$node.append(renderedFilter);
renderedFilter.change(function () {
if ($(this).find('input').prop('checked')) {
$(document).trigger('ui:showRepoIssues', {repo: name});
} else {
$(document).trigger('ui:dontShowRepoIssues', {repo: name});
}
});
}.bind(this));
}
this.after('initialize', function () {
this.addFilters();
});
}
}
);