mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-29 07:09:48 +03:00
Added import validation message when no "Email" mapping selected
no issue - Ensures the "email" field required to create a member is always present with the mapping - If the field is not mapped, import would fail for all members
This commit is contained in:
parent
92857d3f72
commit
1465eb7045
@ -51,6 +51,27 @@
|
||||
{{/if}}
|
||||
|
||||
{{#if this.customizing}}
|
||||
{{#if this.uploadErrors}}
|
||||
<div class="failed flex items-start gh-members-upload-errorcontainer {{if this.importDisabled "error" "warning"}}">
|
||||
<div class="mr3">
|
||||
{{svg-jar "warning" class="nudge-top--2 w5 h5 fill-red"}}
|
||||
</div>
|
||||
<div class="ma0">
|
||||
<p class="ma0 pa0 flex-grow w-100">The import contains errors!</p>
|
||||
<ul class="ma0 pa0 mt4 list bt b--whitegrey">
|
||||
{{#each this.uploadErrors as |error|}}
|
||||
<li class="gh-members-import-errormessage">
|
||||
<span>{{{error.message}}}</span>
|
||||
{{#if error.context}}
|
||||
<p class="gh-members-import-errorcontext">{{{error.context}}}</p>
|
||||
{{/if}}
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<GhFormGroup>
|
||||
{{#if this.config.enableDeveloperExperiments}}
|
||||
<div class="gh-members-import-scrollarea">
|
||||
|
@ -41,6 +41,16 @@ class MembersFieldMapping {
|
||||
return this._mapping;
|
||||
}
|
||||
|
||||
getKeyByValue(searchedValue) {
|
||||
for (const [key, value] of Object.entries(this._mapping)) {
|
||||
if (value === searchedValue) {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
updateMapping(from, to) {
|
||||
for (const key in this._mapping) {
|
||||
if (this.get(key) === to) {
|
||||
@ -75,6 +85,7 @@ export default ModalComponent.extend({
|
||||
importResponse: null,
|
||||
failureMessage: null,
|
||||
validationErrors: null,
|
||||
uploadErrors: null,
|
||||
labels: null,
|
||||
|
||||
// Allowed actions
|
||||
@ -189,6 +200,7 @@ export default ModalComponent.extend({
|
||||
this.set('fileData', null);
|
||||
this.set('mapping', null);
|
||||
this.set('validationErrors', null);
|
||||
this.set('uploadErrors', null);
|
||||
|
||||
this.set('validating', false);
|
||||
this.set('customizing', false);
|
||||
@ -197,8 +209,13 @@ export default ModalComponent.extend({
|
||||
},
|
||||
|
||||
upload() {
|
||||
if (this.file) {
|
||||
if (this.file && this.mapping.getKeyByValue('email')) {
|
||||
this.generateRequest();
|
||||
} else {
|
||||
this.set('uploadErrors', [{
|
||||
message: 'Import as "Email" value is missing.',
|
||||
context: 'The CSV has to contain import as "Email" field.'
|
||||
}]);
|
||||
}
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user