Fix wrong method for updating some settings
This commit is contained in:
parent
0345c593d2
commit
a813bd8088
5 changed files with 22 additions and 14 deletions
|
|
@ -7,9 +7,9 @@ import { on } from '@ember/modifier';
|
|||
import eq from '../helpers/eq';
|
||||
|
||||
export const sizes = {
|
||||
sm: 'text-sm py-0.5',
|
||||
md: 'px-3 py-2',
|
||||
lg: 'px-4 py-3',
|
||||
sm: 'w-20 text-sm px-2.5 py-1',
|
||||
md: 'w-24 px-3 py-2',
|
||||
lg: 'w-24 px-4 py-3',
|
||||
};
|
||||
|
||||
export const iconSizes = {
|
||||
|
|
@ -29,7 +29,7 @@ export default class ButtonComponent extends Component {
|
|||
disabled={{this.disabled}}
|
||||
type={{this.type}}
|
||||
class="
|
||||
inline-flex items-center justify-center w-24 min-w-min
|
||||
inline-flex items-center justify-center min-w-min
|
||||
{{get sizes this.size}}
|
||||
{{get styles this.style}}
|
||||
"
|
||||
|
|
|
|||
|
|
@ -1,13 +1,18 @@
|
|||
<Form::Element @label={{namelize @name}}>
|
||||
<MonacoEditor
|
||||
@value={{this.value}}
|
||||
@value={{json-stringify this.value}}
|
||||
@language='json'
|
||||
@sendValue={{this.save}}
|
||||
class='h-40'
|
||||
as |monaco|
|
||||
>
|
||||
<Button @text='Save' @style='primary' @onClick={{monaco.triggerSendValue}} />
|
||||
<Button @text='Cancel' @onClick={{this.setInitialValue}} />
|
||||
<Button @text='Reset' @onClick={{this.reset}} />
|
||||
<Button
|
||||
@text='Save'
|
||||
@style='primary'
|
||||
@size='sm'
|
||||
@onClick={{monaco.triggerSendValue}}
|
||||
/>
|
||||
<Button @text='Cancel' @size='sm' @onClick={{this.setInitialValue}} />
|
||||
<Button @text='Reset' @size='sm' @onClick={{this.reset}} />
|
||||
</MonacoEditor>
|
||||
</Form::Element>
|
||||
|
|
|
|||
|
|
@ -12,14 +12,13 @@ export default class FormIndexSettingComponent extends Component {
|
|||
}
|
||||
|
||||
@action
|
||||
save() {
|
||||
this.args.index.updateSetting(this.args.name, this.value);
|
||||
save(newValue) {
|
||||
this.args.index.updateSetting(this.args.name, JSON.parse(newValue));
|
||||
}
|
||||
|
||||
@action
|
||||
async setInitialValue() {
|
||||
const result = await this.args.index.getSetting(this.args.name);
|
||||
this.value = JSON.stringify(result);
|
||||
this.value = await this.args.index.getSetting(this.args.name);
|
||||
}
|
||||
|
||||
@action
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ export default class MonacoEditorComponent extends Component {
|
|||
420
|
||||
);
|
||||
|
||||
el.style.height = `${contentHeight}px`;
|
||||
el.style.height = `${contentHeight + 1}px`;
|
||||
this.editor.layout();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,8 +90,12 @@ export default class Index {
|
|||
}
|
||||
|
||||
updateSetting(name, value) {
|
||||
const method = ['faceting', 'pagination', 'typo-tolerance'].includes(name)
|
||||
? 'PATCH'
|
||||
: 'PUT';
|
||||
|
||||
return query(`${this.path}/settings/${dasherize(name)}`, {
|
||||
method: 'PUT',
|
||||
method: method,
|
||||
body: JSON.stringify(value),
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue