diff --git a/app/assets/javascripts/darkswarm/controllers/enterprises_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/enterprises_controller.js.coffee index 29cfb9e677..0bc5c3a460 100644 --- a/app/assets/javascripts/darkswarm/controllers/enterprises_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/enterprises_controller.js.coffee @@ -1,9 +1,9 @@ -Darkswarm.controller "EnterprisesCtrl", ($scope, $rootScope, $timeout, $location, Enterprises, Search, $document, HashNavigation, FilterSelectorsService, EnterpriseBox, enterpriseMatchesNameQueryFilter, distanceWithinKmFilter) -> +Darkswarm.controller "EnterprisesCtrl", ($scope, $rootScope, $timeout, $location, Enterprises, Search, $document, HashNavigation, FilterSelectorsService, EnterpriseModal, enterpriseMatchesNameQueryFilter, distanceWithinKmFilter) -> $scope.Enterprises = Enterprises $scope.producers_to_filter = Enterprises.producers $scope.filterSelectors = FilterSelectorsService.createSelectors() $scope.query = Search.search() - $scope.openModal = EnterpriseBox.open + $scope.openModal = EnterpriseModal.open $scope.activeTaxons = [] $scope.show_profiles = false $scope.show_closed = false diff --git a/app/assets/javascripts/darkswarm/controllers/group_enterprises_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/group_enterprises_controller.js.coffee index 70153da4fd..567767be7b 100644 --- a/app/assets/javascripts/darkswarm/controllers/group_enterprises_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/group_enterprises_controller.js.coffee @@ -1,7 +1,7 @@ -Darkswarm.controller "GroupEnterprisesCtrl", ($scope, Search, FilterSelectorsService, EnterpriseBox) -> +Darkswarm.controller "GroupEnterprisesCtrl", ($scope, Search, FilterSelectorsService, EnterpriseModal) -> $scope.filterSelectors = FilterSelectorsService.createSelectors() $scope.query = Search.search() - $scope.openModal = EnterpriseBox.open + $scope.openModal = EnterpriseModal.open $scope.activeTaxons = [] $scope.show_profiles = false $scope.filtersActive = false diff --git a/app/assets/javascripts/darkswarm/directives/enterprise_modal.js.coffee b/app/assets/javascripts/darkswarm/directives/enterprise_modal.js.coffee index 9ffd7bc0ab..1bd5d177c1 100644 --- a/app/assets/javascripts/darkswarm/directives/enterprise_modal.js.coffee +++ b/app/assets/javascripts/darkswarm/directives/enterprise_modal.js.coffee @@ -7,4 +7,4 @@ Darkswarm.directive "enterpriseModal", (EnterpriseModal) -> elem.on "click", (event) => event.stopPropagation() - scope.modalInstance = EnterpriseModal.open [scope.enterprise] \ No newline at end of file + scope.modalInstance = EnterpriseModal.open scope.enterprise diff --git a/app/assets/javascripts/darkswarm/services/enterprise_box.js.coffee b/app/assets/javascripts/darkswarm/services/enterprise_box.js.coffee deleted file mode 100644 index 0445dbb4f1..0000000000 --- a/app/assets/javascripts/darkswarm/services/enterprise_box.js.coffee +++ /dev/null @@ -1,12 +0,0 @@ -Darkswarm.factory "EnterpriseBox", ($modal, $rootScope, $http)-> - # Build a modal popup for an enterprise. - new class EnterpriseBox - open: (enterprise)-> - scope = $rootScope.$new(true) # Spawn an isolate to contain the enterprise - scope.embedded_layout = window.location.search.indexOf("embedded_shopfront=true") != -1 - - $http.get("/api/shops/" + enterprise.id).success (data) -> - scope.enterprise = data - $modal.open(templateUrl: "enterprise_box.html", scope: scope) - .error (data) -> - console.error(data) diff --git a/app/assets/javascripts/darkswarm/services/enterprise_list_modal.js.coffee b/app/assets/javascripts/darkswarm/services/enterprise_list_modal.js.coffee new file mode 100644 index 0000000000..d5ebf294d7 --- /dev/null +++ b/app/assets/javascripts/darkswarm/services/enterprise_list_modal.js.coffee @@ -0,0 +1,13 @@ +Darkswarm.factory "EnterpriseListModal", ($modal, $rootScope, $http, EnterpriseModal)-> + # Build a modal popup for an enterprise. + new class EnterpriseListModal + open: (enterprises)-> + scope = $rootScope.$new(true) # Spawn an isolate to contain the enterprise + scope.embedded_layout = window.location.search.indexOf("embedded_shopfront=true") != -1 + scope.enterprises = enterprises + scope.openModal = EnterpriseModal.open + len = Object.keys(enterprises).length + if len > 1 + $modal.open(templateUrl: "enterprise_list_modal.html", scope: scope) + else + EnterpriseModal.open enterprises[Object.keys(enterprises)[0]] diff --git a/app/assets/javascripts/darkswarm/services/enterprise_modal.js.coffee b/app/assets/javascripts/darkswarm/services/enterprise_modal.js.coffee index 623b924970..37dafef776 100644 --- a/app/assets/javascripts/darkswarm/services/enterprise_modal.js.coffee +++ b/app/assets/javascripts/darkswarm/services/enterprise_modal.js.coffee @@ -1,13 +1,12 @@ -Darkswarm.factory "EnterpriseModal", ($modal, $rootScope, $http, EnterpriseBox)-> +Darkswarm.factory "EnterpriseModal", ($modal, $rootScope, $http)-> # Build a modal popup for an enterprise. new class EnterpriseModal - open: (enterprises)-> + open: (enterprise)-> scope = $rootScope.$new(true) # Spawn an isolate to contain the enterprise scope.embedded_layout = window.location.search.indexOf("embedded_shopfront=true") != -1 - scope.enterprises = enterprises - scope.EnterpriseBox = EnterpriseBox - len = Object.keys(enterprises).length - if len > 1 + + $http.get("/api/shops/" + enterprise.id).success (data) -> + scope.enterprise = data $modal.open(templateUrl: "enterprise_modal.html", scope: scope) - else - EnterpriseBox.open enterprises[Object.keys(enterprises)[0]] + .error (data) -> + console.error(data) diff --git a/app/assets/javascripts/darkswarm/services/map.js.coffee b/app/assets/javascripts/darkswarm/services/map.js.coffee index 9c98f5c09b..b38d4b4090 100644 --- a/app/assets/javascripts/darkswarm/services/map.js.coffee +++ b/app/assets/javascripts/darkswarm/services/map.js.coffee @@ -1,4 +1,4 @@ -Darkswarm.factory "OfnMap", (Enterprises, EnterpriseModal, MapConfiguration) -> +Darkswarm.factory "OfnMap", (Enterprises, EnterpriseListModal, MapConfiguration) -> new class OfnMap constructor: -> @coordinates = {} @@ -7,9 +7,6 @@ Darkswarm.factory "OfnMap", (Enterprises, EnterpriseModal, MapConfiguration) -> enterprise.latitude != null || enterprise.longitude != null @enterprises = @enterprise_markers(@enterprises) self = this - @enterprises = @enterprises.filter (enterprise) -> - # Remove enterprises w/o lat or long - enterprise.latitude != null || enterprise.longitude != null enterprise_markers: (enterprises) -> @extend(enterprise) for enterprise in enterprises @@ -33,7 +30,7 @@ Darkswarm.factory "OfnMap", (Enterprises, EnterpriseModal, MapConfiguration) -> id: [enterprise.id] enterprises: self.enterprise_hash({}, enterprise) reveal: => - EnterpriseModal.open this.enterprises + EnterpriseListModal.open this.enterprises @coordinates[[enterprise.latitude, enterprise.longitude]] = marker else marker.icon = MapConfiguration.options.cluster_icon diff --git a/app/assets/javascripts/templates/enterprise_box.html.haml b/app/assets/javascripts/templates/enterprise_box.html.haml deleted file mode 100644 index 350cd6ed80..0000000000 --- a/app/assets/javascripts/templates/enterprise_box.html.haml +++ /dev/null @@ -1,5 +0,0 @@ -%ng-include{src: "'partials/enterprise_header.html'"} -%ng-include{src: "'partials/enterprise_details.html'"} -%ng-include{src: "'partials/hub_details.html'"} -%ng-include{src: "'partials/producer_details.html'"} -%ng-include{src: "'partials/close.html'"} diff --git a/app/assets/javascripts/templates/enterprise_list_modal.html.haml b/app/assets/javascripts/templates/enterprise_list_modal.html.haml new file mode 100644 index 0000000000..046029d829 --- /dev/null +++ b/app/assets/javascripts/templates/enterprise_list_modal.html.haml @@ -0,0 +1,2 @@ +%ng-include{src: "'partials/enterprise_listing.html'"} +%ng-include{src: "'partials/close.html'"} diff --git a/app/assets/javascripts/templates/enterprise_modal.html.haml b/app/assets/javascripts/templates/enterprise_modal.html.haml index 046029d829..350cd6ed80 100644 --- a/app/assets/javascripts/templates/enterprise_modal.html.haml +++ b/app/assets/javascripts/templates/enterprise_modal.html.haml @@ -1,2 +1,5 @@ -%ng-include{src: "'partials/enterprise_listing.html'"} +%ng-include{src: "'partials/enterprise_header.html'"} +%ng-include{src: "'partials/enterprise_details.html'"} +%ng-include{src: "'partials/hub_details.html'"} +%ng-include{src: "'partials/producer_details.html'"} %ng-include{src: "'partials/close.html'"} diff --git a/app/assets/javascripts/templates/partials/enterprise_listing.html.haml b/app/assets/javascripts/templates/partials/enterprise_listing.html.haml index b22223ede9..74485865c0 100644 --- a/app/assets/javascripts/templates/partials/enterprise_listing.html.haml +++ b/app/assets/javascripts/templates/partials/enterprise_listing.html.haml @@ -4,7 +4,7 @@ .highlight-top.row.enterprise .small-12.medium-12.large-12.columns %h4 - %a.heading{"ng-click" => "::EnterpriseBox.open(enterprise)"} + %a.heading{"ng-click" => "::openModal(enterprise)"} %i{"ng-class" => "enterprise.icon"} %span{"ng-bind" => "enterprise.name"} %img.hero-img{"ng-src" => "{{::enterprise.promo_image}}"} diff --git a/spec/features/admin/order_cycles_spec.rb b/spec/features/admin/order_cycles_spec.rb index 0da5f07c6d..22ddef04ab 100644 --- a/spec/features/admin/order_cycles_spec.rb +++ b/spec/features/admin/order_cycles_spec.rb @@ -332,11 +332,15 @@ feature ' select 'My supplier', from: 'new_supplier_id' click_button 'Add supplier' expect(page).to have_selector("table.exchanges tr.supplier", text: "My supplier") - page.all("table.exchanges tr.supplier td.products").each(&:click) + page.all("table.exchanges tr.supplier td.products").each do |tab| + tab.click + sleep 1 + end expect(page).to have_selector "#order_cycle_incoming_exchange_1_variants_#{initial_variants.last.id}", visible: true page.find("#order_cycle_incoming_exchange_1_variants_#{initial_variants.last.id}", visible: true).click # uncheck (with visible:true filter) + expect(page).to have_selector "#order_cycle_incoming_exchange_2_variants_#{v1.id}", visible: true check "order_cycle_incoming_exchange_2_variants_#{v1.id}" check "order_cycle_incoming_exchange_2_variants_#{v2.id}" @@ -886,6 +890,7 @@ feature ' # Open the products list for managed_supplier's incoming exchange within "tr.distributor-#{distributor_managed.id}" do page.find("td.products").click + sleep 3 end # I should be able to see and toggle v1