Add helper to form elements

This commit is contained in:
Stanislav Romanov 2022-03-28 13:37:09 +03:00
parent 07fc75487c
commit 4ef828fbe9
5 changed files with 20 additions and 3 deletions

View file

@ -15,4 +15,7 @@
as |option select|>
{{yield option select}}
</PowerSelect>
{{#if @helper}}
<div class="mt-1 text-sm">{{@helper}}</div>
{{/if}}
</div>

View file

@ -20,4 +20,7 @@
{{on 'input' this.onChange}}
>
</div>
{{#if @helper}}
<div class="mt-1 text-sm">{{@helper}}</div>
{{/if}}
</div>

View file

@ -19,4 +19,7 @@
{{on 'input' this.onChange}}
>{{@value}}</textarea>
</div>
{{#if @helper}}
<div class="mt-1 text-sm">{{@helper}}</div>
{{/if}}
</div>

View file

@ -3,7 +3,14 @@ import { action } from '@ember/object';
import arrayEquals from 'meilisearch-admin/utils/array-equals';
export default class AdminIndexesItemSettingsController extends Controller {
returnChar = '\n';
@action
saveStopWords(str) {
if (typeof str !== 'string' || str === '') {
this.model.settings.stopWords = [];
} else {
this.model.settings.stopWords = str.split(',').map((item) => item.trim());
}
}
@action
save() {

View file

@ -80,8 +80,9 @@
<InputTextarea
@label="Stop-words"
@value={{join this.returnChar @model.settings.stopWords}}
@onChange={{pipe (split this.returnChar) (set @model.settings 'stopWords')}}
@value={{join ', ' @model.settings.stopWords}}
@onChange={{this.saveStopWords}}
@helper="Format: of, the, to"
/>
<Button