Skip to content

Commit

Permalink
Merge branch '3.x' into uuid-support
Browse files Browse the repository at this point in the history
  • Loading branch information
yamaha252 authored Aug 7, 2023
2 parents 4139ba5 + 88ec426 commit 7a2b426
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 33 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
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/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
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|string $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|string $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 7a2b426

Please sign in to comment.