mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
[Taxon] Remove drag n drop support
This commit is contained in:
parent
af826a4067
commit
01f4c8d01d
7 changed files with 36 additions and 107 deletions
|
|
@ -7,7 +7,7 @@ Feature: Deleting a taxon
|
|||
Background:
|
||||
Given I am logged in as an administrator
|
||||
|
||||
@ui @javascript
|
||||
@ui
|
||||
Scenario: Deleted taxon should disappear from the registry
|
||||
Given the store classifies its products as "T-Shirts"
|
||||
When I delete taxon named "T-Shirts"
|
||||
|
|
|
|||
|
|
@ -67,15 +67,7 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface
|
|||
$leaves = $this->getLeaves();
|
||||
foreach ($leaves as $leaf) {
|
||||
if ($leaf->getText() === $name) {
|
||||
$leaf = $leaf->getParent();
|
||||
$menuButton = $leaf->find('css', '.wrench');
|
||||
$menuButton->click();
|
||||
$deleteButton = $leaf->find('css', '.sylius-delete-resource');
|
||||
$deleteButton->click();
|
||||
|
||||
$deleteButton->waitFor(5, function () use ($leaf) {
|
||||
return null === $leaf->find('css', '.sylius-delete-resource');
|
||||
});
|
||||
$leaf->getParent()->find('css', '.ui.red.button')->press();
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
@ -164,7 +156,7 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface
|
|||
$tree = $this->getElement('tree');
|
||||
Assert::notNull($tree);
|
||||
/** @var NodeElement[] $leaves */
|
||||
$leaves = $tree->findAll('css', '.item > .content > .header');
|
||||
$leaves = $tree->findAll('css', '.item > .content > .header > a');
|
||||
|
||||
if (null === $parentTaxon) {
|
||||
return $leaves;
|
||||
|
|
@ -206,13 +198,11 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface
|
|||
$leaves = $this->getLeaves();
|
||||
foreach ($leaves as $leaf) {
|
||||
if ($leaf->getText() === $taxon->getName()) {
|
||||
$leaf = $leaf->getParent();
|
||||
$menuButton = $leaf->find('css', '.wrench');
|
||||
$menuButton->click();
|
||||
$moveButton = $leaf->find('css', sprintf('.%s', $direction));
|
||||
$moveButton = $leaf->getParent()->find('css', sprintf('.sylius-taxon-move-%s', $direction));
|
||||
$moveButton->click();
|
||||
$moveButton->waitFor(5, function () use ($taxon) {
|
||||
return $this->getFirstLeafName() === $taxon->getName();
|
||||
|
||||
$moveButton->waitFor(5, function () use ($moveButton) {
|
||||
return !$moveButton->hasClass('loading');
|
||||
});
|
||||
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ var paths = {
|
|||
admin: {
|
||||
js: [
|
||||
'../../../../node_modules/jquery/dist/jquery.min.js',
|
||||
'../../../../node_modules/sortablejs/Sortable.js',
|
||||
'../../../../node_modules/sortablejs/jquery.binding.js',
|
||||
'../../../../node_modules/semantic-ui-css/semantic.min.js',
|
||||
'../PromotionBundle/Resources/public/js/sylius-promotion.js',
|
||||
|
|
|
|||
|
|
@ -1,30 +0,0 @@
|
|||
(function ($) {
|
||||
'use strict';
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('.sylius-delete-resource').api({
|
||||
method: 'delete',
|
||||
onSuccess: function (response) {
|
||||
var redirectUrl = $(this).data('success-redirect-url');
|
||||
|
||||
if (redirectUrl) {
|
||||
location.replace(redirectUrl);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
throw 'You need to define data-success-redirect-url on "' + $(this).attr('class') +'"';
|
||||
},
|
||||
onFailure: function (response) {
|
||||
var message = $(this).parent().parent().popup({
|
||||
inline: true,
|
||||
content: response.error.message,
|
||||
on: 'manual'
|
||||
});
|
||||
message.popup('show');
|
||||
setTimeout(function() { message.popup('hide'); }, 3000);
|
||||
}
|
||||
});
|
||||
});
|
||||
})( jQuery );
|
||||
|
|
@ -2,40 +2,6 @@
|
|||
'use strict';
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('.sylius-sortable-list').sortable({
|
||||
forceFallback: true,
|
||||
onStart: function (event) {
|
||||
$(event.item).addClass('dragging-started');
|
||||
},
|
||||
onEnd: function (event) {
|
||||
$(event.item).removeClass('dragging-started');
|
||||
$(this).api({
|
||||
throttle: 500,
|
||||
method: 'PUT',
|
||||
action: 'move taxon',
|
||||
on: 'now',
|
||||
urlData: {
|
||||
id: $(event.item).data('id')
|
||||
},
|
||||
beforeSend: function (settings) {
|
||||
settings.data = {
|
||||
position: event.newIndex
|
||||
};
|
||||
|
||||
return settings;
|
||||
},
|
||||
onSuccess: function (response) {
|
||||
$(event.item).find('.sylius-taxon-move-up').data('position', event.newIndex);
|
||||
$(event.item).find('.sylius-taxon-move-down').data('position', event.newIndex);
|
||||
},
|
||||
onFailure: function (response) {
|
||||
throw 'Something went wrong with api call.';
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$('.sylius-taxon-move-up').api({
|
||||
method: 'PUT',
|
||||
on: 'click',
|
||||
|
|
|
|||
|
|
@ -13,33 +13,19 @@
|
|||
<a href="{{ path('sylius_admin_product_index_per_taxon', {'taxonId': taxon.id}) }}">
|
||||
{{ taxon.name }}
|
||||
</a>
|
||||
<div class="ui inline dropdown icon button mini">
|
||||
<i class="wrench icon"></i>
|
||||
<div class="menu">
|
||||
<a class="item" href="{{ path('sylius_admin_taxon_create_for_parent', { 'id': taxon.id }) }}">
|
||||
<i class="plus icon"></i>
|
||||
{{ 'sylius.ui.add'|trans }}
|
||||
</a>
|
||||
<a class="item" href="{{ path('sylius_admin_taxon_update', { 'id': taxon.id }) }}">
|
||||
<i class="edit icon"></i>
|
||||
{{ 'sylius.ui.edit'|trans }}
|
||||
</a>
|
||||
<div class="item sylius-taxon-move-up" data-action="move taxon" data-id="{{ taxon.id }}" data-position="{{ taxon.position }}">
|
||||
<div class="ui mini buttons">
|
||||
{{ buttons.create(path('sylius_admin_taxon_create_for_parent', { 'id': taxon.id }), 'sylius.ui.add'|trans) }}
|
||||
{{ buttons.edit(path('sylius_admin_taxon_update', { 'id': taxon.id }), null, null, false) }}
|
||||
{{ buttons.delete(path('sylius_admin_taxon_delete', { 'id': taxon.id }), null, null, false) }}
|
||||
<a class="ui icon button sylius-taxon-move-up" data-action="move taxon" data-id="{{ taxon.id }}" data-position="{{ taxon.position }}">
|
||||
<i class="icon arrow up"></i>
|
||||
{{ 'sylius.ui.move_up'|trans }}
|
||||
</div>
|
||||
<div class="item sylius-taxon-move-down" data-action="move taxon" data-id="{{ taxon.id }}" data-position="{{ taxon.position }}">
|
||||
</a>
|
||||
<a class="ui icon button sylius-taxon-move-down" data-action="move taxon" data-id="{{ taxon.id }}" data-position="{{ taxon.position }}">
|
||||
<i class="icon arrow down"></i>
|
||||
{{ 'sylius.ui.move_down'|trans }}
|
||||
</div>
|
||||
<div class="item sylius-delete-resource" data-url="{{ path('sylius_admin_taxon_delete', { 'id': taxon.id }) ~ '?_format=json' }}" data-success-redirect-url="{{ path('sylius_admin_taxon_index') }}">
|
||||
<i class="delete icon"></i>
|
||||
{{ 'sylius.ui.delete'|trans }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="list sylius-sortable-list">
|
||||
<div class="list">
|
||||
{{ tree.render(taxon.children) }}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ namespace Sylius\Bundle\TaxonomyBundle\Form\Type;
|
|||
use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
/**
|
||||
* @author Arkadiusz Krakowiak <arkadiusz.krakowiak@lakion.com>
|
||||
|
|
@ -28,10 +29,27 @@ final class TaxonPositionType extends AbstractResourceType
|
|||
$builder
|
||||
->add('position', IntegerType::class, [
|
||||
'label' => 'sylius.form.taxon.position',
|
||||
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
parent::configureOptions($resolver);
|
||||
|
||||
$resolver
|
||||
->setDefaults([
|
||||
'csrf_protection' => false,
|
||||
])
|
||||
->setDefined(['position'])
|
||||
->setAllowedTypes('position', 'int')
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue