N°3746 - Migrate modal to new UIBlock system

This commit is contained in:
acognet
2021-03-05 14:57:25 +01:00
parent a4d8fb0b4c
commit 5f217d75bb
5 changed files with 98 additions and 48 deletions

View File

@@ -1,20 +1,7 @@
<?php
/**
* Copyright (C) 2013-2019 Combodo SARL
*
* This file is part of iTop.
*
* iTop is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* iTop is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
/*
* @copyright Copyright (C) 2010-2021 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
*/
use Combodo\iTop\Application\UI\Base\Component\Button\ButtonUIBlockFactory;
@@ -1514,32 +1501,37 @@ JS
$sCancelButtonLabel = Dict::S('UI:Button:Cancel');
$oPage->add_ready_script(
<<<JS
<<<JS
$('#dashlet_creation_dlg').dialog({
width: 600,
modal: true,
title: '$sDialogTitle',
buttons: [
{ text: "$sOkButtonLabel", click: function() {
var oForm = $(this).find('form');
var sFormId = oForm.attr('id');
var oParams = null;
var aErrors = ValidateForm(sFormId, false);
if (aErrors.length == 0)
{
oParams = ReadFormParams(sFormId);
}
oParams.operation = 'add_dashlet';
var me = $(this);
$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', oParams, function(data) {
me.dialog( "close" );
me.remove();
$('body').append(data);
});
} },
{ text: "$sCancelButtonLabel", click: function() {
{ text: "$sCancelButtonLabel",
click: function() {
$(this).dialog( "close" ); $(this).remove();
} },
} ,
'class': 'ibo-button ibo-is-alternative ibo-is-neutral action cancel'
},
{ text: "$sOkButtonLabel",
click: function() {
var oForm = $(this).find('form');
var sFormId = oForm.attr('id');
var oParams = null;
var aErrors = ValidateForm(sFormId, false);
if (aErrors.length == 0)
{
oParams = ReadFormParams(sFormId);
}
oParams.operation = 'add_dashlet';
var me = $(this);
$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', oParams, function(data) {
me.dialog( "close" );
me.remove();
$('body').append(data);
});
},
'class': 'ibo-button ibo-is-regular ibo-is-primary action' }
],
close: function() { $(this).remove(); }
});

View File

@@ -167,3 +167,53 @@ $ibo-vendors-datatables--focus--border-color: $ibo-color-primary-600 !default;
@extend %ibo-font-ral-med-100;
}
}
.sort_order {
display: inline-flex;
width: 16px;
height: 12px;
}
.sort_none {
padding-right: 5px;
&:after {
font-family: "Font Awesome 5 Free";
font-weight: 600;
text-align: right;
content: '\f0dc';
color: $ibo-color-blue-grey-500;
float: right;
}
}
.sort_asc {
padding-right: 5px;
&:after {
font-family: "Font Awesome 5 Free";
font-weight: 600;
text-align: right;
content: '\f0d8';
color: $ibo-color-blue-grey-500;
float: right;
}
}
.sort_desc {
padding-right: 5px;
&:after {
font-family: "Font Awesome 5 Free";
font-weight: 600;
text-align: right;
content: '\f0d7';
color: $ibo-color-blue-grey-500;
float: right;
}
}
.sort_hidden {
display: none;
}

View File

