Skip to content

Commit 859f006

Browse files
authored
Merge branch '3.x' into support-nested-blocks-validation
2 parents 1a48b0d + 5ad2237 commit 859f006

File tree

69 files changed

+854
-244
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+854
-244
lines changed

Diff for: .github/workflows/main.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ jobs:
108108
id: composer-cache
109109
run: |
110110
echo "::set-output name=dir::$(composer config cache-files-dir)"
111-
- uses: actions/cache@v2
111+
- uses: actions/cache@v4
112112
with:
113113
path: ${{ steps.composer-cache.outputs.dir }}
114114
key: ${{ matrix.os }}-${{ matrix.laravel }}-${{ matrix.php }}-${{ matrix.dbal }}-composer-${{ hashFiles('**/composer.lock') }}
@@ -129,10 +129,6 @@ jobs:
129129
run: |
130130
npm ci
131131
132-
- name: Create blocks dir
133-
run: |
134-
mkdir ./frontend/js/components/blocks/customs
135-
136132
- name: Build twill.
137133
run: ./vendor/bin/testbench twill:build --forTesting
138134
env:

Diff for: .github/workflows/release.yml

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version_bump_type:
7+
description: 'Type of version bump (patch, minor, major)'
8+
required: true
9+
default: 'patch'
10+
11+
jobs:
12+
build-and-pr:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v3
18+
with:
19+
ref: 3.x
20+
21+
- name: Setup Node.js
22+
uses: actions/setup-node@v3
23+
with:
24+
node-version: '20'
25+
cache: 'npm'
26+
27+
- name: Install dependencies
28+
run: npm ci
29+
30+
- name: Build project
31+
run: npm run build
32+
33+
- name: Copy build artifacts
34+
run: |
35+
mkdir -p twill-assets/assets
36+
rm -rf twill-assets/assets/*
37+
cp -r dist/assets/* twill-assets/assets/
38+
39+
- name: Bump version
40+
id: bump_version
41+
run: |
42+
npm version ${{ github.event.inputs.version_bump_type }} --no-git-tag-version
43+
echo "::set-output name=new_version::$(node -p "require('./package.json').version")"
44+
45+
- name: Update version in PHP file
46+
run: |
47+
NEW_VERSION="${{ steps.bump_version.outputs.new_version }}"
48+
sed -i "s/\(public const VERSION = '\)[^']*\(';\)/\1${NEW_VERSION}\2/" src/TwillServiceProvider.php
49+
50+
- name: Create Pull Request
51+
uses: peter-evans/create-pull-request@v5
52+
with:
53+
token: ${{ secrets.GITHUB_TOKEN }}
54+
commit-message: |
55+
Update assets and bump version to ${{ steps.bump_version.outputs.new_version }}
56+
title: |
57+
Twill ${{ steps.bump_version.outputs.new_version }} release
58+
body: |
59+
This PR updates the build and bumps the version number to ${{ steps.bump_version.outputs.new_version }}.
60+
branch: release-${{ steps.bump_version.outputs.new_version }}
61+
base: 3.x

Diff for: CHANGELOG.md

+65
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,65 @@
22

33
All notable changes to `twill` will be documented in this file.
44

5+
## 3.5.2
6+
7+
### Fixed
8+
9+
- Fix cropper regression (likely a from a recent browser update) by [@13twelve](https://github.com/13twelve) in [#2744](https://github.com/area17/twill/pull/2744)
10+
11+
12+
## 3.5.1
13+
14+
### Fixed
15+
16+
- Fix file library uploader regression by [@joyceverheije](https://github.com/joyceverheije) in https://github.com/area17/twill/pull/2740
17+
- Fix `timeOnly` variant of the `Datepicker` field by [@MamlukiSn](https://github.com/MamlukiSn) in https://github.com/area17/twill/pull/2739
18+
19+
### Improved
20+
21+
- Add a warning during the `twill:update` and `twill:build` commands for developers that have `twill.load_default_migrations` set to false by [@ifox](https://github.com/ifox) in [de274175](https://github.com/area17/twill/commit/de274175)
22+
23+
## 3.5.0
24+
25+
### Added
26+
27+
- Add a `ModuleController::setPreviewView()` method by @zachgarwood in https://github.com/area17/twill/pull/2724
28+
- Add a `disableCrop()` method to `medias` fields by @ifox in https://github.com/area17/twill/pull/2686
29+
30+
### Fixed
31+
32+
- Fix position management in `medias` and `files` fields by @zeezo887 in https://github.com/area17/twill/pull/2694
33+
- Fix issues with touch actions by @13twelve in https://github.com/area17/twill/pull/2713
34+
- Fix issue with `Relation` column by @zachgarwood in https://github.com/area17/twill/pull/2720
35+
- Fix endpoints initialization for `Browser` component by @zeezo887 in https://github.com/area17/twill/pull/2722
36+
- Fix image cropper for erroneous EXIF orientation: Use JS to read image dimensions on upload by @13twelve in https://github.com/area17/twill/pull/2705
37+
- Fix square crops having mismatching width/height values by @13twelve in https://github.com/area17/twill/pull/2706
38+
- Fix `hideActiveCrop()` not working for medias form field when max is greater than 1 by @zeezo887 in https://github.com/area17/twill/pull/2686
39+
- Fix #2641: `InlineRepeater` updates by @13twelve in https://github.com/area17/twill/pull/2714
40+
- Fix Vue dropdown console warnings: update useCapture param for removeEventListener to match addEventListener by @zeezo887 in https://github.com/area17/twill/pull/2687
41+
- Fix #2657: adds missing Vue draggable deprecations by @13twelve in https://github.com/area17/twill/pull/2707
42+
43+
### Docs
44+
45+
- Added instructions to disable publish switch in create modal by @ordigital in https://github.com/area17/twill/pull/2698
46+
- Added instructions for `MultiSelect` field with dynamic values in form builder by @ordigital in https://github.com/area17/twill/pull/2699
47+
- Added instructions for free cropping with `null` or `0` ratio value by @LucaRed in https://github.com/area17/twill/pull/2715
48+
49+
### Translations
50+
51+
- Fix #2619: adds missing iso languages by @13twelve in https://github.com/area17/twill/pull/2708
52+
53+
## 3.4.1
54+
55+
### Improved
56+
57+
- Allow media and file library disk configuration using an environement variable by [@antonioribeiro](https://github.com/antonioribeiro) in https://github.com/area17/twill/pull/2676
58+
59+
### Fixed
60+
61+
- Fix #2671: 3.4.0 regression on related browsers previews by [@Tofandel](https://github.com/Tofandel) in https://github.com/area17/twill/pull/2672
62+
- Fix #2674: 3.4.0 regression on relation column using a one-to-one relationship by [@Tofandel](https://github.com/Tofandel) in https://github.com/area17/twill/pull/2675
63+
564
## 3.4.0
665

766
### Added
@@ -55,6 +114,12 @@ All notable changes to `twill` will be documented in this file.
55114
- Bump body-parser and express by [@dependabot](https://github.com/dependabot) in https://github.com/area17/twill/pull/2659
56115
- Bump cookie and express by [@dependabot](https://github.com/dependabot) in https://github.com/area17/twill/pull/2664
57116

117+
## 3.3.2
118+
119+
### Fixed
120+
121+
- Backport fix from 3.5.1: `timeOnly` variant of the `Datepicker` field by [@MamlukiSn](https://github.com/MamlukiSn) in https://github.com/area17/twill/pull/2739
122+
58123
## 3.3.1
59124

60125
### Fixed

Diff for: composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@
4848
"area17/phptorch": "dev-main",
4949
"chillerlan/php-qrcode": "~4.0",
5050
"friendsofphp/php-cs-fixer": "^3.0",
51+
"larastan/larastan": "^2.9",
5152
"nette/php-generator": "^4.0.3",
5253
"nunomaduro/collision": "^6.0 || ^7.0 || ^8.0",
53-
"nunomaduro/larastan": "^2.0",
5454
"orchestra/testbench": "^7.8 || ^8.0 || ^9.0",
5555
"orchestra/testbench-dusk": "^7.8 || ^8.0 || ^9.0",
5656
"phpunit/php-invoker": "^3.1 || ^4.0",

Diff for: config/file_library.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
| - 'A17\Twill\Services\FileLibrary\Disk'
1919
|
2020
*/
21-
'disk' => 'twill_file_library',
21+
'disk' => env('FILE_LIBRARY_DISK', 'twill_file_library'),
2222
'endpoint_type' => env('FILE_LIBRARY_ENDPOINT_TYPE', 'local'),
2323
'cascade_delete' => env('FILE_LIBRARY_CASCADE_DELETE', false),
2424
'local_path' => env('FILE_LIBRARY_LOCAL_PATH', 'uploads'),

