diff --git a/app/common/locales/en.json b/app/common/locales/en.json index 0b8aedb27b..881edf69c8 100644 --- a/app/common/locales/en.json +++ b/app/common/locales/en.json @@ -43,20 +43,16 @@ "filter" : "Filter", "categories" : { "categories" : "Categories", - "all_categories" : "All Categories", - "category_1" : "Category 1", - "category_2" : "Category 2", - "category_3" : "Category 3", - "category_4" : "Category 4" + "all_categories" : "All Categories" + }, + "post_types" : { + "post_types" : "Post Types", + "all_types" : "All Types" }, "sets" : { "sets" : "Sets", "my_sets" : "My Sets", - "all_sets" : "All Sets", - "set_1" : "Set 1", - "set_2" : "Set 2", - "set_3" : "Set 3", - "set_4" : "Set 4" + "all_sets" : "All Sets" }, "more" : "More", "keyword" : "Keyword", diff --git a/app/common/services/global-filter.js b/app/common/services/global-filter.js index a4c5e826c6..1771bb46a5 100644 --- a/app/common/services/global-filter.js +++ b/app/common/services/global-filter.js @@ -1,10 +1,12 @@ module.exports = [ 'TagEndpoint', + 'FormEndpoint', // 'SetEndpoint', 'Util', '_', function( TagEndpoint, + FormEndpoint, // SetEndpoint Util, _ @@ -12,6 +14,7 @@ function( var GlobalFilter = { tags: [], + post_types: [], keyword: '', start_date: '', end_date: '', @@ -28,11 +31,25 @@ function( tag.selected = false; }); }, + getSelectedPostTypes: function() { + return _.pluck(_.where(this.post_types, { selected: true }), 'id'); + }, + hasSelectedPostTypes: function() { + return !_.isEmpty(this.getSelectedPostTypes()); + }, + clearSelectedPostTypes: function() { + _.each(this.post_types, function(postType) { + postType.selected = false; + }); + }, getPostQuery: function() { var query = {}; var selected_tags = this.getSelectedTags(); - if (!_.isEmpty(selected_tags)) { query.tags = selected_tags; } + if (!_.isEmpty(selected_tags)) { query.tags = selected_tags.join(','); } + + var selected_types = this.getSelectedPostTypes(); + if (!_.isEmpty(selected_types)) { query.form = selected_types.join(','); } if (this.keyword) { query.q = this.keyword; } if (this.start_date) { query.updated_after = this.start_date; } @@ -51,6 +68,10 @@ function( GlobalFilter.tags = response.results; }); + FormEndpoint.get().$promise.then(function(response) { + GlobalFilter.post_types = response.results; + }); + // @todo - uncomment when sets are ready // SetEndpoint.get().$promise.then(function(response) { // GlobalFilter.sets = response.results; diff --git a/app/post/directives/post-view-tabs-directive.js b/app/post/directives/post-view-tabs-directive.js index 2ff6838346..768c167d9e 100644 --- a/app/post/directives/post-view-tabs-directive.js +++ b/app/post/directives/post-view-tabs-directive.js @@ -72,6 +72,12 @@ function( GlobalFilter.clearSelectedTags(); } }; + + $scope.showAllPostTypesHandler = function() { + if (this.show_all_post_types) { + GlobalFilter.clearSelectedPostTypes(); + } + }; }, }; }]; diff --git a/sass/modules/_dropdown.scss b/sass/modules/_dropdown.scss index 028d0a4b12..b04196da1e 100644 --- a/sass/modules/_dropdown.scss +++ b/sass/modules/_dropdown.scss @@ -1,6 +1,6 @@ .dropdown.filters-menu { > ul.dropdown-menu { - min-width: 250px; + min-width: 350px; .tab-content { padding: 15px; diff --git a/server/www/templates/partials/post-view-tabs.html b/server/www/templates/partials/post-view-tabs.html index e455c14e64..07f64472bb 100644 --- a/server/www/templates/partials/post-view-tabs.html +++ b/server/www/templates/partials/post-view-tabs.html @@ -81,6 +81,15 @@ TODO: Sets content + + +