-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EZP-29408: As an editor I want to delete a content item with an image…
… asset field (#591) * EZP-29408: As an editor I want to delete a content item with an image asset field * EZP-29408: As an editor I want to delete a content item with an image asset field * EZP-29408: Updated modals design * EZP-29408: changed when form options are build + CR fixes * fixup! EZP-29408: changed when form options are build + CR fixes * fixup! EZP-29408: changed when form options are build + CR fixes
- Loading branch information
Showing
21 changed files
with
816 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
src/bundle/Controller/Location/TrashLocationWithAssetController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) eZ Systems AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace EzSystems\EzPlatformAdminUiBundle\Controller\Location; | ||
|
||
use eZ\Publish\API\Repository\ContentService; | ||
use eZ\Publish\API\Repository\LocationService; | ||
use eZ\Publish\API\Repository\TrashService; | ||
use EzSystems\EzPlatformAdminUi\Form\Data\Location\LocationTrashWithAssetData; | ||
use EzSystems\EzPlatformAdminUi\Form\Factory\FormFactory; | ||
use EzSystems\EzPlatformAdminUi\Form\SubmitHandler; | ||
use EzSystems\EzPlatformAdminUi\Form\Type\Location\LocationTrashWithAssetType; | ||
use EzSystems\EzPlatformAdminUiBundle\Controller\Controller; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class TrashLocationWithAssetController extends Controller | ||
{ | ||
/** @var \EzSystems\EzPlatformAdminUi\Form\Factory\FormFactory */ | ||
private $formFactory; | ||
|
||
/** @var \EzSystems\EzPlatformAdminUi\Form\SubmitHandler */ | ||
private $submitHandler; | ||
|
||
/** @var \eZ\Publish\API\Repository\LocationService */ | ||
private $locationService; | ||
|
||
/** @var \eZ\Publish\API\Repository\ContentService */ | ||
private $contentService; | ||
|
||
/** @var \eZ\Publish\API\Repository\TrashService */ | ||
private $trashService; | ||
|
||
/** | ||
* @param \EzSystems\EzPlatformAdminUi\Form\Factory\FormFactory $formFactory | ||
* @param \EzSystems\EzPlatformAdminUi\Form\SubmitHandler $submitHandler | ||
* @param \eZ\Publish\API\Repository\LocationService $locationService | ||
* @param \eZ\Publish\API\Repository\ContentService $contentService | ||
* @param \eZ\Publish\API\Repository\TrashService $trashService | ||
*/ | ||
public function __construct( | ||
FormFactory $formFactory, | ||
SubmitHandler $submitHandler, | ||
LocationService $locationService, | ||
ContentService $contentService, | ||
TrashService $trashService | ||
) { | ||
$this->formFactory = $formFactory; | ||
$this->submitHandler = $submitHandler; | ||
$this->trashService = $trashService; | ||
$this->locationService = $locationService; | ||
$this->contentService = $contentService; | ||
} | ||
|
||
/** | ||
* @param \Symfony\Component\HttpFoundation\Request $request | ||
* | ||
* @return \Symfony\Component\HttpFoundation\Response | ||
* | ||
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException | ||
*/ | ||
public function trashAction(Request $request): Response | ||
{ | ||
$form = $this->formFactory->trashLocationWithAsset( | ||
new LocationTrashWithAssetData() | ||
); | ||
$form->handleRequest($request); | ||
|
||
if ($form->isSubmitted()) { | ||
$result = $this->submitHandler->handle($form, function (LocationTrashWithAssetData $data) { | ||
$location = $data->getLocation(); | ||
$parentLocation = $this->locationService->loadLocation($location->parentLocationId); | ||
if ($data->getTrashAssets() === LocationTrashWithAssetType::RADIO_SELECT_TRASH_WITH_ASSETS) { | ||
$content = $this->contentService->loadContentByContentInfo($location->contentInfo); | ||
$relations = $this->contentService->loadRelations($content->versionInfo); | ||
$imageLocation = $this->locationService->loadLocation($relations[0]->destinationContentInfo->mainLocationId); | ||
$this->trashService->trash($imageLocation); | ||
} | ||
|
||
$this->trashService->trash($location); | ||
|
||
return $this->redirectToLocation($parentLocation); | ||
}); | ||
|
||
if ($result instanceof Response) { | ||
return $result; | ||
} | ||
} | ||
|
||
return $this->redirect($this->generateUrl('ezplatform.trash.list')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/bundle/Resources/public/js/scripts/button.state.radio.toggle.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
(function (global, doc) { | ||
const toggleForms = [...doc.querySelectorAll('.ez-toggle-btn-state-radio')]; | ||
|
||
toggleForms.forEach((toggleForm) => { | ||
const radioInputs = [...toggleForm.querySelectorAll('input[type="radio"]')]; | ||
const toggleButtonState = () => { | ||
const button = doc.querySelector(toggleForm.dataset.toggleButtonId); | ||
const oneIsSelected = radioInputs.some(el => el.checked); | ||
|
||
if (oneIsSelected) { | ||
button['removeAttribute']('disabled', true); | ||
} | ||
}; | ||
|
||
radioInputs.forEach(radioInput => radioInput.addEventListener('change', toggleButtonState, false)); | ||
}); | ||
})(window, document); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.