From d90d352a86f5a1d51e5a526656d934ff8c0c0269 Mon Sep 17 00:00:00 2001 From: Cillian O'Ruanaidh Date: Fri, 16 Dec 2022 12:55:28 +0000 Subject: [PATCH 1/5] Remove unused showMore angular directive --- .../admin/index_utils/directives/show_more.js.coffee | 12 ------------ .../javascripts/templates/admin/show_more.html.haml | 3 --- app/views/admin/customers/index.html.haml | 1 - .../admin/variant_overrides/_show_more.html.haml | 1 - 4 files changed, 17 deletions(-) delete mode 100644 app/assets/javascripts/admin/index_utils/directives/show_more.js.coffee delete mode 100644 app/assets/javascripts/templates/admin/show_more.html.haml diff --git a/app/assets/javascripts/admin/index_utils/directives/show_more.js.coffee b/app/assets/javascripts/admin/index_utils/directives/show_more.js.coffee deleted file mode 100644 index a6e4efa333..0000000000 --- a/app/assets/javascripts/admin/index_utils/directives/show_more.js.coffee +++ /dev/null @@ -1,12 +0,0 @@ -angular.module("admin.indexUtils").component 'showMore', - templateUrl: 'admin/show_more.html' - bindings: - data: "=" - limit: "=" - increment: "=" - -# For now, this component is not being used. -# Something about binding "data" to a variable on the parent scope that is continually refreshed by -# being assigned within an ng-repeat means that we get $digest iteration errors. Seems to be solved -# by using the new "as" syntax for ng-repeat to assign and alias the outcome of the filters, but this -# has the limitation of not being able to be limited AFTER the assignment has been made, which we need diff --git a/app/assets/javascripts/templates/admin/show_more.html.haml b/app/assets/javascripts/templates/admin/show_more.html.haml deleted file mode 100644 index 6bb35e63c8..0000000000 --- a/app/assets/javascripts/templates/admin/show_more.html.haml +++ /dev/null @@ -1,3 +0,0 @@ -%div{ ng: { show: "data.length > limit" } } - %input{ type: 'button', value: t(:show_more), ng: { click: 'limit = limit + increment' } } - %input{ type: 'button', value: t(:show_all_with_more, num: '{{ data.length - limit }}'), ng: { click: 'limit = data.length' } } diff --git a/app/views/admin/customers/index.html.haml b/app/views/admin/customers/index.html.haml index 1124120693..3bacae5a4e 100644 --- a/app/views/admin/customers/index.html.haml +++ b/app/views/admin/customers/index.html.haml @@ -102,7 +102,6 @@ %td.actions %a{ 'ng-click' => "deleteCustomer(customer)", :class => "delete-customer icon-trash no-text" } - -# %show-more.text-center{ data: "filteredCustomers", limit: "customerLimit", increment: "20" } %div.text-center{ ng: { show: "filteredCustomers.length > customerLimit" } } %input{ type: 'button', value: t(:show_more), ng: { click: 'customerLimit = customerLimit + 20' } } %input{ type: 'button', value: t(:show_all_with_more, num: '{{ filteredCustomers.length - customerLimit }}'), ng: { click: 'customerLimit = filteredCustomers.length' } } diff --git a/app/views/admin/variant_overrides/_show_more.html.haml b/app/views/admin/variant_overrides/_show_more.html.haml index 2c2daacad6..a6414a6d52 100644 --- a/app/views/admin/variant_overrides/_show_more.html.haml +++ b/app/views/admin/variant_overrides/_show_more.html.haml @@ -1,4 +1,3 @@ --# %show-more.text-center{ data: "filteredProducts", limit: "productLimit", increment: "10" } .text-center{ ng: { show: "filteredProducts.length > productLimit" } } %input{ type: 'button', value: t(:show_more), ng: { click: 'productLimit = productLimit + 10' } } From d79b4bdcf9ae172290b3ae9f6bdd1f94836c4ee8 Mon Sep 17 00:00:00 2001 From: Cillian O'Ruanaidh Date: Fri, 16 Dec 2022 13:10:36 +0000 Subject: [PATCH 2/5] Remove unused fillVertical angular directive --- .../darkswarm/directives/fill_vertical.js.coffee | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 app/assets/javascripts/darkswarm/directives/fill_vertical.js.coffee diff --git a/app/assets/javascripts/darkswarm/directives/fill_vertical.js.coffee b/app/assets/javascripts/darkswarm/directives/fill_vertical.js.coffee deleted file mode 100644 index b22de98f05..0000000000 --- a/app/assets/javascripts/darkswarm/directives/fill_vertical.js.coffee +++ /dev/null @@ -1,9 +0,0 @@ -angular.module('Darkswarm').directive "fillVertical", ($window)-> - # Makes something fill the window vertically. Used on the Google Map. - restrict: 'A' - link: (scope, element, attrs)-> - setSize = -> - element.css "height", ($window.innerHeight - element.offset().top) - setSize() - angular.element($window).bind "resize", -> - setSize() From 26baad53e4b15c0b503c8eea3ad0579e0d1e16af Mon Sep 17 00:00:00 2001 From: Cillian O'Ruanaidh Date: Fri, 16 Dec 2022 14:50:09 +0000 Subject: [PATCH 3/5] Remove unused singleLineSelectors angular directive --- .../directives/single_line_selectors.coffee | 82 ------------------- .../templates/single_line_selectors.html.haml | 14 ---- 2 files changed, 96 deletions(-) delete mode 100644 app/assets/javascripts/darkswarm/directives/single_line_selectors.coffee delete mode 100644 app/assets/javascripts/templates/single_line_selectors.html.haml diff --git a/app/assets/javascripts/darkswarm/directives/single_line_selectors.coffee b/app/assets/javascripts/darkswarm/directives/single_line_selectors.coffee deleted file mode 100644 index 5bc3daa635..0000000000 --- a/app/assets/javascripts/darkswarm/directives/single_line_selectors.coffee +++ /dev/null @@ -1,82 +0,0 @@ -angular.module('Darkswarm').directive 'singleLineSelectors', ($timeout, $filter) -> - restrict: 'E' - templateUrl: "single_line_selectors.html" - scope: - selectors: "=" - objects: "&" - activeSelectors: "=" - selectorName: "@activeSelectors" - link: (scope, element, attrs) -> - scope.fitting = false - - scope.refit = -> - if scope.allSelectors? - scope.fitting = true - selector.fits = true for selector in scope.allSelectors - $timeout(loadWidths, 0, true).then -> - $timeout fit, 0, true - - fit = -> - used = $(element).find("li.more").outerWidth(true) - used += selector.width for selector in scope.allSelectors when selector.fits - available = $(element).parent(".filter-shopfront").innerWidth() - used - if available > 0 - for selector in scope.allSelectors when !selector.fits - available -= selector.width - selector.fits = true if available > 0 - else - if scope.allSelectors.length > 0 - for i in [scope.allSelectors.length-1..0] - selector = scope.allSelectors[i] - if !selector.fits - continue - else - if available < 0 - selector.fits = false - available += selector.width - scope.fitting = false - - loadWidths = -> - $(element).find("li").not(".more").each (i) -> - if i < scope.allSelectors.length - scope.allSelectors[i].width = $(this).outerWidth(true) - return null # So we don't exit the loop weirdly - - scope.overFlowSelectors = -> - return [] unless scope.allSelectors? - $filter('filter')(scope.allSelectors, { fits: false }) - - scope.selectedOverFlowSelectors = -> - $filter('filter')(scope.overFlowSelectors(), { active: true }) - - # had to duplicate this to make overflow selectors work - scope.emit = -> - scope.activeSelectors = scope.allSelectors.filter (selector)-> - selector.active - .map (selector) -> - selector.object.id - - # From: http://stackoverflow.com/questions/4298612/jquery-how-to-call-resize-event-only-once-its-finished-resizing - debouncer = (func, timeout) -> - timeoutID = undefined - timeout = timeout or 50 - -> - subject = this - args = arguments - clearTimeout timeoutID - timeoutID = setTimeout(-> - func.apply subject, Array::slice.call(args) - , timeout) - - - # -- Event management - scope.$watchCollection "allSelectors", -> - scope.refit() - - scope.$on "filtersToggled", -> - scope.refit() - - $(window).resize debouncer (e) -> - scope.fitting = true - if scope.allSelectors? - $timeout fit, 0, true diff --git a/app/assets/javascripts/templates/single_line_selectors.html.haml b/app/assets/javascripts/templates/single_line_selectors.html.haml deleted file mode 100644 index 87034d9483..0000000000 --- a/app/assets/javascripts/templates/single_line_selectors.html.haml +++ /dev/null @@ -1,14 +0,0 @@ --# In order for the single-line-selector scope to have access to the available selectors, -%filter-selector{"selector-set" => "selectors", objects: "objects()", "active-selectors" => "activeSelectors", "all-selectors" => "allSelectors" } - -%ul{ ng: { if: "overFlowSelectors().length > 0 || fitting" } } - %li.more - %a.dropdown{ data: { dropdown: "{{ 'show-more-' + selectorName }}" }, ng: { class: "{active: selectedOverFlowSelectors().length > 0}" } } - %span - {{ 'js.more_items' | t:{ count: overFlowSelectors().length } }} - %i.ofn-i_052-point-down - .f-dropdown.text-right.content{ ng: { attr: { id: "{{ 'show-more-' + selectorName }}" } } } - %ul - %active-selector{ ng: { repeat: "selector in overFlowSelectors()", hide: "selector.fits" } } - %render-svg{path: "{{selector.object.icon}}", ng: { if: "selector.object.icon"}} - %span {{ selector.object.name }} From c000010d0b28ef214747cb7d1a98c3fcae46a9c7 Mon Sep 17 00:00:00 2001 From: Cillian O'Ruanaidh Date: Fri, 16 Dec 2022 16:24:42 +0000 Subject: [PATCH 4/5] Update CSS comment to reflect that singleLineSelectors directive was replaced by filterSelectors --- app/webpacker/css/darkswarm/_shop-filters.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/webpacker/css/darkswarm/_shop-filters.scss b/app/webpacker/css/darkswarm/_shop-filters.scss index e9ff3b8aac..ca59784e9d 100644 --- a/app/webpacker/css/darkswarm/_shop-filters.scss +++ b/app/webpacker/css/darkswarm/_shop-filters.scss @@ -161,7 +161,7 @@ } } -// singleLineSelectors directive provides a drop-down that can overlap +// filterSelectors directive provides a drop-down that can overlap // content. Ensure that the dropdown appears above the content. .filter-row { position: relative; From 2296a51dd25c2dc941f2a82c0f2e7a092997013d Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Mon, 19 Dec 2022 10:50:00 +0100 Subject: [PATCH 5/5] Remove useless CSS class `.filte-row` --- app/views/producers/_filters.html.haml | 2 +- app/views/shops/_filters.html.haml | 2 +- app/webpacker/css/darkswarm/_shop-filters.scss | 7 ------- spec/system/consumer/caching/darkswarm_caching_spec.rb | 6 +++--- 4 files changed, 5 insertions(+), 12 deletions(-) diff --git a/app/views/producers/_filters.html.haml b/app/views/producers/_filters.html.haml index 283777cf09..c3809aba20 100644 --- a/app/views/producers/_filters.html.haml +++ b/app/views/producers/_filters.html.haml @@ -3,7 +3,7 @@ .small-12.medium-6.columns.text-right   -.row.animate-show.filter-row{"ng-show" => "filtersActive"} +.row.animate-show{"ng-show" => "filtersActive"} .small-12.columns .row.filter-box .small-12.columns diff --git a/app/views/shops/_filters.html.haml b/app/views/shops/_filters.html.haml index f3011a0a25..a460f28846 100644 --- a/app/views/shops/_filters.html.haml +++ b/app/views/shops/_filters.html.haml @@ -4,7 +4,7 @@ .row = render 'shared/components/filter_controls' -.row.animate-show.filter-row{"ng-show" => "filtersActive"} +.row.animate-show{"ng-show" => "filtersActive"} .small-12.columns .row.filter-box .small-12.large-9.columns diff --git a/app/webpacker/css/darkswarm/_shop-filters.scss b/app/webpacker/css/darkswarm/_shop-filters.scss index ca59784e9d..e4bceed102 100644 --- a/app/webpacker/css/darkswarm/_shop-filters.scss +++ b/app/webpacker/css/darkswarm/_shop-filters.scss @@ -161,13 +161,6 @@ } } -// filterSelectors directive provides a drop-down that can overlap -// content. Ensure that the dropdown appears above the content. -.filter-row { - position: relative; - z-index: 90; -} - .sticky-shop-filters-container { position: sticky; top: $topbar-height; diff --git a/spec/system/consumer/caching/darkswarm_caching_spec.rb b/spec/system/consumer/caching/darkswarm_caching_spec.rb index c853f41b24..e6c891a861 100644 --- a/spec/system/consumer/caching/darkswarm_caching_spec.rb +++ b/spec/system/consumer/caching/darkswarm_caching_spec.rb @@ -47,7 +47,7 @@ describe "Darkswarm data caching", js: true, caching: true do toggle_filters - within "#hubs .filter-row" do + within "#hubs .filter-box" do expect(page).to have_content taxon.name expect(page).to have_content property.presentation end @@ -64,7 +64,7 @@ describe "Darkswarm data caching", js: true, caching: true do visit shops_path # Wait for /shops page to load properly before checking for new timestamps - expect(page).to_not have_selector ".row.filter-row" + expect(page).to_not have_selector ".row.filter-box" taxon_timestamp2 = CacheService.latest_timestamp_by_class(Spree::Taxon) expect_cached "views/#{CacheService::FragmentCaching.ams_all_taxons[0]}" @@ -77,7 +77,7 @@ describe "Darkswarm data caching", js: true, caching: true do toggle_filters - within "#hubs .filter-row" do + within "#hubs .filter-box" do expect(page).to have_content "Changed Taxon" expect(page).to have_content "Changed Property" end