Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
autocomplete: task(function* () {
this.set('showResults', true);
const q = cleanQuery(this.query);
if (isBlank(q) || q.length < MIN_INPUT) {
return [];
}
const cachedResults = this.findCachedAutocomplete(q);
if (cachedResults.length) {
return cachedResults.map(text => {
return { text };
});
}
yield timeout(DEBOUNCE_MS);
const { autocomplete } = yield this.iliosSearch.forCurriculum(q, true);
this.autocompleteCache.pushObject({ q, autocomplete });
search() {
const q = cleanQuery(this.query);
if (q.length > 0) {
this.autocompleteCache = [];
this.search(q);
this.set('showResults', false);
}
},
searchForUsers: task(function* () {
const query = this.query;
const q = cleanQuery(query);
yield timeout(DEBOUNCE_TIMEOUT);
const { store, offset, limit } = this;
return yield store.query('user', {
limit, q, offset,
'order_by[lastName]': 'ASC',
'order_by[firstName]': 'ASC'
});
}).cancelOn('deactivate').restartable(),
searchForUsers: task(function * (query) {
const intl = this.intl;
const q = cleanQuery(query);
if (isBlank(q)) {
yield timeout(1);
return [];
}
yield timeout(DEBOUNCE_MS);
if (q.length < MIN_INPUT) {
return [{
type: 'text',
text: intl.t('general.moreInputRequiredPrompt')
}];
}
const searchEnabled = yield this.iliosConfig.searchEnabled;
const searchResults = searchEnabled ? yield this.indexSearch(q) : yield this.apiSearch(q);
if (searchResults.length === 0) {
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
import { dropTask } from 'ember-concurrency-decorators';
import { validatable, Length, NotBlank } from 'ilios-common/decorators/validation';
@validatable
export default class CompetencyTitleEditorComponent extends Component {
@Length(1, 200) @NotBlank() @tracked title;
constructor() {
super(...arguments);
this.title = this.args.competency.title;
}
@action
revert() {
this.title = this.args.competency.title;
}
@dropTask
*save() {
this.addErrorDisplayFor('title');
const isValid = yield this.isValid('title');
if (!isValid) {
transitionToRollover() {
this.router.transitionTo('curriculumInventoryReport.rollover', this.report);
scrollTo('.rollover-form');
}
}