This commit is contained in:
Taras Machyshyn
2020-04-03 18:16:50 +03:00
4 changed files with 68 additions and 7 deletions
+38 -3
View File
@@ -46,9 +46,44 @@ define('controllers/import', 'controllers/record', function (Dep) {
return false;
},
actionIndex: function () {
this.main('views/import/index', null);
}
actionIndex: function (o, d) {
o = o || {};
var step = null;
if (o.step) {
step = parseInt(step);
}
var formData = null;
var fileContents = null;
if (this.storedData) {
formData = this.storedData.formData;
fileContents = this.storedData.fileContents;
}
if (!formData) {
step = null;
}
this.main('views/import/index', {
step: step,
formData: formData,
fileContents: fileContents,
}, function (view) {
this.listenTo(view, 'change', function () {
this.storedData = {
formData: view.formData,
fileContents: view.fileContents,
};
});
this.listenTo(view, 'done', function () {
delete this.storedData;
});
view.render();
}.bind(this));
},
});
});
+23 -2
View File
@@ -42,10 +42,25 @@ define('views/import/index', 'view', function (Dep) {
fileContents: null,
setup: function () {
this.entityType = this.options.entityType || false;
this.entityType = this.options.entityType || null;
this.startFromStep = 1;
if (this.options.formData && this.options.fileContents) {
this.formData = this.options.formData;
this.fileContents = this.options.fileContents;
this.entityType = this.formData.entityType || null;
if (this.options.step) {
this.startFromStep = this.options.step;
}
}
},
changeStep: function (num, result) {
this.step = num;
this.createView('step', 'views/import/step' + num.toString(), {
el: this.options.el + ' > .import-container',
entityType: this.entityType,
@@ -54,10 +69,16 @@ define('views/import/index', 'view', function (Dep) {
}, function (view) {
view.render();
});
var url = '#Import';
if (this.step > 1) {
url += '/index/step=' + this.step;
}
this.getRouter().navigate(url, {trigger: false})
},
afterRender: function () {
this.changeStep(1);
this.changeStep(this.startFromStep);
},
updatePageTitle: function () {
+3
View File
@@ -194,6 +194,9 @@ define('views/import/step1', ['view', 'model'], function (Dep, Model) {
this.formData.skipDuplicateChecking = this.model.get('skipDuplicateChecking');
this.getParentView().formData = this.formData;
this.getParentView().trigger('change');
this.getParentView().changeStep(2);
},
+4 -2
View File
@@ -26,7 +26,7 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
Espo.define('views/import/step2', 'view', function (Dep) {
define('views/import/step2', 'view', function (Dep) {
return Dep.extend({
@@ -385,7 +385,6 @@ Espo.define('views/import/step2', 'view', function (Dep) {
this.getParentView().changeStep(1);
},
next: function () {
if (!this.fetch()) {
return;
@@ -412,6 +411,8 @@ Espo.define('views/import/step2', 'view', function (Dep) {
this.getParentView().formData = this.formData;
this.getParentView().trigger('change');
this.disableButtons();
this.notify('File uploading...');
@@ -444,6 +445,7 @@ Espo.define('views/import/step2', 'view', function (Dep) {
timeout: 0,
success: function (result) {
var id = result.id;
this.getParentView().trigger('done');
if (id) {
this.getRouter().navigate('#Import/view/' + id, {trigger: true});
} else {