Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

AO3-5263: More filters! #3194

Merged
merged 10 commits into from Dec 4, 2017

Conversation

Projects
None yet
4 participants
Owner

elzj commented Dec 2, 2017

Issue

https://otwarchive.atlassian.net/browse/AO3-5263

Purpose

Adds some additional filtering options and also updates the class used for toggling filters.

Testing

New filters should work, old filters should expand/collapse properly.

elzj and others added some commits Dec 1, 2017

@@ -12,6 +12,7 @@ class WorkSearch < Search
:revised_at,
:language_id,
:complete,
+ :crossover,
@houndci-bot

houndci-bot Dec 2, 2017

Align the parameters of a method call if they span more than one line.

@@ -34,6 +35,10 @@ class WorkSearch < Search
:relationship_ids,
:freeform_names,
:freeform_ids,
+ :date_from,
@houndci-bot

houndci-bot Dec 2, 2017

Align the parameters of a method call if they span more than one line.

@@ -34,6 +35,10 @@ class WorkSearch < Search
:relationship_ids,
:freeform_names,
:freeform_ids,
+ :date_from,
+ :date_to,
@houndci-bot

houndci-bot Dec 2, 2017

Align the parameters of a method call if they span more than one line.

@@ -34,6 +35,10 @@ class WorkSearch < Search
:relationship_ids,
:freeform_names,
:freeform_ids,
+ :date_from,
+ :date_to,
+ :words_from,
@houndci-bot

houndci-bot Dec 2, 2017

Align the parameters of a method call if they span more than one line.

+ :date_from,
+ :date_to,
+ :words_from,
+ :words_to,
@houndci-bot

houndci-bot Dec 2, 2017

Align the parameters of a method call if they span more than one line.

@@ -8,7 +8,7 @@ $j(document).ready(function() {
// e.g. Fandoms dt should have a button to toggle dd with Fandom tags
// (actual toggling done with setupAccordion in application.js)
function setupFilterToggles() {
- var filter_option = $j('.filters').find('dt.tags');
+ var filter_option = $j('.filters').find('dt.filter-toggle');
@houndci-bot

houndci-bot Dec 2, 2017

Identifier 'filter_option' is not in camel case.
'$j' is not defined.

function showFilters() {
- var filters = $j('.filters').find('dd.tags');
+ var filters = $j('.filters').find('dd.expandable');
@houndci-bot

houndci-bot Dec 2, 2017

'$j' is not defined.

+ // selected), so we only want to look at inputs with an existing value
+ // attribute that is not blank
+ // https://stackoverflow.com/questions/17248915/
+ var inputs = $j(filter).find('input').filter('[value]:not([value=""])');
@houndci-bot

houndci-bot Dec 2, 2017

'$j' is not defined.

+ // We've already excluded inputs with blank values, so any
+ // text fields in this array will be non-blank and therefore need to be
+ //expanded
+ if ($j(input).is(':checked, [type="text"]')) {
@houndci-bot

houndci-bot Dec 2, 2017

'$j' is not defined.

@@ -1 +1 @@
-function setupFilterToggles(){var e=$j(".filters").find("dt.tags");e.each(function(){var e=$j(this).next().attr("id");$j(this).wrapInner('<button type="button" class="expander" aria-expanded="false" aria-controls="'+e+'"></button>')}),$j("dt.tags button").on("click",function(){"false"==$j(this).attr("aria-expanded")?$j(this).attr("aria-expanded","true"):$j(this).attr("aria-expanded","false")})}function showFilters(){var e=$j(".filters").find("dd.tags");e.each(function(e,t){var a=$j(t).find("input"),r=$j(t).attr("id"),n=$j("#toggle_"+r),i=$j('[aria-controls="'+r+'"]');a.each(function(e,a){$j(a).is(":checked")&&($j(t).removeClass("hidden"),$j(n).removeClass("collapsed").addClass("expanded"),$j(i).attr("aria-expanded","true"))})})}function setupNarrowScreenFilters(){var e=$j("form.filters"),t=$j("#outer"),a=$j("#go_to_filters"),r=$j("#leave_filters");a.click(function(a){a.preventDefault(),e.removeClass("narrow-hidden"),t.addClass("filtering"),e.find(":focusable").first().focus(),e.trap()}),r.click(function(r){r.preventDefault(),t.removeClass("filtering"),e.addClass("narrow-hidden"),a.focus()})}$j(document).ready(function(){setupFilterToggles(),showFilters(),setupNarrowScreenFilters()});
+function setupFilterToggles(){var e=$j(".filters").find("dt.filter-toggle");e.each(function(){var e=$j(this).next().attr("id");$j(this).wrapInner('<button type="button" class="expander" aria-expanded="false" aria-controls="'+e+'"></button>')}),$j("dt.tags button").on("click",function(){"false"==$j(this).attr("aria-expanded")?$j(this).attr("aria-expanded","true"):$j(this).attr("aria-expanded","false")})}function showFilters(){var e=$j(".filters").find("dd.expandable");e.each(function(e,t){var a=$j(t).find("input").filter('[value]:not([value=""])'),r=$j(t).attr("id"),n=$j("#toggle_"+r),i=$j('[aria-controls="'+r+'"]');a.each(function(e,a){$j(a).is(':checked, [type="text"]')&&($j(t).removeClass("hidden"),$j(n).removeClass("collapsed").addClass("expanded"),$j(i).attr("aria-expanded","true"))})})}function setupNarrowScreenFilters(){var e=$j("form.filters"),t=$j("#outer"),a=$j("#go_to_filters"),r=$j("#leave_filters");a.click(function(a){a.preventDefault(),e.removeClass("narrow-hidden"),t.addClass("filtering"),e.find(":focusable").first().focus(),e.trap()}),r.click(function(r){r.preventDefault(),t.removeClass("filtering"),e.addClass("narrow-hidden"),a.focus()})}$j(document).ready(function(){setupFilterToggles(),showFilters(),setupNarrowScreenFilters()});
@houndci-bot

houndci-bot Dec 2, 2017

Line is too long.
Mixed double and single quotes.
Missing semicolon.
Expected an assignment or function call and instead saw an expression.
'$j' is not defined.

@@ -58,7 +58,7 @@
it "should allow you to filter for complete works" do
q = WorkQuery.new(complete: true)
- expect(q.filters).to include({term: { complete: 'true'} })
+ expect(q.filters).to include({ term: { complete: true } })
@houndci-bot

houndci-bot Dec 2, 2017

Redundant curly braces around a hash parameter.

sarken approved these changes Dec 4, 2017

Elz reviewed my frontend changes and I reviewed her backend changes, so let's call this mergeable.

@sarken sarken merged commit 0736a7d into otwcode:master Dec 4, 2017

4 checks passed

Scrutinizer 20 new issues, 5 updated code elements
Details
codeclimate All good!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
hound 11 violations found.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment