Skip to content

Commit

Permalink
Ticket 33287: fix several issues user import
Browse files Browse the repository at this point in the history
  • Loading branch information
derjoachim committed Oct 28, 2024
1 parent d9f2c00 commit 3d71992
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 33 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
- Core: bugfix editing individual field set in entity
- Core: bugfix user export
- Core: Several bug fixes user import

24-10-2024: 6.8.79
- E-mail: Server side sort was disabled by accident since May 2024
Expand Down
11 changes: 10 additions & 1 deletion www/go/core/convert/UserSpreadsheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,16 @@ public function exportPersonalGroup(Entity $entity, array $templateValues, $colu
return "";
}

public function importCreateEmailAccount(Entity $entity, $value, $values) {
public function importPersonalGroup(Entity $entity, $value, $values): void
{
if($entity instanceof User && !$entity->getPersonalGroup()) {
return;
}
return;
}

public function importCreateEmailAccount(Entity $entity, $value, $values): void
{
$this->postFixAdminDomain = false;
$this->postFixAdminPassword = false;

Expand Down
68 changes: 43 additions & 25 deletions www/go/core/views/extjs3/import/CsvMappingDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ go.import.CsvMappingDialog = Ext.extend(go.Window, {
initComponent : function() {

console.log(this.fileName, this.fileName.toLowerCase().substr(-3))
console.log(go.User.dateFormat,go.User.decimalSeparator, go.User.timeFormat, go.User.thousandsSeparator);

const renameWindow = new go.Window({
title: t('Rename profile'),
Expand Down Expand Up @@ -281,6 +282,13 @@ go.import.CsvMappingDialog = Ext.extend(go.Window, {
}, 'new');
Ext.apply(v, this.findAliases());
this.formPanel.form.setValues(v);
this.formPanel.form.setValues({
updateBy: response.updateBy,
dateFormat: response.dateFormat ?? go.User.dateFormat,
timeFormat: response.timeFormat ?? go.User.timeFormat,
decimalSeparator: response.decimalSeparator ?? go.User.decimalSeparator,
thousandsSeparator: response.thousandsSeparator ?? go.User.thousandsSeparator
});
}

this.doLayout();
Expand Down Expand Up @@ -396,52 +404,48 @@ go.import.CsvMappingDialog = Ext.extend(go.Window, {
* @returns {{}}
*
*/
transformCsvHeadersToValues : function(goHeaders, fields, parent) {
var v = {};
transformCsvHeadersToValues: function (goHeaders, fields, parent) {
const v = {};

for(var name in goHeaders) {
var h = goHeaders[name];
for (const name in goHeaders) {
const h = goHeaders[name];

if(h.grouped) {
if(h.many) {
if (h.grouped) {
if (h.many) {
v[h.name] = [];
var index = 1;
for (index = 1; index < 10; index++) {
var part = h.name + "[" + index + "]";
for (let index = 1; index < 10; index++) {
let part = h.name + "[" + index + "]";
part = parent ? parent + "." + part : part;

var headerIndex = this.csvHeaders.findIndex(function (csvH) {
let headerIndex = this.csvHeaders.findIndex(function (csvH) {
return csvH && csvH.toLowerCase().indexOf(part.toLowerCase()) == 0;
});

if (headerIndex == -1) {
if (headerIndex === -1) {
break;
}
headerIndex--;
v[h.name][headerIndex] = this.transformCsvHeadersToValues(h.properties, fields, part);
}
}else
{
} else {
v[h.name] = this.transformCsvHeadersToValues(h.properties, fields, h.name);
}
} else
{
} else {
v[h.name] = this.findSingleCsvIndex(h, parent);
}
};

}

return v;
},

findSingleCsvIndex : function(h, parent) {
var csvIndex = -2;
var storeIndex = this.csvStore.findBy(function(r) {
if(!r.data.name) {
let csvIndex = -2;
const storeIndex = this.csvStore.findBy(function (r) {
if (!r.data.name) {
return false;
}
var csvHeader = r.data.name.toLowerCase().replace(/[_\-\s]/g, '');
var goHeader = (parent ? parent + "." + h.name : h.name).toLowerCase().replace(/[_\-\s]/g, '');
const csvHeader = r.data.name.toLowerCase().replace(/[_\-\s]/g, '');
const goHeader = (parent ? parent + "." + h.name : h.name).toLowerCase().replace(/[_\-\s]/g, '');

return csvHeader == goHeader || "customfields." + csvHeader == goHeader;
});
Expand Down Expand Up @@ -477,8 +481,6 @@ go.import.CsvMappingDialog = Ext.extend(go.Window, {
};

if(h.many) {


var field = {
name: h.name,
xtype: "formgroup",
Expand Down Expand Up @@ -568,9 +570,25 @@ go.import.CsvMappingDialog = Ext.extend(go.Window, {
var updateBy = mapping.updateBy,
decimalSeparator = mapping.decimalSeparator,
thousandsSeparator = mapping.thousandsSeparator,
dateFormat = mapping.dateFormat;
dateFormat = mapping.dateFormat,
timeFormat = mapping.timeFormat;

// Not sure why, but these values are not read properly in the API. Therefore, we translate them
// to string values below
if(Ext.isArray(decimalSeparator)) {
decimalSeparator = decimalSeparator[0];
}

if(Ext.isArray(thousandsSeparator)) {
thousandsSeparator = thousandsSeparator[0];
}
if(Ext.isArray(dateFormat)) {
dateFormat = dateFormat[0];
}
if(Ext.isArray(timeFormat)) {
timeFormat = timeFormat[0];
}

var saveName = this.nameField.getValue();

delete mapping.updateBy;
Expand Down
9 changes: 2 additions & 7 deletions www/go/core/views/extjs3/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -605,10 +605,9 @@ go.util = (function () {
upload: function (response) {
Ext.getBody().mask(t("Importing..."));


if(response.name.toLowerCase().substr(-3) == 'csv' || response.name.toLowerCase().substr(-4) == 'xlsx') {
if(response.name.toLowerCase().slice(-3) === 'csv' || response.name.toLowerCase().slice(-4) === 'xlsx') {
Ext.getBody().unmask();
var dlg = new go.import.CsvMappingDialog({
const dlg = new go.import.CsvMappingDialog({
entity: entity,
fileName: response.name,
blobId: response.blobId,
Expand Down Expand Up @@ -642,10 +641,6 @@ go.util = (function () {

go.Db.store(entity).getUpdates();
}

// if (callback) {
// callback.call(scope || this, response);
// }
},
scope: this
});
Expand Down

0 comments on commit 3d71992

Please sign in to comment.