mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 23:13:15 +00:00
PHRAS-2927_optimize-feedback-process_4.1
add route "lightbox/ajax/GET_ELEMENTS/{{basket_id}}/" to get counts of elements validated as "yes", "no" or "nul". Will allow front to display alert before submitting
This commit is contained in:
@@ -450,6 +450,51 @@ class LightboxController extends Controller
|
||||
return $this->app->json($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Basket $basket
|
||||
* @return Response
|
||||
*/
|
||||
public function ajaxGetElementsAction(Basket $basket)
|
||||
{
|
||||
$ret = [
|
||||
'error' => false,
|
||||
'datas' => [
|
||||
'counts' => [
|
||||
'yes' => 0,
|
||||
'no' => 0,
|
||||
'nul' => 0,
|
||||
'total' => 0
|
||||
]
|
||||
]
|
||||
];
|
||||
try {
|
||||
if (!$basket->getValidation()) {
|
||||
throw new Exception('There is no validation session attached to this basket');
|
||||
}
|
||||
foreach ($basket->getElements() as $element) {
|
||||
$vd = $element->getUserValidationDatas($this->getAuthenticatedUser());
|
||||
if($vd->getAgreement() === true) {
|
||||
$ret['datas']['counts']['yes']++;
|
||||
}
|
||||
elseif($vd->getAgreement() === false) {
|
||||
$ret['datas']['counts']['no']++;
|
||||
}
|
||||
elseif($vd->getAgreement() === null) {
|
||||
$ret['datas']['counts']['nul']++;
|
||||
}
|
||||
$ret['datas']['counts']['total']++;
|
||||
}
|
||||
}
|
||||
catch (Exception $e) {
|
||||
$ret = [
|
||||
'error' => true,
|
||||
'datas' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
|
||||
return $this->app->json($ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Basket $basket
|
||||
* @throws Exception
|
||||
|
Reference in New Issue
Block a user