Skip to content

Commit

Permalink
Merge pull request #262 from Oliver-ctrlo/uiux
Browse files Browse the repository at this point in the history
Added Remove Alert button
  • Loading branch information
abeverley authored Nov 5, 2023
2 parents cd72a25 + a83c078 commit 2ee5475
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
22 changes: 15 additions & 7 deletions lib/GADS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2296,20 +2296,28 @@ prefix '/:layout_name' => sub {
}

# Deal with any alert requests
if (param 'modal_alert')
{
if (param('modal_alert') || param('modal_remove')) {
my $success_message;
my $frequency = '';

if (param('modal_remove')) {
$frequency = '';
$success_message = "The alert has been removed successfully";
}
if (param('modal_alert')) {
$frequency = param('frequency');
$success_message = "The alert has been saved successfully";
}
my $alert_user = session('views_other_user_id') ? rset('User')->find(session('views_other_user_id')) : $user;
my $alert = GADS::Alert->new(
user => $alert_user,
layout => $layout,
schema => schema,
frequency => param('frequency'),
frequency => $frequency,
view_id => param('view_id'),
);
if (process(sub { $alert->write }))
{
return forwardHome(
{ success => "The alert has been saved successfully" }, $layout->identifier.'/data' );
if (process(sub { $alert->write })) {
return forwardHome({ success => $success_message }, $layout->identifier.'/data');
}
}

Expand Down
12 changes: 9 additions & 3 deletions views/wizard/record_alert_me.tt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="modal modal--form" id="[% modalId %]" tabindex="-1" role="dialog" aria-labelledby="[% modalId %]Label" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered " role="document">
<div class="modal-content">
[% INCLUDE wizard/sub/modal_header.tt label="Configure alert for " _ v.name; %]
[% INCLUDE wizard/sub/modal_header.tt label="Configure alert for view: " _ v.name; %]

<form method="post" class="">
[% INCLUDE fields/hidden.tt name="csrf_token" value=csrf_token; %]
Expand All @@ -23,7 +23,6 @@
value = NOT v.alert ? "" : v.alert.frequency
filter = "html"
items = [
{id="", name="Never"},
{id="0", name="Instantly"},
{id="24", name="Every 24 hours"}
];
Expand All @@ -39,11 +38,18 @@
label = "Cancel"
}]
right_buttons = v.is_group ? [] : [{
type = "submit"
class = "btn-danger"
name = "modal_remove"
value = "submit"
label = "Remove"
}
{
type = "submit"
class = "btn-default"
name = "modal_alert"
value = "submit"
label = "Create alert"
label = "Create"
}];
%]
</div>
Expand Down

0 comments on commit 2ee5475

Please sign in to comment.