From 588f9445683c6790edaaa3eb567896e6c5e43fbf Mon Sep 17 00:00:00 2001 From: Josh Jeffryes Date: Fri, 15 Sep 2017 12:59:30 -0400 Subject: [PATCH 1/7] uncomment out settings NSFW --- js/templates/modals/settings/general.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/templates/modals/settings/general.html b/js/templates/modals/settings/general.html index 5caefe1a7..960f6497b 100644 --- a/js/templates/modals/settings/general.html +++ b/js/templates/modals/settings/general.html @@ -98,9 +98,9 @@

<%= ob.polyT('settings.generalTab.sectionName') %>

-
+
- +
<% if (ob.errors.showNsfw) print(ob.formErrorTmpl({ errors: ob.errors.showNsfw })) %> From f4bbbd83917b661ba65974ce4c570489308a0563 Mon Sep 17 00:00:00 2001 From: Josh Jeffryes Date: Fri, 15 Sep 2017 14:23:27 -0400 Subject: [PATCH 2/7] Fix checkboxes - fixes checkbox filters - set NSFW to user's default --- js/templates/search/Search.html | 4 ++-- js/views/search/Search.js | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/js/templates/search/Search.html b/js/templates/search/Search.html index 004ab0c74..c0f6df7e5 100644 --- a/js/templates/search/Search.html +++ b/js/templates/search/Search.html @@ -88,12 +88,12 @@

<%= val.label %>

