Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Massive action + massive performance repair #206

Merged
merged 33 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
443b507
fix(preference.php): remove accessibility menu on preferences
AntoineLemarchand Feb 5, 2024
6d26ac7
feat(massiveaction.php): subform for appliance and calendar
AntoineLemarchand Feb 5, 2024
ac1426a
feat(cartridgeite.class.php): form
AntoineLemarchand Feb 5, 2024
1d9aea2
feat(change_ticket.class.php) : form
AntoineLemarchand Feb 5, 2024
2d25f0a
feat(*::showMassiveActionForm): forms
AntoineLemarchand Feb 5, 2024
e3bfe2b
feat(commonitilobjec.class.php): massive action form
AntoineLemarchand Feb 5, 2024
f52f0c7
feat(commontreedropdown.class.php): massive action form
AntoineLemarchand Feb 5, 2024
7bc3022
fix(header.twig): global search href
AntoineLemarchand Feb 5, 2024
d3442bd
feat(projecttask.class.php): form
AntoineLemarchand Feb 5, 2024
0bc97db
feat(projecttask_ticket.class.php): subform for ticket
AntoineLemarchand Feb 6, 2024
f928fd2
feat(itil_project.class.php): subform for ticket
AntoineLemarchand Feb 6, 2024
098aba6
feat(problem_ticket.class.php): form for ticket
AntoineLemarchand Feb 6, 2024
7a2a6cc
refactor(item_devices.class.php): form
AntoineLemarchand Feb 6, 2024
0aeb22f
fix(item.twig): conditionnal tab load for performance
AntoineLemarchand Feb 7, 2024
b42965e
feat(dropdownMassiveActionOs.php): massive action for os edit
AntoineLemarchand Feb 7, 2024
e513da6
Merge branch 'itsmng:main' into csrf
AntoineLemarchand Feb 7, 2024
281691a
fix(table.twig): export button in ajax
AntoineLemarchand Feb 7, 2024
0a33f4c
fix(html.class.php): massive action on ajax tables
AntoineLemarchand Feb 7, 2024
6e67e56
feat(item_softwareversion.class.php): massive action form
AntoineLemarchand Feb 8, 2024
bab57c9
feat(itwm_softwareversion.class.php): licence table
AntoineLemarchand Feb 8, 2024
887c6bb
feat(item_softwarelicense.class.php): massive action form
AntoineLemarchand Feb 8, 2024
5d71394
feat(document.class.php): add document massive action form
AntoineLemarchand Feb 8, 2024
47a2fd0
feat(document_item.class.php): table for item
AntoineLemarchand Feb 8, 2024
b2d7cfd
feat(document_item.class.php): add existing document for item
AntoineLemarchand Feb 8, 2024
af95e42
feat(massiveaction.class.php): add comment and amend note massive action
AntoineLemarchand Feb 8, 2024
4fe15a6
feat(lock.class.php): unlock component massive action
AntoineLemarchand Feb 8, 2024
2f00349
fix(commonglpi.class.php): unique action modal
AntoineLemarchand Feb 8, 2024
51541dd
feat(itsm2.scss): massive action styling
AntoineLemarchand Feb 8, 2024
f37eefe
feat(itsm2.scss): massive action styling
AntoineLemarchand Feb 8, 2024
c9aad59
feat(knowbase_item.class.php): knowbase table for item
AntoineLemarchand Feb 8, 2024
ea2d257
fix(item.twig): widget loading with ajax reload
AntoineLemarchand Feb 8, 2024
bfcf80b
Merge pull request #1 from AntoineLemarchand/csrf
AntoineLemarchand Feb 8, 2024
04becb9
fix(table.twig): prevent multi activation of table
AntoineLemarchand Feb 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 16 additions & 47 deletions ajax/dropdownAllItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,61 +39,30 @@

