N°3905 - Polishing: CSV Import

This commit is contained in:
acognet
2021-06-17 11:16:31 +02:00
parent 77cf879f4f
commit 11f6c88ac7
8 changed files with 45 additions and 27 deletions

View File

@@ -35,9 +35,9 @@ $ibo-field--value-decoration--spacing-x: 0.5rem !default;
/* Avoid value to overflow from its container with very long strings (typically URLs) */
/* Note: Some types of attribute must be excluding as it can alter their rendering */
&:not([data-attribute-type="AttributeBlob"]):not([data-attribute-type="AttributeFile"]):not([data-attribute-type="AttributeImage"]) {
&:not([data-attribute-type="AttributeBlob"]):not([ data-attribute-type = "AttributeFile" ]):not([ data-attribute-type = "AttributeImage" ]):not(.ibo-input-file-select--container) {
/* We need the rule to apply for the class and all its descendants */
.ibo-field--value {
. ibo-field--value {
* {
word-break: break-word;
white-space: pre-wrap;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -120,7 +120,6 @@ function GetMappingForField($sClassName, $sFieldName, $iFieldIndex, $bAdvancedMo
$aChoices['id'] = Dict::S('UI:CSVImport:idField');
}
foreach (MetaModel::ListAttributeDefs($sClassName) as $sAttCode => $oAttDef) {
$sStar = '';
if ($oAttDef->IsExternalKey()) {
if (($sFieldName == $oAttDef->GetLabel()) || ($sFieldName == $sAttCode)) {
$sFieldCode = $sAttCode;
@@ -128,10 +127,6 @@ function GetMappingForField($sClassName, $sFieldName, $iFieldIndex, $bAdvancedMo
if ($bAdvancedMode) {
$aChoices[$sAttCode] = $oAttDef->GetLabel();
}
$oExtKeyAttDef = MetaModel::GetAttributeDef($sClassName, $oAttDef->GetKeyAttCode());
if (!$oExtKeyAttDef->IsNullAllowed()) {
$sStar = '*';
}
// Get fields of the external class that are considered as reconciliation keys
$sTargetClass = $oAttDef->GetTargetClass();
foreach (MetaModel::ListAttributeDefs($sTargetClass) as $sTargetAttCode => $oTargetAttDef) {
@@ -151,7 +146,7 @@ function GetMappingForField($sClassName, $sFieldName, $iFieldIndex, $bAdvancedMo
$aChoices[$sAttCode.'->'.$sTargetAttCode] = MetaModel::GetLabel($sClassName, $sAttCode.'->'.$sTargetAttCode, true);
foreach ($aSignatures as $sSignature) {
if (strcasecmp($sFieldName, $sSignature) == 0) {
$sFieldCode = $sAttCode.'->'.$sTargetAttCode.$sStar;
$sFieldCode = $sAttCode.'->'.$sTargetAttCode;
}
}
}

View File

@@ -148,12 +148,25 @@ class StaticTable extends UIContentBlock
/**
* @param array $aOptions
*
*
* @return $this
*/
public function SetOptions($aOptions)
{
$this->aOptions = $aOptions;
return $this;
}
/**
* @param array $aOptions
*
* @return $this
*/
public function AddOption($sName, $sValue)
{
$this->aOptions[$sName] = $sValue;
return $this;
}
}

View File

@@ -41,8 +41,8 @@ var oTable{{ sListIDForVarSuffix }} = $('#{{ oUIBlock.GetId() }}').DataTable({
},
scrollX: true,
{% if oUIBlock.GetOption('sMaxHeight') is not empty %}
scrollY: "{{ oUIBlock.GetOption('sMaxHeight') }}",
scrollCollapse: true,
scrollY: {{ oUIBlock.GetOption('sMaxHeight') }},
scrollCollapse: true,
{% endif %}
lengthMenu: [[ {{ iPageSize }}, {{ iPageSize*2 }}, {{ iPageSize*3 }}, {{ iPageSize*4 }}, -1], [ {{ iPageSize }}, {{ iPageSize*2 }}, {{ iPageSize*3 }}, {{ iPageSize*4 }}, "{{ 'UI:Datatables:Language:DisplayLength:All'|dict_s }}"]],
dom: "<'ibo-datatable--toolbar'<'ibo-datatable--toolbar-left' pl><'ibo-datatable--toolbar-right' i>>t<'ibo-datatable--toolbar'<'ibo-datatable--toolbar-left' pl><'ibo-datatable--toolbar-right' i>>",

View File

@@ -7,6 +7,9 @@ var table{{ sListIDForVarSuffix }} = $('#{{ oUIBlock.GetId() }}').DataTable({
},
scrollX: true,
scrollCollapse: true,
{% if oUIBlock.GetOption('sMaxHeight') is not empty %}
scrollY: {{ oUIBlock.GetOption('sMaxHeight') }},
{% endif %}
paging: false,
filter: false,
autoWidth: false,
@@ -26,27 +29,34 @@ var table{{ sListIDForVarSuffix }} = $('#{{ oUIBlock.GetId() }}').DataTable({
{% endif %}
drawCallback: function () {
// Hiding pagination if only one page
if ($(this).closest('.dataTables_wrapper').find('.dataTables_paginate:last .paginate_button:not(.previous):not(.next)').length < 2) {
if ($(this).closest('.dataTables_wrapper').find('.dataTables_paginate:last .paginate_button:not(.previous):not(.next)').length < 2)
{
$(this).closest('.dataTables_wrapper').find('.dataTables_paginate, .dataTables_info').hide();
} else {
}
else
{
$(this).closest('.dataTables_wrapper').find('.dataTables_paginate, .dataTables_info').show();
}
},
createdRow: function( row, data, dataIndex ) {
if (data['@class'] !== undefined) {
createdRow: function (row, data, dataIndex) {
if (data['@class'] !== undefined)
{
$(row).addClass(data['@class']);
}
},
});
if ($('#{{ oUIBlock.GetId() }}').find('thead').is(':visible')) {
if ($('#{{ oUIBlock.GetId() }}').find('thead').is(':visible'))
{
table{{ sListIDForVarSuffix }}.columns.adjust().draw();
}
if(window.ResizeObserver){
if (window.ResizeObserver)
{
let oFromTable{{ sListIDForVarSuffix }}ResizeTimeout = null;
const oFromTable{{ sListIDForVarSuffix }}Resize = new ResizeObserver(function(){
const oFromTable{{ sListIDForVarSuffix }}Resize = new ResizeObserver(function () {
clearTimeout(oFromTable{{ sListIDForVarSuffix }}ResizeTimeout);
oFromTable{{ sListIDForVarSuffix }}ResizeTimeout = setTimeout(function(){
oFromTable{{ sListIDForVarSuffix }}ResizeTimeout = setTimeout(function () {
$('#{{ oUIBlock.GetId() }}').DataTable().columns.adjust();
}, 120);
});

View File

@@ -31,8 +31,8 @@ $('#{{ oUIBlock.GetId() }}').DataTable({
},
scrollX: true,
{% if oUIBlock.GetOption('sMaxHeight') is not empty %}
scrollY: "{{ oUIBlock.GetOption('sMaxHeight') }}",
scrollCollapse: true,
scrollY: {{ oUIBlock.GetOption('sMaxHeight') }},
scrollCollapse: true,
{% endif %}
order: [],
autoWidth: false,