Skip to content

Commit

Permalink
Merge branch '3.x' into patch-2
Browse files Browse the repository at this point in the history
  • Loading branch information
ifox authored Aug 10, 2023
2 parents 76145d4 + 7be10cc commit 4953850
Show file tree
Hide file tree
Showing 15 changed files with 36 additions and 37 deletions.
8 changes: 4 additions & 4 deletions docs/content/1_docs/13_custom-cms-pages/1_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,25 @@ return [
- Add a controller to handle the request

```php
// file: app/Http/Controllers/Admin/CustomPageController.php
// file: app/Http/Controllers/Twill/CustomPageController.php

namespace App\Http\Controllers\Admin;
namespace App\Http\Controllers\Twill;

use A17\Twill\Http\Controllers\Admin\Controller;

class CustomPageController extends Controller
{
public function show()
{
return view('admin.customPage');
return view('twill.customPage');
}
}
```

- And create the view

```php
// file: resources/views/admin/customPage.blade.php
// file: resources/views/twill/customPage.blade.php

@extends('twill::layouts.free')

Expand Down
4 changes: 2 additions & 2 deletions docs/content/1_docs/3_modules/12_nested-modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,17 @@ use A17\Twill\Services\Breadcrumbs\NestedBreadcrumbs;

class IssueArticleController extends BaseModuleController
{
protected $moduleName = 'issues.articles';
protected $modelName = 'IssueArticle';

protected function setUpController(): void
{
$this->setModuleName('issues.articles');
if (request('issue')) {
$this->setBreadcrumbs(
NestedBreadcrumbs::make()
->forParent(
parentModule: 'issues',
module: $this->modelName,
module: $this->moduleName,
activeParentId: request('issue'),
repository: \App\Repositories\IssueRepository::class
)
Expand Down
4 changes: 2 additions & 2 deletions docs/content/1_docs/3_modules/6_table-builder.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ unpublished.

##### NestedData

`NestedData::make()`
`NestedData::make()->...`

This field requires no additional methods, it shows information about the nested models.
Renders the `field` using the relationship of the same name. It shows information and a link about the nested model.

##### Languages

Expand Down
8 changes: 5 additions & 3 deletions frontend/js/components/Previewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,15 @@
components: {
'a17-iframe': A17PreviewerFrame
},
props: ['breakpointsConfig'],
data: function () {
return {
loadedCurrent: false,
slipScreen: false,
activeBreakpoint: 1280,
lastActiveBreakpoint: 1280,
scrollPosition: 0,
breakpoints: [
breakpoints: this.breakpointsConfig || [
{
size: 1280,
name: 'preview-desktop'
Expand Down Expand Up @@ -115,11 +116,12 @@
methods: {
open: function (previewId = 0) {
const self = this
const desktopWidth = this.breakpoints.find(item => item.name === 'preview-desktop').size
// reset previewer state
this.loadedCurrent = false
this.activeBreakpoint = 1280
this.lastActiveBreakpoint = 1280
this.activeBreakpoint = desktopWidth || 1280
this.lastActiveBreakpoint = desktopWidth || 1280
function initPreview () {
if (self.$refs.overlay) self.$refs.overlay.open()
Expand Down
2 changes: 1 addition & 1 deletion frontend/js/components/blocks/Blocks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
:opened="opened"
:with-handle="!isSettings"
:with-actions="!isSettings"
:with-move-dropdown="isSettings"
:with-move-dropdown="!isSettings"
@expand="setOpened"
v-if="availableBlocks.length">
<template v-for="availableBlock in availableBlocks">
Expand Down
2 changes: 1 addition & 1 deletion migrations/default/2023_03_24_125122_add_id_to_related.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function up(): void

public function down(): void
{
Schema::table('related', function (Blueprint $table) {
Schema::table(config('twill.related_table', 'twill_related'), function (Blueprint $table) {
$table->dropColumn('id');
});
}
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Http/Controllers/Admin/ModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ protected function getIndexTableColumns(): TableColumns
if ($this->getIndexOption('includeScheduledInList') && $this->repository->isFillable('publish_start_date')) {
$columns->add(
ScheduledStatus::make()
->title(twillTrans('twill::lang.listing.columns.published'))
->title(twillTrans('twill::lang.publisher.scheduled'))
->optional()
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function input(string $name): mixed
return $this->content[$name] ?? null;
}

public function translatedInput(string $name, bool $forceLocale = null): mixed
public function translatedInput(string $name, string $forceLocale = null): mixed
{
$value = $this->content[$name] ?? null;

Expand Down
2 changes: 1 addition & 1 deletion src/Repositories/Behaviors/HandleFieldsGroups.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ protected function handleFieldsGroups($fields)
$fields[$group] = null;
}

Arr::forget($fields, $groupFields);
$fields = array_filter($fields, fn($key) => !in_array($key, $groupFields), ARRAY_FILTER_USE_KEY);
}

return $fields;
Expand Down
1 change: 1 addition & 0 deletions src/Repositories/Behaviors/HandleMedias.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ public function afterDuplicateHandleMedias(TwillModelContract $original, TwillMo
'crop_x' => $media->pivot->crop_x,
'crop_y' => $media->pivot->crop_y,
'metadatas' => $media->pivot->metadatas,
'locale' => $media->pivot->locale,
];

$newObject->medias()->attach($media->id, $newPushData);
Expand Down
11 changes: 7 additions & 4 deletions src/Services/Breadcrumbs/NestedBreadcrumbs.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class NestedBreadcrumbs extends Breadcrumbs
private int $activeParentId;
private string $titleKey;
private string $label;
private string $routePrefix = '';

public function parentLabel(string $parentLabel): self
{
Expand All @@ -26,13 +27,15 @@ public function forParent(
string $module,
int $activeParentId,
string $repository,
?string $titleKey = 'title'
?string $titleKey = 'title',
?string $routePrefix = '',
): self {
$this->module = $module;
$this->parentModule = $parentModule;
$this->parentRepository = $repository;
$this->activeParentId = $activeParentId;
$this->titleKey = $titleKey;
$this->routePrefix = $routePrefix;

if (!$this->parentLabel) {
$this->parentLabel(Str::title($parentModule));
Expand Down Expand Up @@ -61,16 +64,16 @@ public function toArray(): array
BreadcrumbItem::make()->label($this->parentLabel)
->displayOnForm()
->displayOnListing()
->url(moduleRoute($this->parentModule, '', 'index')),
->url(moduleRoute($this->parentModule, $this->routePrefix, 'index')),
BreadcrumbItem::make()->label($this->getActiveParentTitle())
->displayOnForm()
->displayOnListing()
->url(moduleRoute($this->parentModule, '', 'edit', $this->activeParentId)),
->url(moduleRoute($this->parentModule, $this->routePrefix, 'edit', $this->activeParentId)),
BreadcrumbItem::make()->label($this->label)
->displayOnListing(),
BreadcrumbItem::make()->label($this->label)
->displayOnForm()
->url(moduleRoute($this->module, '', 'index')),
->url(moduleRoute($this->module, $this->routePrefix, 'index')),
BreadcrumbItem::make()->label('Edit')
->displayOnForm(),
];
Expand Down
7 changes: 0 additions & 7 deletions src/Services/Listings/Columns/NestedData.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@

class NestedData extends TableColumn
{
public static function make(): static
{
$item = parent::make();
$item->field('children');
return $item;
}

public function sortable(bool $sortable = true): static
{
if ($sortable && $this->sortFunction === null) {
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/Controllers/Tables/NestedDataColumnTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@ public function setUp(): void

public function testColumn(): void
{
$column = NestedData::make()->title('Child');
$column = NestedData::make()->field('children')->title('Child');

$this->assertEquals('0 children', $column->renderCell($this->parent));
}

public function testSingleChild(): void {
$this->parent->children()->create(['title' => 'Child 1', 'published' => true]);

$column = NestedData::make()->title('Child');
$column = NestedData::make()->field('children')->title('Child');
$this->assertEquals('1 child', $column->renderCell($this->parent));
}

public function testMultipleChilden(): void {
$this->parent->children()->create(['title' => 'Child 1', 'published' => true]);
$this->parent->children()->create(['title' => 'Child 1', 'published' => true]);

$column = NestedData::make()->title('Child');
$column = NestedData::make()->field('children')->title('Child');
$this->assertEquals('2 children', $column->renderCell($this->parent));
}
}
2 changes: 1 addition & 1 deletion views/layouts/form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
</a17-modal>
<a17-editor v-if="editor" ref="editor"
bg-color="{{ config('twill.block_editor.background_color') ?? '#FFFFFF' }}"></a17-editor>
<a17-previewer ref="preview"></a17-previewer>
<a17-previewer ref="preview" :breakpoints-config="{{ json_encode(config('twill.preview.breakpoints')) }}"></a17-previewer>
<a17-dialog ref="warningContentEditor" modal-title="{{ twillTrans('twill::lang.form.dialogs.delete.title') }}"
confirm-label="{{ twillTrans('twill::lang.form.dialogs.delete.confirm') }}">
<p class="modal--tiny-title">
Expand Down

0 comments on commit 4953850

Please sign in to comment.