replaces dataset number id's to urn identifiers in url

This commit is contained in:
Seyi Adebajo 2018-03-26 14:29:06 -04:00
parent 9f05a96478
commit 9a637e3d3b

View File

@ -58,6 +58,21 @@ export default Route.extend({
throw new TypeError(`Could not parse identifier ${identifier}. Please ensure format is valid.`);
},
serialize({ uri }) {
// updates routes dataset_id param with dataset urn (urn property)
return { dataset_id: uri };
},
afterModel(model, transition) {
const { dataset_id } = transition.params['datasets.dataset'];
// Check is dataset_id is a number, and replace with urn
// urn's are the primary means of referencing a dataset
if (!isNaN(parseInt(dataset_id, 10)) && isFinite(dataset_id)) {
this.replaceWith('datasets.dataset', model);
}
},
/**
* resetting the urn query param when the hook is invoked
* @param {Controller} controller