mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Merge pull request #4342 from JacksonBates/edit-button-new-window
makes edit button action open a new tab
This commit is contained in:
@@ -108,9 +108,15 @@ angular.module("ofn.admin").controller "AdminProductEditCtrl", ($scope, $timeout
|
||||
$scope.categoryFilter = "0"
|
||||
$scope.importDateFilter = "0"
|
||||
|
||||
confirm_unsaved_changes = () ->
|
||||
(DirtyProducts.count() > 0 and confirm(t("unsaved_changes_confirmation"))) or (DirtyProducts.count() == 0)
|
||||
|
||||
editProductUrl = (product, variant) ->
|
||||
"/admin/products/" + product.permalink_live + ((if variant then "/variants/" + variant.id else "")) + "/edit"
|
||||
|
||||
$scope.editWarn = (product, variant) ->
|
||||
if (DirtyProducts.count() > 0 and confirm(t("unsaved_changes_confirmation"))) or (DirtyProducts.count() == 0)
|
||||
window.location = "/admin/products/" + product.permalink_live + ((if variant then "/variants/" + variant.id else "")) + "/edit"
|
||||
if confirm_unsaved_changes()
|
||||
window.open(editProductUrl(product, variant), "_blank")
|
||||
|
||||
|
||||
$scope.toggleShowAllVariants = ->
|
||||
|
||||
@@ -513,27 +513,37 @@ feature '
|
||||
visit spree.admin_products_path
|
||||
end
|
||||
|
||||
it "shows an edit button for products, which takes the user to the standard edit page for that product" do
|
||||
it "shows an edit button for products, which takes the user to the standard edit page for that product in a new window" do
|
||||
expect(page).to have_selector "a.edit-product", count: 2
|
||||
|
||||
within "tr#p_#{p1.id}" do
|
||||
find("a.edit-product").click
|
||||
new_window = window_opened_by do
|
||||
within "tr#p_#{p1.id}" do
|
||||
find("a.edit-product").click
|
||||
end
|
||||
end
|
||||
|
||||
expect(URI.parse(current_url).path).to eq "/admin/products/#{p1.permalink}/edit"
|
||||
within_window new_window do
|
||||
expect(URI.parse(current_url).path).to eq "/admin/products/#{p1.permalink}/edit"
|
||||
page.execute_script('window.close()')
|
||||
end
|
||||
end
|
||||
|
||||
it "shows an edit button for variants, which takes the user to the standard edit page for that variant" do
|
||||
it "shows an edit button for variants, which takes the user to the standard edit page for that variant in a new window" do
|
||||
expect(page).to have_selector "a.view-variants"
|
||||
all("a.view-variants").each(&:click)
|
||||
|
||||
expect(page).to have_selector "a.edit-variant", count: 2
|
||||
|
||||
within "tr#v_#{v1.id}" do
|
||||
find("a.edit-variant").click
|
||||
new_window = window_opened_by do
|
||||
within "tr#v_#{v1.id}" do
|
||||
find("a.edit-variant").click
|
||||
end
|
||||
end
|
||||
|
||||
expect(URI.parse(current_url).path).to eq "/admin/products/#{v1.product.permalink}/variants/#{v1.id}/edit"
|
||||
within_window new_window do
|
||||
expect(URI.parse(current_url).path).to eq "/admin/products/#{v1.product.permalink}/variants/#{v1.id}/edit"
|
||||
page.execute_script('window.close()')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user