// Make a select box
if ($_POST["idtable"] && class_exists($_POST["idtable"])) {
// Link to user for search only > normal users
$link = "getDropdownValue.php";

if ($_POST["idtable"] == 'User') {
$link = "getDropdownUsers.php";
}

$rand = mt_rand();
if (isset($_POST['rand'])) {
$rand = $_POST['rand'];
}

$field_id = Html::cleanId("dropdown_".$_POST["name"].$rand);

$p = [
'value' => 0,
'valuename' => Dropdown::EMPTY_VALUE,
'itemtype' => $_POST["idtable"],
'display_emptychoice' => true,
'displaywith' => ['otherserial', 'serial'],
'_idor_token' => Session::getNewIDORToken($_POST["idtable"]),
];
if (isset($_POST['value'])) {
$p['value'] = $_POST['value'];
}
if (isset($_POST['entity_restrict'])) {
$p['entity_restrict'] = $_POST['entity_restrict'];
$entity_restrict = $_POST['entity_restrict'];
}
if (isset($_POST['condition'])) {
$p['condition'] = $_POST['condition'];
$condition = $_POST['condition'];
}

$isDevice = strpos($_POST["idtable"], "Device") === 0;
$values = getOptionForItems($_POST['idtable'], ($condition ?? []) + (isset($entity_restrict)
? ['entities_id' => $_POST['entity_restrict']] : []), true, $isDevice);

if (isset($_POST['used'])) {
$_POST['used'] = Toolbox::jsonDecode($_POST['used'], true);
}
if (isset($_POST['used'][$_POST['idtable']])) {
$p['used'] = $_POST['used'][$_POST['idtable']];
}
if (isset($_POST['width'])) {
$p['width'] = $_POST['width'];
}

echo Html::jsAjaxDropdown($_POST["name"], $field_id,
$CFG_GLPI['root_doc']."/ajax/".$link,
$p);

if (!empty($_POST['showItemSpecificity'])) {
$params = ['items_id' => '__VALUE__',
'itemtype' => $_POST["idtable"]];
if (isset($_POST['entity_restrict'])) {
$params['entity_restrict'] = $_POST['entity_restrict'];
$used = $_POST['used'][$_POST['idtable']];
if (isset($used)) {
foreach($used as $usedId) {
if (isset($values[$usedId])) {
unset($values[$usedId]);
}
}
}

Ajax::updateItemOnSelectEvent($field_id, "showItemSpecificity_".$_POST["name"]."$rand",
$_POST['showItemSpecificity'], $params);

echo "<br><span id='showItemSpecificity_".$_POST["name"]."$rand'>&nbsp;</span>\n";
}

echo json_encode($values);
}
30 changes: 19 additions & 11 deletions ajax/dropdownItilActors.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
$withemail = isset($_POST['allow_email']) && filter_var($_POST['allow_email'], FILTER_VALIDATE_BOOLEAN);

$ticket = new Ticket();
$ticket->getFromDB($_POST['ticketId']);
if (isset($_POST['ticketId']) && $_POST['ticketId'] > 0) {
$ticket->getFromDB($_POST['ticketId']);
}
if ($item = getItemForItemtype($_POST["itemtype"])) {
switch ($_POST["type"]) {
case "user" :
Expand All @@ -58,12 +60,15 @@
}
}

$forbiddenActors = $ticket->getUsers($_POST['actorTypeId']);
$forbiddenActors = array_filter($forbiddenActors, function($actor) {
return isset($actor['users_id']);
});
$options = getOptionsForUsers($right);
$forbiddenActors = [];
if (isset($_POST['actorTypeId'])) {
$forbiddenActors = $ticket->getUsers($_POST['actorTypeId']);
$forbiddenActors = array_filter($forbiddenActors, function($actor) {
return isset($actor['users_id']);
});
}
$forbiddenActors = array_column($forbiddenActors, 'users_id');
$options = getOptionsForUsers($right);
$options = array_diff_key($options, array_combine($forbiddenActors, $forbiddenActors));
echo json_encode($options);

Expand All @@ -82,12 +87,15 @@
$cond['entities_id'] = $_POST['entity_restrict'];
}

$forbiddenActors = $ticket->getGroups($_POST['actorTypeId']);
$forbiddenActors = array_filter($forbiddenActors, function($actor) {
return isset($actor['groups_id']);
});
$options = getOptionForItems('Group');
$forbiddenActors = [];
if (isset($_POST['actorTypeId'])) {
$forbiddenActors = $ticket->getUsers($_POST['actorTypeId']);
$forbiddenActors = array_filter($forbiddenActors, function($actor) {
return isset($actor['users_id']);
});
}
$forbiddenActors = array_column($forbiddenActors, 'groups_id');
$options = getOptionForItems('Group');
$options = array_diff_key($options, array_combine($forbiddenActors, $forbiddenActors));
echo json_encode($options);
break;
Expand Down
10 changes: 5 additions & 5 deletions ajax/dropdownMassiveActionAddActor.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
Session::checkRight('ticket', UPDATE);

if ($_POST["actortype"] > 0) {
$ticket = new Ticket();
$rand = mt_rand();
$ticket->showActorAddForm($_POST["actortype"], $rand, $_SESSION['glpiactive_entity'], [],
true, false, false);
echo "&nbsp;<input type='submit' name='add_actor' class='submit' value=\""._sx('button', 'Add')."\">";
$types = ['user' => User::getTypeName(1)];
if ($withgroup) {
$types['group'] = Group::getTypeName(1);
}
echo json_encode($types);
}
4 changes: 1 addition & 3 deletions ajax/dropdownMassiveActionOs.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,4 @@
exit();
}

