Files
threshold-ui/addons/api/mirage/serializers/group.js
T

26 lines
620 B
JavaScript
Raw Normal View History

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
2020-06-24 17:07:32 -04:00
import ApplicationSerializer from './application';
2020-09-01 12:03:36 -04:00
import { underscore } from '@ember/string';
2020-06-24 17:07:32 -04:00
export default ApplicationSerializer.extend({
2020-09-01 12:03:36 -04:00
modelName: 'group',
keyForRelationshipIds(relationshipName) {
return `${this._container.inflector.singularize(
underscore(relationshipName),
2020-09-01 12:03:36 -04:00
)}_ids`;
},
_hashForModel(model) {
const json = ApplicationSerializer.prototype._hashForModel.apply(
this,
arguments,
);
if (model.memberIds.length) json.member_ids = model.memberIds;
2020-09-01 12:03:36 -04:00
return json;
},
2020-06-24 17:07:32 -04:00
});