$actions = [
//'Backup current database' => 'backup',
'Migrate magic models' => 'migrate',
- 'Import documents' => 'importDocuments',
+ //'Import documents' => 'importDocuments',
'Import publications' => 'importPublications',
'Clean caches' => 'cleanCache'
];
$date = new \DateTime();
$date->setTimestamp($data);
$data = $date;
+ } else if ($k === 'chapters') {
+ $data = $this->_normalizeChapters($data);
}
if (isset($mapValues[$data])) {
$data = $mapValues[$data];
}
}
+ public function _normalizeChapters($value)
+ {
+ if (!$value) {
+ return $value;
+ }
+ if (is_string($value)) {
+ $v = json_decode($value, true);
+ } else {
+ $v = $value;
+ }
+ if (!$v) {
+ return $value;
+ }
+ $res = [];
+ foreach ($v as $k => $chapter) {
+ $chapter['decoration'] = 'regular';
+ $chapter['label'] = trim($chapter['label']);
+ if ($chapter['label'] === '----') {
+ $chapter['label'] = '';
+ $chapter['decoration'] = 'separator';
+ } else if ($chapter['label'] === '--') {
+ $chapter['label'] = '';
+ $chapter['decoration'] = 'forcecut';
+ } else if ($chapter['label'] === '++') {
+ $chapter['label'] = '';
+ $chapter['decoration'] = 'nocut';
+ } else if (str_starts_with($chapter['label'], '!!!')) {
+ $chapter['label'] = substr($chapter['label'], 3);
+ $chapter['decoration'] = 'column_head';
+ }
+ $res[$k] = $chapter;
+ }
+
+ return $res;
+ }
}
return array_merge(parent::getDefaultAttributes(), ["add_label" => __('Nouveau chapitre')]);
}
- public function filterValue($value)
- {
- if (!$value) {
- return $value;
- }
- if (is_string($value)) {
- $v = json_decode($value, true);
- } else {
- $v = $value;
- }
- if (!$v) {
- return $value;
- }
- $res = [];
- foreach ($v as $k => $chapter) {
- $chapter['decoration'] = 'regular';
- $chapter['label'] = trim($chapter['label']);
- if ($chapter['label'] === '----') {
- $chapter['label'] = '';
- $chapter['decoration'] = 'separator';
- } else if ($chapter['label'] === '--') {
- $chapter['label'] = '';
- $chapter['decoration'] = 'forcecut';
- } else if ($chapter['label'] === '++') {
- $chapter['label'] = '';
- $chapter['decoration'] = 'nocut';
- } else if (str_starts_with($chapter['label'], '!!!')) {
- $chapter['label'] = substr($chapter['label'], 3);
- $chapter['decoration'] = 'column_head';
- }
- $res[$k] = $chapter;
- }
-
- return parent::filterValue(json_encode($res));
- }
}
@endif
@php
- $additionalButtons='<a href="#" class="btn btn-sm btn-secondary chaptersImportExcel"><i class="la la-file-excel"></i> '.__('Remplacer par le contenu d\'un fichier excel').'</a>';
- $additionalButtons.='<a href="#" class="btn btn-sm btn-success chaptersExportExcel"><i class="la la-file-excel"></i> '.__('Exporter au format excel').'</a>';
+ $additionalButtons='<a href="#" class="btn btn-sm btn-secondary chaptersImportExcel"><i class="la la-file-excel"></i> '.__('Remplacer par le contenu d\'un fichier excel').'</a>';
+ $additionalButtons.='<a href="#" class="btn btn-sm btn-success chaptersExportExcel"><i class="la la-file-excel"></i> '.__('Exporter au format excel').'</a>';
@endphp
@include('cubist_back::fields.bunch_oneline_multiple')
@php