ui: Add unique slug key id to proxy (#8479)
This commit is contained in:
parent
efcda70b85
commit
85a878549b
|
@ -2,10 +2,10 @@ import Model from 'ember-data/model';
|
|||
import attr from 'ember-data/attr';
|
||||
|
||||
export const PRIMARY_KEY = 'uid';
|
||||
export const SLUG_KEY = 'ID';
|
||||
export const SLUG_KEY = 'Node,ServiceID';
|
||||
export default Model.extend({
|
||||
[PRIMARY_KEY]: attr('string'),
|
||||
[SLUG_KEY]: attr('string'),
|
||||
ID: attr('string'),
|
||||
ServiceName: attr('string'),
|
||||
ServiceID: attr('string'),
|
||||
Node: attr('string'),
|
||||
|
|
|
@ -4,16 +4,20 @@ export default function(foreignKey, nspaceKey, hash = JSON.stringify) {
|
|||
throw new Error('Unable to create fingerprint, missing foreignKey value');
|
||||
}
|
||||
return function(item) {
|
||||
if (item[slugKey] == null || item[slugKey].length < 1) {
|
||||
throw new Error('Unable to create fingerprint, missing slug');
|
||||
}
|
||||
const slugKeys = slugKey.split(',');
|
||||
const slugValues = slugKeys.map(function(slugKey) {
|
||||
if (item[slugKey] == null || item[slugKey].length < 1) {
|
||||
throw new Error('Unable to create fingerprint, missing slug');
|
||||
}
|
||||
return item[slugKey];
|
||||
});
|
||||
const nspaceValue = item[nspaceKey] || 'default';
|
||||
return {
|
||||
...item,
|
||||
...{
|
||||
[nspaceKey]: nspaceValue,
|
||||
[foreignKey]: foreignKeyValue,
|
||||
[primaryKey]: hash([nspaceValue, foreignKeyValue, item[slugKey]]),
|
||||
[primaryKey]: hash([nspaceValue, foreignKeyValue].concat(slugValues)),
|
||||
},
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue