Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ See [keep a changelog] for information about writing changes to this log.
[PR-36](https://github.com/itk-dev/itqr/pull/36)
- Fixed issue with set url
- Batch set url only for admins
[PR-35](https://github.com/itk-dev/itqr/pull/35)
- Removed redirect popup for batch download
[PR-33](https://github.com/itk-dev/itqr/pull/33)
- Fixes and Tidy feedback
[PR-30](https://github.com/itk-dev/itqr/pull/30)
Expand Down
17 changes: 17 additions & 0 deletions assets/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,20 @@ document.addEventListener('DOMContentLoaded', () => {
});
updateQRCode();
});

function handleBatchDisableConfirm() {
document.querySelectorAll('.disable-confirm').forEach(actionBtn => {
actionBtn.addEventListener('click', function() {
let modal = document.getElementById('modal-batch-action');
document.querySelector('.modal-backdrop').classList.add('invisible');
modal.classList.add('invisible');
modal.querySelector('#modal-batch-action-button').click();
});
});
}

document.addEventListener('readystatechange', function(event) {
if ('complete' === document.readyState) {
handleBatchDisableConfirm();
}
});
24 changes: 18 additions & 6 deletions src/Controller/Admin/QrCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public function configureFields(string $pageName): iterable
{
if (Crud::PAGE_INDEX === $pageName) {
return [
TextField::new('title', new TranslatableMessage('qr.title')),
TextField::new('title', new TranslatableMessage('qr.title'))
->setTemplatePath('fields/link/link_to_edit.html.twig'),
TextEditorField::new('description', new TranslatableMessage('qr.description')),
CollectionField::new('urls', new TranslatableMessage('qr.urls'))
->allowAdd()
Expand Down Expand Up @@ -139,13 +140,16 @@ public function configureActions(Actions $actions): Actions
// Define batch download action
$batchDownloadAction = Action::new('download', new TranslatableMessage('qr.configure_download'))
->linkToCrudAction('batchDownload')
->addCssClass('btn btn-success')
->addCssClass('btn btn-success disable-confirm')
->setIcon('fa fa-download')
->displayAsButton();

// Define single download action
$singleDownloadAction = Action::new('quickDownload', new TranslatableMessage('qr.quick_download'))
->linkToCrudAction('quickDownload')
$singleDownloadActionNoConfig = Action::new('downloadWithoutConfig', new TranslatableMessage('qr.quick_download_without_config'))
->linkToCrudAction('downloadWithoutConfig')
->setIcon('fa fa-download');
$singleDownloadActionConfig = Action::new('downloadWithConfig', new TranslatableMessage('qr.quick_download_with_config'))
->linkToCrudAction('downloadWithConfig')
->setIcon('fa fa-download');

// Define batch url change action
Expand All @@ -160,7 +164,8 @@ public function configureActions(Actions $actions): Actions
->update(Crud::PAGE_INDEX, Action::DELETE, fn (Action $action) => $action->setIcon('fa fa-trash')->setLabel('qr.delete'))
->addBatchAction($batchDownloadAction)
->addBatchAction($setUrlAction)
->add(Crud::PAGE_INDEX, $singleDownloadAction);
->add(Crud::PAGE_INDEX, $singleDownloadActionNoConfig)
->add(Crud::PAGE_INDEX, $singleDownloadActionConfig);
}

public function setUrl(BatchActionDto $batchActionDto): RedirectResponse
Expand All @@ -177,13 +182,20 @@ public function setUrl(BatchActionDto $batchActionDto): RedirectResponse
*
* @throws ValidationException
*/
public function quickDownload(AdminContext $context): StreamedResponse
public function downloadWithoutConfig(AdminContext $context): StreamedResponse
{
$qrEntity = $context->getEntity()->getInstance();

return $this->downloadHelper->generateQrCodes([$qrEntity], []);
}

public function downloadWithConfig(AdminContext $context): RedirectResponse
{
$entityId = ['id' => $context->getEntity()->getInstance()->getId()];

return $this->redirectToRoute('admin_batch_download', $entityId);
}

/**
* Handles batch download action, redirecting to the batch download route
* with the provided entity IDs from the BatchActionDto object.
Expand Down
1 change: 1 addition & 0 deletions templates/fields/link/link_to_edit.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<a href="/admin/batch/download/qr/{{ entity.instance.id }}/edit">{{ field.formattedValue }}</a>
5 changes: 3 additions & 2 deletions translations/messages.da.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ qr:
code_color: 'QR-kode farve'
select_design: '-- Vælg et design --'
download: 'Download'
configure_download: 'Konfigurer download af markerede'
quick_download: 'Download uden konfiguration'
configure_download: 'Design og download markerede'
quick_download_without_config: 'Download uden design'
quick_download_with_config: 'Design og download'
set_url: 'Ret destination på markerede'
edit: 'Ret QR-kode'
delete: 'Slet QR-kode'
Expand Down