1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
6 %# <sales@bestpractical.com>
8 %# (Except where explicitly superseded by other copyright notices)
13 %# This work is made available to you under the terms of Version 2 of
14 %# the GNU General Public License. A copy of that license should have
15 %# been provided with this software, but in any event can be snarfed
18 %# This work is distributed in the hope that it will be useful, but
19 %# WITHOUT ANY WARRANTY; without even the implied warranty of
20 %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 %# General Public License for more details.
23 %# You should have received a copy of the GNU General Public License
24 %# along with this program; if not, write to the Free Software
25 %# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 %# 02110-1301 or visit their web page on the internet at
27 %# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
30 %# CONTRIBUTION SUBMISSION POLICY:
32 %# (The following paragraph is not intended to limit the rights granted
33 %# to you to modify and distribute this software under the terms of
34 %# the GNU General Public License and is only of importance to you if
35 %# you choose to contribute your changes and enhancements to the
36 %# community by submitting them to Best Practical Solutions, LLC.)
38 %# By intentionally submitting any modifications, corrections or
39 %# derivatives to this work, or any other work intended for use with
40 %# Request Tracker, to Best Practical Solutions, LLC, you confirm that
41 %# you are the copyright holder for those contributions and you grant
42 %# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
43 %# royalty-free, perpetual, license to use, copy, create derivative
44 %# works based on those contributions, and sublicense and distribute
45 %# those contributions and any derivatives thereof.
47 %# END BPS TAGGED BLOCK }}}
48 <& /Elements/Header, Title => $title &>
49 <& /Dashboards/Elements/Tabs,
50 current_subtab => $current_subtab,
52 $Create ? () : (DashboardObj => $Dashboard),
54 <& /Elements/ListActions, actions => \@results &>
56 <form action="<%RT->Config->Get('WebPath')%>/Dashboards/Modify.html" method="post" enctype="multipart/form-data" name="ModifyDashboard">
58 %unless ($Dashboard->Id) {
59 <input type="hidden" class="hidden" name="id" value="new" />
61 <input type="hidden" class="hidden" name="id" value="<%$Dashboard->Id%>" />
64 <tr><td align="right">
67 <td><input name="Name" value="<%$Dashboard->Name%>" /></td>
69 <tr><td align="right">
72 <& /Dashboards/Elements/SelectPrivacy, Name => "Privacy", Objects => \@privacies, Default => $Dashboard->Privacy &>
76 <& /Elements/Submit, Name => 'Save', Label => loc('Create') &>
78 <& /Elements/Submit, Name => 'Save', Label => loc('Save Changes') &>
80 % if ($Dashboard->Id && $can_delete) {
81 <& /Elements/Submit, Name => 'Delete', Label => loc('Delete') &>
87 my ($title, @results);
90 # user went directly to Modify.html
95 my $Dashboard = RT::Dashboard->new($session{'CurrentUser'});
96 my @privacies = $Dashboard->_PrivacyObjects(($Create ? 'Create' : 'Modify') => 1);
98 Abort(loc("Permission denied")) if @privacies == 0;
101 $current_subtab = 'Dashboards/Modify.html?Create=1';
102 $title = loc("Create a new dashboard");
108 my ($val, $msg) = $Dashboard->Save(
109 Name => $ARGS{'Name'},
110 Privacy => $ARGS{'Privacy'},
114 Abort(loc("Dashboard could not be created: [_1]", $msg));
118 $id = $Dashboard->Id;
121 my ($ok, $msg) = $Dashboard->LoadById($id);
126 $title = loc("Modify the dashboard [_1]", $Dashboard->Name);
127 $current_subtab = 'Dashboards/Modify.html?id=' . $id;
129 # If the create failed
132 $current_subtab = 'Dashboards/Modify.html?Create=1';
133 $title = loc("Create a new dashboard");
137 if (!$Create && !$tried_create && $id && $ARGS{'Save'}) {
138 my ($ok, $msg) = $Dashboard->Update(Privacy => $ARGS{'Privacy'},
139 Name => $ARGS{'Name'});
142 push @results, loc("Dashboard updated");
145 push @results, loc("Dashboard could not be updated: [_1]", $msg);
150 my $can_delete = $Dashboard->CurrentUserCanDelete;
152 if (!$Create && !$tried_create && $id && $ARGS{'Delete'}) {
153 my ($ok, $msg) = $Dashboard->Delete();
154 $ok || Abort(loc("Couldn't delete dashboard [_1]: [_2]", $id, $msg));
156 # put the user back into a useful place with a message
157 RT::Interface::Web::Redirect(RT->Config->Get('WebURL')."Dashboards/index.html?Deleted=$id");
165 $id => '' unless defined $id