$item::dropdown();
echo "<br/><input type='submit' name='update' value=\""._sx('button', 'Update')."\" class='submit'>";
echo "<br/><input type='submit' name='clone' value=\""._sx('button', 'Clone')."\" class='submit'>";
echo json_encode(['name' => $item::getForeignKeyField(), 'options' => getOptionForItems($item::class)]);
19 changes: 10 additions & 9 deletions ajax/dropdownProjectTaskTicket.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,19 @@
$condition['glpi_projecttasks.projects_id'] = $_POST['projects_id'];
}

$p = ['itemtype' => ProjectTask::getType(),
'entity_restrict' => $_POST['entity_restrict'],
'myname' => $_POST["myname"],
'condition' => $condition,
'rand' => $_POST["rand"]];
if (isset($_POST['entity_restrict']) && $_POST['entity_restrict'] > 0) {
$condition['glpi_projecttasks.entities_id'] = $_POST['entity_restrict'];
}

$values = getOptionForItems(ProjectTask::class, $condition);
if (isset($_POST["used"]) && !empty($_POST["used"])) {
if (isset($_POST["used"])) {
$p["used"] = $_POST["used"];
$used = $_POST["used"];
foreach ($used as $key => $value) {
if (isset($values[$key])) {
unset($values[$key]);
}
}
}

ProjectTask::dropdown($p);

echo json_encode($values);
}
22 changes: 8 additions & 14 deletions ajax/dropdownRubDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,16 @@
}
}

if (preg_match('/[^a-z_\-0-9]/i', $_POST['myname'])) {
throw new \RuntimeException('Invalid name provided!');
}

if (!isset($_POST['entity']) || $_POST['entity'] === '') {
$_POST['entity'] = $_SESSION['glpiactive_entity'];
}
$values = getOptionForItems(Document::class, [
'entities_id' => intval($_POST['entity']),
'glpi_documents.documentcategories_id' => (int)$_POST["rubdoc"]
]);
foreach ($used as $id) {
unset($values[$id]);
}

Dropdown::show(
'Document', [
'name' => $_POST['myname'],
'used' => $used,
'width' => '50%',
'entity' => intval($_POST['entity']),
'rand' => intval($_POST['rand']),
'condition' => ['glpi_documents.documentcategories_id' => (int)$_POST["rubdoc"]]
]
);
echo json_encode($values);
}
27 changes: 8 additions & 19 deletions ajax/selectUnaffectedOrNewItem_Device.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,25 +67,14 @@
]
]
);
echo "<table width='100%'><tr><td>" . __('Choose an existing device') . "</td><td rowspan='2'>" .
__('and/or') . "</td><td>" . __('Add new devices') . '</td></tr>';
echo "<tr><td>";
if ($result->count() == 0) {
echo __('No unaffected device !');
} else {
$devices = [];
foreach ($result as $row) {
$name = $row['name'];
if (empty($name)) {
$name = $row['id'];
}
$devices[$row['id']] = $name;

$devices = [];
foreach ($result as $row) {
$name = $row['name'];
if (empty($name)) {
$name = $row['id'];
}
Dropdown::showFromArray($linktype::getForeignKeyField(), $devices, ['multiple' => true]);
}
echo "</td><td>";
Dropdown::showNumber('new_devices', ['min' => 0, 'max' => 10]);
echo "</td></tr></table>";
$devices[$row['id']] = $name;

}
echo json_encode(['name' => $devicetype::getForeignKeyField(), 'options' => $devices]);
}
3 changes: 1 addition & 2 deletions ajax/updateUserMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,10 @@

if (
isset($_POST['itemName'])
&& isset($_POST['content'])
) {
$userId = Session::getLoginUserID();
$itemName = $_POST['itemName'];
$content = json_encode($_POST['content']);
$content = json_encode($_POST['content'] ?? '');
$DB->query(<<<SQL
INSERT INTO `glpi_user_menu` (name, user_id, content)
VALUES ('$itemName', $userId, '$content')
Expand Down
21 changes: 21 additions & 0 deletions css/itsm2.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1213,3 +1213,24 @@ div.chip>p {
.dropdown-checkbox-toggle[aria-expanded="true"] i {
rotate: 90deg;
}

/******************************************************/
/* MODALS */
/******************************************************/
.ui-dialog {
border-radius: .5rem;
padding: 0;

.ui-dialog-titlebar {
background-color: $header-background-color;
color: $header-text-color;
border: 0;
border-radius: .5rem .5rem 0 0;
width: 100%;
}
}

.ui-widget.ui-widget-content {
border: 0;
border-radius: .5rem;
}
4 changes: 0 additions & 4 deletions css/palettes/_itsmng.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@

/* ====== GENERAL ====== */

.ui-widget-content a {
color: #ae0c2a;
}

.main_form tr.headerRow th {
color: #c70c2f;
}
Expand Down
1 change: 0 additions & 1 deletion css/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2565,7 +2565,6 @@ a.icon_nav_move {

.boxnote {
margin: 0 auto;
width: 950px;
text-align: left;
border-radius: 10px;
background: #e7e7e2;
Expand Down
Loading
Loading