From 86f1e06e42630e08c77201a2be1bb5c4ca3fac66 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Mon, 16 Dec 2013 11:32:05 +0100 Subject: [PATCH] document repositioning after delation --- core/lib/Thelia/Model/CategoryDocument.php | 10 ++++++++++ core/lib/Thelia/Model/ContentDocument.php | 10 ++++++++++ core/lib/Thelia/Model/FolderDocument.php | 10 ++++++++++ core/lib/Thelia/Model/ProductDocument.php | 10 ++++++++++ .../backOffice/default/assets/js/document-upload.js | 9 +++++++-- 5 files changed, 47 insertions(+), 2 deletions(-) diff --git a/core/lib/Thelia/Model/CategoryDocument.php b/core/lib/Thelia/Model/CategoryDocument.php index 57ae3c460..432f61bf3 100755 --- a/core/lib/Thelia/Model/CategoryDocument.php +++ b/core/lib/Thelia/Model/CategoryDocument.php @@ -50,4 +50,14 @@ class CategoryDocument extends BaseCategoryDocument { return $this->getCategoryId(); } + + public function preDelete(ConnectionInterface $con = null) + { + $this->reorderBeforeDelete( + array( + "category_id" => $this->getCategoryId(), + ) + ); + return true; + } } \ No newline at end of file diff --git a/core/lib/Thelia/Model/ContentDocument.php b/core/lib/Thelia/Model/ContentDocument.php index 30093573b..0faab1829 100755 --- a/core/lib/Thelia/Model/ContentDocument.php +++ b/core/lib/Thelia/Model/ContentDocument.php @@ -50,4 +50,14 @@ class ContentDocument extends BaseContentDocument { return $this->getContentId(); } + + public function preDelete(ConnectionInterface $con = null) + { + $this->reorderBeforeDelete( + array( + "content_id" => $this->getContentId(), + ) + ); + return true; + } } diff --git a/core/lib/Thelia/Model/FolderDocument.php b/core/lib/Thelia/Model/FolderDocument.php index 29e860294..9940c3eed 100755 --- a/core/lib/Thelia/Model/FolderDocument.php +++ b/core/lib/Thelia/Model/FolderDocument.php @@ -50,4 +50,14 @@ class FolderDocument extends BaseFolderDocument { return $this->getFolderId(); } + + public function preDelete(ConnectionInterface $con = null) + { + $this->reorderBeforeDelete( + array( + "folder_id" => $this->getFolderId(), + ) + ); + return true; + } } diff --git a/core/lib/Thelia/Model/ProductDocument.php b/core/lib/Thelia/Model/ProductDocument.php index eeaec30e9..295f0d929 100755 --- a/core/lib/Thelia/Model/ProductDocument.php +++ b/core/lib/Thelia/Model/ProductDocument.php @@ -51,4 +51,14 @@ class ProductDocument extends BaseProductDocument return $this->getProductId(); } + public function preDelete(ConnectionInterface $con = null) + { + $this->reorderBeforeDelete( + array( + "product_id" => $this->getProductId(), + ) + ); + return true; + } + } diff --git a/templates/backOffice/default/assets/js/document-upload.js b/templates/backOffice/default/assets/js/document-upload.js index bc9cf5898..82be7f46d 100755 --- a/templates/backOffice/default/assets/js/document-upload.js +++ b/templates/backOffice/default/assets/js/document-upload.js @@ -40,7 +40,6 @@ $(function($){ documentDropzone.removeFile(file); $.documentUploadManager.updateDocumentListAjax(); $.documentUploadManager.onClickDeleteDocument(); - $.documentUploadManager.sortDocument(); }); @@ -66,6 +65,7 @@ $(function($){ data ); $.documentUploadManager.onClickDeleteDocument(); + $.documentUploadManager.sortDocument(); }); }; @@ -90,11 +90,16 @@ $(function($){ } } }).done(function(data) { - $parent.parents('tr').remove(); + $parent.parents('li').remove(); $(".document-manager .message").html( data ); + + /* refresh position */ + $( "#js-sort-document").children('li').each(function(position, element) { + $(element).find('.js-sorted-position').html(position + 1); + }); }); return false; });