meilisearch-admin/app/controllers/admin/indexes/item/data.js
Stanislav Romanov 5ad8e3668a Add data request
2022-03-24 13:56:55 +03:00

27 lines
656 B
JavaScript

import Controller from '@ember/controller';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
import { trackedFunction } from 'ember-resources';
export default class AdminIndexesItemDataController extends Controller {
@tracked searchText = 'hello';
request = trackedFunction(this, async () => {
if (typeof this.searchText !== 'string' || this.searchText.length < 1) {
return null;
}
const response = await this.model.search(this.searchText);
return response;
});
get data() {
return this.request.value;
}
@action
searchTextChanged(value) {
this.searchText = value;
}
}