From ad015fba4a055b67296a0f0b0913998a71fcb72f Mon Sep 17 00:00:00 2001 From: jygaulier Date: Thu, 20 Jul 2023 19:08:34 +0200 Subject: [PATCH 1/8] wip --- .../Phrasea/ControllerProvider/Api/V2.php | 3 + .../ControllerProvider/Prod/Lazaret.php | 8 +++ templates/web/prod/upload/lazaret.html.twig | 61 +++++++++++++++++-- 3 files changed, 67 insertions(+), 5 deletions(-) diff --git a/lib/Alchemy/Phrasea/ControllerProvider/Api/V2.php b/lib/Alchemy/Phrasea/ControllerProvider/Api/V2.php index 7ff511332a..3ca74cac8d 100644 --- a/lib/Alchemy/Phrasea/ControllerProvider/Api/V2.php +++ b/lib/Alchemy/Phrasea/ControllerProvider/Api/V2.php @@ -104,13 +104,16 @@ public function connect(Application $app) $controllers->match('/search/', 'controller.api.v2.search:searchAction'); + /** @uses LazaretController::quarantineItemEmptyAction */ $controllers->delete('/quarantine/', 'controller.api.v2.lazaret:quarantineItemEmptyAction') ->bind('api_v2_quarantine_empty'); + /** @uses LazaretController::quarantineItemDeleteAction */ $controller = $controllers->delete('/quarantine/item/{lazaret_id}/', 'controller.api.v2.lazaret:quarantineItemDeleteAction') ->bind('api_v2_quarantine_item_delete'); $this->addQuarantineMiddleware($controller); + /** @uses LazaretController::quarantineItemAddAction */ $controller = $controllers->post('/quarantine/item/{lazaret_id}/add/', 'controller.api.v2.lazaret:quarantineItemAddAction') ->bind('api_v2_quarantine_item_add'); $this->addQuarantineMiddleware($controller); diff --git a/lib/Alchemy/Phrasea/ControllerProvider/Prod/Lazaret.php b/lib/Alchemy/Phrasea/ControllerProvider/Prod/Lazaret.php index 53c2804fce..4b9e1d1932 100644 --- a/lib/Alchemy/Phrasea/ControllerProvider/Prod/Lazaret.php +++ b/lib/Alchemy/Phrasea/ControllerProvider/Prod/Lazaret.php @@ -56,32 +56,40 @@ public function connect(Application $app) $firewall->requireRight(\ACL::CANADDRECORD); }); + /** @uses LazaretController::listElement */ $controllers->get('/', 'controller.prod.lazaret:listElement') ->bind('lazaret_elements'); + /** @uses LazaretController::getElement */ $controllers->get('/{file_id}/', 'controller.prod.lazaret:getElement') ->assert('file_id', '\d+') ->bind('lazaret_element'); + /** @uses LazaretController::addElement */ $controllers->post('/{file_id}/force-add/', 'controller.prod.lazaret:addElement') ->assert('file_id', '\d+') ->bind('lazaret_force_add'); + /** @uses LazaretController::denyElement */ $controllers->post('/{file_id}/deny/', 'controller.prod.lazaret:denyElement') ->assert('file_id', '\d+') ->bind('lazaret_deny_element'); + /** @uses LazaretController::emptyLazaret */ $controllers->post('/empty/', 'controller.prod.lazaret:emptyLazaret') ->bind('lazaret_empty'); + /** @uses LazaretController::acceptElement */ $controllers->post('/{file_id}/accept/', 'controller.prod.lazaret:acceptElement') ->assert('file_id', '\d+') ->bind('lazaret_accept'); + /** @uses LazaretController::thumbnailElement */ $controllers->get('/{file_id}/thumbnail/', 'controller.prod.lazaret:thumbnailElement') ->assert('file_id', '\d+') ->bind('lazaret_thumbnail'); + /** @uses LazaretController::getDestinationStatus */ $controllers->get('/{databox_id}/{record_id}/status', 'controller.prod.lazaret:getDestinationStatus') ->assert('databox_id', '\d+') ->assert('record_id', '\d+') diff --git a/templates/web/prod/upload/lazaret.html.twig b/templates/web/prod/upload/lazaret.html.twig index 99b0a37130..5c8796ddd2 100644 --- a/templates/web/prod/upload/lazaret.html.twig +++ b/templates/web/prod/upload/lazaret.html.twig @@ -270,20 +270,56 @@ var html = that.parent().closest('.wrapper-item').find(".status-backup").html(); that.parent().closest('.wrapper-item').find(".status-container").html(''); that.parent().closest('.wrapper-item').find(".status-container").append(html); - }; + } + + + + + function isRecordSelected(selected) { + if(selected) { + $('BUTTON.subtitute-lazaret').removeAttr('disabled'); + $('.copy_meta').show(); + } + else { + $('BUTTON.subtitute-lazaret').attr('disabled', "true"); + $('.copy_meta').hide(); + checkCopyMeta(false); + $("#lazaretBox INPUT[name=copy_meta]").removeAttr("checked"); + } + } + + function checkCopyMeta(checked) { + const $b = $("BUTTON.add-lazaret .b_label"); + if (checked) { + console.log("checked"); + $b.text("checked") + } + else { + console.log("unchecked"); + $b.text("unchecked") + } + } + + + + $(".span12 img, .reset-status").click(function () { var that = $(this).closest('.wrapper-item').find('.lazaret-proposals .diapo'); resetStatus(that); }); + $(".records-subititution .diapo", scope).bind('click', function () { var that = $(this); var diapo = that.closest('.lazaret-proposals').find('.diapo'); var container = that.closest('.wrapper-item'); + diapo.not(this).removeClass('selected'); /*Set selected or not to check for sending ajax request*/ if (that.hasClass("selected")) { resetStatus(that); - } else { + isRecordSelected(false); + } + else { that.addClass('selected'); var elements = $(".selected", container); var recordId = elements.first().attr("data-record_id"); @@ -333,9 +369,11 @@ html += ''; html += ''; } - ; + that.parent().closest('.wrapper-item').find(".status-container").html(''); that.parent().closest('.wrapper-item').find(".status-container").append(html); + + isRecordSelected(true); } }, complete: function () { @@ -346,6 +384,12 @@ } }); + $("INPUT[name=copy_meta]", scope).change( + function(event) { + checkCopyMeta(event.target.checked); + } + ); + //substitute lazaret file click action $("button.subtitute-lazaret", scope).bind('click', function () { var that = $(this); @@ -419,6 +463,7 @@ }); /*Toggle status block*/ $(".toggle-status").click(function () { + debugger; $(this).nextAll('.status-wrapper').first().toggleClass('hidden'); }); }); @@ -464,6 +509,11 @@
Reset status + + +
{{ 'upload:: Status :' | trans }}
+ +
+  {{ 'upload:: Copy meta' | trans }} +
+
{% endif %} - -
- - {% if records|length > 0 %} - {% endif %} @@ -650,10 +669,11 @@