Commit 487471e1 authored by cconard96's avatar cconard96 Committed by Johan Cwiklinski
Browse files

Add unsaved changes warning

Add ability to mark forms as trackable and then warn users if they try to leave a page that has unsaved changes
 - Forms can be marked as trackable with "data-track-changes='true'"
 - Individual form inputs can be ignored with "data-track-changes='false'"

Track followups, tasks, and solutions. Fix EOF.

Fix dropdown form options. Change beforeunload for modern browsers.
parent 17e51a38
......@@ -23,6 +23,7 @@ The present file will list all changes made to the project; according to the
- the API gives the ID of the user who logs in with initSession
- Kanban view for projects
- Network ports on Monitors
- Add warning when there are unsaved changes in forms
- Add ability to get information from the status endpoint in JSON format using Accept header
- Add `glpi:system:status` CLI command for getting the GLPI status
......
......@@ -115,6 +115,6 @@ if (isset($_POST["add"])) {
} else {
$appliance->checkGlobal(READ);
Html::header(Appliance::getTypeName(1), $_SERVER['PHP_SELF'], "management", "appliance");
$appliance->display($_GET);
$appliance->display($_GET + ['formoptions' => "data-track-changes=true"]);
Html::footer();
}
......@@ -104,8 +104,11 @@ if (isset($_POST["add"])) {
} else {
Html::header(Budget::getTypeName(1), $_SERVER['PHP_SELF'], "management", "budget");
$budget->display(['id' => $_GET["id"],
'withtemplate' => $_GET["withtemplate"]]);
$budget->display([
'id' => $_GET["id"],
'withtemplate' => $_GET["withtemplate"],
'formoptions' => "data-track-changes=true"
]);
Html::footer();
}
......@@ -96,6 +96,7 @@ if (isset($_POST["add"])) {
} else {
Html::header(Cartridge::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "assets", "cartridgeitem");
$cartype->display(['id' => $_GET["id"]]);
$cartype->display(['id' => $_GET["id"],
'formoptions' => "data-track-changes=true"]);
Html::footer();
}
......@@ -98,8 +98,10 @@ if (isset($_POST["add"])) {
} else {
Html::header(Certificate::getTypeName(Session::getPluralNumber()),
$_SERVER['PHP_SELF'], 'management', 'certificate');
$certificate->display(['id' => $_GET["id"],
'withtemplate' => $_GET["withtemplate"]
]);
$certificate->display([
'id' => $_GET["id"],
'withtemplate' => $_GET["withtemplate"],
'formoptions' => "data-track-changes=true"
]);
Html::footer();
}
......@@ -95,14 +95,17 @@ if (isset($_POST["add"])) {
} else {
Html::header(Cluster::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "management", "cluster");
$options = ['id' => $_GET['id']];
$options = [
'id' => $_GET['id'],
'withtemplate' => $_GET['withtemplate'],
'formoptions' => "data-track-changes=true"
];
if (isset($_GET['position'])) {
$options['position'] = $_GET['position'];
}
if (isset($_GET['room'])) {
$options['room'] = $_GET['room'];
}
$options['withtemplate'] = $_GET['withtemplate'];
$cluster->display($options);
Html::footer();
}
......@@ -100,7 +100,10 @@ if (isset($_POST["add"])) {
} else {//print computer information
Html::header(Computer::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "assets", "computer");
//show computer form to add
$computer->display(['id' => $_GET["id"],
'withtemplate' => $_GET["withtemplate"]]);
$computer->display([
'id' => $_GET["id"],
'withtemplate' => $_GET["withtemplate"],
'formoptions' => "data-track-changes=true"
]);
Html::footer();
}
......@@ -67,5 +67,8 @@ if (!empty($_GET['reset_cache'])) {
}
Html::header(Config::getTypeName(1), $_SERVER['PHP_SELF'], "config", "config");
$config->display(['id' => 1]);
$config->display([
'id' => 1,
'formoptions' => "data-track-changes=true"
]);
Html::footer();
......@@ -96,6 +96,7 @@ if (isset($_POST["add"])) {
} else {
Html::header(_n('Consumable', 'Consumables', 2), $_SERVER['PHP_SELF'], "assets", "consumableitem");
$constype->display(['id' =>$_GET["id"]]);
$constype->display(['id' =>$_GET["id"],
'formoptions' => "data-track-changes=true"]);
Html::footer();
}
......@@ -103,6 +103,9 @@ if (isset($_GET['getvcard'])) {
} else {
Html::header(Contact::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "management", "contact");
$contact->display(['id' => $_GET["id"]]);
$contact->display([
'id' => $_GET["id"],
'formoptions' => "data-track-changes=true"
]);
Html::footer();
}
......@@ -101,7 +101,10 @@ if (isset($_POST["add"])) {
} else {
Html::header(Contract::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "management", "contract");
$contract->display(['id' => $_GET["id"],
'withtemplate' => $_GET["withtemplate"]]);
$contract->display([
'id' => $_GET["id"],
'withtemplate' => $_GET["withtemplate"],
'formoptions' => "data-track-changes=true"
]);
Html::footer();
}
......@@ -95,6 +95,9 @@ if (isset($_POST["add"])) {
} else {
Html::header(Datacenter::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "management", "datacenter");
$datacenter->display(['id' => $_GET["id"]]);
$datacenter->display([
'id' => $_GET["id"],
'formoptions' => "data-track-changes=true"
]);
Html::footer();
}
......@@ -114,6 +114,9 @@ if (isset($_POST["add"])) {
} else {
Html::header(Document::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "management", "document");
$doc->display(['id' =>$_GET["id"]]);
$doc->display([
'id' => $_GET["id"],
'formoptions' => "data-track-changes=true"
]);
Html::footer();
}
......@@ -107,7 +107,8 @@ if (isset($_POST["add"])) {
Html::header(Domain::getTypeName(1), $_SERVER['PHP_SELF'], "management", "domain");
$domain->display([
'id' => $_GET["id"],
'withtemplate' => $_GET["withtemplate"]
'withtemplate' => $_GET["withtemplate"],
'formoptions' => "data-track-changes=true"
]);
Html::footer();
......
......@@ -137,7 +137,9 @@ if (isset($_POST["add"])) {
if (!isset($options)) {
$options = [];
}
$options['id'] = $_GET["id"];
$options['id'] = $_GET['id'];
$options['formoptions'] = ($options['formoptions'] ?? '') . ' data-track-changes=true';
$dropdown->display($options);
Html::footer();
}
......@@ -95,14 +95,17 @@ if (isset($_POST["add"])) {
} else {
Html::header(Enclosure::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "assets", "enclosure");
$options = ['id' => $_GET['id']];
$options = [
'id' => $_GET['id'],
'withtemplate' => $_GET['withtemplate'],
'formoptions' => "data-track-changes=true"
];
if (isset($_GET['position'])) {
$options['position'] = $_GET['position'];
}
if (isset($_GET['room'])) {
$options['room'] = $_GET['room'];
}
$options['withtemplate'] = $_GET['withtemplate'];
$enclosure->display($options);
Html::footer();
}
......@@ -94,7 +94,10 @@ if (isset($_POST["add"])) {
} else {
Html::header(Group::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "admin", "group");
$group->display(['id' =>$_GET["id"]]);
$group->display([
'id' => $_GET["id"],
'formoptions' => "data-track-changes=true"
]);
Html::footer();
}
......@@ -95,6 +95,9 @@ if (isset($_POST["add"])) {
} else {
Html::header(Line::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "management", "line");
$line->display(['id' => $_GET["id"]]);
$line->display([
'id' => $_GET["id"],
'formoptions' => "data-track-changes=true"
]);
Html::footer();
}
......@@ -105,7 +105,10 @@ if (isset($_POST["add"])) {
} else {
Html::header(Monitor::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "assets", "monitor");
$monitor->display(['id' => $_GET["id"],
'withtemplate' => $_GET["withtemplate"]]);
$monitor->display([
'id' => $_GET["id"],
'withtemplate' => $_GET["withtemplate"],
'formoptions' => "data-track-changes=true"
]);
Html::footer();
}
......@@ -95,7 +95,10 @@ if (isset($_POST["add"])) {
} else {
Html::header(NetworkEquipment::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "assets", "networkequipment");
$netdevice->display(['id' => $_GET["id"],
'withtemplate' => $_GET["withtemplate"]]);
$netdevice->display([
'id' => $_GET["id"],
'withtemplate' => $_GET["withtemplate"],
'formoptions' => "data-track-changes=true"
]);
Html::footer();
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment