You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
consul/ui-v2/app/utils/update-array-object.js

13 lines
398 B

import { get, set } from '@ember/object';
export default function(arr, item, prop, value) {
value = typeof value === 'undefined' ? get(item, prop) : value;
const current = arr.findBy(prop, value);
if (current) {
// TODO: This is reliant on changeset?
Object.keys(get(item, 'data')).forEach(function(prop) {
set(current, prop, get(item, prop));
});
return current;
}
}