From d5c20b928fa963b3f6669776b860ae1774a708f5 Mon Sep 17 00:00:00 2001 From: Jeremy Postlethwaite Date: Mon, 4 Mar 2024 17:49:20 -0800 Subject: [PATCH] GH-11 --- .github/workflows/ci.yml | 6 +- composer.json | 7 +- ...-row-actions-delete-relationship.blade.php | 12 ++ .../table/data-row-actions-delete.blade.php | 10 ++ .../table/data-row-actions-edit.blade.php | 19 +++ .../table/data-row-actions-unlock.blade.php | 10 ++ .../table/data-row-actions.blade.php | 59 +------ .../views/components/table/data.blade.php | 7 + .../resource/detail-information.blade.php | 156 ++++++++++-------- .../views/layouts/resource/detail.blade.php | 8 + .../resource/form-information.blade.php | 45 +++-- .../layouts/resource/form-status.blade.php | 21 ++- .../views/layouts/resource/form.blade.php | 20 ++- .../views/layouts/resource/index.blade.php | 3 +- src/View/Components/Table/Data.php | 1 + 15 files changed, 221 insertions(+), 163 deletions(-) create mode 100644 resources/views/components/table/data-row-actions-delete-relationship.blade.php create mode 100644 resources/views/components/table/data-row-actions-delete.blade.php create mode 100644 resources/views/components/table/data-row-actions-edit.blade.php create mode 100644 resources/views/components/table/data-row-actions-unlock.blade.php diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e3f616b..15f6b93 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,7 +30,7 @@ jobs: echo "TIMESTAMP_START=$(date +'%s')" >> $GITHUB_OUTPUT - name: "Slack notification: IN PROGRESS" id: slack - uses: slackapi/slack-github-action@v1.24.0 + uses: slackapi/slack-github-action@v1.25.0 with: channel-id: 'C068A06PV43' payload: | @@ -133,7 +133,7 @@ jobs: echo "DATE_END=$(date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_OUTPUT echo "DURATION_PHRASE=$(($(date +'%s')-$TIMESTAMP_START)) seconds" >> $GITHUB_OUTPUT - name: "Slack notification: Done" - uses: slackapi/slack-github-action@v1.24.0 + uses: slackapi/slack-github-action@v1.25.0 with: channel-id: 'C068A06PV43' update-ts: ${{ steps.slack.outputs.ts }} @@ -194,7 +194,7 @@ jobs: SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} - name: "Send a notification for failures" if: ${{ failure() }} - uses: slackapi/slack-github-action@v1.24.0 + uses: slackapi/slack-github-action@v1.25.0 with: channel-id: 'C068A06PV43' update-ts: ${{ steps.slack.outputs.ts }} diff --git a/composer.json b/composer.json index ee8cfa8..ab83743 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,6 @@ "gammamatrix", "laravel", "playground", - "playground", "playground-blade" ], "homepage": "https://github.com/gammamatrix/playground-blade/wiki", @@ -20,11 +19,11 @@ ], "require": { "php": "^8.1", - "gammamatrix/playground": "dev-develop|dev-master|^73.0" + "gammamatrix/playground": "dev-develop|dev-master|dev-feature/*|^73.0" }, "require-dev": { - "gammamatrix/playground-auth": "dev-develop|dev-master|^73.0", - "gammamatrix/playground-test": "dev-develop|dev-master|^73.0", + "gammamatrix/playground-auth": "dev-develop|dev-master|dev-feature/*|^73.0", + "gammamatrix/playground-test": "dev-develop|dev-master|dev-feature/*|^73.0", "tomasvotruba/bladestan": "^0.4.1" }, "minimum-stability": "dev", diff --git a/resources/views/components/table/data-row-actions-delete-relationship.blade.php b/resources/views/components/table/data-row-actions-delete-relationship.blade.php new file mode 100644 index 0000000..42d0b70 --- /dev/null +++ b/resources/views/components/table/data-row-actions-delete-relationship.blade.php @@ -0,0 +1,12 @@ +
+ @method('DELETE') + @csrf + + + + +
diff --git a/resources/views/components/table/data-row-actions-delete.blade.php b/resources/views/components/table/data-row-actions-delete.blade.php new file mode 100644 index 0000000..c684301 --- /dev/null +++ b/resources/views/components/table/data-row-actions-delete.blade.php @@ -0,0 +1,10 @@ +
+ @method('DELETE') + @csrf + + +
diff --git a/resources/views/components/table/data-row-actions-edit.blade.php b/resources/views/components/table/data-row-actions-edit.blade.php new file mode 100644 index 0000000..5401561 --- /dev/null +++ b/resources/views/components/table/data-row-actions-edit.blade.php @@ -0,0 +1,19 @@ +@if (!empty($record['deleted_at']) && $routeRestore) +
+ @method('PUT') + @csrf + + +
+@elseif ($withEdit && $routeEdit) + + + Edit + +@endif diff --git a/resources/views/components/table/data-row-actions-unlock.blade.php b/resources/views/components/table/data-row-actions-unlock.blade.php new file mode 100644 index 0000000..b20a43a --- /dev/null +++ b/resources/views/components/table/data-row-actions-unlock.blade.php @@ -0,0 +1,10 @@ +
+ @method('DELETE') + @csrf + + +
diff --git a/resources/views/components/table/data-row-actions.blade.php b/resources/views/components/table/data-row-actions.blade.php index c62a898..ee3c4ff 100644 --- a/resources/views/components/table/data-row-actions.blade.php +++ b/resources/views/components/table/data-row-actions.blade.php @@ -1,57 +1,12 @@
- - @php - if (!empty($record['deleted_at'])) { - $withDelete = false; - } - @endphp - - @if ($withDelete && $routeDeleteRelationship && $routeDelete) -
- @method('DELETE') - @csrf - - - - -
- @elseif ($withDelete && $routeDelete) -
- @method('DELETE') - @csrf - - -
+ @if ($withUnlock && !empty($record['locked']) && $routeUnlock) + @include('playground::components/table/data-row-actions-unlock') + @else + @if ($withDelete && $routeDelete && empty($record['deleted_at'])) + @include('playground::components/table/data-row-actions-delete') + @endif + @include('playground::components/table/data-row-actions-edit') @endif - - @if (!empty($record['deleted_at']) && $routeRestore) -
- @method('PUT') - @csrf - - -
- @elseif ($withEdit && $routeEdit) - - - Edit - - @endif -
diff --git a/resources/views/components/table/data.blade.php b/resources/views/components/table/data.blade.php index 3bf95e1..01ceb69 100644 --- a/resources/views/components/table/data.blade.php +++ b/resources/views/components/table/data.blade.php @@ -33,6 +33,13 @@ 'roles' => ['admin', 'manager'], ])->allowed(); +$withUnlock = \Playground\Auth\Facades\Can::access($user, [ + 'allow' => false, + 'any' => true, + 'privilege' => $withPrivilege . ':unlock', + 'roles' => ['admin', 'manager'], +])->allowed(); + /** * @var array> $columns The columns in the table, keyed by slug. */ diff --git a/resources/views/layouts/resource/detail-information.blade.php b/resources/views/layouts/resource/detail-information.blade.php index 0ed935f..bf55649 100644 --- a/resources/views/layouts/resource/detail-information.blade.php +++ b/resources/views/layouts/resource/detail-information.blade.php @@ -20,87 +20,111 @@ {{ __('Edit') }} + @endif +