<% _.each(val.options, function(option, index) { let checked = ''; if (ob.filterVals.hasOwnProperty(key)) { - checked = option.value === ob.filterVals[key] ? 'checked' : ''; + checked = ob.filterVals[key] ? 'checked' : ''; } else { checked = option.default ? 'checked' : ''; } var parsedLabel = ob.parseEmojis(option.label); - print(``); + print(``); print(``); }); %>
diff --git a/js/views/search/Search.js b/js/views/search/Search.js index f5de0018d..2748a66b4 100644 --- a/js/views/search/Search.js +++ b/js/views/search/Search.js @@ -79,6 +79,9 @@ export default class extends baseVw { this.sortBySelected = options.sortBySelected || params.sortBy || ''; // all parameters not specified above are assumed to be filters this.filters = _.omit(params, ['q', 'p', 'ps', 'sortBy', 'providerQ', 'network']); + // replace the nsfw in the query, if any, with the user's default. They can manually change it + // if the provider has a nsfw filter + this.filters.nsfw = app.settings.get('showNsfw'); this.processTerm(this.term); } @@ -367,7 +370,11 @@ export default class extends baseVw { changeFilter(e) { const targ = $(e.target); - this.filters[targ.prop('name')] = targ.val(); + if (targ[0].type === 'checkbox') { + this.filters[targ.prop('name')] = targ[0].checked; + } else { + this.filters[targ.prop('name')] = targ.val(); + } this.serverPage = 0; this.processTerm(this.term); } From cf81764bb924c5512818e4b71899d88df7e4131e Mon Sep 17 00:00:00 2001 From: Josh Jeffryes Date: Tue, 19 Sep 2017 11:14:55 -0400 Subject: [PATCH 3/7] Correct logic in template - fixes the logic for checkboxes in the template - assigns the name of the checkbox from the option.name - this assumes a pending change in the API --- js/templates/search/Search.html | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/js/templates/search/Search.html b/js/templates/search/Search.html index c0f6df7e5..730a59a1b 100644 --- a/js/templates/search/Search.html +++ b/js/templates/search/Search.html @@ -87,14 +87,10 @@

<%= val.label %>

<% _.each(val.options, function(option, index) { let checked = ''; - if (ob.filterVals.hasOwnProperty(key)) { - checked = ob.filterVals[key] ? 'checked' : ''; - } else { - checked = option.default ? 'checked' : ''; - } + checked = option.checked ? 'checked' : ''; var parsedLabel = ob.parseEmojis(option.label); - print(``); - print(``); + print(``); + print(``); }); %>
<% } %> From 90d386148b88a013fe8442b26a43dafaa9389c21 Mon Sep 17 00:00:00 2001 From: Josh Jeffryes Date: Thu, 21 Sep 2017 16:34:32 -0400 Subject: [PATCH 4/7] make default showNsfw false --- js/models/Settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/models/Settings.js b/js/models/Settings.js index 456968850..9734f4c15 100644 --- a/js/models/Settings.js +++ b/js/models/Settings.js @@ -9,7 +9,7 @@ export default class extends BaseModel { return { paymentDataInQR: false, showNotifications: true, - showNsfw: true, + showNsfw: false, localCurrency: 'USD', country: 'UNITED_STATES', language: 'en-US', From 8749ef9880101f49e23e4dd7881f1a7d36007d7b Mon Sep 17 00:00:00 2001 From: Josh Jeffryes Date: Thu, 21 Sep 2017 18:48:57 -0400 Subject: [PATCH 5/7] Fix template, don't override query - cast the filter values as strings when comparing them to the server values (which are always strings) in the template - use the nsfw value in the query, only use the settings value if it isn't set. --- js/templates/search/Search.html | 4 ++-- js/views/search/Search.js | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/js/templates/search/Search.html b/js/templates/search/Search.html index 730a59a1b..18d8525f6 100644 --- a/js/templates/search/Search.html +++ b/js/templates/search/Search.html @@ -58,7 +58,7 @@

<%= val.label %>

<% _.each(val.options, function(option) { let selected = ''; if (ob.filterVals.hasOwnProperty(key)) { - selected = option.value === ob.filterVals[key] ? 'selected' : ''; + selected = option.value === String(ob.filterVals[key]) ? 'selected' : ''; } else { selected = option.default ? 'selected' : ''; } @@ -72,7 +72,7 @@

<%= val.label %>

<% let checked = ''; if (ob.filterVals.hasOwnProperty(key)) { - checked = option.value === ob.filterVals[key] ? 'checked' : ''; + checked = option.value === String(ob.filterVals[key]) ? 'checked' : ''; } else { checked = option.default ? 'checked' : ''; } diff --git a/js/views/search/Search.js b/js/views/search/Search.js index 2748a66b4..fdc16f437 100644 --- a/js/views/search/Search.js +++ b/js/views/search/Search.js @@ -79,9 +79,8 @@ export default class extends baseVw { this.sortBySelected = options.sortBySelected || params.sortBy || ''; // all parameters not specified above are assumed to be filters this.filters = _.omit(params, ['q', 'p', 'ps', 'sortBy', 'providerQ', 'network']); - // replace the nsfw in the query, if any, with the user's default. They can manually change it - // if the provider has a nsfw filter - this.filters.nsfw = app.settings.get('showNsfw'); + // if the nsfw filter is not set, use the value from settings + this.filters.nsfw = this.filters.nsfw || app.settings.get('showNsfw'); this.processTerm(this.term); } From ea8f4854b1ad16be36212aed0634114c99a0105c Mon Sep 17 00:00:00 2001 From: Josh Jeffryes Date: Fri, 22 Sep 2017 11:55:18 -0400 Subject: [PATCH 6/7] Set checked val to string --- js/templates/search/Search.html | 4 ++-- js/views/search/Search.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/js/templates/search/Search.html b/js/templates/search/Search.html index 18d8525f6..730a59a1b 100644 --- a/js/templates/search/Search.html +++ b/js/templates/search/Search.html @@ -58,7 +58,7 @@

<%= val.label %>

<% _.each(val.options, function(option) { let selected = ''; if (ob.filterVals.hasOwnProperty(key)) { - selected = option.value === String(ob.filterVals[key]) ? 'selected' : ''; + selected = option.value === ob.filterVals[key] ? 'selected' : ''; } else { selected = option.default ? 'selected' : ''; } @@ -72,7 +72,7 @@

<%= val.label %>

<% let checked = ''; if (ob.filterVals.hasOwnProperty(key)) { - checked = option.value === String(ob.filterVals[key]) ? 'checked' : ''; + checked = option.value === ob.filterVals[key] ? 'checked' : ''; } else { checked = option.default ? 'checked' : ''; } diff --git a/js/views/search/Search.js b/js/views/search/Search.js index fdc16f437..77b54e0ad 100644 --- a/js/views/search/Search.js +++ b/js/views/search/Search.js @@ -370,7 +370,7 @@ export default class extends baseVw { changeFilter(e) { const targ = $(e.target); if (targ[0].type === 'checkbox') { - this.filters[targ.prop('name')] = targ[0].checked; + this.filters[targ.prop('name')] = String(targ[0].checked); } else { this.filters[targ.prop('name')] = targ.val(); } From 5a6f8b49ab327b028ca0510e01eb9f335c22e878 Mon Sep 17 00:00:00 2001 From: Josh Jeffryes Date: Fri, 22 Sep 2017 12:24:08 -0400 Subject: [PATCH 7/7] set to string from settings --- js/views/search/Search.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/views/search/Search.js b/js/views/search/Search.js index 77b54e0ad..d9a6c1536 100644 --- a/js/views/search/Search.js +++ b/js/views/search/Search.js @@ -80,7 +80,7 @@ export default class extends baseVw { // all parameters not specified above are assumed to be filters this.filters = _.omit(params, ['q', 'p', 'ps', 'sortBy', 'providerQ', 'network']); // if the nsfw filter is not set, use the value from settings - this.filters.nsfw = this.filters.nsfw || app.settings.get('showNsfw'); + this.filters.nsfw = this.filters.nsfw || String(app.settings.get('showNsfw')); this.processTerm(this.term); }