Skip to content

Commit

Permalink
Merge branch '7.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanmcclean committed Dec 9, 2024
2 parents f448e9e + 7822e57 commit 40efda4
Show file tree
Hide file tree
Showing 49 changed files with 403 additions and 155 deletions.
5 changes: 2 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
/.gitattributes export-ignore
/.gitignore export-ignore
/tests export-ignore
/banner.png export-ignore
/permissions.png export-ignore
/listing-buttons.png export-ignore
/logo-dark.svg export-ignore
/logo-default.svg export-ignore
13 changes: 8 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ jobs:

strategy:
matrix:
php: [8.3, 8.2]
php: [8.2, 8.3, 8.4]
laravel: [10.*, 11.*]
statamic: [^5.0]
stability: [prefer-lowest, prefer-stable]
os: [ubuntu-latest]
exclude:
- php: 8.4
laravel: 10.*

name: ${{ matrix.php }} - ${{ matrix.statamic }} - ${{ matrix.laravel }}
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }}

steps:
- name: Checkout code
Expand All @@ -31,8 +34,8 @@ jobs:

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "statamic/cms:${{ matrix.statamic }}" --no-interaction --no-update
composer install --no-interaction
composer require "illuminate/contracts:${{ matrix.laravel }}" --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-suggest
- name: Run PHPUnit
run: vendor/bin/phpunit
79 changes: 79 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,84 @@
# Changelog

## v7.13.2 (2024-12-09)

### What's fixed
* Only published models should be returned by augmentation #642 by @duncanmcclean
* Prevent Belongs To fields being saved as an array in entry data #640 #641 by @duncanmcclean



## v7.13.1 (2024-12-04)

### What's fixed
* Respect "Duplicate" toggle on fields #639 by @duncanmcclean
* Fixed error when running resource actions #638 by @duncanmcclean



## v7.13.0 (2024-11-29)

### What's new
* PHP 8.4 Support #633 by @duncanmcclean

### What's improved
* Docs: Updated settings title in fieldtypes table #636 by @Joel-Jensen



## v7.12.0 (2024-11-04)

### What's improved
* Updated the `.gitattributes` file by @duncanmcclean

### What's fixed
* Fixed an issue where Has Many relationships weren't being resolved #624 #630 by @duncanmcclean
* Fixed an error when augmenting model mutators #627 #629 by @TheBnl
* Added a check when getting a search value to see if the model has a method #625 #628 by @ryanmitchell
* Fixed deprecation error when checking if a value is a JSON string #626 by @indykoning
* Fixed the incorrect context for resource actions on the listing page by @duncanmcclean



## v7.11.0 (2024-10-11)

### What's new
* Runway URIs are now warmed as part of the `static:warm` command #623 by @duncanmcclean

### What's improved
* Prevented duplicate queries for table columns by @duncanmcclean
* Minor optimisations around the `isJson` function #619 by @indykoning
* Tidied up the `ServiceProvider` to take advantage of autoloading #622 by @duncanmcclean

### What's fixed
* Fixed an issue where the "Published" toggle was disabled for non-super users #621 by @duncanmcclean



## v7.10.1 (2024-09-27)

### What's fixed
* Fixed missing title on fieldtype dropdown options #615 #617 by @duncanmcclean
* Fixed error when linking related model with publish states #612 #616 by @duncanmcclean
* Bump minimum version of `statamic/cms` to 5.26.0, to hopefully fix an issue with actions by @duncanmcclean



## v7.10.0 (2024-09-25)

### What's improved
* Improve feedback when action fails #608 by @duncanmcclean



## v7.9.5 (2024-09-24)

### What's fixed
* Fixed augmentation on frontend routes #606 #610 by @duncanmcclean
* Fixed error when removing filters #607 #609 by @duncanmcclean



## v7.9.4 (2024-09-19)