{{ $data->getAttributeValue($meta['info']['model_attribute']) }}

+ @if ($withImage && $data && $data->image) +
+ {{ $meta['info']['model_label'] }} Image +
@endif -

{{ $data->label }}

- -@if ($withImage && $data && $data->image) -
- {{ $meta['info']['model_label'] }} Image -
-@endif -
+
-

{{ __('Information') }}

+

{{ __('Information') }}

- - - - - - - @if ($parent) +
{{ __('Slug') }}{{ $data->slug }}
+ - + + + + @if ($parent) + + + + + @endif + + - @endif - - - - - - - - - - - - - @yield('detail-information-table') - -
{{ __('Parent ' . $meta['info']['model_label']) }}{{ __('Slug') }}{{ $data->slug }}
{{ __('Parent ' . $meta['info']['model_label']) }} + + {{ $parent->label }} + +
{{ __('Created') }} - - {{ $parent->label }} - + @if ($data->created_at) + + @endif
{{ __('Created') }} - @if ($data->created_at) - - @endif -
{{ __('Updated') }} - @if ($data->updated_at) - - @endif -
{{ __('Active') }} - @if ($data->active) - - @endif -
+ + {{ __('Updated') }} + + @if ($data->updated_at) + + @endif + + + @yield('detail-information-table') + + - @if ($data->description) -

