[Rt-commit] rt branch, 4.4/mandatory-global-dashboard, created. rt-4.2.3-203-g579634e
? sunnavy
sunnavy at bestpractical.com
Tue May 6 11:51:58 EDT 2014
The branch, 4.4/mandatory-global-dashboard has been created
at 579634ee3edbb6681b9eae23557c6a4f16bc49ff (commit)
- Log -----------------------------------------------------------------
commit 579634ee3edbb6681b9eae23557c6a4f16bc49ff
Author: sunnavy <sunnavy at bestpractical.com>
Date: Mon May 5 23:37:09 2014 +0800
status(mandatory/optional) support for global dashboards
so we can add mandatory ones to everyone automatically.
seel also #25717
diff --git a/etc/schema.Oracle b/etc/schema.Oracle
index 58665c7..e4280d1 100755
--- a/etc/schema.Oracle
+++ b/etc/schema.Oracle
@@ -406,6 +406,7 @@ CREATE TABLE Attributes (
ContentType VARCHAR(16),
ObjectType VARCHAR2(25) NOT NULL,
ObjectId NUMBER(11,0) DEFAULT 0 NOT NULL,
+ Status VARCHAR(255),
Creator NUMBER(11,0) DEFAULT 0 NOT NULL,
Created DATE,
LastUpdatedBy NUMBER(11,0) DEFAULT 0 NOT NULL,
diff --git a/etc/schema.Pg b/etc/schema.Pg
index 356441b..f61db9e 100755
--- a/etc/schema.Pg
+++ b/etc/schema.Pg
@@ -631,6 +631,7 @@ CREATE TABLE Attributes (
ContentType varchar(16),
ObjectType varchar(64),
ObjectId integer,
+ Status varchar(255) NULL ,
Creator integer NOT NULL DEFAULT 0 ,
Created TIMESTAMP NULL ,
LastUpdatedBy integer NOT NULL DEFAULT 0 ,
diff --git a/etc/schema.SQLite b/etc/schema.SQLite
index 7ba11f7..5e4d17f 100755
--- a/etc/schema.SQLite
+++ b/etc/schema.SQLite
@@ -454,6 +454,7 @@ CREATE TABLE Attributes (
ContentType varchar(16) collate NOCASE,
ObjectType varchar(25) collate NOCASE NOT NULL ,
ObjectId INTEGER ,
+ Status varchar(255) collate NOCASE NULL ,
Creator integer NULL DEFAULT 0 ,
Created DATETIME NULL ,
LastUpdatedBy integer NULL DEFAULT 0 ,
diff --git a/etc/schema.mysql b/etc/schema.mysql
index 1030eb2..4daeabf 100755
--- a/etc/schema.mysql
+++ b/etc/schema.mysql
@@ -429,6 +429,7 @@ CREATE TABLE Attributes (
ContentType varchar(16) CHARACTER SET ascii,
ObjectType varchar(64) CHARACTER SET ascii,
ObjectId integer, # foreign key to anything
+ Status varchar(255) NULL ,
Creator integer NOT NULL DEFAULT 0 ,
Created DATETIME NULL ,
LastUpdatedBy integer NOT NULL DEFAULT 0 ,
diff --git a/etc/upgrade/4.3.1/schema.Oracle b/etc/upgrade/4.3.1/schema.Oracle
index 6056ee0..2bd78f6 100644
--- a/etc/upgrade/4.3.1/schema.Oracle
+++ b/etc/upgrade/4.3.1/schema.Oracle
@@ -1 +1,2 @@
ALTER TABLE CustomFields ADD EntryHint VARCHAR2(255) NULL;
+ALTER TABLE Attributes ADD Status VARCHAR(255) NULL;
diff --git a/etc/upgrade/4.3.1/schema.Pg b/etc/upgrade/4.3.1/schema.Pg
index 92c28dc..9d7ce56 100644
--- a/etc/upgrade/4.3.1/schema.Pg
+++ b/etc/upgrade/4.3.1/schema.Pg
@@ -1 +1,2 @@
ALTER TABLE CustomFields ADD COLUMN EntryHint VARCHAR(255) NULL;
+ALTER TABLE Attributes ADD COLUMN Status VARCHAR(255) NULL;
diff --git a/etc/upgrade/4.3.1/schema.SQLite b/etc/upgrade/4.3.1/schema.SQLite
index 92c28dc..8997a67 100644
--- a/etc/upgrade/4.3.1/schema.SQLite
+++ b/etc/upgrade/4.3.1/schema.SQLite
@@ -1 +1,2 @@
ALTER TABLE CustomFields ADD COLUMN EntryHint VARCHAR(255) NULL;
+ALTER TABLE Attributes ADD COLUMN Status VARCHAR(255) collate NOCASE NULL;
diff --git a/etc/upgrade/4.3.1/schema.mysql b/etc/upgrade/4.3.1/schema.mysql
index 92c28dc..9d7ce56 100644
--- a/etc/upgrade/4.3.1/schema.mysql
+++ b/etc/upgrade/4.3.1/schema.mysql
@@ -1 +1,2 @@
ALTER TABLE CustomFields ADD COLUMN EntryHint VARCHAR(255) NULL;
+ALTER TABLE Attributes ADD COLUMN Status VARCHAR(255) NULL;
diff --git a/lib/RT/Attribute.pm b/lib/RT/Attribute.pm
index a39601a..45ac9f7 100644
--- a/lib/RT/Attribute.pm
+++ b/lib/RT/Attribute.pm
@@ -573,6 +573,23 @@ Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
=cut
+=head2 Status
+
+Returns the current value of Status.
+(In the database, Status is stored as varchar(255).)
+
+
+
+=head2 SetStatus VALUE
+
+
+Set Status to VALUE.
+Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
+(In the database, Status will be stored as a varchar(255).)
+
+
+=cut
+
=head2 Creator
@@ -628,6 +645,8 @@ sub _CoreAccessible {
{read => 1, write => 1, sql_type => 12, length => 64, is_blob => 0, is_numeric => 0, type => 'varchar(64)', default => ''},
ObjectId =>
{read => 1, write => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => ''},
+ Status =>
+ {read => 1, write => 1, sql_type => 12, length => 255, is_blob => 0, is_numeric => 0, type => 'varchar(255)', default => ''},
Creator =>
{read => 1, auto => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'},
Created =>
diff --git a/lib/RT/Dashboard.pm b/lib/RT/Dashboard.pm
index 6b9244f..381bc82 100644
--- a/lib/RT/Dashboard.pm
+++ b/lib/RT/Dashboard.pm
@@ -138,6 +138,18 @@ sub UpdateAttribute {
$self->{'Privacy'} = $args->{'Privacy'} if $status;
}
+ if ($status) {
+ if ( $self->{'Privacy'} =~ /^RT::System/ ) {
+ if ( exists $args->{'Status'} ) {
+ ( $status, $msg ) = $self->{'Attribute'}->SetStatus( $args->{'Status'} )
+ unless ( $self->Status || '' ) eq ( $args->{'Status'} || '' );
+ }
+ }
+ else {
+ ( $status, $msg ) = $self->{'Attribute'}->SetStatus('') if $self->Status;
+ }
+ }
+
return ($status, $msg);
}
diff --git a/lib/RT/SharedSetting.pm b/lib/RT/SharedSetting.pm
index 2eece3c..98f071e 100644
--- a/lib/RT/SharedSetting.pm
+++ b/lib/RT/SharedSetting.pm
@@ -328,6 +328,18 @@ sub Privacy {
return $self->{'Privacy'};
}
+=head2 Status
+
+Returns the status of this shared setting.
+
+=cut
+
+sub Status {
+ my $self = shift;
+ return unless ref($self->{'Attribute'}) eq 'RT::Attribute';
+ return $self->{'Attribute'}->Status();
+}
+
=head2 GetParameter
Returns the given named parameter of the setting.
diff --git a/share/html/Admin/Global/DashboardsInMenu.html b/share/html/Admin/Global/DashboardsInMenu.html
index 279c022..5838f4f 100644
--- a/share/html/Admin/Global/DashboardsInMenu.html
+++ b/share/html/Admin/Global/DashboardsInMenu.html
@@ -67,13 +67,28 @@ my $default_dashboards_in_menu =
? $dashboard_attr->Content->{dashboards}
: [];
+my @mandatory =
+ map { $_->id }
+ grep { $_->Status && $_->Status eq 'mandatory' }
+ RT->System->Attributes->Named('Dashboard');
+my %existing = map { $_ => 1 } @$default_dashboards_in_menu;
+push @$default_dashboards_in_menu, grep { !$existing{$_} } @mandatory;
+
use RT::Dashboards;
my $dashboards = RT::Dashboards->new( $RT::SystemUser );
$dashboards->LimitToPrivacy('RT::System-' . $sys->id);
my @dashboards;
while ( my $dashboard = $dashboards->Next ) {
- push @dashboards, [$dashboard->id, $dashboard->Name];
+ push @dashboards,
+ [
+ $dashboard->id,
+ $dashboard->Name
+ . (
+ $dashboard->Status
+ && $dashboard->Status eq 'mandatory' ? ' (' . loc('mandatory') . ')' : ''
+ )
+ ];
}
my @panes = $m->comp(
@@ -85,6 +100,17 @@ my @panes = $m->comp(
current_portlets => $default_dashboards_in_menu,
OnSave => sub {
my ( $conf ) = @_;
+ my @mandatory =
+ map { $_->id }
+ grep { $_->Status && $_->Status eq 'mandatory' }
+ RT->System->Attributes->Named('Dashboard');
+ my %existing = map { $_ => 1 } @{$conf->{dashboards}};
+ my @missing = grep { !$existing{$_} } @mandatory;
+ if ( @missing ) {
+ push @{$conf->{dashboards}}, @missing;
+ push @actions, loc("Can't delete mandatory dashboards.");
+ }
+
my ( $status, $msg );
if (!$has_right) {
diff --git a/share/html/Dashboards/Elements/ShowDashboards b/share/html/Dashboards/Elements/SelectStatus
similarity index 72%
copy from share/html/Dashboards/Elements/ShowDashboards
copy to share/html/Dashboards/Elements/SelectStatus
index e04e149..e139754 100644
--- a/share/html/Dashboards/Elements/ShowDashboards
+++ b/share/html/Dashboards/Elements/SelectStatus
@@ -45,27 +45,20 @@
%# those contributions and any derivatives thereof.
%#
%# END BPS TAGGED BLOCK }}}
-% foreach my $Object (@Objects) {
-% my $Dashboards = RT::Dashboards->new($session{CurrentUser});
-% $Dashboards->LimitToPrivacy(join('-',ref($Object),$Object->Id));
-% my $title;
-% if (ref $Object eq 'RT::User' && $Object->Id == $session{CurrentUser}->Id) {
-% $title = loc("My dashboards");
-% } else {
-% $title = loc("[_1]'s dashboards",$Object->Name);
-% }
-% $title = $m->interp->apply_escapes($title, 'h');
-<& /Elements/CollectionList,
- %ARGS,
- Format => qq{'<a href="__WebPath__/__ShowURL__">__Name__</a>/TITLE:$title', __Subscription__},
- Collection => $Dashboards,
-&>
-% }
-<%init>
-use RT::Dashboards;
-
-my @Objects = RT::Dashboard->new($session{CurrentUser})->ObjectsForLoading(IncludeSuperuserGroups => $IncludeSuperuserGroups);
-</%init>
<%args>
-$IncludeSuperuserGroups => 1
+$Name => undef
+$Default => undef
</%args>
+<select name="<%$Name%>">
+<option
+% if ( !$Default || $Default ne 'mandatory' ) {
+selected="selected"
+% }
+value=""><% loc('Optional') %></option>
+
+<option
+% if ( $Default && $Default eq 'mandatory' ) {
+selected="selected"
+% }
+value="mandatory"><% loc('Mandatory') %></option>
+</select>
diff --git a/share/html/Dashboards/Elements/ShowDashboards b/share/html/Dashboards/Elements/ShowDashboards
index e04e149..18f1c67 100644
--- a/share/html/Dashboards/Elements/ShowDashboards
+++ b/share/html/Dashboards/Elements/ShowDashboards
@@ -57,7 +57,8 @@
% $title = $m->interp->apply_escapes($title, 'h');
<& /Elements/CollectionList,
%ARGS,
- Format => qq{'<a href="__WebPath__/__ShowURL__">__Name__</a>/TITLE:$title', __Subscription__},
+ Format => qq{'<a href="__WebPath__/__ShowURL__">__Name__</a>/TITLE:$title', __Subscription__} .
+ ($Object->isa('RT::System') ? ', __Status__' : ''),
Collection => $Dashboards,
&>
% }
diff --git a/share/html/Dashboards/Modify.html b/share/html/Dashboards/Modify.html
index bba6edf..12e002d 100644
--- a/share/html/Dashboards/Modify.html
+++ b/share/html/Dashboards/Modify.html
@@ -66,7 +66,13 @@
<tr>
<td class="label"><&|/l&>Privacy</&>:</td>
<td><& /Dashboards/Elements/SelectPrivacy, Name => "Privacy", Objects => \@privacies, Default => $Dashboard->Privacy &></td>
-</tr>
+ </tr>
+ <tr>
+% if ( $Dashboard->Privacy && $Dashboard->Privacy =~ /^RT::System/ ) {
+ <td class="label"><&|/l&>Status</&>:</td>
+ <td><& /Dashboards/Elements/SelectStatus, Name => "Status", Default => $Dashboard->Status &></td>
+ </tr>
+% }
</table>
</&>
<& /Elements/Submit, Name => 'Save', Label =>( $Create ? loc('Create') : loc('Save Changes') ) &>
@@ -104,6 +110,7 @@ else {
my ($val, $msg) = $Dashboard->Save(
Name => $ARGS{'Name'},
Privacy => $ARGS{'Privacy'},
+ Status => $ARGS{'Status'},
);
if (!$val) {
@@ -134,6 +141,7 @@ else {
if (!$Create && !$tried_create && $id && $ARGS{'Save'}) {
my ($ok, $msg) = $Dashboard->Update(Privacy => $ARGS{'Privacy'},
+ Status => $ARGS{'Status'},
Name => $ARGS{'Name'});
if ($ok) {
diff --git a/share/html/Elements/RT__Dashboard/ColumnMap b/share/html/Elements/RT__Dashboard/ColumnMap
index 6891d4d..a954d11 100644
--- a/share/html/Elements/RT__Dashboard/ColumnMap
+++ b/share/html/Elements/RT__Dashboard/ColumnMap
@@ -119,7 +119,12 @@ my $COLUMN_MAP = {
return "Dashboards/$id/$name";
},
- }
+ },
+ Status => {
+ title => 'Status', # loc
+ attribute => 'Status',
+ value => sub { return ucfirst($_[0]->Status || 'optional') }, # loc('optional')
+ },
};
</%ONCE>
diff --git a/share/html/Elements/Tabs b/share/html/Elements/Tabs
index 0b3a50e..48f6112 100644
--- a/share/html/Elements/Tabs
+++ b/share/html/Elements/Tabs
@@ -460,6 +460,13 @@ my $build_main_nav = sub {
$session{'dashboards_in_menu'} = $dashboards_in_menu->{dashboards} || [];
}
+
+ my @mandatory =
+ map { $_->id }
+ grep { $_->Status && $_->Status eq 'mandatory' }
+ RT->System->Attributes->Named('Dashboard');
+ my %existing = map { $_ => 1 } @{$session{'dashboards_in_menu'}};
+ push @{$session{'dashboards_in_menu'}}, grep { !$existing{$_} } @mandatory;
my @dashboards;
for my $id ( @{$session{'dashboards_in_menu'}} ) {
diff --git a/share/html/Prefs/DashboardsInMenu.html b/share/html/Prefs/DashboardsInMenu.html
index 067b14b..fcc809a 100644
--- a/share/html/Prefs/DashboardsInMenu.html
+++ b/share/html/Prefs/DashboardsInMenu.html
@@ -89,7 +89,26 @@ my $dashboard_pref =
my $current_dashboards = $dashboard_pref->{dashboards} || [];
-my @dashboards = map { [$_->id, $_->Name] } $m->comp("/Dashboards/Elements/ListOfDashboards", IncludeSuperuserGroups => 0 );
+my @mandatory =
+ map { $_->id }
+ grep { $_->Status && $_->Status eq 'mandatory' }
+ RT->System->Attributes->Named('Dashboard');
+my %existing = map { $_ => 1 } @$current_dashboards;
+push @$current_dashboards, grep { !$existing{$_} } @mandatory;
+
+my @dashboards = map {
+ [
+ $_->id,
+ $_->Name
+ . (
+ $_->Status && $_->Status eq 'mandatory'
+ ? ' (' . loc('mandatory') . ')'
+ : ''
+ )
+ ]
+ } $m->comp( "/Dashboards/Elements/ListOfDashboards", IncludeSuperuserGroups => 0 );
+
+
my @panes = $m->comp(
'/Admin/Elements/ConfigureDashboardsInMenu',
@@ -99,6 +118,16 @@ my @panes = $m->comp(
current_portlets => $current_dashboards,
OnSave => sub {
my ( $conf ) = @_;
+ my @mandatory =
+ map { $_->id }
+ grep { $_->Status && $_->Status eq 'mandatory' }
+ RT->System->Attributes->Named('Dashboard');
+ my %existing = map { $_ => 1 } @{$conf->{dashboards}};
+ my @missing = grep { !$existing{$_} } @mandatory;
+ if ( @missing ) {
+ push @{$conf->{dashboards}}, @missing;
+ push @results, loc("Can't delete mandatory dashboards.");
+ }
my ( $ok, $msg ) =
$user->SetPreferences( 'DashboardsInMenu', $conf );
push @results, $ok ? loc('Preferences saved for dashboards in menu.') : $msg;
-----------------------------------------------------------------------
More information about the rt-commit
mailing list