diff --git a/app/components/gh-members-import-mapping-input.hbs b/app/components/gh-members-import-mapping-input.hbs new file mode 100644 index 000000000..64b134493 --- /dev/null +++ b/app/components/gh-members-import-mapping-input.hbs @@ -0,0 +1,13 @@ + + + {{svg-jar "arrow-down-small"}} + \ No newline at end of file diff --git a/app/components/gh-members-import-mapping-input.js b/app/components/gh-members-import-mapping-input.js new file mode 100644 index 000000000..a7c29ed69 --- /dev/null +++ b/app/components/gh-members-import-mapping-input.js @@ -0,0 +1,29 @@ +import Component from '@glimmer/component'; +import {action} from '@ember/object'; +import {tracked} from '@glimmer/tracking'; + +const FIELD_MAPPINGS = [ + {label: 'email', value: 'email'}, + {label: 'name', value: 'name'}, + {label: 'note', value: 'note'}, + {label: 'subscribed_to_emails', value: 'subscribed_to_emails'}, + {label: 'stripe_customer_id', value: 'stripe_customer_id'}, + {label: 'complimentary_plan', value: 'complimentary_plan'}, + {label: 'labels', value: 'labels'}, + {label: 'created_at', value: 'created_at'} +]; + +export default class extends Component { + @tracked availableFields = FIELD_MAPPINGS; + + get mapTo() { + return this.args.mapTo; + } + + @action + updateMapping(newMapTo) { + if (this.args.updateMapping) { + this.args.updateMapping(this.args.mapFrom, newMapTo); + } + } +} diff --git a/app/components/gh-members-import-table.hbs b/app/components/gh-members-import-table.hbs index 8a8bbd074..e62186fe9 100644 --- a/app/components/gh-members-import-table.hbs +++ b/app/components/gh-members-import-table.hbs @@ -1,26 +1,28 @@ - + + - {{#each-in currentlyDisplayedData as |key value|}} + {{#each currentlyDisplayedData as |row|}} - - + + + {{else}} - {{/each-in}} + {{/each}}
HeaderField Import as...
{{key}}{{value}}{{row.key}}{{row.value}}
No data
\ No newline at end of file diff --git a/app/components/gh-members-import-table.js b/app/components/gh-members-import-table.js index fa73a6ed5..350f034d4 100644 --- a/app/components/gh-members-import-table.js +++ b/app/components/gh-members-import-table.js @@ -6,11 +6,26 @@ export default class GhMembersImportTable extends Component { @tracked dataPreviewIndex = 0; get currentlyDisplayedData() { - if (this.args && this.args.importData) { - return this.args.importData[this.dataPreviewIndex]; + 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 {}; + return rows; + } + + @action + updateMapping(mapFrom, mapTo) { + this.args.updateMapping(mapFrom, mapTo); } @action diff --git a/app/components/modal-import-members.hbs b/app/components/modal-import-members.hbs index 64305f754..7165f2702 100644 --- a/app/components/modal-import-members.hbs +++ b/app/components/modal-import-members.hbs @@ -12,12 +12,12 @@ {{#if this.importResponse}}