Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (view) {
const method = view.get(name);
if (!method) {
// eslint-disable-next-line no-console
console.warn(`${name} not found`);
return;
}
if (typeof method === "string") {
view[method](param);
promise = Promise.resolve();
} else {
const target = view.get("target") || view;
promise = method.call(target, param);
if (!promise || !promise.then) {
promise = Promise.resolve(promise);
}
}
}
return this.rerenderResult(() => promise);
}
resolve(shouldContinue, payload) {
// A ResolvedHandlerInfo just resolved with itself.
if (payload && payload.resolvedModels) {
payload.resolvedModels[this.name] = this.context;
}
return Promise.resolve(this, this.promiseLabel('Resolve'));
}
destroyRecord(type, record) {
// If the record is new, don't perform an Ajax call
if (record.get("isNew")) {
removeMap(type, record.get("id"));
return Promise.resolve(true);
}
return this.adapterFor(type)
.destroyRecord(this, type, record)
.then(function(result) {
removeMap(type, record.get("id"));
return result;
});
},
let operation = options[SaveOp];
// TODO We have to cast due to our reliance on this private property
// this will be refactored away once we change our pending API to be identifier based
let internalModel = ((snapshot as unknown) as PrivateSnapshot)._internalModel;
let modelName = snapshot.modelName;
let store = this._store;
let modelClass = store.modelFor(modelName);
assert(`You tried to update a record but you have no adapter (for ${modelName})`, adapter);
assert(
`You tried to update a record but your adapter (for ${modelName}) does not implement '${operation}'`,
typeof adapter[operation] === 'function'
);
let promise = Promise.resolve().then(() => adapter[operation](store, modelClass, snapshot));
let serializer = store.serializerFor(modelName);
let label = `DS: Extract and notify about ${operation} completion of ${internalModel}`;
assert(
`Your adapter's '${operation}' method must return a value, but it returned 'undefined'`,
promise !== undefined
);
promise = guardDestroyedStore(promise, store, label);
promise = _guard(promise, _bind(_objectIsAlive, internalModel));
promise = promise.then(
adapterPayload => {
if (adapterPayload) {
return normalizeResponseHelper(serializer, store, modelClass, adapterPayload, snapshot.id, operation);
}
if (!entity) {
debug(id, 'missing from', lang);
return this._fetchResources(supported.slice(1)).then(
this._getFallback.bind(this, id, args),
function(err) {
debug(err);
// XXX comply to Gaia's l10n.js behavior for now;
// return id in the future
return Promise.resolve(null);
});
} else {
debug(id, 'found in', lang);
// XXX format the entity here, passing ctx and args
// XXX handle compiler's runtime errors and fall back if needed
// return entity.format(this, args);
return Promise.resolve(entity);
}
};
_createSubcategoryList(category) {
this._categoryList = null;
if (category.isParent && category.show_subcategory_list) {
return CategoryList.listForParent(this.store, category).then(
(list) => (this._categoryList = list)
);
}
// If we're not loading a subcategory list just resolve
return Promise.resolve();
},
afterEach() {
let afterEach = options.afterEach && options.afterEach.apply(this, arguments);
return Promise.resolve(afterEach).then(() => destroyApp(this.application));
},
});
function validationReturnValueHandler(attribute, value, model, validator) {
let result;
let commonProps = {
model,
attribute,
_validator: validator
};
if (isPromise(value)) {
result = ValidationResult.create(commonProps, {
_promise: Promise.resolve(value)
});
} else {
result = ValidationResult.create(commonProps);
result.update(value);
}
return result;
}
_searchWrapper(filter) {
this.clearErrors();
this.setProperties({
mainCollection: [],
"selectKit.isLoading": true,
"selectKit.enterDisabled": true,
});
this._safeAfterRender(() => this.popper && this.popper.update());
let content = [];
return Promise.resolve(this.search(filter))
.then((result) => {
content = content.concat(makeArray(result));
content = this.selectKit.modifyContent(content).filter(Boolean);
if (this.selectKit.valueProperty) {
content = content.uniqBy(this.selectKit.valueProperty);
} else {
content = content.uniq();
}
if (this.selectKit.options.limitMatches) {
content = content.slice(0, this.selectKit.options.limitMatches);
}
const noneItem = this.selectKit.noneItem;
if (
markReadRequest() {
return Promise.resolve();
},