Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added skip all unknown fields button #114 #234

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion addon/data-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,15 @@ class Model {
copyToClipboard(importOptions.toString());
}

skipAllUnknownFields() {
for (let column of this.importData.importTable.header) {
if (column.columnUnknownField()) {
column.columnSkip();
}
}
this.didUpdate();
}

invalidInput() {
// We should try to allow imports to succeed even if our validation logic does not exactly match the one in Salesforce.
// We only hard-fail on errors that prevent us from building the API request.
Expand Down Expand Up @@ -271,6 +280,17 @@ class Model {
return this.importData.taggedRows != null;
}

canSkipAllUnknownFields() {
if (this.importData.importTable && this.importData.importTable.header) {
for (let column of this.importData.importTable.header) {
if (!column.columnIgnore() && column.columnUnknownField()) {
return true;
}
}
}
return false;
}

copyResult(separator) {
let header = this.importData.importTable.header.map(c => c.columnValue);
let data = this.importData.taggedRows.filter(row => this.showStatus[row.status]).map(row => row.cells);
Expand Down Expand Up @@ -471,6 +491,9 @@ class Model {
return "Error: Unknown field";
}
return "";
},
columnUnknownField() {
return columnVm.columnError() === "Error: Unknown field";
}
};
return columnVm;
Expand Down Expand Up @@ -656,6 +679,7 @@ class App extends React.Component {
this.onCopyAsExcelClick = this.onCopyAsExcelClick.bind(this);
this.onCopyAsCsvClick = this.onCopyAsCsvClick.bind(this);
this.onCopyOptionsClick = this.onCopyOptionsClick.bind(this);
this.onSkipAllUnknownFieldsClick = this.onSkipAllUnknownFieldsClick.bind(this);
this.onConfirmPopupYesClick = this.onConfirmPopupYesClick.bind(this);
this.onConfirmPopupNoClick = this.onConfirmPopupNoClick.bind(this);
this.unloadListener = null;
Expand Down Expand Up @@ -746,6 +770,11 @@ class App extends React.Component {
let {model} = this.props;
model.copyOptions();
}
onSkipAllUnknownFieldsClick(e) {
e.preventDefault();
let {model} = this.props;
model.skipAllUnknownFields();
}
onConfirmPopupYesClick(e) {
e.preventDefault();
let {model} = this.props;
Expand Down Expand Up @@ -897,7 +926,8 @@ class App extends React.Component {
h("button", {disabled: !model.importCounts().Failed > 0, onClick: this.onRetryFailedClick, className: "button-space"}, "Retry failed"),
h("button", {disabled: !model.canCopy(), onClick: this.onCopyAsExcelClick, title: "Copy import result to clipboard for pasting into Excel or similar"}, "Copy (Excel format)"),
h("button", {disabled: !model.canCopy(), onClick: this.onCopyAsCsvClick, className: "button-space", title: "Copy import result to clipboard for saving as a CSV file"}, "Copy (CSV)"),
h("button", {onClick: this.onCopyOptionsClick, title: "Save these import options by pasting them into Excel in the top left cell, just above the header row"}, "Copy options")
h("button", {onClick: this.onCopyOptionsClick, title: "Save these import options by pasting them into Excel in the top left cell, just above the header row"}, "Copy options"),
h("button", {onClick: this.onSkipAllUnknownFieldsClick, disabled: !model.canSkipAllUnknownFields() || model.isWorking() || model.importCounts().Queued == 0}, "Skip all unknown fields"),
),
h("div", {hidden: !model.showHelp},
h("p", {}, "Use for quick one-off data imports."),
Expand Down