N°3912 - Polishing: Export : fix date entry + size of datatable

This commit is contained in:
acognet
2021-06-21 16:50:19 +02:00
parent 32ac999ff5
commit 1281d475e4
2 changed files with 31 additions and 13 deletions

View File

@@ -504,8 +504,6 @@ try {
} }
$iUnchanged = count($aRes) - $iErrors - $iModified - $iCreated; $iUnchanged = count($aRes) - $iErrors - $iModified - $iCreated;
$oTable = DataTableUIBlockFactory::MakeForForm("csvImport", $aColumns, $aTableData);
$oContainer = UIContentBlockUIBlockFactory::MakeStandard(); $oContainer = UIContentBlockUIBlockFactory::MakeStandard();
$oContainer->AddCSSClass("wizContainer"); $oContainer->AddCSSClass("wizContainer");
$oPage->AddSubBlock($oContainer); $oPage->AddSubBlock($oContainer);
@@ -585,9 +583,12 @@ try {
$oPanel = PanelUIBlockFactory::MakeNeutral(''); $oPanel = PanelUIBlockFactory::MakeNeutral('');
$oPanel->AddCSSClasses(['ibo-datatable-panel', 'mb-5']); $oPanel->AddCSSClasses(['ibo-datatable-panel', 'mb-5']);
$oForm->AddSubBlock($oPanel);
$oTable = DataTableUIBlockFactory::MakeForForm("csvImport", $aColumns, $aTableData);
$oTable->AddOption('bFullscreen', true);
$oPanel->AddSubBlock($oTable); $oPanel->AddSubBlock($oTable);
$oForm->AddSubBlock($oPanel);
if ($bSimulate) { if ($bSimulate) {
$oForm->AddSubBlock(ButtonUIBlockFactory::MakeForCancel(Dict::S('UI:Button:Restart'))->SetOnClickJsCode("CSVRestart()")); $oForm->AddSubBlock(ButtonUIBlockFactory::MakeForCancel(Dict::S('UI:Button:Restart'))->SetOnClickJsCode("CSVRestart()"));
@@ -1295,14 +1296,15 @@ EOF
$sDefaultFormat = htmlentities((string)AttributeDateTime::GetFormat(), ENT_QUOTES, 'UTF-8'); $sDefaultFormat = htmlentities((string)AttributeDateTime::GetFormat(), ENT_QUOTES, 'UTF-8');
$sExample = htmlentities(date((string)AttributeDateTime::GetFormat()), ENT_QUOTES, 'UTF-8'); $sExample = htmlentities(date((string)AttributeDateTime::GetFormat()), ENT_QUOTES, 'UTF-8');
$oRadioDefault = InputUIBlockFactory::MakeForInputWithLabel(Dict::Format('Core:BulkExport:DateTimeFormatDefault_Example', $sDefaultFormat, $sExample), "date_time_format", "default", "radio_date_time_std", "radio"); $oRadioDefault = InputUIBlockFactory::MakeForInputWithLabel(Dict::Format('UI:CSVImport:DefaultDateTimeFormat_Format_Example', $sDefaultFormat, $sExample), "date_time_format", "default", "radio_date_time_std", "radio");
$oRadioDefault->GetInput()->SetIsChecked(($sDateTimeFormat == (string)AttributeDateTime::GetFormat())); $oRadioDefault->GetInput()->SetIsChecked(($sDateTimeFormat == (string)AttributeDateTime::GetFormat()));
$oRadioDefault->SetBeforeInput(false); $oRadioDefault->SetBeforeInput(false);
$oRadioDefault->GetInput()->AddCSSClass('ibo-input-checkbox'); $oRadioDefault->GetInput()->AddCSSClass('ibo-input-checkbox');
$oFieldSetDate->AddSubBlock($oRadioDefault); $oFieldSetDate->AddSubBlock($oRadioDefault);
$oFieldSetDate->AddSubBlock(new Html('</br>')); $oFieldSetDate->AddSubBlock(new Html('</br>'));
$oRadioCustom = InputUIBlockFactory::MakeForInputWithLabel(Dict::Format('Core:BulkExport:DateTimeFormatCustom_Format', $sDateTimeFormat), "date_time_format", "custom", "radio_date_time_custom", "radio"); $sFormatInput = '<input type="text" size="15" name="custom_date_time_format" id="excel_custom_date_time_format" title="" value="'.htmlentities($sCustomDateTimeFormat, ENT_QUOTES, 'UTF-8').'"/>';
$oRadioCustom = InputUIBlockFactory::MakeForInputWithLabel(Dict::Format('UI:CSVImport:CustomDateTimeFormat', $sFormatInput), "date_time_format", "custom", "radio_date_time_custom", "radio");
$oRadioCustom->GetInput()->SetIsChecked($sDateTimeFormat !== (string)AttributeDateTime::GetFormat()); $oRadioCustom->GetInput()->SetIsChecked($sDateTimeFormat !== (string)AttributeDateTime::GetFormat());
$oRadioCustom->SetBeforeInput(false); $oRadioCustom->SetBeforeInput(false);
$oRadioCustom->GetInput()->AddCSSClass('ibo-input-checkbox'); $oRadioCustom->GetInput()->AddCSSClass('ibo-input-checkbox');

View File

@@ -26,27 +26,43 @@ var table{{ sListIDForVarSuffix }} = $('#{{ oUIBlock.GetId() }}').DataTable({
{% endif %} {% endif %}
drawCallback: function () { drawCallback: function () {
// Hiding pagination if only one page // 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(); $(this).closest('.dataTables_wrapper').find('.dataTables_paginate, .dataTables_info').hide();
} else { }
else
{
$(this).closest('.dataTables_wrapper').find('.dataTables_paginate, .dataTables_info').show(); $(this).closest('.dataTables_wrapper').find('.dataTables_paginate, .dataTables_info').show();
} }
}, },
createdRow: function( row, data, dataIndex ) { createdRow: function (row, data, dataIndex) {
if (data['@class'] !== undefined) { if (data['@class'] !== undefined)
{
$(row).addClass(data['@class']); $(row).addClass(data['@class']);
} }
}, },
}); });
if ($('#{{ oUIBlock.GetId() }}').find('thead').is(':visible')) {
{% if (oUIBlock.GetOption('bFullscreen')) %}
var myheight = $("#ibo-main-content").height()-$("#ibo-main-content")[0].scrollHeight+$("#{{ oUIBlock.GetId() }}").height();
if (myheight < 200)
{
myheight = 200;
};
$("#{{ oUIBlock.GetId() }}_wrapper").find(".dataTables_scrollBody").height(myheight);
{% endif %}
if ($('#{{ oUIBlock.GetId() }}').find('thead').is(':visible'))
{
table{{ sListIDForVarSuffix }}.columns.adjust().draw(); table{{ sListIDForVarSuffix }}.columns.adjust().draw();
} }
if(window.ResizeObserver){ if (window.ResizeObserver)
{
let oFromTable{{ sListIDForVarSuffix }}ResizeTimeout = null; let oFromTable{{ sListIDForVarSuffix }}ResizeTimeout = null;
const oFromTable{{ sListIDForVarSuffix }}Resize = new ResizeObserver(function(){ const oFromTable{{ sListIDForVarSuffix }}Resize = new ResizeObserver(function () {
clearTimeout(oFromTable{{ sListIDForVarSuffix }}ResizeTimeout); clearTimeout(oFromTable{{ sListIDForVarSuffix }}ResizeTimeout);
oFromTable{{ sListIDForVarSuffix }}ResizeTimeout = setTimeout(function(){ oFromTable{{ sListIDForVarSuffix }}ResizeTimeout = setTimeout(function () {
$('#{{ oUIBlock.GetId() }}').DataTable().columns.adjust(); $('#{{ oUIBlock.GetId() }}').DataTable().columns.adjust();
}, 120); }, 120);
}); });