mirror of
https://github.com/flarum/framework.git
synced 2024-11-25 09:41:49 +08:00
Merge pull request #3197 from flarum/as/permission-grid-fixes
Permission grid fixes
This commit is contained in:
commit
a10495d03e
|
@ -38,7 +38,6 @@ export default class PermissionDropdown extends Dropdown {
|
||||||
|
|
||||||
attrs.className = 'PermissionDropdown';
|
attrs.className = 'PermissionDropdown';
|
||||||
attrs.buttonClassName = 'Button Button--text';
|
attrs.buttonClassName = 'Button Button--text';
|
||||||
attrs.lazyDraw = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
view(vnode) {
|
view(vnode) {
|
||||||
|
|
|
@ -38,11 +38,13 @@ export default class PermissionGrid<CustomAttrs extends IPermissionGridAttrs = I
|
||||||
|
|
||||||
const permissionCells = (permission: PermissionGridEntry | { children: PermissionGridEntry[] }) => {
|
const permissionCells = (permission: PermissionGridEntry | { children: PermissionGridEntry[] }) => {
|
||||||
return scopes.map((scope) => {
|
return scopes.map((scope) => {
|
||||||
|
// This indicates the "permission" is a permission category,
|
||||||
|
// in which case we return an empty table cell.
|
||||||
if ('children' in permission) {
|
if ('children' in permission) {
|
||||||
return <td></td>;
|
return <td></td>;
|
||||||
}
|
}
|
||||||
|
|
||||||
return scope.render(permission);
|
return <td>{scope.render(permission)}</td>;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -416,7 +418,7 @@ export default class PermissionGrid<CustomAttrs extends IPermissionGridAttrs = I
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return '';
|
return null;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
100
|
100
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import app from '../../admin/app';
|
import app from '../app';
|
||||||
import SelectDropdown from '../../common/components/SelectDropdown';
|
import SelectDropdown from '../../common/components/SelectDropdown';
|
||||||
import Button from '../../common/components/Button';
|
import Button from '../../common/components/Button';
|
||||||
import saveSettings from '../utils/saveSettings';
|
import saveSettings from '../utils/saveSettings';
|
||||||
|
@ -11,18 +11,23 @@ export default class SettingDropdown extends SelectDropdown {
|
||||||
attrs.buttonClassName = 'Button Button--text';
|
attrs.buttonClassName = 'Button Button--text';
|
||||||
attrs.caretIcon = 'fas fa-caret-down';
|
attrs.caretIcon = 'fas fa-caret-down';
|
||||||
attrs.defaultLabel = 'Custom';
|
attrs.defaultLabel = 'Custom';
|
||||||
|
|
||||||
|
if ('key' in attrs) {
|
||||||
|
attrs.setting = attrs.key;
|
||||||
|
delete attrs.key;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
view(vnode) {
|
view(vnode) {
|
||||||
return super.view({
|
return super.view({
|
||||||
...vnode,
|
...vnode,
|
||||||
children: this.attrs.options.map(({ value, label }) => {
|
children: this.attrs.options.map(({ value, label }) => {
|
||||||
const active = app.data.settings[this.attrs.key] === value;
|
const active = app.data.settings[this.attrs.setting] === value;
|
||||||
|
|
||||||
return Button.component(
|
return Button.component(
|
||||||
{
|
{
|
||||||
icon: active ? 'fas fa-check' : true,
|
icon: active ? 'fas fa-check' : true,
|
||||||
onclick: saveSettings.bind(this, { [this.attrs.key]: value }),
|
onclick: saveSettings.bind(this, { [this.attrs.setting]: value }),
|
||||||
active,
|
active,
|
||||||
},
|
},
|
||||||
label
|
label
|
||||||
|
|
Loading…
Reference in New Issue
Block a user