Parcourir la source

[Backend] CollectifData : export CSV

develop
Guillaume il y a 2 ans
Parent
révision
27a15fdb5e
6 fichiers modifiés avec 138 ajouts et 65 suppressions
  1. +10
    -11
      package.json
  2. +24
    -24
      public/build/entrypoints.json
  3. +15
    -14
      public/build/manifest.json
  4. +2
    -2
      src/Controller/AbstractAdminController.php
  5. +84
    -11
      src/Controller/Admin/CollectifDataCrudController.php
  6. +3
    -3
      yarn.lock

+ 10
- 11
package.json Voir le fichier

@@ -8,26 +8,25 @@
"build": "encore production --progress"
},
"dependencies": {
"@amcharts/amcharts4": "^4.10.22",
"@symfony/stimulus-bridge": "^2.0.0",
"@symfony/webpack-encore": "^1.4.0",
"admin-lte": "^3.1.0",
"bootstrap-autocomplete": "^2.3.7",
"bootstrap-daterangepicker": "^3.1.0",
"ckeditor": "^4.12.1",
"core-js": "^3.0.0",
"file-loader": "^6.0.0",
"jquery": "^3.6.0",
"jquery-ui-sortable": "^1.0.0",
"regenerator-runtime": "^0.13.2",
"sass": "^1.34.0",
"sass-loader": "^11.1.1",
"select2-bootstrap4-theme": "^1.0.0",
"stimulus": "^2.0.0",
"ts-loader": "^8.0.1",
"typescript": "^4.4.2",
"webpack-notifier": "^1.6.0",
"@amcharts/amcharts4": "^4.10.22",
"admin-lte": "^3.1.0",
"bootstrap-autocomplete": "^2.3.7",
"jquery": "^3.6.0",
"jquery-ui-sortable": "^1.0.0",
"sass-loader": "^11.1.1",
"ckeditor": "^4.12.1",
"file-loader": "^6.0.0"
"webpack-notifier": "^1.6.0"
},
"devDependencies": {
}
"devDependencies": {}
}

+ 24
- 24
public/build/entrypoints.json Voir le fichier

