diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index 338af8241..c0b814d3b 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -1050,15 +1050,12 @@ HTML $sClass = get_class($this); $iKey = $this->GetKey(); - if ($sMode === static::ENUM_OBJECT_MODE_VIEW) - { + if ($sMode === static::ENUM_OBJECT_MODE_VIEW) { // The concurrent access lock makes sense only for already existing objects $LockEnabled = MetaModel::GetConfig()->Get('concurrent_lock_enabled'); - if ($LockEnabled) - { + if ($LockEnabled) { $aLockInfo = iTopOwnershipLock::IsLocked($sClass, $iKey); - if ($aLockInfo['locked'] === true && $aLockInfo['owner']->GetKey() == UserRights::GetUserId() && $bBlockReentrance === false) - { + if ($aLockInfo['locked'] === true && $aLockInfo['owner']->GetKey() == UserRights::GetUserId() && $bBlockReentrance === false) { // If the object is locked by the current user, it's worth trying again, since // the lock may be released by 'onunload' which is called AFTER loading the current page. //$bTryAgain = $oOwner->GetKey() == UserRights::GetUserId(); @@ -1072,6 +1069,9 @@ HTML // Object's details $oObjectDetails = ObjectFactory::MakeDetails($this); + if ($oPage->IsPrintableVersion()) { + $oObjectDetails->SetIsHeaderVisibleOnScroll(false); + } // Note: DisplayBareHeader is called before adding $oObjectDetails to the page, so it can inject HTML before it through $oPage. /** @var \iTopWebPage $oPage */ @@ -2057,10 +2057,8 @@ HTML; $sHours = ""; $sMinutes = ""; $sSeconds = ""; - $sHidden = ""; - $sHTMLValue = Dict::Format('UI:DurationForm_Days_Hours_Minutes_Seconds', $sDays, $sHours, $sMinutes, - $sSeconds).$sHidden." ".$sValidationSpan.$sReloadSpan; + $sHidden = ""; + $sHTMLValue = Dict::Format('UI:DurationForm_Days_Hours_Minutes_Seconds', $sDays, $sHours, $sMinutes, $sSeconds).$sHidden." ".$sValidationSpan.$sReloadSpan; $oPage->add_ready_script("$('#{$iId}').on('update', function(evt, sFormId) { return ToggleDurationField('$iId'); });"); break; @@ -4699,7 +4697,9 @@ HTML $aFieldsMap[$sAttCode] = $sInputId; - $oFieldset = FieldSetUIBlockFactory::MakeStandard($sAttLabel); + $sCommentAsHtml = ($sComment != '') ? '
'.$sComment.'
' : ''; + + $oFieldset = FieldSetUIBlockFactory::MakeStandard($sAttLabel.$sCommentAsHtml); $oPage->AddSubBlock($oFieldset); $oDivField = FieldUIBlockFactory::MakeLarge(""); @@ -4713,10 +4713,9 @@ HTML $oDivField->AddDataAttribute("attribute-flag-must-prompt", $sAttMetaDataFlagMustPrompt); $oDivField->AddDataAttribute("attribute-flag-slave", false); $oFieldset->AddSubBlock($oDivField); - - $sCommentAsHtml = ($sComment != '') ? ''.$sComment.'
' : ''; + //$oDivField->SetComments($sComment); $sFieldAsHtml = self::GetFormElementForField($oPage, $sClass, $sAttCode, $oAttDef, $sValue, $sDisplayValue, $sInputId, '', $iFlags, $aArgs); - $sHTMLValue = $sCommentAsHtml.$sFieldAsHtml; + $sHTMLValue = $sFieldAsHtml; $oDivField->AddSubBlock(new Html($sHTMLValue)); } } diff --git a/js/dataTables.pipeline.js b/js/dataTables.pipeline.js index 43dd28d4a..68984de28 100644 --- a/js/dataTables.pipeline.js +++ b/js/dataTables.pipeline.js @@ -46,14 +46,6 @@ $.fn.dataTable.pipeline = function (opts, initJson) { } var requestEnd = requestStart+requestLength; - //Manage case requestLength=-1 => all the row are display - if (requestLength == -1) { - requestLength = cacheLastJson.recordsTotal; - if (cacheLower != 0 || cacheLastJson.recordsTotal > cacheUpper) { - //new server request is mandatory - ajax = true; - } - } if (request.draw == 1 && initJson != null) { //do nothing cacheLastJson = $.extend(true, {}, initJson); @@ -76,15 +68,24 @@ $.fn.dataTable.pipeline = function (opts, initJson) { ajax = true; } + //Manage case requestLength=-1 => all the row are display + if (requestLength == -1) { + requestLength = cacheLastJson.recordsTotal; + if (cacheLower != 0 || cacheLastJson.recordsTotal > cacheUpper) { + //new server request is mandatory + ajax = true; + } + } + // Store the request for checking next time around - cacheLastRequest = $.extend( true, {}, request ); + cacheLastRequest = $.extend(true, {}, request); - if ( ajax ) { + if (ajax) { // Need data from the server - if ( requestStart < cacheLower ) { - requestStart = requestStart - (requestLength*(conf.pages-1)); + if (requestStart < cacheLower) { + requestStart = requestStart-(requestLength * (conf.pages-1)); - if ( requestStart < 0 ) { + if (requestStart < 0) { requestStart = 0; } } diff --git a/sources/application/UI/Base/Component/DataTable/DataTable.php b/sources/application/UI/Base/Component/DataTable/DataTable.php index b36e67b30..f77f0e57e 100644 --- a/sources/application/UI/Base/Component/DataTable/DataTable.php +++ b/sources/application/UI/Base/Component/DataTable/DataTable.php @@ -184,8 +184,18 @@ class DataTable extends UIContentBlock $this->aOptions = $aOptions; } + /** + * @param string $sName + * @param mixed $sValue + */ + public function AddOption($sName, $sValue): void + { + $this->aOptions[$sName] = $sValue; + } + /** * Get $aInitDisplayData as a JSON This is data of first page + * * @return string */ public function GetJsonInitDisplayData(): string diff --git a/sources/application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php b/sources/application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php index 91d7efad9..cecdca883 100644 --- a/sources/application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php +++ b/sources/application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php @@ -85,6 +85,10 @@ class DataTableUIBlockFactory extends AbstractUIBlockFactory public static function MakeForObject(WebPage $oPage, string $sListId, DBObjectSet $oSet, $aExtraParams = array()) { $oDataTable = DataTableUIBlockFactory::MakeForRenderingObject($sListId, $oSet, $aExtraParams); + if ($oPage->IsPrintableVersion()) { + $oDataTable->AddOption('printVersion', true); + } + return self::RenderDataTable($oDataTable, 'listInObject', $oPage, $sListId, $oSet, $aExtraParams); } diff --git a/sources/application/WebPage/iTopWebPage.php b/sources/application/WebPage/iTopWebPage.php index 9d259e951..95a0895a1 100644 --- a/sources/application/WebPage/iTopWebPage.php +++ b/sources/application/WebPage/iTopWebPage.php @@ -132,9 +132,8 @@ class iTopWebPage extends NiceWebPage implements iTabbedPage $this->add_header("Content-type: text/html; charset=".self::PAGES_CHARSET); $this->no_cache(); $this->add_xframe_options(); - if (!$this->IsPrintableVersion()) { - $this->PrepareLayout(); - } else { + $this->PrepareLayout(); + if ($this->IsPrintableVersion()) { $oPrintHeader = $this->OutputPrintable(); $this->AddUiBlock($oPrintHeader); } @@ -362,21 +361,21 @@ class iTopWebPage extends NiceWebPage implements iTabbedPage } JS ); - - // TODO 3.0.0: Change CSS class and extract this in backoffice/toolbox.js - // Make image attributes zoomable - $this->add_ready_script( - <<IsPrintableVersion()) { + // TODO 3.0.0: Change CSS class and extract this in backoffice/toolbox.js + // Make image attributes zoomable + $this->add_ready_script( + <<add_ready_script( - <<< JS + // TODO 3.0.0: What is this for? + $this->add_ready_script( + <<< JS PrepareWidgets(); // Make sortable, everything that claims to be sortable @@ -450,6 +449,7 @@ JS } JS ); + } } diff --git a/templates/base/components/datatable/layout.ready.js.twig b/templates/base/components/datatable/layout.ready.js.twig index c447a5550..d4c2c6dee 100644 --- a/templates/base/components/datatable/layout.ready.js.twig +++ b/templates/base/components/datatable/layout.ready.js.twig @@ -43,30 +43,38 @@ var oTable{{ sListIDForVarSuffix }} = $('#{{ oUIBlock.GetId() }}').DataTable({ }, scrollX: true, {% if oUIBlock.GetOption('sMaxHeight') is not empty %} - scrollY: "{{ oUIBlock.GetOption('sMaxHeight') }}", + scrollY: "{{ oUIBlock.GetOption('sMaxHeight') }}", {% endif %} scrollCollapse: true, + {% if oUIBlock.GetOption('printVersion') is not empty %} + paging: false, + info: false, + {% 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>>", {% if( oUIBlock.GetOption("sort")[0] is defined ) %} - order: [[{{ oUIBlock.GetOptions()["sort"][0] }}, '{{ oUIBlock.GetOptions()["sort"][1] }}']], + order: [[{{ oUIBlock.GetOptions()["sort"][0] }}, '{{ oUIBlock.GetOptions()["sort"][1] }}']], {% else %} - order: [], + order: [], {% endif %} ordering: true, {% if oUIBlock.GetOption("select_mode") is not empty %} - select: { - style: "{% if oUIBlock.GetOption("select_mode") == "multiple" %}multi{% else %}single{% endif %}", - info: false - }, - rowCallback: function (oRow, oData) { - if ($(this).closest('.ibo-panel--body').find('[name=selectionMode]').val() === "negative") { - if (oSelectedItems{{ sListId }}.indexOf(oData.id) === -1) { - this.api().row($(oRow)).select(); - // $(oRow).addClass('selected'); - $(oRow).find('td:first-child input').prop('checked', true); - } - } else { + select: { + style: "{% if oUIBlock.GetOption("select_mode") == "multiple" %}multi{% else %}single{% endif %}", + info: false + }, + rowCallback: function (oRow, oData) { + if ($(this).closest('.ibo-panel--body').find('[name=selectionMode]').val() === "negative") + { + if (oSelectedItems{{ sListId }}.indexOf(oData.id) === -1) + { + this.api().row($(oRow)).select(); + // $(oRow).addClass('selected'); + $(oRow).find('td:first-child input').prop('checked', true); + } + } + else + { if (oSelectedItems{{ sListId }}.indexOf(oData.id) > -1) { this.api().row($(oRow)).select(); $(oRow).find('td:first-child input').prop('checked', true); diff --git a/templates/base/layouts/tab-container/layout.js.twig b/templates/base/layouts/tab-container/layout.js.twig index 7c93d4ef8..2853c9329 100644 --- a/templates/base/layouts/tab-container/layout.js.twig +++ b/templates/base/layouts/tab-container/layout.js.twig @@ -4,15 +4,34 @@ {% if not aPage.isPrintable %} $('#{{ oUIBlock.GetId() }}').tab_container({'remote_tab_load_dict': '{{ 'UIBlock:TabContainer:RemoteTabLoad'|dict_s|escape('js') }}'}); {% else %} + +function refresh_status() { + var loaded = true; + $('#{{ oUIBlock.GetId() }}').find('.ibo-tab-container--tab-container').each(function (i, elt) { + if ($(elt).attr('data-status') != 'loaded') + { + loaded = false; + } + }); + if (loaded) + { + $('#{{ oUIBlock.GetId() }}').attr('data-status', 'loaded'); + } +} + {% for oTab in oUIBlock.GetSubBlocks() %} oHiddeableChapters['tab_{{ oTab.GetId()|sanitize(constant('utils::ENUM_SANITIZATION_FILTER_ELEMENT_IDENTIFIER')) }}'] = '{{ oTab.GetTitle()|escape('js') }}'; {% if oTab.GetType() == constant('TabManager::ENUM_TAB_TYPE_AJAX') %} -$.post('{{ oTab.GetUrl()|raw }}', {printable: '1'}, function (data) -{ +$.post('{{ oTab.GetUrl()|raw }}', {printable: '1'}, function (data) { $('#tab_{{ oTab.GetId()|sanitize(constant('utils::ENUM_SANITIZATION_FILTER_ELEMENT_IDENTIFIER')) }} > .printable-tab-content').append(data); + $('#tab_{{ oTab.GetId()|sanitize(constant('utils::ENUM_SANITIZATION_FILTER_ELEMENT_IDENTIFIER')) }}').attr('data-status', 'loaded'); + refresh_status(); }); +{% else %} +$('#tab_{{ oTab.GetId()|sanitize(constant('utils::ENUM_SANITIZATION_FILTER_ELEMENT_IDENTIFIER')) }}').attr('data-status', 'loaded'); {% endif %} {% endfor %} +refresh_status(); {% endif %} diff --git a/templates/pages/backoffice/itopwebpage/layout.html.twig b/templates/pages/backoffice/itopwebpage/layout.html.twig index 8924d5735..9aa4ef07d 100644 --- a/templates/pages/backoffice/itopwebpage/layout.html.twig +++ b/templates/pages/backoffice/itopwebpage/layout.html.twig @@ -2,19 +2,6 @@ {# @license http://opensource.org/licenses/AGPL-3.0 #} {% extends "pages/backoffice/nicewebpage/layout.html.twig" %} {% block iboPageBodyHtml %} - {% if aPage.isPrintable %} -
-
- {{ render_block(aLayouts.oPageContent, {aPage: aPage, aLayouts: aLayouts}) }} - - {# TODO: Remove this when modal development is done #} -
{{ aPage.sDeferredContent|raw }}
- - - -
-
- {% else %} {{ render_block(aLayouts.oNavigationMenu, {aPage: aPage}) }}
@@ -30,7 +17,6 @@
{{ 'UI:DisconnectedDlgMessage'|dict_s }}
- {% endif %} {% endblock %} {% block iboDeferredBlocks %} diff --git a/templates/pages/backoffice/webpage/layout.html.twig b/templates/pages/backoffice/webpage/layout.html.twig index e23cefc9b..cfbc31072 100644 --- a/templates/pages/backoffice/webpage/layout.html.twig +++ b/templates/pages/backoffice/webpage/layout.html.twig @@ -49,11 +49,15 @@ {% endblock %} -{% block iboPageBodyHtml %} -
- {{ render_block(oLayout, {aPage: aPage}) }} -
-{% endblock %} +{% if aPage.isPrintable %} +
{% endif %} + {% block iboPageBodyHtml %} + +
+ {{ render_block(oLayout, {aPage: aPage}) }} +
+ {% endblock %} + {% if aPage.isPrintable %}
{% endif %} {% block iboDeferredBlocks %} {% for oBlock in aDeferredBlocks %} @@ -62,8 +66,8 @@ {% endblock %} {% if aPage.aJsFiles is not empty %}