{{ __('Description') }}

+ @if ($data->description) +

{{ __('Description') }}

-
{{ $data->description }}
- @endif +
{{ $data->description }}
+ @endif - @if ($data->introduction) -

{{ __('Introduction') }}

+ @if ($data->introduction) +

{{ __('Introduction') }}

-
{{ $data->introduction }}
- @endif +
{{ $data->introduction }}
+ @endif - @if ($data->content) -

{{ __('Content') }}

+ @if ($data->content) +

{{ __('Content') }}

-
{!! $data->content !!}
- @endif +
{!! $data->content !!}
+ @endif - @if ($data->summary) -

{{ __('Summary') }}

+ @if ($data->summary) +

{{ __('Summary') }}

-
{!! $data->summary !!}
- @endif +
{!! $data->summary !!}
+ @endif -
+
+ + + + + diff --git a/resources/views/layouts/resource/detail.blade.php b/resources/views/layouts/resource/detail.blade.php index c7c8389..0d9bb5d 100644 --- a/resources/views/layouts/resource/detail.blade.php +++ b/resources/views/layouts/resource/detail.blade.php @@ -28,6 +28,7 @@ $withPrivilege = !empty($meta['info']) && !empty($meta['info']['privilege']) && is_string($meta['info']['privilege']) ? $meta['info']['privilege'] : 'playground'; +$routeUnlock = !$data ? '' : route(sprintf('%1$s.unlock', $meta['info']['model_route']), [$meta['info']['model_slug'] => $data->getAttributeValue('id')]); $routeDelete = !$data ? '' : route(sprintf('%1$s.destroy', $meta['info']['model_route']), [$meta['info']['model_slug'] => $data->getAttributeValue('id')]); $routeEdit = !$data ? '' : route(sprintf('%1$s.edit', $meta['info']['model_route']), [$meta['info']['model_slug'] => $data->getAttributeValue('id')]); @@ -54,6 +55,13 @@ 'roles' => ['admin', 'manager'], ])->allowed(); +$withUnlock = \Playground\Auth\Facades\Can::access($user, [ + 'allow' => false, + 'any' => true, + 'privilege' => $withPrivilege . ':unlock', + 'roles' => ['admin', 'manager'], +])->allowed(); + /** * @var boolean|string $withInfo */ diff --git a/resources/views/layouts/resource/form-information.blade.php b/resources/views/layouts/resource/form-information.blade.php index 62788a4..cc6d83d 100644 --- a/resources/views/layouts/resource/form-information.blade.php +++ b/resources/views/layouts/resource/form-information.blade.php @@ -3,37 +3,30 @@ {{ __('Information') }} @if ($withFormLabel) - @formInput([ - 'label' => 'Label', - 'column' => 'label', - 'autocomplete' => false, - 'rules' => [ - 'required' => true, - 'maxlength' => 255, - ], - ]) + + + @endif + + @if ($withFormTitle) + + @endif @if ($withFormSlug) - @formInput([ - 'label' => 'SLUG', - 'column' => 'slug', - 'autocomplete' => false, - 'rules' => [ - 'required' => 'patch' === $_method, - 'maxlength' => 255, - ], - ]) + @endif - @if ($withFormParent) - @formSelect([ - 'label' => sprintf('%1$s Parent', $meta['info']['module_label']), - 'column' => 'parent_id', - 'default' => true, - 'key' => $meta['info']['model_attribute'], - 'records' => $parents, - ]) + @if ($withFormParent && !empty($parents)) + @endif @yield('fieldset-information') diff --git a/resources/views/layouts/resource/form-status.blade.php b/resources/views/layouts/resource/form-status.blade.php index 189d43d..3b9ec3f 100644 --- a/resources/views/layouts/resource/form-status.blade.php +++ b/resources/views/layouts/resource/form-status.blade.php @@ -9,24 +9,33 @@
- + {{ $data->active ? 'checked' : '' }}> +
- + {{ $data->locked ? 'checked' : '' }}> +
- + {{ $data->flagged ? 'checked' : '' }}> +
diff --git a/resources/views/layouts/resource/form.blade.php b/resources/views/layouts/resource/form.blade.php index 58db4c1..0e5fcae 100644 --- a/resources/views/layouts/resource/form.blade.php +++ b/resources/views/layouts/resource/form.blade.php @@ -29,6 +29,21 @@ */ $withFormLabel = isset($withFormLabel) && is_bool($withFormLabel) ? $withFormLabel : true; +/** + * @var boolean $withFormLabelRequired + */ +$withFormLabelRequired = $withFormLabel && !empty($withFormLabelRequired); + +/** + * @var boolean $withFormTitle + */ +$withFormTitle = isset($withFormTitle) && is_bool($withFormTitle) ? $withFormTitle : true; + +/** + * @var boolean $withFormTitleRequired + */ +$withFormTitleRequired = $withFormTitle && !empty($withFormTitleRequired); + /** * @var boolean $withFormSlug */ @@ -39,11 +54,6 @@ */ $withFormParent = isset($withFormParent) && is_bool($withFormParent) ? $withFormParent : true; -/** - * @var boolean $withFormSpec - */ -$withFormSpec = isset($withFormSpec) && is_bool($withFormSpec) ? $withFormSpec : true; - /** * @var boolean|string $withFormButtons */ diff --git a/resources/views/layouts/resource/index.blade.php b/resources/views/layouts/resource/index.blade.php index 21a9ac0..2d65b54 100644 --- a/resources/views/layouts/resource/index.blade.php +++ b/resources/views/layouts/resource/index.blade.php @@ -101,6 +101,7 @@ 'routeEdit' => sprintf('%1$s.edit', $meta['info']['model_route']), 'routeDelete' => sprintf('%1$s.destroy', $meta['info']['model_route']), 'routeRestore' => sprintf('%1$s.restore', $meta['info']['model_route']), + 'routeUnlock' => sprintf('%1$s.unlock', $meta['info']['model_route']), 'paginator' => $paginator ?? null, 'privilege' => $withPrivilege, 'styling' => [ @@ -152,7 +153,7 @@ + :route-unlock="$tableComponent['routeUnlock']" :styling="$tableComponent['styling']"> {{ $meta['info']['model_label_plural'] }} diff --git a/src/View/Components/Table/Data.php b/src/View/Components/Table/Data.php index fead2bd..3a5649f 100644 --- a/src/View/Components/Table/Data.php +++ b/src/View/Components/Table/Data.php @@ -27,6 +27,7 @@ public function __construct( public string $routeParameterKey = 'id', public string $routeEdit = '', public string $routeRestore = '', + public string $routeUnlock = '', public string $routeDelete = '', public string $routeDeleteRelationship = '', public string $routeDeleteRelationshipId = '',