Skip to content

Commit

Permalink
👍 Make theme setting UI
Browse files Browse the repository at this point in the history
  • Loading branch information
juzaweb committed Aug 12, 2023
1 parent bfaabed commit f7a98e4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
18 changes: 16 additions & 2 deletions modules/DevTool/Http/Controllers/Themes/SettingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Inertia\Response;
use Juzaweb\CMS\Contracts\LocalThemeRepositoryContract;
use Juzaweb\CMS\Interfaces\Theme\ThemeInterface;
use Juzaweb\CMS\Models\ThemeConfig;
use Juzaweb\DevTool\Http\Controllers\Controller;

class SettingController extends Controller
Expand Down Expand Up @@ -63,14 +64,27 @@ function ($item) {

protected function getSettingFields(ThemeInterface $theme): array
{
return collect($theme->getRegister('configs'))
$collection = collect($theme->getRegister('configs'))
->map(
function ($item, $key) {
if (!is_numeric($key)) {
$item['name'] = $key;
}

return $item;
}
);

$settings = ThemeConfig::where('theme', $theme->getName())
->whereIn('code', $collection->pluck('name')->toArray())
->get()
->keyBy('code');

return $collection
->map(
function ($item) use ($settings) {
// Cannot be edit name filed added
$item['nameReadonly'] = true;
$item['nameReadonly'] = $settings->has($item['name']);
return $item;
}
)
Expand Down
6 changes: 5 additions & 1 deletion themes/default-inertia/register.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@
"test_config_2": {
"label": "Test Config 2",
"type": "textarea"
},
"cxvxcv": {
"label": "Cxvxcv",
"type": "text"
}
},
"taxonomies": {
Expand All @@ -84,4 +88,4 @@
"menu_position": "20"
}
}
}
}

0 comments on commit f7a98e4

Please sign in to comment.