Skip to content

Commit

Permalink
Merge pull request #232 from AntoineLemarchand/main
Browse files Browse the repository at this point in the history
minor fixes
  • Loading branch information
minzords authored Mar 13, 2024
2 parents 23f83cc + ba976c3 commit 5c6778b
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 39 deletions.
4 changes: 2 additions & 2 deletions inc/oidc.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ static function addUserData($user_array, $id)
*/
static function showFormUserConfig()
{
global $DB;
global $DB, $CFG_GLPI;

if (isset($_POST["config"])) {
Html::redirect("auth.oidc.php");
Expand Down Expand Up @@ -298,7 +298,7 @@ static function showFormUserConfig()
}

$form = [
'action' => '/front/auth.oidc_profile.php',
'action' => $CFG_GLPI['root_doc'] . '/front/auth.oidc_profile.php',
'buttons' => [
[
'type' => 'submit',
Expand Down
8 changes: 5 additions & 3 deletions inc/user.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -737,8 +737,10 @@ function prepareInputForUpdate($input) {
global $CFG_GLPI;

// avoid xss (picture name is autogenerated when uploading/synchronising the picture)
$picture = json_decode(stripslashes($input['picture']), true)[0];
unset($input['picture']);
if (isset($input['picture']) && !empty($input['picture'])) {
$picture = json_decode(stripslashes($input['picture']), true)[0];
unset($input['picture']);
}

//picture manually uploaded by user
if (isset($input["_blank_picture"]) && $input["_blank_picture"]) {
Expand Down Expand Up @@ -2118,7 +2120,7 @@ function () {
$defaultEmailTitle = __('Default email');
foreach($emails as $email) {
$emailsValues[] = [
"<input type='radio' class='form-check-input mx-1' title='{$defaultEmailTitle}' name='_default_email' value='".$email['id']."' ".($email['is_default'] ? 'checked' : '').">",
"<input type='radio' class='form-check mx-1' title='{$defaultEmailTitle}' name='_default_email' value='".$email['id']."' ".($email['is_default'] ? 'checked' : '').">",
"<input type='email' class='form-control' name='_useremails[{$email['id']}]' value='".$email['email']."'>",
];
}
Expand Down
2 changes: 1 addition & 1 deletion templates/dashboard/widget.twig
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{% set rand = random() %}
<div class="fw-bold fs-6 {{color ? "text-" ~ color : ''}}">{{title}}</div>
<div class="ct-chart ct-golden-section w-100" style="max-height: 20rem" id="widgetFor{{title|slug}}_{{rand}}"></div>
<link rel="stylesheet" href="/~antoine/itsm-ng2.0/node_modules/chartist/dist/index.css">
<link rel="stylesheet" href="{{root_doc}}/node_modules/chartist/dist/index.css">
<script>
$(document).ready(function() {
var chart = new Chartist.{{type|capitalize ~ 'Chart'}}("#widgetFor{{title|slug}}_{{rand}}",
Expand Down
42 changes: 14 additions & 28 deletions templates/item.twig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="grid-stack border" id="ContentForTabs"></div>
<div class='d-none' id="hidden_gridStack_items">
{% for key, tab in tabs %}
<div class="grid-stack-item" id="ContentFor{{key|slug}}" gs-h='6' gs-min-w='6' data-gs-value="test">
<div class="grid-stack-item" id="ContentFor{{key|slug}}" gs-min-w='6' data-gs-value="test">
<div class="card grid-stack-item-content">
<div>
<div class="card-header position-sticky">{{tab['title']|raw}}</div>
Expand Down Expand Up @@ -31,8 +31,9 @@
// Update the width of widgets based on the number of widgets present
function updateWidgetWidth() {
const columnWidgets = grid.getGridItems();
const targetWidth = columnWidgets.length === 1 ? 12 : 6; // Full width for single widget, else half
grid.update(columnWidgets[0], { w: targetWidth });
if (columnWidgets.length === 1) {
grid.update(columnWidgets[0], { w: 12 });
}
grid.compact();
}
Expand Down Expand Up @@ -94,7 +95,7 @@
grid.removeWidget(element[0], false);
element.detach().prependTo('#hidden_gridStack_items');
setTimeout(() => {
element.removeAttr('gs-x gs-y').attr({'gs-w': 6, 'gs-min-w': 6});
element.removeAttr('gs-x gs-y');
}, 300);
}
Expand Down Expand Up @@ -141,32 +142,17 @@
}
}
async function initTable() {
initCheckbox();
for (option of options) {
await moveAndMakeWidget(option);
}
updateWidgetWidth();
}
// Document ready function
$(document).ready(() => {
// Handle widgets based on whether there's only one tab or more
async function handleInitialWidgets() {
const savedLayout = {{selectedTabs|json_encode|raw}} ?? [];
let widgetName = '';
if ({{tabs | length == 1 ? 1 : 0}}) {
widgetName = $('#hidden_gridStack_items > div').first().attr('id').replace('ContentFor', '');
moveAndMakeWidget(widgetName).then(() => {
if ({{(tabs|length == 1 or selectedTabs|length == 0) ? 1 : 0}}) {
updateWidgetWidth()
grid.setStatic(true);
}
});
} else {
$('.dropdown-menu a').each(async (i, e) => {
if ($(e).children('input').prop('checked')) {
widgetName = $(e).attr('data-value');
await moveAndMakeWidget(widgetName)
}
});
}
}
initCheckbox();
handleInitialWidgets();
initTable();
});
// Dropdown menu item click handlers
Expand Down
6 changes: 3 additions & 3 deletions templates/macros/input.twig
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,10 @@
{% endif %}
{% endfor %}
{% for name, value in inputs|filter((v, k) => k != 'id') %}
{% if name and value.title is not defined %}
{{value}}
{% if value.title is not defined %}
{{value|raw}}
{% elseif name %}
{{value.title}}
{{value.title|raw}}
{% endif %}
{% endfor %}
</td>
Expand Down
8 changes: 6 additions & 2 deletions templates/macros/wrappedInput.twig
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@
<div class="d-flex justify-content-between align-items-center input-group my-1">
{% endif %}
{% if input.before %}
<div class="form-text mx-2">{{input.before | raw}}</div>
<div class="input-group-text">
{{input.before|raw}}
</div>
{% endif %}
{% if input.type %}
{{ inputMacro.input(attributes, root_doc) }}
{% else %}
{{ input.content|raw }}
{% endif %}
{% if input.after %}
{{input.after|raw}}
<div class="input-group-text">
{{input.after|raw}}
</div>
{% endif %}
{% for action in input.actions %}
<button type="button" class="btn border" onclick="{{action.onClick}}">
Expand Down

0 comments on commit 5c6778b

Please sign in to comment.