Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide permissions table unless custom permissions are enabled #1505

Merged
merged 1 commit into from Jun 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions resources/assets/js/components/entity-permissions-editor.js
@@ -0,0 +1,20 @@

class EntityPermissionsEditor {

constructor(elem) {
this.permissionsTable = elem.querySelector('[permissions-table]');

// Handle toggle all event
this.restrictedCheckbox = elem.querySelector('[name=restricted]');
this.restrictedCheckbox.addEventListener('change', this.updateTableVisibility.bind(this));
}

updateTableVisibility() {
this.permissionsTable.style.display =
this.restrictedCheckbox.checked
? null
: 'none';
}
}

export default EntityPermissionsEditor;
2 changes: 2 additions & 0 deletions resources/assets/js/components/index.js
Expand Up @@ -26,6 +26,7 @@ import permissionsTable from "./permissions-table";
import customCheckbox from "./custom-checkbox";
import bookSort from "./book-sort";
import settingAppColorPicker from "./setting-app-color-picker";
import entityPermissionsEditor from "./entity-permissions-editor";

const componentMapping = {
'dropdown': dropdown,
Expand Down Expand Up @@ -56,6 +57,7 @@ const componentMapping = {
'custom-checkbox': customCheckbox,
'book-sort': bookSort,
'setting-app-color-picker': settingAppColorPicker,
'entity-permissions-editor': entityPermissionsEditor
};

window.components = {};
Expand Down
4 changes: 2 additions & 2 deletions resources/views/form/entity-permissions.blade.php
@@ -1,4 +1,4 @@
<form action="{{ $model->getUrl('/permissions') }}" method="POST">
<form action="{{ $model->getUrl('/permissions') }}" method="POST" entity-permissions-editor>
{!! csrf_field() !!}
<input type="hidden" name="_method" value="PUT">

Expand All @@ -11,7 +11,7 @@
])
</div>

<table permissions-table class="table permissions-table toggle-switch-list">
<table permissions-table class="table permissions-table toggle-switch-list" style="{{ !$model->restricted ? 'display: none' : '' }}">
<tr>
<th>{{ trans('common.role') }}</th>
<th @if($model->isA('page')) colspan="3" @else colspan="4" @endif>
Expand Down