Skip to content

Commit d71e4a8

Browse files
committed
Testing
1 parent 7229269 commit d71e4a8

24 files changed

+675
-225
lines changed

resources/config/ui.php

Lines changed: 57 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,28 @@
22

33
return [
44

5+
'admin' => [
6+
'prefix' => 'admin',
7+
'enabled' => env('ADMIN_ENABLED', true),
8+
'default' => \Streams\Ui\Components\Admin\AdminDashboard::class,
9+
'navigation' => [
10+
[
11+
'text' => 'Dashboard',
12+
'url' => '/admin',
13+
'sort_order' => 0,
14+
'component' => 'anchor',
15+
],
16+
],
17+
'buttons' => [],
18+
'menu' => [],
19+
//'actions' => [],
20+
],
21+
22+
/**
23+
* Registered components.
24+
*
25+
* @livewire($name, $class)
26+
*/
527
'components' => [
628
'form' => \Streams\Ui\Components\Form::class,
729
'field' => \Streams\Ui\Components\Field::class,
@@ -15,7 +37,7 @@
1537

1638
'anchor' => \Streams\Ui\Components\Anchor::class,
1739
'button' => \Streams\Ui\Components\Button::class,
18-
40+
1941
'image' => \Streams\Ui\Components\Image::class,
2042

2143
// Inputs
@@ -24,7 +46,7 @@
2446
'datetime-input' => \Streams\Ui\Components\Inputs\DatetimeInput::class,
2547

2648
'slug' => \Streams\Ui\Components\Inputs\SlugInput::class,
27-
49+
2850
'editor' => \Streams\Ui\Components\Inputs\EditorInput::class,
2951
'object' => \Streams\Ui\Components\Inputs\EditorInput::class,
3052
'markdown' => \Streams\Ui\Components\Inputs\MarkdownInput::class,
@@ -47,6 +69,8 @@
4769
'input' => \Streams\Ui\Components\Inputs\TextInput::class,
4870
'email' => \Streams\Ui\Components\Inputs\EmailInput::class,
4971

72+
'tags' => \Streams\Ui\Components\Inputs\TagsInput::class,
73+
5074
'file' => \Streams\Ui\Components\Inputs\FileInput::class,
5175

5276
'checkbox' => \Streams\Ui\Components\Inputs\CheckboxInput::class,
@@ -57,8 +81,6 @@
5781
// Admin Components
5882
'admin' => \Streams\Ui\Components\Admin\AdminDashboard::class,
5983
'admin.menu' => \Streams\Ui\Components\Admin\AdminMenu::class,
60-
'admin.form' => \Streams\Ui\Components\Admin\AdminForm::class,
61-
'admin.table' => \Streams\Ui\Components\Admin\AdminTable::class,
6284
'admin.navigation' => \Streams\Ui\Components\Admin\AdminNavigation::class,
6385

6486

@@ -68,84 +90,40 @@
6890
'hash' => \Streams\Ui\Components\Inputs\TextInput::class,
6991
'uuid' => \Streams\Ui\Components\Inputs\TextInput::class,
7092
'string' => \Streams\Ui\Components\Inputs\TextInput::class,
71-
93+
7294
'array' => \Streams\Ui\Components\Inputs\TagsInput::class,
73-
95+
7496
'boolean' => \Streams\Ui\Components\Inputs\CheckboxInput::class,
7597
],
7698

77-
'field_types' => [
78-
79-
// Strings
80-
// 'string' => [
81-
// 'input' => 'text',
82-
// ],
83-
// 'url' => [
84-
// 'input' => 'text',
85-
// 'type' => 'url',
86-
// ],
87-
// 'uuid' => [
88-
// 'input' => 'text',
89-
// ],
90-
// 'hash' => [
91-
// 'input' => 'text',
92-
// ],
93-
// 'email' => [
94-
// 'input' => 'text',
95-
// 'type' => 'email',
96-
// ],
97-
// 'encrypted' => [
98-
// 'input' => 'text',
99-
// 'type' => 'password',
100-
// ],
101-
102-
// // Boolean
103-
// 'boolean' => [
104-
// // radio + options|checkbox
105-
// ],
106-
107-
// // Arrays
108-
// 'array' => [
109-
// // tags|items
110-
// ],
111-
112-
// // Selections
113-
// 'enum' => [
114-
// 'type' => 'select',
115-
// ],
116-
117-
// 'image' => [
118-
// // file + accepts
119-
// ],
99+
'buttons' => [
100+
101+
'create' => [
102+
'text' => 'ui::buttons.create',
103+
'attributes' => [
104+
'data-keymap' => 'n',
105+
],
106+
],
107+
'edit' => [
108+
'text' => 'ui::buttons.edit',
109+
'attributes' => [
110+
'data-keymap' => 'n',
111+
],
112+
],
113+
'save' => [
114+
'text' => 'ui::buttons.save',
115+
'attributes' => [
116+
'data-keymap' => 'command+s',
117+
]
118+
],
119+
'cancel' => [
120+
'text' => 'ui::buttons.cancel',
121+
'attributes' => [
122+
'data-keymap' => 'cmd+esc',
123+
],
124+
],
125+
'delete' => [
126+
'text' => 'ui::buttons.delete',
127+
],
120128
],
121-
122-
// GET RID OF THIS
123-
/**
124-
* Specify whether the CP is enabled or not.
125-
*/
126-
'cp_enabled' => env('STREAMS_CP_ENABLED', false),
127-
128-
/**
129-
* This is the URI prefix
130-
* for the control panel.
131-
*/
132-
'cp_prefix' => env('STREAMS_CP_PREFIX', 'cp'),
133-
134-
/**
135-
* The active theme.
136-
*/
137-
'cp_theme' => env('STREAMS_CP_THEME', 'default'),
138-
139-
/*
140-
* Specify the CP fallback policy.
141-
*
142-
* This policy will be ran if no stream, route,
143-
* or component policy is otherwise specified.
144-
*/
145-
'cp_policy' => env('STREAMS_CP_POLICY'),
146-
147-
/*
148-
* Specify the CP group middleware.
149-
*/
150-
'cp_middleware' => ['web', 'cp'],
151129
];

resources/lang/en/buttons.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
<?php
22

33
return [
4-
'all' => 'All',
54
'edit' => 'Edit',
65
'save' => 'Save',
7-
'view' => 'View',
8-
'trash' => 'Trash',
96
'cancel' => 'Cancel',
107
'create' => 'Create',
11-
'update' => 'Update',
12-
'restore' => 'Restore',
138
];

resources/public/css/tailwind.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,9 @@ video {
537537
.overflow-hidden {
538538
overflow: hidden;
539539
}
540+
.overflow-y-auto {
541+
overflow-y: auto;
542+
}
540543
.rounded {
541544
border-radius: 0.25rem;
542545
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<div>
2+
@if (Request::segment(4))
3+
@livewire('form', [
4+
'stream' => Request::segment(2),
5+
'entry' => Request::segment(4),
6+
])
7+
@elseif (Request::segment(3))
8+
@livewire('form', [
9+
'stream' => Request::segment(2),
10+
])
11+
@elseif (Request::segment(2))
12+
@livewire('table', [
13+
'stream' => Request::segment(2),
14+
])
15+
@else
16+
Unknown
17+
@endif
18+
</div>

resources/views/components/admin/form.blade.php

Lines changed: 0 additions & 5 deletions
This file was deleted.

resources/views/components/admin/table.blade.php

Lines changed: 0 additions & 3 deletions
This file was deleted.

resources/views/layouts/admin.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
</aside>
3131

32-
<main class="w-full">
32+
<main class="w-full overflow-y-auto">
3333

3434
{{-- Topbar --}}
3535
<div class="bg-gray-200 w-full p-4 flex justify-between items-center">

src/Components/Admin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66

77
class Admin extends Component
88
{
9-
protected string $layout = 'ui::layouts.admin';
9+
public ?string $layout = 'ui::layouts.admin';
1010
}

src/Components/Admin/AdminAction.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Streams\Ui\Components\Admin;
4+
5+
use Streams\Ui\Components\Admin;
6+
7+
class AdminAction extends Admin
8+
{
9+
public string $template = 'ui::components.admin.action';
10+
}

src/Components/Admin/AdminForm.php

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/Components/Admin/AdminNavigation.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@
44

55
use Illuminate\Support\Arr;
66
use Streams\Ui\Components\Navigation;
7+
use Illuminate\Support\Facades\Config;
78
use Streams\Core\Support\Facades\Streams;
89

910
class AdminNavigation extends Navigation
1011
{
1112
public function booted()
1213
{
14+
$this->items = Config::get('streams.ui.admin.navigation', []);
15+
1316
$streams = Streams::collection()->where('ui.admin.navigation', '!=', null);
1417

1518
foreach ($streams as $stream) {

src/Components/Admin/AdminTable.php

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/Components/Field.php

Lines changed: 13 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,77 +2,36 @@
22

33
namespace Streams\Ui\Components;
44

5-
use Illuminate\Support\Str;
6-
use Livewire\Livewire;
75
use Streams\Ui\Support\Component;
86
use Streams\Core\Field\Field as StreamsField;
97
use Streams\Ui\Components\Traits\HasAttributes;
10-
use Streams\Ui\Support\Facades\UI;
8+
use Streams\Ui\Components\Workflows\FieldBuilder;
119

1210
class Field extends Component
1311
{
1412
use HasAttributes;
1513

14+
public $workflow = FieldBuilder::class;
15+
1616
public string $template = 'ui::components.field';
1717

1818
public ?string $field = null;
19-
20-
public ?string $name = null;
21-
public ?string $description = null;
22-
23-
public array $input = [];
24-
25-
public $label = null;
26-
27-
public ?string $instructions = null;
19+
20+
public string|bool|null $label = null;
21+
public string|bool|null $instructions = null;
22+
public string|bool|null $description = null;
2823

2924
public bool $required = false;
3025

26+
public array $input = [];
27+
3128
public array $attributes = [];
3229

33-
public function booted()
34-
{
35-
if ($this->stream && $this->field) {
36-
37-
$field = $this->stream()->fields->{$this->field};
38-
39-
$this->label = $field->name;
40-
$this->name = $field->handle;
41-
$this->description = $field->description;
42-
$this->instructions = $field->instructions;
43-
$this->required = $field->isRequired();
44-
45-
//$this->input = array_merge($this->input, (array) $field->input);
46-
47-
$this->input['stream'] = $this->stream;
48-
$this->input['field'] = $this->field;
49-
50-
if (!isset($this->input['type'])) {
51-
// @todo map this
52-
$this->input['type'] = $field->type;
53-
}
54-
55-
if ($this->input['type'] == 'datetime') {
56-
$this->input['type'] = 'datetime-input';
57-
}
58-
59-
//$this->input['value'] = $field->default($field->config('default'));
60-
}
61-
62-
if (!$this->label && $this->label !== false) {
63-
$this->label = Str::title(Str::humanize($this->name));
64-
}
65-
66-
$this->input['name'] = $this->name;
67-
$this->input['required'] = $this->required;
68-
69-
if (!isset($this->input['type'])) {
70-
$this->input['type'] = 'input';
71-
}
72-
}
73-
7430
public function field(): StreamsField|null
7531
{
76-
return $this->once(__METHOD__ . '.' . $this->field, fn () => $this->stream()->fields->{$this->field});
32+
return $this->once(
33+
__METHOD__ . '.' . $this->stream . '.' . $this->field,
34+
fn () => $this->stream()?->fields->{$this->field}
35+
);
7736
}
7837
}

0 commit comments

Comments
 (0)