@@ -659,13 +659,19 @@ class DataTableUIBlockFactory extends AbstractUIBlockFactory
$aColumnsDefinitions = [];
$aColumnDefinition = [];
if ($sSelectMode != ""){
$sSortCol = utils::ReadParam('sort_col', '', false, 'raw_data');
$sSortOrder = utils::ReadParam('sort_order', '', false, 'raw_data');
$sOrder = [];
if ($sSortCol != "") {
$sOrder[] = [$sSortCol, $sSortOrder];
}
if ($sSelectMode != "") {
$aColumnDefinition["width"] = "auto";
$aColumnDefinition["searchable"] = false;
$aColumnDefinition["sortable"] = false;
if ($sSelectMode != "single") {
$aColumnDefinition["title"] = "<span class=\"row_input\"><input type=\"checkbox\" onclick=\"checkAllDataTable('".$sTableId."',this.checked,'".$sListId."');\" class=\"checkAll\" id=\"field_".$sTableId."_check_all\" name=\"field_".$sTableId."_check_all\" title=\"".Dict::S('UI:SearchValue:CheckAll' )." / ".Dict::S('UI:SearchValue:UncheckAll')."\" /></span>";
} else{
$aColumnDefinition["title"] = "<span class=\"row_input\"><input type=\"checkbox\" onclick=\"checkAllDataTable('".$sTableId."',this.checked,'".$sListId."');\" class=\"checkAll\" id=\"field_".$sTableId."_check_all\" name=\"field_".$sTableId."_check_all\" title=\"".Dict::S('UI:SearchValue:CheckAll')." / ".Dict::S('UI:SearchValue:UncheckAll')."\" /></span>";
} else {
$aColumnDefinition["title"] = "";
}
$aColumnDefinition["type"] = "html";
@@ -749,7 +755,7 @@ class DataTableUIBlockFactory extends AbstractUIBlockFactory
]);
$aOptions =array_merge ($aOptions, [
$aOptions = array_merge($aOptions, [
"language" =>
[
"processing" => Dict::Format('UI:Datatables:Language:Processing'),
@@ -764,17 +770,19 @@ class DataTableUIBlockFactory extends AbstractUIBlockFactory
"first" => "<<",
"previous" => "<",
"next" => ">",
"last" => ">>"
"last" => ">>",
],
"aria" => [
"sortAscending" => Dict::Format('UI:Datatables:Language:Sort:Ascending'),
"sortDescending" => Dict::Format('UI:Datatables:Language:Sort:Descending')
"sortDescending" => Dict::Format('UI:Datatables:Language:Sort:Descending'),
],
],
"lengthMenu" => Dict::Format('Portal:Datatables:Language:DisplayLength:All'),
"dom" => "<'ibo-datatable-toolbar'pil>t<'ibo-datatable-toolbar'pil>",
"ordering"=>true,
"order" => [],
"scrollX" => true,
"scrollCollapse" => true,
"ordering" => true,
"order" => $sOrder,
"filter" => false,
"processing" => true,
"serverSide" => true,

View File

@@ -41,8 +41,8 @@
</div>
<div class="ui-dialog-buttonpane ui-widget-content ui-helper-clearfix">
<div class=" ui-dialog-buttonset">
<button type="button" class="ibo-button ibo-is-regular ibo-is-secondary " onclick="$('#datatable_dlg_{{ oUIBlock.GetTableId() }}').dialog('close')">&nbsp;{{ 'UI:Button:Cancel'|dict_s }}</button>
<button type="submit" class="ibo-button ibo-is-regular ibo-is-primary" onclick="$('#datatable_dlg_{{ oUIBlock.GetTableId() }}').DataTableSettings('onDlgOk'); ">&nbsp;{{ 'UI:Button:Ok'|dict_s }}</button>
<button type="button" class="ibo-button ibo-is-alternative ibo-is-neutral action cancel" onclick="$('#datatable_dlg_{{ oUIBlock.GetTableId() }}').dialog('close')">&nbsp;{{ 'UI:Button:Cancel'|dict_s }}</button>
<button type="submit" class="ibo-button ibo-is-regular ibo-is-primary action" onclick="$('#datatable_dlg_{{ oUIBlock.GetTableId() }}').DataTableSettings('onDlgOk'); ">&nbsp;{{ 'UI:Button:Ok'|dict_s }}</button>
</div>
</div>
</form>

View File

@@ -371,10 +371,10 @@ EOF
function InteractiveShell($sExpression, $sQueryId, $sFormat, $sFileName, $sMode)
{
if ($sMode == 'dialog') {
$oP = new AjaxPage();
$oP->add('<div id="interactive_export_dlg">');
$sExportBtnLabel = json_encode(Dict::S('UI:Button:Export'));
$sJSTitle = json_encode(htmlentities(utils::ReadParam('dialog_title', '', false, 'raw_data'), ENT_QUOTES, 'UTF-8'));
$oP = new AjaxPage($sJSTitle);
$oP->add('<div id="interactive_export_dlg">');
$oP->add_ready_script(
<<<EOF
$('#interactive_export_dlg').dialog({