mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-08-26 20:22:18 +00:00
Hide permissions table unless custom permissions are enabled
This commit is contained in:
parent
bf1371d04c
commit
6504a6f599
20
resources/assets/js/components/entity-permissions-editor.js
Normal file
20
resources/assets/js/components/entity-permissions-editor.js
Normal file
@ -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;
|
@ -26,6 +26,7 @@ import permissionsTable from "./permissions-table";
|
|||||||
import customCheckbox from "./custom-checkbox";
|
import customCheckbox from "./custom-checkbox";
|
||||||
import bookSort from "./book-sort";
|
import bookSort from "./book-sort";
|
||||||
import settingAppColorPicker from "./setting-app-color-picker";
|
import settingAppColorPicker from "./setting-app-color-picker";
|
||||||
|
import entityPermissionsEditor from "./entity-permissions-editor";
|
||||||
|
|
||||||
const componentMapping = {
|
const componentMapping = {
|
||||||
'dropdown': dropdown,
|
'dropdown': dropdown,
|
||||||
@ -56,6 +57,7 @@ const componentMapping = {
|
|||||||
'custom-checkbox': customCheckbox,
|
'custom-checkbox': customCheckbox,
|
||||||
'book-sort': bookSort,
|
'book-sort': bookSort,
|
||||||
'setting-app-color-picker': settingAppColorPicker,
|
'setting-app-color-picker': settingAppColorPicker,
|
||||||
|
'entity-permissions-editor': entityPermissionsEditor
|
||||||
};
|
};
|
||||||
|
|
||||||
window.components = {};
|
window.components = {};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<form action="{{ $model->getUrl('/permissions') }}" method="POST">
|
<form action="{{ $model->getUrl('/permissions') }}" method="POST" entity-permissions-editor>
|
||||||
{!! csrf_field() !!}
|
{!! csrf_field() !!}
|
||||||
<input type="hidden" name="_method" value="PUT">
|
<input type="hidden" name="_method" value="PUT">
|
||||||
|
|
||||||
@ -11,7 +11,7 @@
|
|||||||
])
|
])
|
||||||
</div>
|
</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>
|
<tr>
|
||||||
<th>{{ trans('common.role') }}</th>
|
<th>{{ trans('common.role') }}</th>
|
||||||
<th @if($model->isA('page')) colspan="3" @else colspan="4" @endif>
|
<th @if($model->isA('page')) colspan="3" @else colspan="4" @endif>
|
||||||
|
Loading…
Reference in New Issue
Block a user