Finish Import / Export categories management
modifié: core/lib/Thelia/Config/Resources/routing/admin.xml modifié: core/lib/Thelia/Controller/Admin/ExportController.php modifié: core/lib/Thelia/Controller/Admin/ImportExportController.php modifié: core/lib/Thelia/Core/FileFormat/Formatting/Formatter/JsonFormatter.php modifié: core/lib/Thelia/Core/FileFormat/Formatting/Formatter/XMLFormatter.php modifié: core/lib/Thelia/Core/FileFormat/Formatting/FormatterInterface.php modifié: core/lib/Thelia/Core/Template/Loop/Export.php modifié: core/lib/Thelia/Core/Template/Loop/Formatter.php nouveau fichier: core/lib/Thelia/ImportExport/Both/NewsletterImportExport.php nouveau fichier: core/lib/Thelia/ImportExport/Export/ExportType.php nouveau fichier: core/lib/Thelia/ImportExport/Export/MailingExport.php modifié: core/lib/Thelia/ImportExport/ExportHandlerInterface.php modifié: core/lib/Thelia/Model/Export.php modifié: core/lib/Thelia/Model/ExportCategory.php modifié: core/lib/Thelia/Model/ImportCategory.php modifié: templates/backOffice/default/export-page.html modifié: templates/backOffice/default/export.html modifié: templates/backOffice/default/import.html modifié: templates/backOffice/default/includes/export-form-definition.html
This commit is contained in:
@@ -74,6 +74,11 @@ class Export extends BaseExport
|
||||
$this->setPosition($position)->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ContainerInterface $container
|
||||
* @return ExportHandlerInterface
|
||||
* @throws \ErrorException
|
||||
*/
|
||||
public function getHandleClassInstance(ContainerInterface $container)
|
||||
{
|
||||
$class = $this->getHandleClass();
|
||||
|
||||
@@ -2,9 +2,73 @@
|
||||
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Model\Base\CategoryQuery;
|
||||
use Thelia\Model\Base\ExportCategory as BaseExportCategory;
|
||||
use Thelia\Model\Map\ExportCategoryTableMap;
|
||||
|
||||
class ExportCategory extends BaseExportCategory
|
||||
{
|
||||
public function upPosition()
|
||||
{
|
||||
if (($position = $this->getPosition()) > 1) {
|
||||
|
||||
}
|
||||
$previous = ExportCategoryQuery::create()
|
||||
->findOneByPosition($position - 1)
|
||||
;
|
||||
|
||||
if (null !== $previous) {
|
||||
$previous->setPosition($position)->save();
|
||||
}
|
||||
|
||||
$this->setPosition($position - 1)->save();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function downPosition()
|
||||
{
|
||||
$max = CategoryQuery::create()
|
||||
->orderByPosition(Criteria::DESC)
|
||||
->select(ExportCategoryTableMap::POSITION)
|
||||
->findOne()
|
||||
;
|
||||
|
||||
$count = CategoryQuery::create()->count();
|
||||
|
||||
if ($count > $max) {
|
||||
$max = $count;
|
||||
}
|
||||
|
||||
$position = $this->getPosition();
|
||||
|
||||
if ($position < $max) {
|
||||
|
||||
$next = ExportCategoryQuery::create()
|
||||
->findOneByPosition($position + 1)
|
||||
;
|
||||
|
||||
if (null !== $next) {
|
||||
$next->setPosition($position)->save();
|
||||
}
|
||||
|
||||
$this->setPosition($position + 1)->save();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function updatePosition($position)
|
||||
{
|
||||
$reverse = ExportCategoryQuery::create()
|
||||
->findOneByPosition($position)
|
||||
;
|
||||
|
||||
if (null !== $reverse) {
|
||||
$reverse->setPosition($this->getPosition())->save();
|
||||
}
|
||||
|
||||
$this->setPosition($position)->save();
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,72 @@
|
||||
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Model\Base\ImportCategory as BaseImportCategory;
|
||||
use Thelia\Model\Map\ImportCategoryTableMap;
|
||||
|
||||
class ImportCategory extends BaseImportCategory
|
||||
{
|
||||
public function upPosition()
|
||||
{
|
||||
if (($position = $this->getPosition()) > 1) {
|
||||
|
||||
$previous = ImportCategoryQuery::create()
|
||||
->findOneByPosition($position - 1)
|
||||
;
|
||||
|
||||
if (null !== $previous) {
|
||||
$previous->setPosition($position)->save();
|
||||
}
|
||||
|
||||
$this->setPosition($position - 1)->save();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function downPosition()
|
||||
{
|
||||
$max = CategoryQuery::create()
|
||||
->orderByPosition(Criteria::DESC)
|
||||
->select(ImportCategoryTableMap::POSITION)
|
||||
->findOne()
|
||||
;
|
||||
|
||||
$count = CategoryQuery::create()->count();
|
||||
|
||||
if ($count > $max) {
|
||||
$max = $count;
|
||||
}
|
||||
|
||||
$position = $this->getPosition();
|
||||
|
||||
if ($position < $max) {
|
||||
|
||||
$next = ImportCategoryQuery::create()
|
||||
->findOneByPosition($position + 1)
|
||||
;
|
||||
|
||||
if (null !== $next) {
|
||||
$next->setPosition($position)->save();
|
||||
}
|
||||
|
||||
$this->setPosition($position + 1)->save();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function updatePosition($position)
|
||||
{
|
||||
$reverse = ImportCategoryQuery::create()
|
||||
->findOneByPosition($position)
|
||||
;
|
||||
|
||||
if (null !== $reverse) {
|
||||
$reverse->setPosition($this->getPosition())->save();
|
||||
}
|
||||
|
||||
$this->setPosition($position)->save();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user