mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-12 04:23:19 +00:00
[skip ci]
PHRAS-3381_tx-as-classification-plan_MASTER back controller for ok button fix : PHRAS-3383 WIP
This commit is contained in:
@@ -26,6 +26,8 @@ use Alchemy\Phrasea\Twig\PhraseanetExtension;
|
||||
use Alchemy\Phrasea\Vocabulary\ControlProvider\ControlProviderInterface;
|
||||
use Alchemy\Phrasea\WorkerManager\Event\RecordEditInWorkerEvent;
|
||||
use Alchemy\Phrasea\WorkerManager\Event\WorkerEvents;
|
||||
use stdClass;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
@@ -342,6 +344,29 @@ class EditController extends Controller
|
||||
return $this->app->json(['success' => true]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* performs an editing using a similar json-body as api_v3:record:patch (except here we can work on a list of records)
|
||||
*
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function applyJSAction(Request $request): JsonResponse
|
||||
{
|
||||
// todo : by worker
|
||||
|
||||
// for now call record_adapter. no check, no acl, ...
|
||||
/** @var stdClass $arg */
|
||||
$arg = json_decode($request->getContent());
|
||||
|
||||
foreach($arg->records as $rec) {
|
||||
$r = $this->getApplicationBox()->get_databox($rec->sbas_id)->get_record($rec->record_id);
|
||||
$r->setMetadatasByActions($arg->actions);
|
||||
}
|
||||
|
||||
return $this->app->json(['success' => true]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $preset_id
|
||||
* @return Preset
|
||||
@@ -359,7 +384,7 @@ class EditController extends Controller
|
||||
* route GET "../prod/records/edit/presets/{preset_id}"
|
||||
*
|
||||
* @param int $preset_id
|
||||
* @return \Symfony\Component\HttpFoundation\JsonResponse
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function presetsLoadAction($preset_id)
|
||||
{
|
||||
@@ -381,7 +406,7 @@ class EditController extends Controller
|
||||
* route GET "../prod/records/edit/presets"
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Symfony\Component\HttpFoundation\JsonResponse
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function presetsListAction(Request $request)
|
||||
{
|
||||
@@ -399,7 +424,7 @@ class EditController extends Controller
|
||||
* route DELETE "../prod/records/edit/presets/{preset_id}"
|
||||
*
|
||||
* @param int $preset_id
|
||||
* @return \Symfony\Component\HttpFoundation\JsonResponse
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function presetsDeleteAction($preset_id)
|
||||
{
|
||||
@@ -421,7 +446,7 @@ class EditController extends Controller
|
||||
* route POST "../prod/records/edit/presets"
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Symfony\Component\HttpFoundation\JsonResponse
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function presetsSaveAction(Request $request)
|
||||
{
|
||||
|
@@ -30,15 +30,24 @@ class ThesaurusController extends Controller
|
||||
{
|
||||
$sbas_id = $request->get('sbas_id');
|
||||
$tx_term_id = $request->get('tx_term_id');
|
||||
|
||||
$records = RecordsRequest::fromRequest($this->app, $request, RecordsRequest::FLATTEN_YES_PRESERVE_STORIES, [ACL::CANMODIFRECORD]);
|
||||
|
||||
// array of sbid/rid. too bad we cannot array_map on arraycollection
|
||||
$recRefs = [];
|
||||
foreach($records as $r) {
|
||||
$recRefs[] = [
|
||||
'sbas_id'=>$r->getDataboxId(),
|
||||
'record_id'=>$r->getRecordId()
|
||||
];
|
||||
}
|
||||
|
||||
// twig parameters
|
||||
$twp = [
|
||||
'error' => null,
|
||||
'dlg_level' => $request->get('dlg_level'),
|
||||
// 'fields' => [], // fields the can receive the value
|
||||
// 'fvalue' => 'Europe',
|
||||
'lst' => $records->serializedList(),
|
||||
// 'lst' => $records->serializedList(),
|
||||
'records' => $recRefs,
|
||||
'received_cnt' => $records->received()->count(),
|
||||
'rejected_cnt' => $records->rejected()->count(),
|
||||
'up_paths' => [],
|
||||
|
@@ -12,9 +12,9 @@
|
||||
namespace Alchemy\Phrasea\ControllerProvider\Prod;
|
||||
|
||||
use Alchemy\Phrasea\Application as PhraseaApplication;
|
||||
use Alchemy\Phrasea\Core\LazyLocator;
|
||||
use Alchemy\Phrasea\Controller\Prod\EditController;
|
||||
use Alchemy\Phrasea\ControllerProvider\ControllerProviderTrait;
|
||||
use Alchemy\Phrasea\Core\LazyLocator;
|
||||
use Silex\Application;
|
||||
use Silex\ControllerProviderInterface;
|
||||
use Silex\ServiceProviderInterface;
|
||||
@@ -54,6 +54,11 @@ class Edit implements ControllerProviderInterface, ServiceProviderInterface
|
||||
|
||||
$controllers->get('/vocabulary/{vocabulary}/', 'controller.prod.edit:searchVocabularyAction');
|
||||
|
||||
/** @uses \Alchemy\Phrasea\Controller\Prod\EditController::applyJSAction */
|
||||
$controllers
|
||||
->post('/applyjs/', 'controller.prod.edit:applyJSAction')
|
||||
->bind('prod_edit_applyJSAction');
|
||||
|
||||
$controllers->post('/apply/', 'controller.prod.edit:applyAction');
|
||||
|
||||
$controllers->get('/presets/{preset_id}', 'controller.prod.edit:presetsLoadAction');
|
||||
|
@@ -42,11 +42,6 @@ class Thesaurus implements ControllerProviderInterface, ServiceProviderInterface
|
||||
public function connect(Application $app)
|
||||
{
|
||||
$controllers = $this->createAuthenticatedCollection($app);
|
||||
// $firewall = $this->getFirewall($app);
|
||||
|
||||
// $controllers->before(function () use ($firewall) {
|
||||
// $firewall->requireRight(\ACL::CANMODIFRECORD);
|
||||
// });
|
||||
|
||||
/** @uses ThesaurusController::dropRecordsAction() */
|
||||
$controllers->get('/droprecords', 'controller.prod.thesaurus:dropRecordsAction');
|
||||
|
Reference in New Issue
Block a user