mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
N°4230 - Printable version issues
This commit is contained in:
@@ -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 = "<input class=\"ibo-input ibo-input-duration\" title=\"$sHelpText\" type=\"text\" size=\"2\" name=\"attr_{$sFieldPrefix}{$sAttCode}[h]{$sNameSuffix}\" value=\"{$aVal['hours']}\" id=\"{$iId}_h\"/>";
|
||||
$sMinutes = "<input class=\"ibo-input ibo-input-duration\" title=\"$sHelpText\" type=\"text\" size=\"2\" name=\"attr_{$sFieldPrefix}{$sAttCode}[m]{$sNameSuffix}\" value=\"{$aVal['minutes']}\" id=\"{$iId}_m\"/>";
|
||||
$sSeconds = "<input class=\"ibo-input ibo-input-duration\" title=\"$sHelpText\" type=\"text\" size=\"2\" name=\"attr_{$sFieldPrefix}{$sAttCode}[s]{$sNameSuffix}\" value=\"{$aVal['seconds']}\" id=\"{$iId}_s\"/>";
|
||||
$sHidden = "<input type=\"hidden\" id=\"{$iId}\" value=\"".htmlentities($value, ENT_QUOTES,
|
||||
'UTF-8')."\"/>";
|
||||
$sHTMLValue = Dict::Format('UI:DurationForm_Days_Hours_Minutes_Seconds', $sDays, $sHours, $sMinutes,
|
||||
$sSeconds).$sHidden." ".$sValidationSpan.$sReloadSpan;
|
||||
$sHidden = "<input type=\"hidden\" id=\"{$iId}\" value=\"".htmlentities($value, ENT_QUOTES, 'UTF-8')."\"/>";
|
||||
$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 != '') ? ' <div class="ibo-field--comments">'.$sComment.'</div>' : '';
|
||||
|
||||
$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 != '') ? '<span>'.$sComment.'</span><br/>' : '';
|
||||
//$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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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(
|
||||
<<<JS
|
||||
if (!$this->IsPrintableVersion()) {
|
||||
// TODO 3.0.0: Change CSS class and extract this in backoffice/toolbox.js
|
||||
// Make image attributes zoomable
|
||||
$this->add_ready_script(
|
||||
<<<JS
|
||||
$('.ibo-input-image--image-view img').each(function(){
|
||||
$(this).attr('href', $(this).attr('src'))
|
||||
})
|
||||
.magnificPopup({type: 'image', closeOnContentClick: true });
|
||||
JS
|
||||
);
|
||||
);
|
||||
|
||||
// TODO 3.0.0: What is this for?
|
||||
$this->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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 %}
|
||||
|
||||
|
||||
|
||||
@@ -2,19 +2,6 @@
|
||||
{# @license http://opensource.org/licenses/AGPL-3.0 #}
|
||||
{% extends "pages/backoffice/nicewebpage/layout.html.twig" %}
|
||||
{% block iboPageBodyHtml %}
|
||||
{% if aPage.isPrintable %}
|
||||
<div class="printable-content" style="width: 27.7cm;">
|
||||
<div id="ibo-page-container">
|
||||
{{ render_block(aLayouts.oPageContent, {aPage: aPage, aLayouts: aLayouts}) }}
|
||||
|
||||
{# TODO: Remove this when modal development is done #}
|
||||
<div id="at_the_end">{{ aPage.sDeferredContent|raw }}</div>
|
||||
<div style="display:none" title="ex2" id="ex2">Please wait...</div>
|
||||
<div style="display:none" title="dialog" id="ModalDlg"></div>
|
||||
<div style="display:none" id="ajax_content"></div>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
{{ render_block(aLayouts.oNavigationMenu, {aPage: aPage}) }}
|
||||
<div id="ibo-page-container">
|
||||
<div id="ibo-top-container">
|
||||
@@ -30,7 +17,6 @@
|
||||
<div style="display:none" id="ajax_content"></div>
|
||||
<div class="ibo-is-hidden" id="ibo-user-disconnected-dialog">{{ 'UI:DisconnectedDlgMessage'|dict_s }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block iboDeferredBlocks %}
|
||||
|
||||
@@ -49,11 +49,15 @@
|
||||
{% endblock %}
|
||||
</head>
|
||||
<body data-gui-type="backoffice">
|
||||
{% block iboPageBodyHtml %}
|
||||
<div id="ibo-page-container">
|
||||
{{ render_block(oLayout, {aPage: aPage}) }}
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% if aPage.isPrintable %}
|
||||
<div class="printable-content" style="width: 27.7cm;"> {% endif %}
|
||||
{% block iboPageBodyHtml %}
|
||||
|
||||
<div id="ibo-page-container">
|
||||
{{ render_block(oLayout, {aPage: aPage}) }}
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% if aPage.isPrintable %}</div> {% endif %}
|
||||
|
||||
{% block iboDeferredBlocks %}
|
||||
{% for oBlock in aDeferredBlocks %}
|
||||
@@ -62,8 +66,8 @@
|
||||
{% endblock %}
|
||||
{% if aPage.aJsFiles is not empty %}
|
||||
<script type="text/javascript">
|
||||
var aListJsFiles = [];
|
||||
{% for sJsFile in aPage.aJsFiles %}
|
||||
var aListJsFiles = [];
|
||||
{% for sJsFile in aPage.aJsFiles %}
|
||||
aListJsFiles.push("{{ sJsFile|raw }}");
|
||||
{% endfor %}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user