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