mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-29 07:09:48 +03:00
e36b79c940
no issue - Adds UI to map imported csv fields to ones accepted by Ghost API - Includes automatic mapping detection for emails and stripe_customer_ids
49 lines
1.2 KiB
JavaScript
49 lines
1.2 KiB
JavaScript
import Component from '@glimmer/component';
|
|
import {action} from '@ember/object';
|
|
import {tracked} from '@glimmer/tracking';
|
|
|
|
export default class GhMembersImportTable extends Component {
|
|
@tracked dataPreviewIndex = 0;
|
|
|
|
get currentlyDisplayedData() {
|
|
let rows = [];
|
|
|
|
if (this.args && this.args.importData && this.args.mapping && this.args.mapping.mapping) {
|
|
let currentRecord = this.args.importData[this.dataPreviewIndex];
|
|
|
|
for (const [key, value] of Object.entries(currentRecord)) {
|
|
rows.push({
|
|
key: key,
|
|
value: value,
|
|
mapTo: this.args.mapping.get(key)
|
|
});
|
|
}
|
|
}
|
|
|
|
return rows;
|
|
}
|
|
|
|
@action
|
|
updateMapping(mapFrom, mapTo) {
|
|
this.args.updateMapping(mapFrom, mapTo);
|
|
}
|
|
|
|
@action
|
|
next() {
|
|
const nextValue = this.dataPreviewIndex + 1;
|
|
|
|
if (this.args.importData[nextValue]) {
|
|
this.dataPreviewIndex = nextValue;
|
|
}
|
|
}
|
|
|
|
@action
|
|
prev() {
|
|
const nextValue = this.dataPreviewIndex - 1;
|
|
|
|
if (this.args.importData[nextValue]) {
|
|
this.dataPreviewIndex = nextValue;
|
|
}
|
|
}
|
|
}
|