Skip to content

Commit

Permalink
Merge branch '3.x' into feat/conditional-field-in-form-builder
Browse files Browse the repository at this point in the history
  • Loading branch information
ifox authored Nov 19, 2023
2 parents 2b6bb61 + 0df914c commit 965e3b2
Show file tree
Hide file tree
Showing 36 changed files with 312 additions and 211 deletions.
2 changes: 2 additions & 0 deletions config/twill.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@
'tags_table' => 'twill_tags',
'users_oauth_table' => 'twill_users_oauth',
'users_table' => 'twill_users',
'permissions_table' => 'permissions',
'roles_table' => 'roles',

/*
|--------------------------------------------------------------------------
Expand Down
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
15 changes: 14 additions & 1 deletion docs/content/1_docs/4_form-fields/01_input.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Input::make()
type="textarea"
:rows="3"
:translated="true"
direction="ltr"
/>
```

Expand All @@ -62,7 +63,8 @@ Input::make()
'note' => 'Hint message goes here',
'placeholder' => 'Placeholder goes here',
'type' => 'textarea',
'rows' => 3
'rows' => 3,
'direction' => 'ltr'
])
```

Expand All @@ -85,6 +87,7 @@ Input::make()
| readonly | Sets the field as readonly | boolean | false |
| default | Sets a default value if empty | string | |
| mask | Set a mask using the alpinejs mask plugin | string | |
| direction | Set custom input direction <small>(from `v3.1.0`)</small> | ltr<br/>rtl<br>auto | auto |

Specific options for the "number" type:

Expand Down Expand Up @@ -122,3 +125,13 @@ Schema::table('articles', function (Blueprint $table) {
```

When used in a [block](../5_block-editor), no migration is needed, as data contained in blocks, including componentBlocks, is stored in a separate table from the model, which is managed by Twill for you.

## Manually setting input direction

Introduced in `v3.1.0`

For certain types of input it maybe useful to manually set the direction to left-to-right (`ltr`) or right-to-left (`rtl`) depending upon the expected text input.

For example, maybe you have an Arabic translated page and need URL which mixes Arabic with an `ltr` domain name and TLD. In this case content entry maybe proving difficult for your CMS users with a `rtl` input; in which case you may find setting the direction to `ltr` beneficial.

You may also simply just need a single Hebrew text entry in an otherwise `ltr` form.
35 changes: 21 additions & 14 deletions docs/content/1_docs/4_form-fields/02_wysiwyg.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,21 @@ $wysiwygOptions = [
```


| Option | Description | Type/values | Default value |
|:---------------|:-------------------------------------------------------------------------------------------------------------------------|:-----------------|:--------------|
| name | Name of the field | string | |
| label | Label of the field | string | |
| type | Type of wysiwyg field | quill<br/>tiptap | tiptap |
| toolbarOptions | Array of options/tools that will be displayed in the editor | | See above |
| editSource | Displays a button to view source code | boolean | false |
| hideCounter | Hide the character counter displayed at the bottom | boolean | false |
| limitHeight | Limit the editor height from growing beyond the viewport | boolean | false |
| translated | Defines if the field is translatable | boolean | false |
| maxlength | Max character count of the field | integer | |
| note | Hint message displayed above the field | string | |
| placeholder | Text displayed as a placeholder in the field | string | |
| required | Displays an indicator that this field is required<br/>A backend validation rule is required to prevent users from saving | boolean | false |
| Option | Description | Type/values | Default value |
|:---------------|:-------------------------------------------------------------------------------------------------------------------------|:--------------------|:--------------|
| name | Name of the field | string | |
| label | Label of the field | string | |
| type | Type of wysiwyg field | quill<br/>tiptap | tiptap |
| toolbarOptions | Array of options/tools that will be displayed in the editor | | See above |
| editSource | Displays a button to view source code | boolean | false |
| hideCounter | Hide the character counter displayed at the bottom | boolean | false |
| limitHeight | Limit the editor height from growing beyond the viewport | boolean | false |
| translated | Defines if the field is translatable | boolean | false |
| maxlength | Max character count of the field | integer | |
| note | Hint message displayed above the field | string | |
| placeholder | Text displayed as a placeholder in the field | string | |
| required | Displays an indicator that this field is required<br/>A backend validation rule is required to prevent users from saving | boolean | false |
| direction | Set custom input direction <small>(from `v3.1.0`)</small> | ltr<br/>rtl<br>auto | auto |

Note that Quill outputs CSS classes in the HTML for certain toolbar modules (indent, font, align, etc.), and that the image module is not integrated with Twill's media library. It outputs the base64 representation of the uploaded image.
It is not a recommended way of using and storing images, prefer using one or multiple `medias` form fields or blocks fields for flexible content. This will give you greater control over your frontend output.
Expand Down Expand Up @@ -171,3 +172,9 @@ For regular fields on models you will have to manually call `parseInternalLinks`
```blade
{{ \A17\Twill\Facades\TwillUtil::parseInternalLinks($item->description) }}
```

## Manually setting input direction

Introduced in `v3.1.0`

For certain types of input it maybe useful to manually set the direction to left-to-right (`ltr`) or right-to-left (`rtl`) depending upon the expected text input; for example you may need a single Hebrew text entry in an otherwise `ltr` form.
2 changes: 1 addition & 1 deletion docs/content/1_docs/4_form-fields/06_multi-select.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ In this case that it can be implemented as follows:
- Create a Sectors [module](../3_modules/2_cli-generator.md)

```
php artisan twill:module sectors
php artisan twill:make:module sectors
```

- Create a migration for a pivot table.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Creating the page module

Now that we area ready with the initial setup of Laravel and Twill we can start building our CMS.
Now that we are ready with the initial setup of Laravel and Twill we can start building our CMS.

In Twill we use Modules. A module is a single "content type" and exists out of a few files:

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
8 changes: 7 additions & 1 deletion frontend/js/components/dashboard/shortcutCreator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,19 @@
border-bottom: 1px solid $color__border;
}
.shortcutCreator .wrapper--reverse {
@include breakpoint('medium+') {
flex-flow: row-reverse;
}
}
.shortcutCreator__listing {
display: flex;
flex-grow: 1;
flex-flow: column nowrap;
@include breakpoint('small+') {
flex-flow: row nowrap;
flex-flow: row wrap;
}
}
Expand Down
4 changes: 4 additions & 0 deletions frontend/js/mixins/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ export default {
type: String,
default: ''
},
direction: {
type: String,
default: 'auto'
},
name: {
default: ''
},
Expand Down
3 changes: 3 additions & 0 deletions frontend/js/mixins/locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ export default {
else return false
},
dirLocale: function () {
if (this.direction && this.direction !== 'auto') {
return this.direction;
}
return (this.isLocaleRTL ? 'rtl' : 'auto')
},
displayedLocale: function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@ class SupportPermission extends Migration
*/
public function up()
{
if (!Schema::hasTable('permissions')
$permissionsTableName = config('twill.permissions_table', 'permissions');
$rolesTableName = config('twill.roles_table', 'roles');

if (!Schema::hasTable($permissionsTableName)
&& !Schema::hasTable('groups')
&& !Schema::hasTable('roles')
&& !Schema::hasTable($rolesTableName)
&& !Schema::hasTable('permission_twill_user')
&& !Schema::hasTable('group_twill_user')
&& !Schema::hasTable('group_permission')
&& !Schema::hasTable('permission_role')
) {
Schema::create('permissions', function (Blueprint $table) {
Schema::create($permissionsTableName, function (Blueprint $table) {
createDefaultTableFields($table);
$table->string('name');
$table->string('display_name')->nullable();
Expand All @@ -40,14 +43,14 @@ public function up()
$table->boolean('is_everyone_group')->default(false);
});

Schema::create('roles', function (Blueprint $table) {
Schema::create($rolesTableName, function (Blueprint $table) {
createDefaultTableFields($table);
$table->string('name', 255)->nullable();
$table->boolean('in_everyone_group')->default(true);
$table->integer('position')->unsigned()->nullable();
});

Schema::create('permission_twill_user', function (Blueprint $table) {
Schema::create('permission_twill_user', function (Blueprint $table) use($permissionsTableName) {
$table->bigInteger('twill_user_id')->unsigned()->nullable();
$table->foreign('twill_user_id')
->references('id')
Expand All @@ -57,7 +60,7 @@ public function up()
$table->bigInteger('permission_id')->unsigned()->nullable();
$table->foreign('permission_id')
->references('id')
->on('permissions')
->on($permissionsTableName)
->onDelete('cascade');
});

Expand All @@ -77,11 +80,11 @@ public function up()
$table->integer('position')->unsigned()->nullable();
});

Schema::create('group_permission', function (Blueprint $table) {
Schema::create('group_permission', function (Blueprint $table) use($permissionsTableName) {
$table->bigInteger('permission_id')->unsigned()->nullable();
$table->foreign('permission_id')
->references('id')
->on('permissions')
->on($permissionsTableName)
->onDelete('cascade');

$table->bigInteger('group_id')->unsigned()->nullable();
Expand All @@ -91,17 +94,17 @@ public function up()
->onDelete('cascade');
});

Schema::create('permission_role', function (Blueprint $table) {
Schema::create('permission_role', function (Blueprint $table) use($permissionsTableName, $rolesTableName) {
$table->bigInteger('permission_id')->unsigned()->nullable();
$table->foreign('permission_id')
->references('id')
->on('permissions')
->on($permissionsTableName)
->onDelete('cascade');

$table->bigInteger('role_id')->unsigned()->nullable();
$table->foreign('role_id')
->references('id')
->on('roles')
->on($rolesTableName)
->onDelete('cascade');
});

Expand All @@ -118,13 +121,17 @@ public function up()
*/
public function down()
{
$permissionsTableName = config('twill.permissions_table', 'permissions');
$rolesTableName = config('twill.roles_table', 'roles');


Schema::dropIfExists('permission_twill_user');
Schema::dropIfExists('group_twill_user');
Schema::dropIfExists('group_permission');
Schema::dropIfExists('permission_role');
Schema::dropIfExists('permissions');
Schema::dropIfExists($permissionsTableName);
Schema::dropIfExists('groups');
Schema::dropIfExists('roles');
Schema::dropIfExists($rolesTableName);
}

private function seedBasicPermissions()
Expand Down
Loading

0 comments on commit 965e3b2

Please sign in to comment.