Skip to content

Commit abcc88f

Browse files
authored
Merge pull request #125 from NotFoundNL/develop
Version 0.11.3
2 parents 207cb39 + 0d51ed5 commit abcc88f

File tree

11 files changed

+83
-10
lines changed

11 files changed

+83
-10
lines changed

routes/cms/editor.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
Route::prefix('{tableItem}')->group(function () {
2929
Route::get('', [CmsEditorTableItemController::class, 'readOne']);
3030
Route::post('', [CmsEditorTableItemController::class, 'update']);
31+
Route::post('enabled', [CmsEditorTableItemController::class, 'enabled']);
3132
});
3233
});
3334
});
@@ -48,6 +49,7 @@
4849
Route::prefix('{tableItem}')->group(function () {
4950
Route::get('', [CmsEditorTemplateItemController::class, 'readOne']);
5051
Route::post('', [CmsEditorTemplateItemController::class, 'update']);
52+
Route::post('enabled', [CmsEditorTemplateItemController::class, 'enabled']);
5153
});
5254
});
5355
});

src/Http/Controllers/Assets/TableEditorController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use NotFound\Layout\Elements\LayoutWidget;
2323
use NotFound\Layout\LayoutResponse;
2424
use NotFound\Layout\Responses\Redirect;
25+
use NotFound\Layout\Responses\Reload;
2526
use NotFound\Layout\Responses\Toast;
2627

2728
/**
@@ -138,7 +139,7 @@ public function update(FormDataRequest $request, Table $table, int $recordId, st
138139
if ($newTableRecord) {
139140
$response->addAction(new Redirect('/table/'.$table->url.'/'.$id.'/'));
140141
} else {
141-
// TODO: Refresh page
142+
$response->addAction(new Reload());
142143
}
143144
} else {
144145
// Redirect

src/Http/Controllers/CmsEditor/CmsEditorTableController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,10 @@ public function readOne(Table $table)
177177
$row->addColumn(new LayoutTableColumn($cmsTable->enabled ? $this->checkColumn($tableName, $cmsTable) : '-', 'text'));
178178

179179
$row->addColumn(new LayoutTableColumn($cmsTable->internal, 'text'));
180-
$row->addColumn(new LayoutTableColumn($cmsTable->enabled, 'checkbox'));
180+
181+
$checkbox = new LayoutTableColumn($cmsTable->enabled, 'checkbox');
182+
$checkbox->setToggleEndPoint('/app/editor/table/'.$table->id.'/'.$cmsTable->id.'/enabled');
183+
$row->addColumn($checkbox);
181184
$UItable->addRow($row);
182185
}
183186
$widget2->addTable($UItable);

src/Http/Controllers/CmsEditor/CmsEditorTableItemController.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,25 @@ public function update(FormDataRequest $request, Table $table, TableItem $tableI
9696

9797
return $response->build();
9898
}
99+
100+
/**
101+
* enabled
102+
*
103+
* @param mixed $table
104+
* @param mixed $tableItem
105+
* @return void
106+
*/
107+
public function enabled(Table $table, TableItem $tableItem)
108+
{
109+
$tableItem->enabled = ! $tableItem->enabled;
110+
try {
111+
$tableItem->save();
112+
113+
$response = ['value' => $tableItem->enabled, 'message' => 'Item updated'];
114+
} catch (\Exception $e) {
115+
$response = ['error' => $e];
116+
}
117+
118+
return $response;
119+
}
99120
}

src/Http/Controllers/CmsEditor/CmsEditorTemplateController.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,11 @@ public function readOne(Template $table)
159159
$row->addColumn(new LayoutTableColumn($cmsTable->name, 'text'));
160160
$row->addColumn(new LayoutTableColumn($cmsTable->type, 'text'));
161161
$row->addColumn(new LayoutTableColumn($cmsTable->internal, 'internal'));
162-
// $row->addColumn(new LayoutTableColumn($cmsTable->enabled, 'checkbox'));
162+
163+
$checkbox = new LayoutTableColumn($cmsTable->enabled, 'checkbox');
164+
$checkbox->setToggleEndPoint('/app/editor/page/'.$table->id.'/'.$cmsTable->id.'/enabled');
165+
$row->addColumn($checkbox);
166+
163167
$UItable->addRow($row);
164168
}
165169
$widget2->addTable($UItable);

