[Rt-commit] rt branch, menu-redo, updated. 6b43cc837f6244d827c3c61bd45be060b817bca0
jesse
jesse at bestpractical.com
Tue Nov 10 20:25:34 EST 2009
The branch, menu-redo has been updated
via 6b43cc837f6244d827c3c61bd45be060b817bca0 (commit)
via bfaf67a1d0feb6882cf5eca8a3904c4d10e66602 (commit)
via 97edc7c3828ebd8ed0a1eda6b3774bdd9cc5431c (commit)
via 2c2b7edc95cf1030d51ff2be436c7123e40293b6 (commit)
via 0b02ce070aa357a773564283d6739f2533681a34 (commit)
via 9949ff55fdd7cbbfa77e437f583f005d121f8596 (commit)
via 666059f50f8557b0e11ae887f941c987bf4dbd01 (commit)
via 7597cbd198b254f1963ba286836b97f2f6c924fb (commit)
from 668c5e583571db21bfe5e23405f5af6b3303e186 (commit)
Summary of changes:
lib/RT/Dispatcher.pm | 62 +++++++++++++++++++++++
share/html/Dashboards/Modify.html | 99 +++----------------------------------
share/html/Elements/ListActions | 3 +-
3 files changed, 70 insertions(+), 94 deletions(-)
- Log -----------------------------------------------------------------
commit 7597cbd198b254f1963ba286836b97f2f6c924fb
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Tue Nov 10 18:45:50 2009 -0500
ARGS -> Jifty->web->request
diff --git a/share/html/Dashboards/Modify.html b/share/html/Dashboards/Modify.html
index 2ed8e74..4017582 100644
--- a/share/html/Dashboards/Modify.html
+++ b/share/html/Dashboards/Modify.html
@@ -47,7 +47,6 @@
%# END BPS TAGGED BLOCK }}}
<&| /_elements/wrapper, title => $title &>
<& /Elements/Tabs,
- current_subtab => $current_subtab,
title => $title,
$create ? () : (dashboard_obj => $Dashboard),
&>
@@ -80,7 +79,6 @@
</&>
<%INIT>
-my $current_subtab;
my ($title, @results);
my $tried_create = 0;
@@ -95,7 +93,6 @@ my @privacies = $Dashboard->_privacy_objects(($create ? 'create' : 'modify') =>
abort(_("Permission denied")) if @privacies == 0;
if ($create) {
- $current_subtab = 'Dashboards/Modify.html?create=1';
$title = _("Create a new dashboard");
}
else {
@@ -103,8 +100,8 @@ else {
$tried_create = 1;
my ($val, $msg) = $Dashboard->save(
- name => $ARGS{'name'},
- privacy => $ARGS{'privacy'},
+ name => Jifty->web->request->argument('name'),
+ privacy => Jifty->web->request->argument('privacy'),
);
if (!$val) {
@@ -126,19 +123,17 @@ else {
if ($id) {
$title = _("Modify the dashboard %1", $Dashboard->name);
- $current_subtab = 'Dashboards/Modify.html?id=' . $id;
}
# If the create failed
else {
$create = 1;
- $current_subtab = 'Dashboards/Modify.html?create=1';
$title = _("Create a new dashboard");
}
}
-if (!$create && !$tried_create && $id && $ARGS{'save'}) {
- my ($ok, $msg) = $Dashboard->update(privacy => $ARGS{'privacy'},
- name => $ARGS{'name'});
+if (!$create && !$tried_create && $id && Jifty->web->request->argument('save')) {
+ my ($ok, $msg) = $Dashboard->update(privacy => Jifty->web->request->argument('privacy'),
+ name => Jifty->web->request->argument('name'));
if ($ok) {
push @results, _("Dashboard updated");
@@ -151,12 +146,12 @@ if (!$create && !$tried_create && $id && $ARGS{'save'}) {
my $can_delete = $Dashboard->current_user_can_delete;
-if (!$create && !$tried_create && $id && $ARGS{'delete'}) {
+if (!$create && !$tried_create && $id && Jifty->web->request->argument('delete')) {
my ($ok, $msg) = $Dashboard->delete();
$ok || abort(_("Couldn't delete dashboard %1: %2", $id, $msg));
# put the user back into a useful place with a message
- RT::Interface::Web::redirect(Jifty->web->url."Dashboards/index.html?deleted=$id");
+ RT::Interface::Web::redirect(Jifty->web->url."Dashboards/index.html?deleted=$id");
}
</%INIT>
commit 666059f50f8557b0e11ae887f941c987bf4dbd01
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Tue Nov 10 19:05:27 2009 -0500
clean up dashboard logic a bit
diff --git a/share/html/Dashboards/Modify.html b/share/html/Dashboards/Modify.html
index 4017582..f8359e5 100644
--- a/share/html/Dashboards/Modify.html
+++ b/share/html/Dashboards/Modify.html
@@ -48,7 +48,6 @@
<&| /_elements/wrapper, title => $title &>
<& /Elements/Tabs,
title => $title,
- $create ? () : (dashboard_obj => $Dashboard),
&>
<& /Elements/ListActions, actions => \@results &>
@@ -72,86 +71,85 @@
</td></tr>
</table>
<& /Elements/Submit, name => 'save', label => _('Save Changes') &>
-% if ($Dashboard->id && $can_delete) {
+% if ($Dashboard->id && $Dashboard->current_user_can_delete) {
<& /Elements/Submit, name => 'delete', label => _('Delete') &>
% }
</form>
</&>
<%INIT>
-my ($title, @results);
+my ( $title, @results );
my $tried_create = 0;
# user went directly to Modify.html
$create = 1 if !$id;
-use RT::Dashboard;
+my $Dashboard = RT::Dashboard->new();
+my @privacies = $Dashboard->_privacy_objects( ( $create ? 'create' : 'modify' ) => 1 );
-my $Dashboard = RT::Dashboard->new( );
-my @privacies = $Dashboard->_privacy_objects(($create ? 'create' : 'modify') => 1);
-
-abort(_("Permission denied")) if @privacies == 0;
+abort( _("Permission denied") ) if @privacies == 0;
if ($create) {
$title = _("Create a new dashboard");
-}
-else {
- if ($id eq 'new') {
+} else {
+ if ( $id eq 'new' ) {
$tried_create = 1;
- my ($val, $msg) = $Dashboard->save(
+ my ( $val, $msg ) = $Dashboard->save(
name => Jifty->web->request->argument('name'),
privacy => Jifty->web->request->argument('privacy'),
);
- if (!$val) {
- abort(_("Dashboard could not be created: %1", $msg));
+ if ( !$val ) {
+ abort( _( "Dashboard could not be created: %1", $msg ) );
}
push @results, $msg;
- $id = $Dashboard->id;
- RT::Interface::Web::redirect(
- url => Jifty->web->url . "Dashboards/Modify.html?id=" . $Dashboard->id,
- messages => \@results
- );
-
- }
- else {
- my ($ok, $msg) = $Dashboard->load_by_id($id);
+ $id = $Dashboard->id;
+ RT::Interface::Web::redirect(
+ url => Jifty->web->url . "Dashboards/Modify.html?id=" . $Dashboard->id,
+ messages => \@results
+ );
+
+ } else {
+ my ( $ok, $msg ) = $Dashboard->load_by_id($id);
$ok || abort($msg);
}
if ($id) {
- $title = _("Modify the dashboard %1", $Dashboard->name);
- }
+ $title = _( "Modify the dashboard %1", $Dashboard->name );
+ }
+
# If the create failed
else {
$create = 1;
- $title = _("Create a new dashboard");
+ $title = _("Create a new dashboard");
}
}
-if (!$create && !$tried_create && $id && Jifty->web->request->argument('save')) {
- my ($ok, $msg) = $Dashboard->update(privacy => Jifty->web->request->argument('privacy'),
- name => Jifty->web->request->argument('name'));
+if ( $id =~ /^\d+$/ ) {
+ if ( Jifty->web->request->argument('save') ) {
+ my ( $ok, $msg ) = $Dashboard->update(
+ privacy => Jifty->web->request->argument('privacy'),
+ name => Jifty->web->request->argument('name')
+ );
- if ($ok) {
- push @results, _("Dashboard updated");
- }
- else {
- push @results, _("Dashboard could not be updated: %1", $msg);
- }
+ if ($ok) {
+ push @results, _("Dashboard updated");
+ } else {
+ push @results, _( "Dashboard could not be updated: %1", $msg );
+ }
-}
+ }
-my $can_delete = $Dashboard->current_user_can_delete;
+ if ( Jifty->web->request->argument('delete') ) {
+ my ( $ok, $msg ) = $Dashboard->delete();
+ $ok || abort( _( "Couldn't delete dashboard %1: %2", $id, $msg ) );
-if (!$create && !$tried_create && $id && Jifty->web->request->argument('delete')) {
- my ($ok, $msg) = $Dashboard->delete();
- $ok || abort(_("Couldn't delete dashboard %1: %2", $id, $msg));
+ # put the user back into a useful place with a message
+ RT::Interface::Web::redirect( Jifty->web->url . "Dashboards/index.html?deleted=$id" );
- # put the user back into a useful place with a message
- RT::Interface::Web::redirect(Jifty->web->url."Dashboards/index.html?deleted=$id");
+ }
}
</%INIT>
@@ -159,7 +157,7 @@ if (!$create && !$tried_create && $id && Jifty->web->request->argument('delete')
<%ARGS>
$create => undef
$name => undef
-$id => '' unless defined $id
+$id => ''
$delete => undef
</%ARGS>
commit 9949ff55fdd7cbbfa77e437f583f005d121f8596
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Tue Nov 10 19:10:08 2009 -0500
logic cleanup
diff --git a/share/html/Dashboards/Modify.html b/share/html/Dashboards/Modify.html
index f8359e5..5acfecf 100644
--- a/share/html/Dashboards/Modify.html
+++ b/share/html/Dashboards/Modify.html
@@ -140,9 +140,7 @@ if ( $id =~ /^\d+$/ ) {
push @results, _( "Dashboard could not be updated: %1", $msg );
}
- }
-
- if ( Jifty->web->request->argument('delete') ) {
+ } elsif ( Jifty->web->request->argument('delete') ) {
my ( $ok, $msg ) = $Dashboard->delete();
$ok || abort( _( "Couldn't delete dashboard %1: %2", $id, $msg ) );
commit 0b02ce070aa357a773564283d6739f2533681a34
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Tue Nov 10 19:19:16 2009 -0500
further untangling logic
diff --git a/share/html/Dashboards/Modify.html b/share/html/Dashboards/Modify.html
index 5acfecf..8977e45 100644
--- a/share/html/Dashboards/Modify.html
+++ b/share/html/Dashboards/Modify.html
@@ -79,53 +79,20 @@
<%INIT>
my ( $title, @results );
-my $tried_create = 0;
-
-# user went directly to Modify.html
-$create = 1 if !$id;
-
my $Dashboard = RT::Dashboard->new();
my @privacies = $Dashboard->_privacy_objects( ( $create ? 'create' : 'modify' ) => 1 );
abort( _("Permission denied") ) if @privacies == 0;
-if ($create) {
- $title = _("Create a new dashboard");
+if ( $id =~ /^\d+$/ ) {
+ my ( $ok, $msg ) = $Dashboard->load_by_id($id);
+ $ok || abort($msg);
+ $title = _( "Modify the dashboard %1", $Dashboard->name );
} else {
- if ( $id eq 'new' ) {
- $tried_create = 1;
-
- my ( $val, $msg ) = $Dashboard->save(
- name => Jifty->web->request->argument('name'),
- privacy => Jifty->web->request->argument('privacy'),
- );
-
- if ( !$val ) {
- abort( _( "Dashboard could not be created: %1", $msg ) );
- }
-
- push @results, $msg;
- $id = $Dashboard->id;
- RT::Interface::Web::redirect(
- url => Jifty->web->url . "Dashboards/Modify.html?id=" . $Dashboard->id,
- messages => \@results
- );
-
- } else {
- my ( $ok, $msg ) = $Dashboard->load_by_id($id);
- $ok || abort($msg);
- }
+ $title = _("Create a new dashboard");
+}
- if ($id) {
- $title = _( "Modify the dashboard %1", $Dashboard->name );
- }
- # If the create failed
- else {
- $create = 1;
- $title = _("Create a new dashboard");
- }
-}
if ( $id =~ /^\d+$/ ) {
if ( Jifty->web->request->argument('save') ) {
@@ -148,8 +115,25 @@ if ( $id =~ /^\d+$/ ) {
RT::Interface::Web::redirect( Jifty->web->url . "Dashboards/index.html?deleted=$id" );
}
+} elsif ( $id eq 'new' ) {
+ my ( $val, $msg ) = $Dashboard->save(
+ name => Jifty->web->request->argument('name'),
+ privacy => Jifty->web->request->argument('privacy'),
+ );
+
+ if ( !$val ) {
+ abort( _( "Dashboard could not be created: %1", $msg ) );
+ }
+
+ push @results, $msg;
+ $id = $Dashboard->id;
+ RT::Interface::Web::redirect(
+ url => Jifty->web->url . "Dashboards/Modify.html?id=" . $Dashboard->id,
+ messages => \@results
+ );
}
+
</%INIT>
<%ARGS>
commit 2c2b7edc95cf1030d51ff2be436c7123e40293b6
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Tue Nov 10 19:23:58 2009 -0500
typo fix
diff --git a/share/html/Dashboards/Modify.html b/share/html/Dashboards/Modify.html
index 8977e45..2117236 100644
--- a/share/html/Dashboards/Modify.html
+++ b/share/html/Dashboards/Modify.html
@@ -80,7 +80,7 @@
my ( $title, @results );
my $Dashboard = RT::Dashboard->new();
-my @privacies = $Dashboard->_privacy_objects( ( $create ? 'create' : 'modify' ) => 1 );
+my @privacies = $Dashboard->_privacy_objects( ( $id =~ /^\d+$/ ? 'create' : 'modify' ) => 1 );
abort( _("Permission denied") ) if @privacies == 0;
commit 97edc7c3828ebd8ed0a1eda6b3774bdd9cc5431c
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Tue Nov 10 19:48:04 2009 -0500
menu-redo now fails as it did 5 commits ago
diff --git a/share/html/Dashboards/Modify.html b/share/html/Dashboards/Modify.html
index 2117236..b2f7c2f 100644
--- a/share/html/Dashboards/Modify.html
+++ b/share/html/Dashboards/Modify.html
@@ -80,7 +80,7 @@
my ( $title, @results );
my $Dashboard = RT::Dashboard->new();
-my @privacies = $Dashboard->_privacy_objects( ( $id =~ /^\d+$/ ? 'create' : 'modify' ) => 1 );
+my @privacies = $Dashboard->_privacy_objects( ( !$id ? 'create' : 'modify' ) => 1 );
abort( _("Permission denied") ) if @privacies == 0;
commit bfaf67a1d0feb6882cf5eca8a3904c4d10e66602
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Tue Nov 10 20:24:31 2009 -0500
port ListActions to the jifty request API
diff --git a/share/html/Elements/ListActions b/share/html/Elements/ListActions
index 5a187d1..e234957 100755
--- a/share/html/Elements/ListActions
+++ b/share/html/Elements/ListActions
@@ -56,8 +56,7 @@
</div>
<%init>
-my $actions_pointer = $m->request_args->{'results'};
-
+my $actions_pointer = Jifty->web->request->argument('results');
if ($actions_pointer &&
ref Jifty->web->session->get("actions_$actions_pointer") eq 'ARRAY' ) {
unshift @actions, @{Jifty->web->session->get("actions_$actions_pointer")};
commit 6b43cc837f6244d827c3c61bd45be060b817bca0
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Tue Nov 10 20:25:09 2009 -0500
move dashboard modify logic to RT's dispatcher
diff --git a/lib/RT/Dispatcher.pm b/lib/RT/Dispatcher.pm
index 2c47203..b804df4 100644
--- a/lib/RT/Dispatcher.pm
+++ b/lib/RT/Dispatcher.pm
@@ -287,6 +287,68 @@ before qr'Dashboards/?' => run {
}
};
+before 'Dashboards/Modify.html' => run {
+ my $id = Jifty->web->request->argument('id') || '';
+ my $results = [];
+ my $title;
+ my $Dashboard = RT::Dashboard->new();
+ my $privacies = [$Dashboard->_privacy_objects( ( !$id ? 'create' : 'modify' ) => 1 )];
+
+ abort( _("Permission denied") ) if @$privacies == 0;
+
+ if ( $id =~ /^\d+$/ ) {
+ my ( $ok, $msg ) = $Dashboard->load_by_id($id);
+ $ok || abort($msg);
+ $title = _( "Modify the dashboard %1", $Dashboard->name );
+ } else {
+ $title = _("Create a new dashboard");
+ }
+
+ if ( $id =~ /^\d+$/ ) {
+ if ( Jifty->web->request->argument('save') ) {
+ my ( $ok, $msg ) = $Dashboard->update(
+ privacy => Jifty->web->request->argument('privacy'),
+ name => Jifty->web->request->argument('name')
+ );
+
+ if ($ok) {
+ push @$results, _("Dashboard updated");
+ } else {
+ push @$results, _( "Dashboard could not be updated: %1", $msg );
+ }
+
+ } elsif ( Jifty->web->request->argument('delete') ) {
+ my ( $ok, $msg ) = $Dashboard->delete();
+ $ok || abort( _( "Couldn't delete dashboard %1: %2", $id, $msg ) );
+
+ # put the user back into a useful place with a message
+ RT::Interface::Web::redirect( Jifty->web->url . "Dashboards/index.html?deleted=$id" );
+
+ }
+ } elsif ( $id eq 'new' ) {
+ my ( $val, $msg ) = $Dashboard->save(
+ name => Jifty->web->request->argument('name'),
+ privacy => Jifty->web->request->argument('privacy'),
+ );
+
+ if ( !$val ) {
+ abort( _( "Dashboard could not be created: %1", $msg ) );
+ }
+
+ push @$results, $msg;
+ RT::Interface::Web::redirect(
+ url => Jifty->web->url . "Dashboards/Modify.html?id=" . $Dashboard->id,
+ messages => $results
+ );
+
+ }
+ set privacies => $privacies;
+ set Dashboard => $Dashboard;
+ set results => $results;
+ set title => $title;
+};
+
+
before qr'Dashboards/(\d*)?' => run {
if ( my $id = ($1 || Jifty->web->request->argument('id') )) {
my $obj = RT::Dashboard->new();
diff --git a/share/html/Dashboards/Modify.html b/share/html/Dashboards/Modify.html
index b2f7c2f..d34ae72 100644
--- a/share/html/Dashboards/Modify.html
+++ b/share/html/Dashboards/Modify.html
@@ -49,7 +49,7 @@
<& /Elements/Tabs,
title => $title,
&>
-<& /Elements/ListActions, actions => \@results &>
+<& /Elements/ListActions, actions => $results &>
<form action="<%RT->config->get('web_path')%>/Dashboards/Modify.html" method="post" enctype="multipart/form-data" name="modify_dashboard">
@@ -67,7 +67,7 @@
<tr><td align="right">
<&|/l&>Privacy</&>:
</td><td>
-<& /Dashboards/Elements/SelectPrivacy, name => "privacy", objects => \@privacies, default => $Dashboard->privacy &>
+<& /Dashboards/Elements/SelectPrivacy, name => "privacy", objects => $privacies, default => $Dashboard->privacy &>
</td></tr>
</table>
<& /Elements/Submit, name => 'save', label => _('Save Changes') &>
@@ -76,70 +76,10 @@
% }
</form>
</&>
-<%INIT>
-
-my ( $title, @results );
-my $Dashboard = RT::Dashboard->new();
-my @privacies = $Dashboard->_privacy_objects( ( !$id ? 'create' : 'modify' ) => 1 );
-
-abort( _("Permission denied") ) if @privacies == 0;
-
-if ( $id =~ /^\d+$/ ) {
- my ( $ok, $msg ) = $Dashboard->load_by_id($id);
- $ok || abort($msg);
- $title = _( "Modify the dashboard %1", $Dashboard->name );
-} else {
- $title = _("Create a new dashboard");
-}
-
-
-
-if ( $id =~ /^\d+$/ ) {
- if ( Jifty->web->request->argument('save') ) {
- my ( $ok, $msg ) = $Dashboard->update(
- privacy => Jifty->web->request->argument('privacy'),
- name => Jifty->web->request->argument('name')
- );
-
- if ($ok) {
- push @results, _("Dashboard updated");
- } else {
- push @results, _( "Dashboard could not be updated: %1", $msg );
- }
-
- } elsif ( Jifty->web->request->argument('delete') ) {
- my ( $ok, $msg ) = $Dashboard->delete();
- $ok || abort( _( "Couldn't delete dashboard %1: %2", $id, $msg ) );
-
- # put the user back into a useful place with a message
- RT::Interface::Web::redirect( Jifty->web->url . "Dashboards/index.html?deleted=$id" );
-
- }
-} elsif ( $id eq 'new' ) {
- my ( $val, $msg ) = $Dashboard->save(
- name => Jifty->web->request->argument('name'),
- privacy => Jifty->web->request->argument('privacy'),
- );
-
- if ( !$val ) {
- abort( _( "Dashboard could not be created: %1", $msg ) );
- }
-
- push @results, $msg;
- $id = $Dashboard->id;
- RT::Interface::Web::redirect(
- url => Jifty->web->url . "Dashboards/Modify.html?id=" . $Dashboard->id,
- messages => \@results
- );
-
-}
-
-</%INIT>
-
<%ARGS>
-$create => undef
-$name => undef
-$id => ''
-$delete => undef
+$Dashboard => undef
+$privacies => undef
+$results => undef
+$title => undef
</%ARGS>
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list