fix: scope page
This commit is contained in:
parent
bd1c7f36bb
commit
8a23f8ddf0
2 changed files with 11 additions and 10 deletions
|
@ -2,7 +2,7 @@ import app from 'flarum/admin/app';
|
|||
import Page from 'flarum/common/components/Page';
|
||||
import Button from 'flarum/common/components/Button';
|
||||
import Select from 'flarum/common/components/Select';
|
||||
import CheckBox from 'flarum/common/components/Checkbox';
|
||||
import Checkbox from 'flarum/common/components/Checkbox';
|
||||
|
||||
export default class ScopesPage extends Page {
|
||||
translationPrefix = 'foskym-oauth-center.admin.scopes.';
|
||||
|
@ -50,18 +50,20 @@ export default class ScopesPage extends Page {
|
|||
'PATCH': 'PATCH',
|
||||
},
|
||||
value: scope[key]() || 'GET',
|
||||
onchange: (event) => {
|
||||
this.saveScopeInfo(index, key, event.target.value);
|
||||
onchange: (value) => {
|
||||
this.saveScopeInfo(index, key, value);
|
||||
},
|
||||
}) : key === 'is_default' ? CheckBox.component({
|
||||
state: scope[key]() || false,
|
||||
onchange: (event) => {
|
||||
this.saveScopeInfo(index, key, event.target.checked ? 1 : 0);
|
||||
}) : key === 'is_default' ? Checkbox.component({
|
||||
state: scope[key]() === 1 || false,
|
||||
onchange: (checked) => {
|
||||
this.scopes[index].is_default((this.scopes[index].is_default() + 1) % 2)
|
||||
this.saveScopeInfo(index, key, checked ? 1 : 0);
|
||||
},
|
||||
}) : m('input.FormControl', {
|
||||
type: 'text',
|
||||
value: scope[key]() || '',
|
||||
onchange: (event) => {
|
||||
|
||||
this.saveScopeInfo(index, key, event.target.value);
|
||||
},
|
||||
}))
|
||||
|
@ -106,7 +108,6 @@ export default class ScopesPage extends Page {
|
|||
return str;
|
||||
}
|
||||
saveScopeInfo(index, key, value) {
|
||||
console.log(index, key, value);
|
||||
this.scopes[index].save({
|
||||
[key]: value,
|
||||
});
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import Model from 'flarum/common/Model';
|
||||
|
||||
export default class Client extends Model {
|
||||
export default class Scope extends Model {
|
||||
scope = Model.attribute('scope');
|
||||
resource_path = Model.attribute('resource_path');
|
||||
method = Model.attribute('method');
|
||||
is_default = Model.attribute('is_default', value => value === 1);
|
||||
is_default = Model.attribute('is_default');
|
||||
scope_name = Model.attribute('scope_name');
|
||||
scope_icon = Model.attribute('scope_icon');
|
||||
scope_desc = Model.attribute('scope_desc');
|
||||
|
|
Loading…
Reference in a new issue