@@ -2,14 +2,14 @@
"entrypoints": {
"adminlte-plugins": {
"js": [
"/build/runtime.3d27a626.js",
"/build/runtime.13c4345a.js",
"/build/vendors-node_modules_core-js_internals_export_js.b6b23703.js",
"/build/vendors-node_modules_core-js_internals_advance-string-index_js-node_modules_core-js_internals-7d93ee.fb71db4a.js",
"/build/vendors-node_modules_jquery_src_jquery_js.e65c0e33.js",
"/build/vendors-node_modules_core-js_internals_add-to-unscopables_js-node_modules_core-js_modules_es_-cd53d9.25be4035.js",
"/build/vendors-node_modules_core-js_modules_es_string_split_js-node_modules_popper_js_dist_esm_popper_js.2bb90f63.js",
"/build/vendors-node_modules_admin-lte_dist_js_adminlte_min_js-node_modules_bootstrap-autocomplete_di-0f2281.3c330cc7.js",
"/build/adminlte-plugins.d8487c35.js"
"/build/adminlte-plugins.57e6b1d2.js"
],
"css": [
"/build/vendors-node_modules_admin-lte_dist_js_adminlte_min_js-node_modules_bootstrap-autocomplete_di-0f2281.bb1c83c0.css"
@@ -17,23 +17,23 @@
},
"adminlte-index": {
"js": [
"/build/runtime.3d27a626.js",
"/build/runtime.13c4345a.js",
"/build/vendors-node_modules_core-js_internals_export_js.b6b23703.js",
"/build/vendors-node_modules_core-js_internals_advance-string-index_js-node_modules_core-js_internals-7d93ee.fb71db4a.js",
"/build/vendors-node_modules_core-js_internals_add-to-unscopables_js-node_modules_core-js_modules_es_-cd53d9.25be4035.js",
"/build/vendors-node_modules_core-js_modules_es_array_find_js-node_modules_core-js_modules_es_array_i-feaec3.5bf458bc.js",
"/build/adminlte-index.4f294872.js"
"/build/adminlte-index.95eb752b.js"
],
"css": [
"/build/adminlte-index.5737ef9f.css"
"/build/adminlte-index.22b0d5e9.css"
]
},
"adminlte-form": {
"js": [
"/build/runtime.3d27a626.js",
"/build/runtime.13c4345a.js",
"/build/vendors-node_modules_core-js_internals_export_js.b6b23703.js",
"/build/vendors-node_modules_core-js_modules_es_array_find_js-_7db01.c27eb96d.js",
"/build/adminlte-form.24a91721.js"
"/build/adminlte-form.98ea3027.js"
],
"css": [
"/build/adminlte-form.3e7d9bc7.css"
@@ -41,13 +41,13 @@
},
"adminlte-sort": {
"js": [
"/build/runtime.3d27a626.js",
"/build/runtime.13c4345a.js",
"/build/vendors-node_modules_core-js_internals_export_js.b6b23703.js",
"/build/vendors-node_modules_core-js_internals_advance-string-index_js-node_modules_core-js_internals-7d93ee.fb71db4a.js",
"/build/vendors-node_modules_jquery_src_jquery_js.e65c0e33.js",
"/build/vendors-node_modules_jquery-ui-sortable_jquery-ui_min_js.4192d4ce.js",
"/build/vendors-node_modules_core-js_modules_es_array_find_js-node_modules_core-js_modules_es_string_-b9e064.2ecf2f9f.js",
"/build/adminlte-sort.e6f4f49f.js"
"/build/adminlte-sort.1719f809.js"
],
"css": [
"/build/adminlte-sort.7e9350c2.css"
@@ -55,9 +55,9 @@
},
"adminlte-field-filemanager": {
"js": [
"/build/runtime.3d27a626.js",
"/build/runtime.13c4345a.js",
"/build/vendors-node_modules_core-js_internals_export_js.b6b23703.js",
"/build/adminlte-field-filemanager.cf4425cd.js"
"/build/adminlte-field-filemanager.be92c053.js"
],
"css": [
"/build/adminlte-field-filemanager.2473d8f3.css"
@@ -65,10 +65,10 @@
},
"adminlte-field-collection": {
"js": [
"/build/runtime.3d27a626.js",
"/build/runtime.13c4345a.js",
"/build/vendors-node_modules_jquery_src_jquery_js.e65c0e33.js",
"/build/vendors-node_modules_jquery-ui-sortable_jquery-ui_min_js.4192d4ce.js",
"/build/adminlte-field-collection.bf51b4fd.js"
"/build/adminlte-field-collection.7e6cc250.js"
],
"css": [
"/build/adminlte-field-collection.0e96676f.css"
@@ -76,19 +76,19 @@
},
"adminlte-main": {
"js": [
"/build/runtime.3d27a626.js",
"/build/runtime.13c4345a.js",
"/build/vendors-node_modules_core-js_internals_export_js.b6b23703.js",
"/build/vendors-node_modules_core-js_internals_advance-string-index_js-node_modules_core-js_internals-7d93ee.fb71db4a.js",
"/build/adminlte-main.a68c6b41.js"
"/build/adminlte-main.a8e37b78.js"
],
"css": [
"/build/adminlte-main.1c300872.css"
"/build/adminlte-main.56708bb5.css"
]
},
"sov-reminder": {
"js": [
"/build/runtime.3d27a626.js",
"/build/sov-reminder.5e053a2b.js"
"/build/runtime.13c4345a.js",
"/build/sov-reminder.8302acd0.js"
],
"css": [
"/build/sov-reminder.3a67c840.css"
@@ -96,13 +96,13 @@
},
"sov-ticket": {
"js": [
"/build/runtime.3d27a626.js",
"/build/sov-ticket.ed87120e.js"
"/build/runtime.13c4345a.js",
"/build/sov-ticket.3527403c.js"
]
},
"app-backend": {
"js": [
"/build/runtime.3d27a626.js",
"/build/runtime.13c4345a.js",
"/build/vendors-node_modules_core-js_internals_export_js.b6b23703.js",
"/build/vendors-node_modules_core-js_modules_es_array_find_js-_7db00.48e9ded1.js",
"/build/app-backend.bca91793.js"
@@ -113,7 +113,7 @@
},
"app-frontend": {
"js": [
"/build/runtime.3d27a626.js",
"/build/runtime.13c4345a.js",
"/build/vendors-node_modules_core-js_internals_export_js.b6b23703.js",
"/build/vendors-node_modules_core-js_internals_advance-string-index_js-node_modules_core-js_internals-7d93ee.fb71db4a.js",
"/build/vendors-node_modules_jquery_src_jquery_js.e65c0e33.js",
@@ -122,12 +122,12 @@
"/build/app-frontend.f8975c31.js"
],
"css": [
"/build/app-frontend.e5188731.css"
"/build/app-frontend.91dae722.css"
]
},
"app-bulle": {
"js": [
"/build/runtime.3d27a626.js",
"/build/runtime.13c4345a.js",
"/build/vendors-node_modules_core-js_internals_export_js.b6b23703.js",
"/build/vendors-node_modules_core-js_internals_advance-string-index_js-node_modules_core-js_internals-7d93ee.fb71db4a.js",
"/build/vendors-node_modules_amcharts_amcharts4_charts_js-node_modules_amcharts_amcharts4_core_js-nod-680fc8.3921a227.js",

+ 15
- 14
public/build/manifest.json Voir le fichier

@@ -1,26 +1,26 @@
{
"build/adminlte-plugins.js": "/build/adminlte-plugins.d8487c35.js",
"build/adminlte-index.css": "/build/adminlte-index.5737ef9f.css",
"build/adminlte-index.js": "/build/adminlte-index.4f294872.js",
"build/adminlte-plugins.js": "/build/adminlte-plugins.57e6b1d2.js",
"build/adminlte-index.css": "/build/adminlte-index.22b0d5e9.css",
"build/adminlte-index.js": "/build/adminlte-index.95eb752b.js",
"build/adminlte-form.css": "/build/adminlte-form.3e7d9bc7.css",
"build/adminlte-form.js": "/build/adminlte-form.24a91721.js",
"build/adminlte-form.js": "/build/adminlte-form.98ea3027.js",
"build/adminlte-sort.css": "/build/adminlte-sort.7e9350c2.css",
"build/adminlte-sort.js": "/build/adminlte-sort.e6f4f49f.js",
"build/adminlte-sort.js": "/build/adminlte-sort.1719f809.js",
"build/adminlte-field-filemanager.css": "/build/adminlte-field-filemanager.2473d8f3.css",
"build/adminlte-field-filemanager.js": "/build/adminlte-field-filemanager.cf4425cd.js",
"build/adminlte-field-filemanager.js": "/build/adminlte-field-filemanager.be92c053.js",
"build/adminlte-field-collection.css": "/build/adminlte-field-collection.0e96676f.css",
"build/adminlte-field-collection.js": "/build/adminlte-field-collection.bf51b4fd.js",
"build/adminlte-main.css": "/build/adminlte-main.1c300872.css",
"build/adminlte-main.js": "/build/adminlte-main.a68c6b41.js",
"build/adminlte-field-collection.js": "/build/adminlte-field-collection.7e6cc250.js",
"build/adminlte-main.css": "/build/adminlte-main.56708bb5.css",
"build/adminlte-main.js": "/build/adminlte-main.a8e37b78.js",
"build/sov-reminder.css": "/build/sov-reminder.3a67c840.css",
"build/sov-reminder.js": "/build/sov-reminder.5e053a2b.js",
"build/sov-ticket.js": "/build/sov-ticket.ed87120e.js",
"build/sov-reminder.js": "/build/sov-reminder.8302acd0.js",
"build/sov-ticket.js": "/build/sov-ticket.3527403c.js",
"build/app-backend.css": "/build/app-backend.90192bf1.css",
"build/app-backend.js": "/build/app-backend.bca91793.js",
"build/app-frontend.css": "/build/app-frontend.e5188731.css",
"build/app-frontend.css": "/build/app-frontend.91dae722.css",
"build/app-frontend.js": "/build/app-frontend.f8975c31.js",
"build/app-bulle.js": "/build/app-bulle.351444bd.js",
"build/runtime.js": "/build/runtime.3d27a626.js",
"build/runtime.js": "/build/runtime.13c4345a.js",
"build/pdfmake.js": "/build/pdfmake.594e5fcf.js",
"build/canvg.js": "/build/canvg.07f0c63e.js",
"build/xlsx.js": "/build/xlsx.05855660.js",
@@ -30,7 +30,7 @@
"build/vendors-node_modules_core-js_internals_add-to-unscopables_js-node_modules_core-js_modules_es_-cd53d9.25be4035.js": "/build/vendors-node_modules_core-js_internals_add-to-unscopables_js-node_modules_core-js_modules_es_-cd53d9.25be4035.js",
"build/vendors-node_modules_core-js_modules_es_string_split_js-node_modules_popper_js_dist_esm_popper_js.2bb90f63.js": "/build/vendors-node_modules_core-js_modules_es_string_split_js-node_modules_popper_js_dist_esm_popper_js.2bb90f63.js",
"build/vendors-node_modules_jquery-ui-sortable_jquery-ui_min_js.4192d4ce.js": "/build/vendors-node_modules_jquery-ui-sortable_jquery-ui_min_js.4192d4ce.js",
"build/vendors-node_modules_symfony_webpack-encore_lib_webpack_copy-files-loader_js_context_var_www_-d8ac68.95095c71.js": "/build/vendors-node_modules_symfony_webpack-encore_lib_webpack_copy-files-loader_js_context_var_www_-d8ac68.95095c71.js",
"build/vendors-node_modules_symfony_webpack-encore_lib_webpack_copy-files-loader_js_context_home_gui-f9c03a.7d817997.js": "/build/vendors-node_modules_symfony_webpack-encore_lib_webpack_copy-files-loader_js_context_home_gui-f9c03a.7d817997.js",
"build/vendors-node_modules_amcharts_amcharts4_charts_js-node_modules_amcharts_amcharts4_core_js-nod-680fc8.3921a227.js": "/build/vendors-node_modules_amcharts_amcharts4_charts_js-node_modules_amcharts_amcharts4_core_js-nod-680fc8.3921a227.js",
"build/vendors-node_modules_admin-lte_dist_js_adminlte_min_js-node_modules_bootstrap-autocomplete_di-0f2281.bb1c83c0.css": "/build/vendors-node_modules_admin-lte_dist_js_adminlte_min_js-node_modules_bootstrap-autocomplete_di-0f2281.bb1c83c0.css",
"build/vendors-node_modules_admin-lte_dist_js_adminlte_min_js-node_modules_bootstrap-autocomplete_di-0f2281.3c330cc7.js": "/build/vendors-node_modules_admin-lte_dist_js_adminlte_min_js-node_modules_bootstrap-autocomplete_di-0f2281.3c330cc7.js",
@@ -203,6 +203,7 @@
"build/ckeditor/plugins/bbcode/plugin.js": "/build/ckeditor/plugins/bbcode/plugin.js",
"build/ckeditor/skins/kama/dialog.css": "/build/ckeditor/skins/kama/dialog.css",
"build/ckeditor/plugins/balloonpanel/plugin.js": "/build/ckeditor/plugins/balloonpanel/plugin.js",
"build/images/stripped.png": "/build/images/stripped.74df2199.png",
"build/ckeditor/plugins/autocomplete/plugin.js": "/build/ckeditor/plugins/autocomplete/plugin.js",
"build/ckeditor/plugins/table/dialogs/table.js": "/build/ckeditor/plugins/table/dialogs/table.js",
"build/ckeditor/plugins/imagebase/plugin.js": "/build/ckeditor/plugins/imagebase/plugin.js",

+ 2
- 2
src/Controller/AbstractAdminController.php Voir le fichier

@@ -2,9 +2,9 @@

namespace App\Controller;

use Lc\SovBundle\Controller\AbstractAdminController as SovAbstractAdminController;
use Lc\PietroBundle\Controller\AbstractAdminController as PietroAbstractAdminController;

abstract class AbstractAdminController extends SovAbstractAdminController
abstract class AbstractAdminController extends PietroAbstractAdminController
{
use ControllerTrait;
}

+ 84
- 11
src/Controller/Admin/CollectifDataCrudController.php Voir le fichier

@@ -4,23 +4,17 @@ namespace App\Controller\Admin;

use App\Controller\AbstractAdminController;
use App\Entity\CollectifData\CollectifData;
use Lc\PietroBundle\Form\Dream\DreamType;
use Lc\PietroBundle\Form\ProjectBoost\ProjectBoostType;
use Lc\PietroBundle\Form\ProjectInspiring\ProjectInspiringType;
use Lc\PietroBundle\Form\Revolt\RevoltType;
use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\QueryBuilder;
use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection;
use EasyCorp\Bundle\EasyAdminBundle\Collection\FilterCollection;
use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto;
use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDto;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\HiddenField;
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\SovBundle\Field\CollectionField;
use Lc\SovBundle\Field\StatusField;
use Lc\SovBundle\Generator\CsvGenerator;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Symfony\Component\HttpFoundation\Request;

class CollectifDataCrudController extends AbstractAdminController
{
@@ -41,6 +35,19 @@ class CollectifDataCrudController extends AbstractAdminController
->getFields($pageName);
}

public function configureActions(Actions $actions): Actions
{
parent::configureActions($actions);

$export = Action::new('export', 'actions.export')
->setIcon('fa fa-download')
->linkToCrudAction('exportCsv')
->setCssClass('btn btn-sm btn-primary export-csv')
->createAsGlobalAction();

return $actions->add(Crud::PAGE_INDEX, $export);
}

public function getRepositoryQuery(): RepositoryQueryInterface
{
return $this->getCollectifDataContainer()->getRepositoryQuery();
@@ -68,4 +75,70 @@ class CollectifDataCrudController extends AbstractAdminController

parent::persistEntity($entityManager, $entityInstance);
}

public function exportCsv(Request $request)
{
$csv = new CsvGenerator();
$csv->enableConvertEncoding('ISO-8859-1');
$csv->setTitle('Export_Liste_Collectif', true);

$columns = [
'category' => 'Catégorie',
'thematic' => 'Thématique',
'subthematic' => 'Contribution',
'territory' => 'Lieu',
'nb_participant' => 'Participants',
'description' => 'Description'
];
$csv->setColumns($columns);

$resultArray = $this->generateAllResultArray();

$csv = $this->generateCsvData($csv, $resultArray);

return $csv->getReponse();
}

private function generateAllResultArray(): array
{
$dreamArray = $this->getDreamContainer()->getStore()->get();
$revoltArray = $this->getRevoltContainer()->getStore()->get();
$projectBoostArray = $this->getProjectBoostContainer()->getStore()->get();
$projectInspiringArray = $this->getProjectInspiringContainer()->getStore()->get();

return array_merge($dreamArray, $revoltArray, $projectBoostArray, $projectInspiringArray);
}

private function generateCsvData($csv, $resultArray)
{
foreach ($resultArray as $result) {
$territory = $subthematic = $thematic = "";

if ($result->getCollectifData()) {
$collectifData = $result->getCollectifData();
$territory = $collectifData->getTerritory()->getName();

if ($result->getSubthematic()) {
$subthematic = $result->getSubthematic()->getName();
}

if ($result->getThematic()) {
$thematic = $result->getThematic()->getName();
}

$data = [
'category' => $result->__toString(),
'thematic' => $thematic,
'subthematic' => $subthematic,
'territory' => $territory,
'nb_participant' => $collectifData->getNbParticipant(),
'description' => $result->getDescription()
];

$csv->row($data);
}
}

return $csv;
}
}

+ 3
- 3
yarn.lock Voir le fichier

@@ -1879,9 +1879,9 @@ caniuse-api@^3.0.0:
lodash.uniq "^4.5.0"

caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001271:
version "1.0.30001271"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001271.tgz#0dda0c9bcae2cf5407cd34cac304186616cc83e8"
integrity sha512-BBruZFWmt3HFdVPS8kceTBIguKxu4f99n5JNp06OlPD/luoAMIaIK5ieV5YjnBLH3Nysai9sxj9rpJj4ZisXOA==
version "1.0.30001299"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001299.tgz"
integrity sha512-iujN4+x7QzqA2NCSrS5VUy+4gLmRd4xv6vbBBsmfVqTx8bLAD8097euLqQgKxSVLvxjSDcvF1T/i9ocgnUFexw==

center-align@^0.1.1:
version "0.1.3"

Chargement…
Annuler
Enregistrer