Commit cacb0270 authored by Clare Lenihan's avatar Clare Lenihan Committed by Clare Lenihan
Browse files

adding confirm dialog to cancel with new view, and cancelling now deletes the...

adding confirm dialog to cancel with new view, and cancelling now deletes the partially created view
parent a2faf100
......@@ -168,6 +168,8 @@ $string['viewsavedsuccessfully'] = 'View saved successfully';
$string['invalidcolumn'] = 'Column %s out of range';
$string['confirmcancelcreatingview'] = 'This view has not been completed. Do you really want to cancel?';
// view control stuff
$string['displaymyview'] = 'Display my view';
......
......@@ -42,6 +42,11 @@
<div id="view-wizard-controls" class="center">
{if $new}
<form action="" method="POST">
<input type="hidden" name="id" value="{$view}">
<input type="hidden" name="new" value="1">
<input type="submit" name="cancel" class="submit" value="{str tag='cancel'}" onclick="return confirm('{str tag='confirmcancelcreatingview' section='view'}');">
</form>
<form action="{$WWWROOT}view/edit.php" method="GET">
<input type="hidden" name="id" value="{$view}">
<input type="hidden" name="new" value="1">
......
......@@ -100,6 +100,7 @@ $form = array(
'value' => !empty($new)
? array(get_string('cancel'), get_string('back','view'), get_string('save'))
: array(get_string('save'), get_string('cancel')),
'confirm' => !empty($new) ? array(get_string('confirmcancelcreatingview', 'view'), null, null) : null,
),
)
);
......@@ -111,6 +112,10 @@ function editaccess_validate(Pieform $form, $values) {
}
function editaccess_cancel_submit() {
global $view, $new;
if ($new) {
$view->delete();
}
redirect('/view/');
}
......
......@@ -33,6 +33,13 @@ $view = new View(param_integer('id'));
define('TITLE', get_string('editblocksforview', 'view', $view->get('title')));
$new = param_boolean('new');
// check if cancel was selected
if ($new && isset($_POST['cancel'])) {
$view->delete();
redirect(get_config('wwwroot') . '/view/');
}
$category = param_alpha('c', '');
// Make the default category the first tab if none is set
if ($category === '') {
......
......@@ -119,11 +119,16 @@ $editview = pieform(array(
'submit' => array(
'type' => 'submitcancel',
'value' => array(empty($new) ? get_string('save') : get_string('next'), get_string('cancel')),
),
'confirm' => $new && isset($view) ? array(null, get_string('confirmcancelcreatingview', 'view')) : null,
)
),
));
function editview_cancel_submit() {
global $view, $new;
if (isset($view) && $new) {
$view->delete();
}
redirect('/view');
}
......
Markdown is supported
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