-
-
-
diff --git a/frontend/client/src/controllers/import.js b/frontend/client/src/controllers/import.js
index f658f69ee7..661a125004 100644
--- a/frontend/client/src/controllers/import.js
+++ b/frontend/client/src/controllers/import.js
@@ -17,22 +17,24 @@
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
- ************************************************************************/
-Espo.define('Controllers.Import', 'Controller', function (Dep) {
-
- return Dep.extend({
-
+ ************************************************************************/
+Espo.define('Controllers.Import', 'Controllers.Record', function (Dep) {
+
+ return Dep.extend({
+
+ defaultAction: 'index',
+
checkAccess: function () {
if (this.getUser().isAdmin()) {
return true;
}
return false;
- },
-
- index: function () {
- this.main('Import.Index', null);
},
-
+
+ index: function () {
+ this.main('Import.Index', null);
+ }
+
});
-
+
});
diff --git a/frontend/client/src/views/import/index.js b/frontend/client/src/views/import/index.js
index 4897584bcf..8688a6518e 100644
--- a/frontend/client/src/views/import/index.js
+++ b/frontend/client/src/views/import/index.js
@@ -17,27 +17,27 @@
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
- ************************************************************************/
+ ************************************************************************/
Espo.define('Views.Import.Index', 'View', function (Dep) {
-
+
return Dep.extend({
-
+
template: 'import.index',
-
+
data: function () {
return {
-
+
};
},
-
+
formData: null,
-
+
fileContents: null,
-
+
setup: function () {
this.entityType = this.options.entityType || false;
- },
-
+ },
+
changeStep: function (num, result) {
this.createView('step', 'Import.Step' + num.toString(), {
el: this.options.el + ' > .import-container',
@@ -48,14 +48,14 @@ Espo.define('Views.Import.Index', 'View', function (Dep) {
view.render();
});
},
-
+
afterRender: function () {
this.changeStep(1);
},
-
+
updatePageTitle: function () {
this.setPageTitle(this.getLanguage().translate('Import'));
},
-
+
});
});
diff --git a/frontend/client/src/views/import/list.js b/frontend/client/src/views/import/list.js
new file mode 100644
index 0000000000..02eaa38d48
--- /dev/null
+++ b/frontend/client/src/views/import/list.js
@@ -0,0 +1,57 @@
+/************************************************************************
+ * This file is part of EspoCRM.
+ *
+ * EspoCRM - Open Source CRM application.
+ * Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
+ * Website: http://www.espocrm.com
+ *
+ * EspoCRM is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * EspoCRM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with EspoCRM. If not, see http://www.gnu.org/licenses/.
+ ************************************************************************/
+
+Espo.define('Views.Import.List', 'Views.List', function (Dep) {
+
+ return Dep.extend({
+
+ createButton: false,
+
+ setup: function () {
+ Dep.prototype.setup.call(this);
+
+ this.menu.buttons.unshift({
+ label: this.translate('Import', 'scopeNames'),
+ link: '#Import',
+ style: 'danger',
+ acl: 'edit'
+ });
+ },
+
+ actionCreateEmailAccount: function () {
+ if (this.options.userId) {
+ this.getRouter().dispatch('EmailAccount', 'create', {
+ attributes: {
+ assignedUserId: this.options.userId,
+ assignedUserName: this.options.userId
+ }
+ });
+ this.getRouter().navigate('#EmailAccount/create', {trigger: false});
+ } else {
+ this.getRouter().navigate('#EmailAccount/create', {trigger: true});
+ }
+
+ },
+
+
+ });
+});
+
diff --git a/frontend/client/src/views/import/record/detail.js b/frontend/client/src/views/import/record/detail.js
new file mode 100644
index 0000000000..86008c1ddd
--- /dev/null
+++ b/frontend/client/src/views/import/record/detail.js
@@ -0,0 +1,31 @@
+/************************************************************************
+ * This file is part of EspoCRM.
+ *
+ * EspoCRM - Open Source CRM application.
+ * Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
+ * Website: http://www.espocrm.com
+ *
+ * EspoCRM is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * EspoCRM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with EspoCRM. If not, see http://www.gnu.org/licenses/.
+ ************************************************************************/
+
+Espo.define('Views.Import.Record.Detail', 'Views.Record.Detail', function (Dep) {
+
+ return Dep.extend({
+
+ readOnly: true
+
+ });
+
+});
+
diff --git a/frontend/client/src/views/import/record/list.js b/frontend/client/src/views/import/record/list.js
new file mode 100644
index 0000000000..56bec5072e
--- /dev/null
+++ b/frontend/client/src/views/import/record/list.js
@@ -0,0 +1,36 @@
+/************************************************************************
+ * This file is part of EspoCRM.
+ *
+ * EspoCRM - Open Source CRM application.
+ * Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
+ * Website: http://www.espocrm.com
+ *
+ * EspoCRM is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * EspoCRM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with EspoCRM. If not, see http://www.gnu.org/licenses/.
+ ************************************************************************/
+
+Espo.define('Views.Import.Record.List', 'Views.Record.List', function (Dep) {
+
+ return Dep.extend({
+
+ allowQuickEdit: false,
+
+ checkAllResultDisabled: true,
+
+ massActionList: ['remove'],
+
+ rowActionsView: 'Record.RowActions.RemoveOnly'
+
+ });
+});
+
diff --git a/frontend/client/src/views/import/step1.js b/frontend/client/src/views/import/step1.js
index 20eecaa457..55e5a61b80 100644
--- a/frontend/client/src/views/import/step1.js
+++ b/frontend/client/src/views/import/step1.js
@@ -17,13 +17,13 @@
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
- ************************************************************************/
+ ************************************************************************/
Espo.define('Views.Import.Step1', 'View', function (Dep) {
-
+
return Dep.extend({
-
+
template: 'import.step-1',
-
+
events: {
'change #import-file': function (e) {
var $file = $(e.currentTarget);
@@ -32,25 +32,25 @@ Espo.define('Views.Import.Step1', 'View', function (Dep) {
this.loadFile(files[0]);
}
},
-
+
'change #import-field-delimiter': function (e) {
this.formData.fieldDelimiter = e.currentTarget.value;
this.preview();
},
-
+
'change #import-text-qualifier': function (e) {
this.formData.textQualifier = e.currentTarget.value;
this.preview();
},
-
+
'click button[data-action="next"]': function () {
this.next();
}
},
-
+
getEntityList: function () {
var list = [];
- var scopes = this.getMetadata().get('scopes');
+ var scopes = this.getMetadata().get('scopes');
for (var scopeName in scopes) {
if (scopes[scopeName].importable) {
list.push(scopeName);
@@ -61,15 +61,15 @@ Espo.define('Views.Import.Step1', 'View', function (Dep) {
}.bind(this));
return list;
},
-
+
data: function () {
return {
entityList: this.getEntityList(),
currencyList: this.getConfig().get('currencyList'),
};
},
-
- setup: function () {
+
+ setup: function () {
this.formData = this.options.formData || {
entityType: this.options.entityType || false,
headerRow: true,
@@ -79,9 +79,9 @@ Espo.define('Views.Import.Step1', 'View', function (Dep) {
timeFormat: 'HH:mm',
decimalMark: '.',
personNameFormat: 'f l',
- };
+ };
},
-
+
afterRender: function () {
this.setupFormData();
if (this.getParentView() && this.getParentView().fileContents) {
@@ -89,7 +89,7 @@ Espo.define('Views.Import.Step1', 'View', function (Dep) {
this.preview();
}
},
-
+
next: function () {
this.formData.headerRow = $('#import-header-row').get(0).checked;
this.formData.entityType = $('#import-entity-type').val();
@@ -101,69 +101,69 @@ Espo.define('Views.Import.Step1', 'View', function (Dep) {
this.formData.decimalMark = $('#import-decimal-mark').val();
this.formData.currency = $('#import-currency').val();
this.formData.personNameFormat = $('#import-person-name-format').val();
-
+
this.getParentView().formData = this.formData;
this.getParentView().changeStep(2);
},
-
- setupFormData: function () {
+
+ setupFormData: function () {
$('#import-header-row').get(0).checked = this.formData.headerRow || false;
-
+
if (this.formData.entityType) {
$('#import-entity-type').val(this.formData.entityType);
}
if (this.formData.action) {
$('#import-action').val(this.formData.action);
}
-
+
$('#import-field-delimiter').val(this.formData.fieldDelimiter);
$('#import-text-qualifier').val(this.formData.textQualifier);
$('#import-date-format').val(this.formData.dateFormat);
$('#import-time-format').val(this.formData.timeFormat);
$('#import-decimal-mark').val(this.formData.decimalMark);
$('#import-person-name-format').val(this.formData.personNameFormat);
-
+
if (this.formData.currency) {
$('#import-currency').val(this.formData.currency);
}
},
-
+
loadFile: function (file) {
var blob = file.slice(0, 1024 * 16);
-
- var readerPreview = new FileReader();
+
+ var readerPreview = new FileReader();
readerPreview.onloadend = function (e) {
if (e.target.readyState == FileReader.DONE) {
this.formData.previewString = e.target.result;
this.preview();
- }
- }.bind(this);
+ }
+ }.bind(this);
readerPreview.readAsText(blob);
-
- var reader = new FileReader();
+
+ var reader = new FileReader();
reader.onloadend = function (e) {
if (e.target.readyState == FileReader.DONE) {
this.getParentView().fileContents = e.target.result;
this.setFileIsLoaded();
- }
- }.bind(this);
- reader.readAsText(file);
+ }
+ }.bind(this);
+ reader.readAsText(file);
},
-
+
setFileIsLoaded: function () {
this.$el.find('button[data-action="next"]').removeClass('hidden');
},
-
- preview: function () {
+
+ preview: function () {
if (!this.formData.previewString) {
return;
- }
+ }
var arr = this.csvToArray(this.formData.previewString, this.formData.fieldDelimiter, this.formData.textQualifier);
-
+
this.formData.previewArray = arr;
-
+
var $table = $('
').addClass('table').addClass('table-bordered');
-
+
arr.forEach(function (row, i) {
if (i >= 3) {
return;
@@ -173,15 +173,15 @@ Espo.define('Views.Import.Step1', 'View', function (Dep) {
$cell = $('
').html(value);
$row.append($cell);
});
-
+
$table.append($row);
});
-
+
var $container = $('#import-preview');
$container.empty().append($table);
},
-
- csvToArray: function (strData, strDelimiter, strQualifier) {
+
+ csvToArray: function (strData, strDelimiter, strQualifier) {
strDelimiter = (strDelimiter || ',');
strQualifier = (strQualifier || '\"');
@@ -226,6 +226,6 @@ Espo.define('Views.Import.Step1', 'View', function (Dep) {
return arrData;
}
-
+
});
});
diff --git a/frontend/client/src/views/import/step2.js b/frontend/client/src/views/import/step2.js
index 23cac11975..99d0593562 100644
--- a/frontend/client/src/views/import/step2.js
+++ b/frontend/client/src/views/import/step2.js
@@ -17,14 +17,14 @@
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
- ************************************************************************/
+ ************************************************************************/
Espo.define('Views.Import.Step2', 'View', function (Dep) {
-
+
return Dep.extend({
-
+
template: 'import.step-2',
-
- events: {
+
+ events: {
'click button[data-action="back"]': function () {
this.back();
},
@@ -36,36 +36,36 @@ Espo.define('Views.Import.Step2', 'View', function (Dep) {
$(e.currentTarget).parent().addClass('hidden');
this.addField(field);
},
-
+
'click a[data-action="removeField"]': function (e) {
var field = $(e.currentTarget).data('name');
-
- this.$el.find('a[data-action="addField"]').parent().removeClass('hidden');
- var index = this.additionalFields.indexOf(field);
+ this.$el.find('a[data-action="addField"]').parent().removeClass('hidden');
+
+ var index = this.additionalFields.indexOf(field);
if (~index) {
this.additionalFields.splice(index, 1);
}
this.$el.find('.field-' + field).parent().remove();
},
- },
-
+ },
+
data: function () {
return {
scope: this.scope,
fieldList: this.getFieldList(),
};
},
-
- setup: function () {
+
+ setup: function () {
this.formData = this.options.formData;
-
+
this.scope = this.formData.entityType;
-
+
var mapping = [];
-
+
this.additionalFields = [];
-
+
if (this.formData.previewArray) {
var index = 0;
if (this.formData.headerRow) {
@@ -81,23 +81,23 @@ Espo.define('Views.Import.Step2', 'View', function (Dep) {
}
mapping.push(d);
}, this);
- }
+ }
}
-
+
this.wait(true);
this.getModelFactory().create(this.scope, function (model) {
this.model = model;
- this.wait(false);
+ this.wait(false);
}, this);
-
- this.mapping = mapping;
+
+ this.mapping = mapping;
},
-
+
afterRender: function () {
$container = $('#mapping-container');
-
+
$table = $('