From 93a9406f56a96ca8046e0fd83c6c733af8041365 Mon Sep 17 00:00:00 2001 From: Damien <damien.burel@maarch.org> Date: Thu, 6 Feb 2020 10:56:02 +0100 Subject: [PATCH] FEAT #12361 TIME 1:10 Export custom ban + get DOC versions --- src/app/resource/controllers/ExportController.php | 12 ++++++++++-- src/app/resource/controllers/ResController.php | 14 +++++++++----- src/frontend/app/list/export/export.component.ts | 1 + 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/app/resource/controllers/ExportController.php b/src/app/resource/controllers/ExportController.php index 63a5d53b4c5..ba5e5e5fa40 100644 --- a/src/app/resource/controllers/ExportController.php +++ b/src/app/resource/controllers/ExportController.php @@ -17,6 +17,7 @@ namespace Resource\controllers; use Attachment\models\AttachmentModel; use Basket\models\BasketModel; use Contact\controllers\ContactController; +use CustomField\models\CustomFieldModel; use Entity\models\EntityModel; use Entity\models\ListInstanceModel; use Folder\controllers\FolderController; @@ -656,8 +657,15 @@ class ExportController return null; } - if (is_array($customValues)) { - return implode("\n", $customValues); + $field = CustomFieldModel::getById(['select' => ['type'], 'id' => $customFieldId]); + + if ($field['type'] == 'banAutocomplete') { + $line = "{$customValues[0]['addressNumber']} {$customValues[0]['addressStreet']} {$customValues[0]['addressTown']} ({$customValues[0]['addressPostcode']})"; + $line .= "\n"; + $line .= "{$customValues[0]['latitude']},{$customValues[0]['longitude']}"; + $customValues = $line; + } elseif (is_array($customValues)) { + $customValues = implode("\n", $customValues); } return $customValues; diff --git a/src/app/resource/controllers/ResController.php b/src/app/resource/controllers/ResController.php index df15c4399a6..ec54d54d48b 100755 --- a/src/app/resource/controllers/ResController.php +++ b/src/app/resource/controllers/ResController.php @@ -441,26 +441,29 @@ class ResController extends ResourceControlController return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']); } + $docVersions = []; $pdfVersions = []; $signedVersions = []; $noteVersions = []; $resource = ResModel::getById(['resId' => $args['resId'], 'select' => ['version', 'filename']]); if (empty($resource['filename'])) { - return $response->withJson(['PDF' => $pdfVersions, 'SIGN' => $signedVersions, 'NOTE' => $noteVersions]); + return $response->withJson(['DOC' => $docVersions, 'PDF' => $pdfVersions, 'SIGN' => $signedVersions, 'NOTE' => $noteVersions]); } $convertedDocuments = AdrModel::getDocuments([ 'select' => ['type', 'version'], 'where' => ['res_id = ?', 'type in (?)'], - 'data' => [$args['resId'], ['PDF', 'SIGN', 'NOTE']], + 'data' => [$args['resId'], ['DOC', 'PDF', 'SIGN', 'NOTE']], 'orderBy' => ['version ASC'] ]); if (empty($convertedDocuments)) { - return $response->withJson(['PDF' => $pdfVersions, 'SIGN' => $signedVersions, 'NOTE' => $noteVersions]); + return $response->withJson(['DOC' => [$resource['version']], 'PDF' => $pdfVersions, 'SIGN' => $signedVersions, 'NOTE' => $noteVersions]); } foreach ($convertedDocuments as $convertedDocument) { - if ($convertedDocument['type'] == 'PDF') { + if ($convertedDocument['type'] == 'DOC') { + $docVersions[] = $convertedDocument['version']; + } elseif ($convertedDocument['type'] == 'PDF') { $pdfVersions[] = $convertedDocument['version']; } elseif ($convertedDocument['type'] == 'SIGN') { $signedVersions[] = $convertedDocument['version']; @@ -468,8 +471,9 @@ class ResController extends ResourceControlController $noteVersions[] = $convertedDocument['version']; } } + $docVersions[] = $resource['version']; - return $response->withJson(['PDF' => $pdfVersions, 'SIGN' => $signedVersions, 'NOTE' => $noteVersions]); + return $response->withJson(['DOC' => $docVersions, 'PDF' => $pdfVersions, 'SIGN' => $signedVersions, 'NOTE' => $noteVersions]); } public function getVersionFileContent(Request $request, Response $response, array $args) diff --git a/src/frontend/app/list/export/export.component.ts b/src/frontend/app/list/export/export.component.ts index f26c4047f64..e6d0f7daaf2 100644 --- a/src/frontend/app/list/export/export.component.ts +++ b/src/frontend/app/list/export/export.component.ts @@ -247,6 +247,7 @@ export class ExportComponent implements OnInit { }), tap((data: any) => { this.dataAvailable = this.dataAvailable.concat(data.customFields); + this.dataAvailableClone = this.dataAvailableClone.concat(data.customFields); }), catchError((err: any) => { this.notify.handleErrors(err); -- GitLab