diff --git a/Bundle/BlogBundle/Controller/ArticleController.php b/Bundle/BlogBundle/Controller/ArticleController.php index 1260c534a..668387c7e 100644 --- a/Bundle/BlogBundle/Controller/ArticleController.php +++ b/Bundle/BlogBundle/Controller/ArticleController.php @@ -180,7 +180,7 @@ public function settingsAction(Request $request, Article $article) $response = [ 'success' => true, 'url' => $this->generateUrl('victoire_core_page_show', [ - '_locale' => $page->getLocale(), + '_locale' => $page->getCurrentLocale(), 'url' => $page->getReference()->getUrl(), ]), ]; diff --git a/Bundle/BlogBundle/Controller/BlogController.php b/Bundle/BlogBundle/Controller/BlogController.php index 14a6b89d1..4ed4e4fe3 100644 --- a/Bundle/BlogBundle/Controller/BlogController.php +++ b/Bundle/BlogBundle/Controller/BlogController.php @@ -156,7 +156,7 @@ public function settingsAction(Request $request, BasePage $blog) 'success' => true, 'url' => $this->generateUrl( 'victoire_core_page_show', [ - '_locale' => $blog->getLocale(), 'url' => $reference->getUrl(), + '_locale' => $blog->getCurrentLocale(), 'url' => $reference->getUrl(), ]), ]); } @@ -218,7 +218,7 @@ public function categoryAction(Request $request, BasePage $blog) return new JsonResponse([ 'success' => true, - 'url' => $this->generateUrl('victoire_core_page_show', ['_locale' => $blog->getLocale(), 'url' => $blog->getUrl()]), ]); + 'url' => $this->generateUrl('victoire_core_page_show', ['_locale' => $blog->getCurrentLocale(), 'url' => $blog->getUrl()]), ]); } //we display the form $errors = $this->get('victoire_form.error_helper')->getRecursiveReadableErrors($form); diff --git a/Bundle/BlogBundle/Entity/Article.php b/Bundle/BlogBundle/Entity/Article.php index 246cc26f0..25053f8e7 100644 --- a/Bundle/BlogBundle/Entity/Article.php +++ b/Bundle/BlogBundle/Entity/Article.php @@ -156,7 +156,7 @@ class Article */ public function __toString() { - return $this->name; + return $this->getName(); } /** diff --git a/Bundle/CoreBundle/Form/ViewType.php b/Bundle/CoreBundle/Form/ViewType.php index 62bfad534..fb9d15b7f 100644 --- a/Bundle/CoreBundle/Form/ViewType.php +++ b/Bundle/CoreBundle/Form/ViewType.php @@ -13,6 +13,8 @@ use Victoire\Bundle\BlogBundle\Entity\ArticleTemplate; use Victoire\Bundle\BusinessPageBundle\Entity\BusinessTemplate; use Victoire\Bundle\CoreBundle\Entity\View; +use Victoire\Bundle\FormBundle\Form\Type\UrlvalidatedType; +use Victoire\Bundle\PageBundle\Entity\BasePage; use Victoire\Bundle\TemplateBundle\Entity\Template; /** @@ -88,15 +90,24 @@ public function buildForm(FormBuilderInterface $builder, array $options) ] ); } - }); - $builder->add('translations', TranslationsType::class, [ - 'fields' => [ - 'name' => [ - 'label' => 'form.view.type.name.label', - ], - ], - ]); + if ($view instanceof BasePage) { + $translationOptions = [ + 'fields' => [ + 'name' => [ + 'label' => 'form.view.type.name.label', + ], + ], + ]; + if ($view->getId() && !$view->isHomepage()) { + $translationOptions['fields']['slug'] = [ + 'label' => 'form.page.type.slug.label', + 'field_type' => UrlvalidatedType::class, + ]; + } + $form->add('translations', TranslationsType::class, $translationOptions); + } + }); } protected function getAvailableLocales() diff --git a/Bundle/CoreBundle/Resources/public/js/edit/victoire.js b/Bundle/CoreBundle/Resources/public/js/edit/victoire.js index 659215162..b2945ec4e 100644 --- a/Bundle/CoreBundle/Resources/public/js/edit/victoire.js +++ b/Bundle/CoreBundle/Resources/public/js/edit/victoire.js @@ -19,8 +19,9 @@ $vic(document).on("keydown", function (e){ $vic('button[data-mode="admin-style"]').click(); } else if ($vic('body').attr('role') == 'admin-style') { $vic('button[data-mode="admin-readonly"]').click(); + } else if ($vic('button[data-mode="admin-readonly"]') != undefined) { + $vic('button[data-mode="admin-readonly"]').click(); } - } }); diff --git a/Bundle/CoreBundle/Resources/public/js/edit/widget.js b/Bundle/CoreBundle/Resources/public/js/edit/widget.js index 0ab6e7bc1..a0f323dbe 100644 --- a/Bundle/CoreBundle/Resources/public/js/edit/widget.js +++ b/Bundle/CoreBundle/Resources/public/js/edit/widget.js @@ -20,66 +20,27 @@ $vic(document).on('change', '.vic-new-widget select', function(event) { $vic(this).parents('.vic-new-widget').first().addClass('vic-creating'); }); - -// Create new widget after submit -$vic(document).on('click', '.vic-widget-modal *[data-modal="create"]', function(event) { +$vic(document).on('click', '.vic-widget-modal a[data-modal="update"], .vic-widget-modal a[data-modal="create"]', function(event) { event.preventDefault(); // we remove the prototype picker to avoid persist it - if ($vic("select.picker_entity_select").length != 0 && $vic("select.picker_entity_select").attr('name').indexOf('[items][__name__][entity]') !== -1) { + if ($vic("select.picker_entity_select").length != 0 && $vic("select.picker_entity_select").attr('name').indexOf('appventus_victoirecorebundle_widgetlistingtype[items][__name__][entity]') !== -1) { $vic("select.picker_entity_select").remove(); } - //we look for the form currently active and visible - var form = $vic(this).parents('.vic-modal-content').find('.vic-tab-pane.vic-active form').filter(":visible"); - $vic(form).trigger("victoire_widget_form_create_presubmit"); - - loading(true); - formData = form.serialize(); - var contentType = 'application/x-www-form-urlencoded; charset=UTF-8'; - if ($vic(form).attr('enctype') == 'multipart/form-data') { - var formData = new FormData($vic(form)[0]); - var contentType = false; - } - $vic.ajax({ - type: form.attr('method'), - url : form.attr('action'), - data : formData, - processData : false, - contentType : contentType - }).done(function(response){ - if (true === response.success) { - if (response.hasOwnProperty("redirect")) { - window.location.replace(response.redirect); - } else { - window.location.reload(); - } - - loading(false); - - } else { - warn(response.message, 10000); - //inform user there have been an error - if (response.html) { - $vic('.vic-modal-body .vic-container .vic-tab-pane.vic-active').html(response.html); - } + var forms = []; + $vic('.vic-tab-quantum').each(function(index, quantum) { + // matches widget edit form with more than one mode available + var activeForm = $vic(quantum).find('.vic-tab-mode.vic-active .vic-tab-pane.vic-active > form'); + // matches widget edit form with only static mode available + if (activeForm.length == 0) { + activeForm = $vic(quantum).find('.vic-tab-pane.vic-active form, #picker-static-static.vic-active form'); } - }).fail(function(response) { - console.log(response); - error('Oups, une erreur est apparue', 10000); + // matches widget stylize form + if (activeForm.length == 0 && $vic(quantum).hasClass('vic-active')) { + activeForm = $vic(quantum).find('form[name="widget_style"]'); + } + forms = $vic.merge(forms, [activeForm]); }); - $vic(form).trigger("victoire_widget_form_create_postsubmit"); -}); - - -$vic(document).on('click', '.vic-widget-modal a[data-modal="update-bulk"], .vic-widget-modal a[data-modal="create-bulk"]', function(event) { - event.preventDefault(); - // we remove the prototype picker to avoid persist it - if ($vic("select.picker_entity_select").length != 0 && $vic("select.picker_entity_select").attr('name').indexOf('appventus_victoirecorebundle_widgetlistingtype[items][__name__][entity]') !== -1) { - $vic("select.picker_entity_select").remove(); - } - - var forms = $vic(this).parents('.vic-modal-content').find('.vic-tab-quantum .vic-tab-mode.vic-active > form'); - forms = $vic.merge(forms, $vic(this).parents('.vic-modal-content').find('.vic-tab-quantum .vic-tab-mode.vic-active .vic-tab-pane.vic-active > form')); loading(true); var calls = []; @@ -130,70 +91,12 @@ $vic(document).on('click', '.vic-widget-modal a[data-modal="update-bulk"], .vic- loading(false); }); }); -$vic(document).on('click', '.vic-widget-modal a[data-modal="update"]', function(event) { - event.preventDefault(); - - // we remove the prototype picker to avoid persist it - if ($vic("select.picker_entity_select").length != 0 && $vic("select.picker_entity_select").attr('name').indexOf('appventus_victoirecorebundle_widgetlistingtype[items][__name__][entity]') !== -1) { - $vic("select.picker_entity_select").remove(); - } - var form = $vic(this).parents('.vic-modal-content').find('form.vic-form-active'); - if ($vic(form).length == 0) { - form = $vic(this).parents('.vic-modal-content').find('.vic-tab-pane.vic-active form').filter(":visible"); - } - $vic(form).trigger("victoire_widget_form_update_presubmit"); - - loading(true); - - formData = form.serialize(); - var contentType = 'application/x-www-form-urlencoded; charset=UTF-8'; - if ($vic(form).attr('enctype') == 'multipart/form-data') { - var formData = new FormData($vic(form)[0]); - var contentType = false; - } - $vic.ajax({ - type: form.attr('method'), - url : form.attr('action'), - data : formData, - processData : false, - contentType : contentType - }).done(function(response){ - if (true === response.success) { - if (response.hasOwnProperty("redirect")) { - window.location.replace(response.redirect); - } else { - if (response.hasOwnProperty("redirect")) { - window.location.replace(response.redirect); - } else { - window.location.reload(); - } - } - if(typeof(Storage) !== "undefined") { - var object = {data: response.html, timestamp: new Date().getTime()}; - localStorage.setItem('victoire__widget__html__' + response.widgetId, JSON.stringify(object)); - } - loading(false); - } else { - - //inform user there have been an error - warn(response.message, 10000); - - if (response.html) { - $vic(form).parent('div').html(response.html); - } - } - }).fail(function(response) { - console.log(response); - error('Oups, une erreur est apparue', 10000); - }); - $vic(form).trigger("victoire_widget_form_update_postsubmit"); -}); // Delete a widget after submit $vic(document).on('click', 'a#widget-new-tab', function(event) { event.preventDefault(); loading(true); - var url = Routing.generate('victoire_core_widget_new_quantum_item', { + var url = Routing.generate('victoire_core_widget_new', { type: $vic(this).data('type'), viewReference: viewReferenceId, slot: $vic(this).data('slot'), diff --git a/Bundle/CoreBundle/Resources/style/less/ugly.less b/Bundle/CoreBundle/Resources/style/less/ugly.less index 29f47f794..466f791c3 100644 --- a/Bundle/CoreBundle/Resources/style/less/ugly.less +++ b/Bundle/CoreBundle/Resources/style/less/ugly.less @@ -20,3 +20,10 @@ color: @green; } +.vic-quantum-nav { + position: fixed; + bottom: 50px; +} +.quantum-tab-name { + background-color: #fff; +} \ No newline at end of file diff --git a/Bundle/CoreBundle/Resources/views/Widget/Form/_modal.html.twig b/Bundle/CoreBundle/Resources/views/Widget/Form/_modal.html.twig index fe5d70191..a459bfd22 100644 --- a/Bundle/CoreBundle/Resources/views/Widget/Form/_modal.html.twig +++ b/Bundle/CoreBundle/Resources/views/Widget/Form/_modal.html.twig @@ -16,7 +16,7 @@ {{ 'modal.button.delete.title'|trans({}, 'victoire') }} {% endif %} {{ 'modal.button.cancel.title'|trans({}, 'victoire') }} - {{ ('modal.button.'~ block('action') ~'.title')|trans({}, 'victoire') }} + {{ ('modal.button.'~ block('action') ~'.title')|trans({}, 'victoire') }} {% endblock modal_footer_content %} diff --git a/Bundle/CoreBundle/Resources/views/Widget/Form/new.html.twig b/Bundle/CoreBundle/Resources/views/Widget/Form/new.html.twig index 5320727b5..3624e1d0e 100644 --- a/Bundle/CoreBundle/Resources/views/Widget/Form/new.html.twig +++ b/Bundle/CoreBundle/Resources/views/Widget/Form/new.html.twig @@ -10,7 +10,7 @@ {% include "VictoireCoreBundle:Widget:Form/new_partial.html.twig" with {forms: forms[key], widget: widget, classes: classes, id: widgets[key].id ? widgets[key].id : id, quantum: forms[key]['quantum'] }%} {% endfor %} -