From 78cfc2c5443c2c34d2fb4d272f8f790c8759d833 Mon Sep 17 00:00:00 2001 From: Mateusz Zalewski Date: Tue, 8 Nov 2016 12:58:36 +0100 Subject: [PATCH] [Admin] Some build and UI fixes --- .../managing_taxons/adding_taxon_for_parent.feature | 1 + .../taxonomy/managing_taxons/editing_taxon.feature | 2 +- .../Resources/private/js/sylius-taxon-slug.js | 10 +++++----- .../Resources/views/Product/_slugField.html.twig | 2 +- .../Resources/views/Taxon/_slugField.html.twig | 4 ++-- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/features/taxonomy/managing_taxons/adding_taxon_for_parent.feature b/features/taxonomy/managing_taxons/adding_taxon_for_parent.feature index 164b94a325..4579783a26 100644 --- a/features/taxonomy/managing_taxons/adding_taxon_for_parent.feature +++ b/features/taxonomy/managing_taxons/adding_taxon_for_parent.feature @@ -14,6 +14,7 @@ Feature: Adding a new taxon for parent Given I want to create a new taxon for "Category" And I specify its code as "guns" And I name it "Guns" in "English (United States)" + And I set its slug to "guns" And I add it Then I should be notified that it has been successfully created And the "Guns" taxon should appear in the registry diff --git a/features/taxonomy/managing_taxons/editing_taxon.feature b/features/taxonomy/managing_taxons/editing_taxon.feature index b0f154330c..e36c3e6858 100644 --- a/features/taxonomy/managing_taxons/editing_taxon.feature +++ b/features/taxonomy/managing_taxons/editing_taxon.feature @@ -31,7 +31,7 @@ Feature: Editing a taxon Given I want to modify the "T-Shirts" taxon When I rename it to "Stickers" in "English (United States)" And I change its description to "Main taxonomy for stickers" in "English (United States)" - And I change its slug to "stickers" in "English (United States)" + And I set its slug to "stickers" And I change its parent taxon to "Accessories" And I save my changes Then I should be notified that it has been successfully edited diff --git a/src/Sylius/Bundle/AdminBundle/Resources/private/js/sylius-taxon-slug.js b/src/Sylius/Bundle/AdminBundle/Resources/private/js/sylius-taxon-slug.js index 7730a8e48e..15d3f736bc 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/private/js/sylius-taxon-slug.js +++ b/src/Sylius/Bundle/AdminBundle/Resources/private/js/sylius-taxon-slug.js @@ -17,14 +17,14 @@ $(document).ready(function() { }); function updateSlug($element) { - $form = $element.parents('form'); $slugInput = $element.parents('.content').find('[name*="[slug]"]'); + $loadableParent = $slugInput.parents('.field.loadable'); if ('readonly' == $slugInput.attr('readonly')) { return; } - $form.addClass('loading'); + $loadableParent.addClass('loading'); if ('' != $slugInput.attr('data-parent') && undefined != $slugInput.attr('data-parent')) { $data = { name: $element.val(), parentId: $slugInput.attr('data-parent') }; @@ -46,7 +46,7 @@ function updateSlug($element) { $slugInput.parents('.field').removeClass('error'); $slugInput.parents('.field').find('.sylius-validation-error').remove(); } - $form.removeClass('loading'); + $loadableParent.removeClass('loading'); } }); } @@ -54,9 +54,9 @@ function updateSlug($element) { function toggleSlugModification($button, $slugInput) { if ($slugInput.attr('readonly')) { $slugInput.removeAttr('readonly'); - $button.html(''); + $button.html(''); } else { $slugInput.attr('readonly', 'readonly'); - $button.html(''); + $button.html(''); } } diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Product/_slugField.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Product/_slugField.html.twig index d0f359d144..a6ae9e77fb 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/views/Product/_slugField.html.twig +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Product/_slugField.html.twig @@ -6,7 +6,7 @@
{{ form_widget(slugField, {'attr': {'readonly': 'readonly', 'data-url': path('sylius_admin_api_generate_product_slug')}}) }} - +
{% endif %} diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Taxon/_slugField.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Taxon/_slugField.html.twig index d0629d594c..ec5228a183 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/views/Taxon/_slugField.html.twig +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Taxon/_slugField.html.twig @@ -1,4 +1,4 @@ -
+
{{ form_label(slugField) }} {% if taxon.slug == null %} {{ form_widget(slugField, {'attr': {'data-url': path('sylius_admin_api_generate_taxon_slug'), 'data-parent': app.request.attributes.get('id')}}) }} @@ -6,7 +6,7 @@
{{ form_widget(slugField, {'attr': {'readonly': 'readonly', 'data-url': path('sylius_admin_api_generate_taxon_slug')}}) }} - +
{% endif %}