1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2015 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 &>
50 <& /Elements/ListActions, actions => \@results &>
52 <form action="<%RT->Config->Get('WebPath')%>/Dashboards/Modify.html" method="post" enctype="multipart/form-data" name="ModifyDashboard" id="ModifyDashboard">
54 %unless ($Dashboard->Id) {
55 <input type="hidden" class="hidden" name="id" value="new" />
57 <input type="hidden" class="hidden" name="id" value="<%$Dashboard->Id%>" />
60 <&|/Widgets/TitleBox, title => loc('Basics') &>
63 <td class="label"><&|/l&>Name</&>:</td>
64 <td class="value"><input name="Name" value="<%$Dashboard->Name%>" /></td>
67 <td class="label"><&|/l&>Privacy</&>:</td>
68 <td><& /Dashboards/Elements/SelectPrivacy, Name => "Privacy", Objects => \@privacies, Default => $Dashboard->Privacy &></td>
72 <& /Elements/Submit, Name => 'Save', Label =>( $Create ? loc('Create') : loc('Save Changes') ) &>
74 % if ($Dashboard->Id && $can_delete) {
75 <& /Elements/Submit, Name => 'Delete', Label => loc('Delete') &>
80 my ($title, @results);
83 # user went directly to Modify.html
87 my $redirect_to ='/Dashboards/Modify.html';
91 my $Dashboard = RT::Dashboard->new($session{'CurrentUser'});
92 my $method = $Create ? 'ObjectsForCreating' : 'ObjectsForModifying';
93 my @privacies = $Dashboard->$method;
95 Abort(loc("Permission Denied")) if @privacies == 0;
98 $title = loc("Create a new dashboard");
104 my ($val, $msg) = $Dashboard->Save(
105 Name => $ARGS{'Name'},
106 Privacy => $ARGS{'Privacy'},
110 Abort(loc("Dashboard could not be created: [_1]", $msg));
114 $id = $Dashboard->Id;
115 if (!$Dashboard->id || ! $Dashboard->CurrentUserCanSee) {
116 $redirect_to='/Dashboards/index.html';
121 my ($ok, $msg) = $Dashboard->LoadById($id);
122 $ok || Abort(loc("Couldn't load dashboard [_1]: [_2]", $id, $msg));
126 $title = loc("Modify the dashboard [_1]", $Dashboard->Name);
128 # If the create failed
131 $title = loc("Create a new dashboard");
135 if (!$Create && !$tried_create && $id && $ARGS{'Save'}) {
136 my ($ok, $msg) = $Dashboard->Update(Privacy => $ARGS{'Privacy'},
137 Name => $ARGS{'Name'});
140 push @results, loc("Dashboard [_1] updated", $Dashboard->Name);
143 push @results, loc("Dashboard [_1] could not be updated: [_2]", $Dashboard->Name, $msg);
149 my $can_delete = $Dashboard->CurrentUserCanDelete;
151 if (!$Create && !$tried_create && $id && $ARGS{'Delete'}) {
152 my ($ok, $msg) = $Dashboard->Delete();
154 Abort(loc("Couldn't delete dashboard [_1]: [_2]", $id, $msg));
158 $redirect_to = '/Dashboards/index.html';
161 # This code does automatic redirection if any updates happen.
162 MaybeRedirectForResults(
163 Actions => \@results,
164 Path => $redirect_to,
165 Arguments => { id => $id },
173 $id => '' unless defined $id