Skip to content

Commit

Permalink
Skip All Unknown Fields For Import. sorenkrabbe#234
Browse files Browse the repository at this point in the history
  • Loading branch information
petrbartonicekcarvago committed Dec 2, 2022
1 parent a4a728e commit 76c458f
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions addon/data-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,15 @@ class Model {
importOptions.set("threads", this.batchConcurrency);
copyToClipboard(importOptions.toString());
}
//https://github.com/sorenkrabbe/Chrome-Salesforce-inspector/pull/234/files
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.
Expand Down Expand Up @@ -271,6 +280,17 @@ class Model {
canCopy() {
return this.importData.taggedRows != null;
}
//https://github.com/sorenkrabbe/Chrome-Salesforce-inspector/pull/234/files
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);
Expand Down Expand Up @@ -474,6 +494,10 @@ class Model {
return "Error: Unknown field";
}
return "";
//https://github.com/sorenkrabbe/Chrome-Salesforce-inspector/pull/234/files
},
columnUnknownField() {
return columnVm.columnError() === "Error: Unknown field";
}
};
return columnVm;
Expand Down Expand Up @@ -659,6 +683,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 @@ -750,6 +775,12 @@ class App extends React.Component {
let {model} = this.props;
model.copyOptions();
}
//https://github.com/sorenkrabbe/Chrome-Salesforce-inspector/pull/234/files
onSkipAllUnknownFieldsClick(e) {
e.preventDefault();
let {model} = this.props;
model.skipAllUnknownFields();
}
onConfirmPopupYesClick(e) {
e.preventDefault();
let {model} = this.props;
Expand Down Expand Up @@ -922,6 +953,7 @@ class App extends React.Component {
h("div", {className: "button-group"},
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, title: "Copy import result to clipboard for saving as a CSV file"}, "Copy (CSV)"),
h("button", {disabled: !model.canSkipAllUnknownFields() || model.isWorking() || model.importCounts().Queued == 0, onClick: this.onSkipAllUnknownFieldsClick}, "Skip all unknown fields")
),
),
h("div", {className: "status-group"},
Expand Down

0 comments on commit 76c458f

Please sign in to comment.