1
0
Fork 0
mirror of https://github.com/TryGhost/Ghost-Admin.git synced 2023-12-14 02:33:04 +01:00
Ghost-Admin/app/serializers/member.js
Kevin Ansfield 89b10f69fa Added member's geographic location to admin
no issue

- added `geolocation` attribute to member model with json-string transform
- prevent geolocation from being sent back to the API in member serializer
- add "Location" column to members list
  - if country is "US" then display "{State}, US" otherwise show full country name such as "United Kingdom"
  - displays "-" if no geolocation data has been collected for the member
2020-02-27 12:56:26 +00:00

22 lines
686 B
JavaScript

/* eslint-disable camelcase */
import ApplicationSerializer from './application';
import {EmbeddedRecordsMixin} from '@ember-data/serializer/rest';
export default ApplicationSerializer.extend(EmbeddedRecordsMixin, {
attrs: {
createdAtUTC: {key: 'created_at'},
labels: {embedded: 'always'}
},
serialize(/*snapshot, options*/) {
let json = this._super(...arguments);
// Properties that exist on the model but we don't want sent in the payload
delete json.stripe;
delete json.geolocation;
// Normalize properties
json.name = json.name || '';
json.note = json.note || '';
return json;
}
});