Diff for: config/media_library.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
| - 'A17\Twill\Services\MediaLibrary\Local'
2121
|
2222
*/
23-
'disk' => 'twill_media_library',
23+
'disk' => env('MEDIA_LIBRARY_DISK', 'twill_media_library'),
2424
'endpoint_type' => env('MEDIA_LIBRARY_ENDPOINT_TYPE', 'local'),
2525
'cascade_delete' => env('MEDIA_LIBRARY_CASCADE_DELETE', false),
2626
'local_path' => env('MEDIA_LIBRARY_LOCAL_PATH', 'uploads'),

Diff for: docs/content/1_docs/4_form-fields/06_multi-select.md

+22-2
Original file line numberDiff line numberDiff line change
@@ -200,21 +200,38 @@ public function sectors() {
200200
- In your repository, make sure to sync the association when saving:
201201

202202
```php
203-
public function afterSave($object, $fields)
203+
public function afterSave($object, $fields): void
204204
{
205205
$object->sectors()->sync($fields['sectors'] ?? []);
206206

207207
parent::afterSave($object, $fields);
208208
}
209209
```
210210

211+
:::tabs=currenttab.FormBuilder&items.FormBuilder|FormView:::
212+
:::tab=name.FormBuilder:::
213+
214+
```php
215+
$form->add(
216+
MultiSelect::make()
217+
->name('sectors')
218+
->options(
219+
Options::fromArray(app()->make(SectorsRepository::class)->listAll()->toArray())
220+
)
221+
);
222+
```
223+
224+
:::#tab:::
225+
226+
:::tab=name.FormView:::
227+
211228
- In your controller, add to the formData the collection of options:
212229

213230
```php
214231
protected function formData($request)
215232
{
216233
return [
217-
'sectors' => app()->make(SectorRepository::class)->listAll()
234+
'sectors' => app()->make(SectorRepository::class)->listAll()->toArray()
218235
];
219236
}
220237
```
@@ -229,6 +246,9 @@ protected function formData($request)
229246
/>
230247
```
231248

249+
:::#tab:::
250+
:::#tabs:::
251+
232252
When used in a [block](../5_block-editor), no migration is needed.
233253

234254
## Multi Select Inline

Diff for: docs/content/1_docs/4_form-fields/11_repeater.md

+11
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,17 @@ class ProjectController extends BaseModuleController
163163
}
164164
```
165165

166+
| Option | Description | Type | Default value |
167+
|:---------------|:---------------------------------------------|:--------|:-----------------|
168+
| type | Type of repeater items | string | |
169+
| name | Name of the field | string | same as `type` |
170+
| max | Maximum amount that can be created | number | null (unlimited) |
171+
| buttonAsLink | Displays the `Add` button as a centered link | boolean | false |
172+
| disableCreate | Disables ability to add new items | boolean | false |
173+
| disableActions | Removes row item actions | boolean | false |
174+
| disableReorder | Disables reordering of repeater items | boolean | false |
175+
176+
166177
## Blade repeater fields
167178

168179
The following example demonstrates how to define a relationship between `Team` and `TeamMember` modules to implement

Diff for: docs/content/1_docs/5_block-editor/02_creating-a-block-editor.md

+2
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,8 @@ See also [Default Configuration](./11_default-configuration.md).
393393

394394
If the `resource_path('assets/admin/icons')` directory contains a `my-custom-icon.svg` file, you can use this icon in your block by using its basename: `@twillBlockIcon('my-custom-icon')`.
395395

396+
In order to make the icons appear in the CMS, you'll need to run `php artisan twill:build`
397+
396398
## Use Block traits in your Model and Repository
397399

398400
Now, to handle the block data you must integrate it with your module. *Use* the *Blocks* traits in the Model and Repository associated with your module.

Diff for: docs/content/1_docs/7_media-library/03_role-crop-params.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ A _role_ is a way to define different contexts in which an image might be placed
66

77
_Crops_ are more self-explanatory. Twill comes with some pre-defined crop settings to allow you to set different variants of a given image, so crops can be used in combination with _roles,_ or they can be used on their own with a single role to define multiple cropping ratios on the same image.
88

9-
Using the Person example, your `cover` image could have a `square` crop for mobile screens, but could use a `16/9` crop on larger screens. Those values are editable at your convenience for each model, even if there are already some crops created in the CMS.
9+
Using the Person example, your `cover` image could have a `square` crop for mobile screens, but could use a `16/9` crop on larger screens. Those values are editable at your convenience for each model in the `ratio` option, even if there are already some crops created in the CMS. By specifying `null` or `0` as a `ratio`, no automatic crop will happen and you'll be able to crop freely.
1010

1111
The only thing you have to do to make it work is to compose your model and repository with the appropriate traits, respectively `HasMedias` and `HandleMedias`, set up your `$mediasParams` configuration and use the `medias` form partial in your form view (more info in the CRUD section).
1212

Diff for: docs/content/2_guides/3_adding-fields-to-the-create-modal.md

+86-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Often you might want to add some mandatory fields to the create modal of your mo
1616
In our module controller we can override the `getCreateForm` method and add the fields to render:
1717

1818
:::filename:::
19-
`app/Http/Controllers/Twill/YourModuleController.php`
19+
`app/Http/Controllers/Twill/BlogController.php`
2020
:::#filename:::
2121

2222
```phptorch
@@ -168,3 +168,88 @@ Result:
168168

169169
:::#tab:::
170170
:::#tabs:::
171+
172+
# Removing publish switch from create modal
173+
174+
In our module controller we can override the `indexData` to remove publish switch from modal. We can also override `setUpController` method to disable language select box used for making a translation active.
175+
176+
:::filename:::
177+
`app/Http/Controllers/Twill/BlogController.php`
178+
:::#filename:::
179+
180+
```phptorch
181+
##CODE##
182+
<?php
183+
184+
namespace App\Http\Controllers\Twill;
185+
186+
use A17\Twill\Http\Controllers\Admin\NestedModuleController as BaseModuleController;
187+
use A17\Twill\Services\Forms\Fields\Input;
188+
use A17\Twill\Services\Forms\Fields\Wysiwyg;
189+
use A17\Twill\Services\Forms\Form;
190+
191+
class BlogController extends BaseModuleController
192+
{
193+
protected $moduleName = 'blogs';
194+
195+
public function getCreateForm(): Form
196+
{
197+
...
198+
}
199+
200+
protected function setUpController(): void
201+
{
202+
$this->disablePublish();
203+
$this->disableBulkPublish();
204+
// $this->disableEditor(); # uncomment this to disable full editor
205+
// $this->enableEditInModal(); # uncomment this to enable editing in modal
206+
207+
}
208+
209+
protected function formData($request)
210+
{
211+
return [ 'controlLanguagesPublication' => false ]; # disable select box to make language active
212+
}
213+
}
214+
```
215+
216+
If we also want to make all languages active by default, we can override `prepareFieldsBeforeCreate` function in our module repository:
217+
218+
:::filename:::
219+
`app/Repositories/BlogRepository.php`
220+
:::#filename:::
221+
222+
```phptorch
223+
##CODE##
224+
<?php
225+
226+
namespace App\Repositories;
227+
228+
use A17\Twill\Repositories\Behaviors\HandleTranslations;
229+
use A17\Twill\Repositories\Behaviors\HandleSlugs;
230+
use A17\Twill\Repositories\ModuleRepository;
231+
use App\Models\Category;
232+
233+
class BlogRepository extends ModuleRepository
234+
{
235+
use HandleTranslations, HandleSlugs;
236+
237+
public function __construct(Category $model)
238+
{
239+
$this->model = $model;
240+
}
241+
242+
### make all languages active for this model
243+
public function prepareFieldsBeforeCreate($fields): array
244+
{
245+
foreach ($fields['languages'] as $key => $language) {
246+
$fields['languages'][$key]['published'] = true;
247+
}
248+
249+
return parent::prepareFieldsBeforeCreate($fields); // @phpstan-ignore-line
250+
}
251+
252+
}
253+
```
254+
255+
![Customized create modal without publish switch](./assets/customized-without-publish-switch.png)

Diff for: docs/content/2_guides/4_creating_custom_components_form_fields_and_blocks.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ npm install vue-numeric --save
409409
### Blade view
410410

411411
:::filename:::
412-
`resources/views/admin/partials/form/_custom_number.blade.php`
412+
`resources/views/twill/partials/form/_custom_number.blade.php`
413413
:::#filename:::
414414

415415
```blade
Loading

Diff for: frontend/js/components/Cropper.vue

+2-3
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,12 @@
189189
//
190190
// from my testing it seems to be a little inconsistent and unpredictable
191191
// I guess you just need for the rounding error to happen
192-
// But, it seems setting the properties individually avoids this...
192+
// But, it seems re-setting the properties individually avoids this...
193193
//
194194
// -- Mike ([email protected])
195+
this.cropper.setData(crop)
195196
this.cropper.setData({ x: crop.x })
196197
this.cropper.setData({ y: crop.y })
197-
this.cropper.setData({ width: crop.width })
198-
this.cropper.setData({ height: crop.height })
199198
},
200199
test: function () {
201200
const crop = this.toNaturalCrop({ x: 0, y: 0, width: 380, height: 475 })

0 commit comments

Comments
 (0)