### What's fixed
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@
"require": {
"php": "^8.2",
"ajthinking/archetype": "^1.0.3 || ^2.0",
"laravel/framework": "^10.25.0 || ^11.0",
"laravel/framework": "^10.25.0 || ^11.3",
"laravel/prompts": "^0.1.17",
"pixelfear/composer-dist-plugin": "^0.1.5",
"spatie/ignition": "^1.15",
"spatie/invade": "^2.1",
"statamic/cms": "^5.25.0"
"statamic/cms": "^5.41"
},
"require-dev": {
"laravel/pint": "^1.0",
"spatie/test-time": "^1.2",
"orchestra/testbench": "^8.0 || ^9.0",
"phpunit/phpunit": "^10.0"
"orchestra/testbench": "^8.28 || ^9.6.1",
"phpunit/phpunit": "^10.5.35"
},
"config": {
"optimize-autoloader": true,
Expand Down
4 changes: 2 additions & 2 deletions docs/blueprints.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ Asset Container| `string`/`json` |
[Button Group](https://statamic.dev/fieldtypes/button_group)| `string` |
[Checkboxes](https://statamic.dev/fieldtypes/checkboxes)| `json` |
[Code](https://statamic.dev/fieldtypes/code)| `string` |
[Collections](https://statamic.dev/fieldtypes/collections)| `string`/`json` |If 'Allow multiple' is `1`, column type should be `string`. Otherwise, `json` is what you want.
[Collections](https://statamic.dev/fieldtypes/collections)| `string`/`json` |If 'Max items' is `1`, column type should be `string`. Otherwise, `json` is what you want.
[Color](https://statamic.dev/fieldtypes/color)| `string` |
[Date](https://statamic.dev/fieldtypes/date)| `string`/`range` |Format is specified field configuration options. Ranges are should be stored as json.
[Entries](https://statamic.dev/fieldtypes/entries)| `string`/`json` |If 'Allow multiple' is `1`, column type should be `string`. Otherwise, `json` is what you want.
[Entries](https://statamic.dev/fieldtypes/entries)| `string`/`json` |If 'Max items' is `1`, column type should be `string`. Otherwise, `json` is what you want.
Float| `float` |
[Grid](https://statamic.dev/fieldtypes/grid)| `json` |
[Group](https://statamic.dev/fieldtypes/group)| `json` |
Expand Down
2 changes: 1 addition & 1 deletion docs/search.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Search
---

As of Runway v3.0, you may now search Runway models using [Statamic's search functionality](https://statamic.dev/search#overview). It's as simple as adjusting your config file.
Runway integrates with [Statamic's Search functionality](https://statamic.dev/search#overview), allowing you to search your Eloquent models in the Conteol Panel and via the `{{ search:results }}` tag. It's as simple as adjusting your config file.

## Configuration

Expand Down
Binary file removed permissions.png
Binary file not shown.
2 changes: 1 addition & 1 deletion resources/js/components/data-list/Filters.vue
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export default {
},
removeFieldFilter(handle) {
let fields = clone(this.activeFilters.fields);
let fields = clone(this.activeFilters['runway-fields']);
delete fields[handle];
Expand Down
2 changes: 1 addition & 1 deletion resources/views/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
create-another-url="{{ cp_route('runway.create', ['resource' => $resource->handle()]) }}"
initial-listing-url="{{ cp_route('runway.index', ['resource' => $resource->handle()]) }}"
:initial-item-actions="{{ json_encode($itemActions) }}"
item-action-url="{{ cp_route('runway.actions.run', ['resource' => $resource->handle()]) }}"
item-action-url="{{ cp_route('runway.models.actions.run', ['resource' => $resource->handle()]) }}"
:revisions-enabled="{{ $str::bool($revisionsEnabled) }}"
></runway-publish-form>

Expand Down
9 changes: 6 additions & 3 deletions routes/cp.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

use Illuminate\Support\Facades\Route;
use StatamicRadPack\Runway\Http\Controllers\CP\ModelActionController;
use StatamicRadPack\Runway\Http\Controllers\CP\ModelRevisionsController;
use StatamicRadPack\Runway\Http\Controllers\CP\PublishedModelsController;
use StatamicRadPack\Runway\Http\Controllers\CP\ResourceActionController;
Expand All @@ -10,10 +11,12 @@

Route::name('runway.')->prefix('runway')->group(function () {
Route::get('/{resource}', [ResourceController::class, 'index'])->name('index');

Route::get('{resource}/listing-api', [ResourceListingController::class, 'index'])->name('listing-api');
Route::post('{resource}/actions', [ResourceActionController::class, 'runAction'])->name('actions.run');
Route::post('{resource}/actions/list', [ResourceActionController::class, 'bulkActionsList'])->name('actions.bulk');

Route::post('{resource}/actions', [ResourceActionController::class, 'run'])->name('actions.run');

Route::post('{resource}/models/actions', [ModelActionController::class, 'runAction'])->name('models.actions.run');
Route::post('{resource}/models/actions/list', [ModelActionController::class, 'bulkActionsList'])->name('models.actions.bulk');

Route::get('{resource}/create', [ResourceController::class, 'create'])->name('create');
Route::post('{resource}/create', [ResourceController::class, 'store'])->name('store');
Expand Down
16 changes: 15 additions & 1 deletion src/Actions/DeleteModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,21 @@ public function bypassesDirtyWarning(): bool

public function run($items, $values)
{
$items->each->delete();
$failures = $items->reject(fn ($model) => $model->delete());
$total = $items->count();

if ($failures->isNotEmpty()) {
$success = $total - $failures->count();
if ($total === 1) {
throw new \Exception(__('Item could not be deleted'));
} elseif ($success === 0) {
throw new \Exception(__('Items could not be deleted'));
} else {
throw new \Exception(__(':success/:total items were deleted', ['total' => $total, 'success' => $success]));
}
}

return trans_choice('Item deleted|Items deleted', $total);
}

public function redirect($items, $values)
Expand Down
2 changes: 1 addition & 1 deletion src/Actions/DuplicateModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function run($items, $values)

private function duplicateModel(Model $original, Resource $resource): Model
{
$model = $original->replicate();
$model = $original->replicate($resource->blueprint()->fields()->all()->reject->shouldBeDuplicated()->keys()->all());

if ($resource->titleField()) {
$model->setAttribute($resource->titleField(), $original->getAttribute($resource->titleField()).' (Duplicate)');
Expand Down
16 changes: 15 additions & 1 deletion src/Actions/Publish.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ public function buttonText()

public function run($models, $values)
{
$models->each(fn ($model) => $model->published(true)->save());
$failures = $models->reject(fn ($model) => $model->published(true)->save());
$total = $models->count();

if ($failures->isNotEmpty()) {
$success = $total - $failures->count();
if ($total === 1) {
throw new \Exception(__('Model could not be published'));
} elseif ($success === 0) {
throw new \Exception(__('Model could not be published'));
} else {
throw new \Exception(__(':success/:total models were published', ['total' => $total, 'success' => $success]));
}
}

return trans_choice('Model published|Models published', $total);
}
}
16 changes: 15 additions & 1 deletion src/Actions/Unpublish.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ public function buttonText()

public function run($models, $values)
{
$models->each(fn ($model) => $model->published(false)->save());
$failures = $models->reject(fn ($model) => $model->published(false)->save());
$total = $models->count();

if ($failures->isNotEmpty()) {
$success = $total - $failures->count();
if ($total === 1) {
throw new \Exception(__('Model could not be unpublished'));
} elseif ($success === 0) {
throw new \Exception(__('Models could not be unpublished'));
} else {
throw new \Exception(__(':success/:total models were unpublished', ['total' => $total, 'success' => $success]));
}
}

return trans_choice('Model unpublished|Models unpublished', $total);
}
}
5 changes: 4 additions & 1 deletion src/Data/AugmentedModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Statamic\Fields\Field;
use Statamic\Fields\Value;
use Statamic\Statamic;
use Statamic\Support\Arr;
use StatamicRadPack\Runway\Runway;

class AugmentedModel extends AbstractAugmented
Expand Down Expand Up @@ -181,7 +182,9 @@ function () use ($handle) {
return $this->data->getAttribute($handle);
}

return ($attribute->get)();
$attributes = $this->data->getAttributes();

return ($attribute->get)(Arr::get($attributes, $handle), $attributes);
},
$handle,
$this->fieldtype($handle),
Expand Down
14 changes: 12 additions & 2 deletions src/Fieldtypes/BaseFieldtype.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
use Statamic\Search\Result;
use StatamicRadPack\Runway\Http\Resources\CP\FieldtypeModel;
use StatamicRadPack\Runway\Http\Resources\CP\FieldtypeModels;
use StatamicRadPack\Runway\Query\Scopes\Filters\Fields\Models;
use StatamicRadPack\Runway\Resource;
use StatamicRadPack\Runway\Runway;
use StatamicRadPack\Runway\Scopes\Fields\Models;

class BaseFieldtype extends Relationship
abstract class BaseFieldtype extends Relationship
{
protected $canEdit = true;
protected $canCreate = true;
Expand Down Expand Up @@ -133,6 +133,15 @@ private function getUnlinkBehavior(): string
return 'unlink';
}

public function process($data)
{
if ($this->config('max_items') === 1 && ! $this->field->parent() instanceof Model) {
return Arr::first($data);
}

return parent::process($data);
}

public function getIndexItems($request)
{
$resource = Runway::findResource($this->config('resource'));
Expand Down Expand Up @@ -277,6 +286,7 @@ protected function getAugmentableModels(Resource $resource, $values): Collection

return $model;
})
->when($resource->hasPublishStates(), fn ($collection) => $collection->filter(fn ($model) => $model->published()))
->filter();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Fieldtypes/HasManyFieldtype.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function preProcess($data)
public function preload()
{
return array_merge(parent::preload(), [
'actionUrl' => cp_route('runway.actions.run', [
'actionUrl' => cp_route('runway.models.actions.run', [
'resource' => $this->config('resource'),
]),
]);
Expand Down
Loading

0 comments on commit 40efda4

Please sign in to comment.