src/Http/Controllers/CmsEditor/CmsEditorTemplateItemController.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,25 @@ public function update(FormDataRequest $request, Template $table, TemplateItem $
104104

105105
return $response->build();
106106
}
107+
108+
/**
109+
* enabled
110+
*
111+
* @param mixed $table
112+
* @param mixed $tableItem
113+
* @return void
114+
*/
115+
public function enabled(Template $table, TemplateItem $tableItem)
116+
{
117+
$tableItem->enabled = ! $tableItem->enabled;
118+
try {
119+
$tableItem->save();
120+
121+
$response = ['value' => $tableItem->enabled, 'message' => 'Item updated'];
122+
} catch (\Exception $e) {
123+
$response = ['error' => $e];
124+
}
125+
126+
return $response;
127+
}
107128
}

src/Services/Assets/Components/ComponentDatePicker.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ public function getTableOverviewContent(): LayoutTableColumn
6969

7070
public function setValueFromStorage(string $value): bool
7171
{
72+
if (isset($this->properties()->datetimeFormat)) {
73+
$this->currentValue = $value;
74+
75+
return true;
76+
}
77+
7278
$timeValue = intval($value);
7379
if ($timeValue == 0) {
7480
$this->currentValue = '';
@@ -85,6 +91,10 @@ public function setValueFromStorage(string $value): bool
8591
*/
8692
public function getValueForStorage(): ?string
8793
{
94+
if (isset($this->properties()->datetimeFormat)) {
95+
return $this->newValue;
96+
}
97+
8898
if ($this->newValue == null) {
8999
return '0';
90100
}

src/Services/Editor/Fields/DatePicker.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public function properties(): void
1818
$this->localize();
1919
$this->required();
2020
$this->addCheckbox('allowEmpty', 'Allow empty', true);
21+
$this->addCheckbox('datetimeFormat', 'Use datetime format', true);
2122
$this->addText('placeholderText', 'Placeholder text');
2223
}
2324

@@ -37,8 +38,12 @@ public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string
3738
if ($type === null) {
3839
return 'COLUMN MISSING';
3940
}
40-
if (! in_array($type->getName(), ['int'])) {
41-
return 'TYPE ERROR: '.$type->getName().' is not a valid type for a text field';
41+
if ($type->getName() === 'int') {
42+
return 'TYPE WARNING: '.$type->getName().' should be converted to datetime';
43+
}
44+
45+
if ($type->getName() !== 'datetime') {
46+
return 'TYPE ERROR: '.$type->getName().' is not a valid type for a date field';
4247
}
4348

4449
return '';

src/Services/Editor/Fields/DateTimePicker.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ public function checkColumnType(?\Doctrine\DBAL\Types\Type $type): string
2727
if ($type === null) {
2828
return 'COLUMN MISSING';
2929
}
30-
if (! in_array($type->getName(), ['int'])) {
31-
return 'TYPE ERROR: '.$type->getName().' is not a valid type for a text field';
30+
if (! in_array($type->getName(), ['datetime'])) {
31+
return 'TYPE ERROR: '.$type->getName().' is not a valid type for a date field';
3232
}
3333

3434
return '';

src/Services/Indexer/IndexBuilderService.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,12 @@ private function updateSubitems($class, $lang)
212212
{
213213
app()->setLocale($lang->url);
214214
$subPages = $class->searchSubitems();
215+
216+
// We need to check if the subPages is an array of arrays
217+
// If not we wrap it in an extra array
218+
if (count($subPages) > 0 && ! is_array($subPages[0])) {
219+
$subPages = [$subPages];
220+
}
215221
foreach ($subPages as $subPage) {
216222

217223
foreach ($subPage as $searchItem) {

0 commit comments

Comments
 (0)