claire bontempo c265f5a132
UI: helper sort-objects to alphabetize list items (#24103)
* move list to component

* use helper instead

* add changelog

* clarify changelog copy

* delete components now that helper is in use

* move helper to util, remove template helper invokation

* add optional sorting to lazyPaginatedQuery based on sortBy query attribute

* Add serialization to entity-alias and entity so that they can be sorted by name on list view

* Same logic as base normalizeItems for extractLazyPaginatedData so that metadata shows on list

* Add headers

---------

Co-authored-by: Chelsea Shaw <cshaw@hashicorp.com>
Co-authored-by: Chelsea Shaw <82459713+hashishaw@users.noreply.github.com>
2023-11-14 21:57:29 +00:00

26 lines
651 B
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';
import IdentitySerializer from './_base';
export default IdentitySerializer.extend(EmbeddedRecordsMixin, {
// we don't need to serialize relationships here
serializeHasMany() {},
attrs: {
aliases: { embedded: 'always' },
},
extractLazyPaginatedData(payload) {
return payload.data.keys.map((key) => {
const model = payload.data.key_info[key];
model.id = key;
if (payload.backend) {
model.backend = payload.backend;
}
return model;
});
},
});