[Rt-commit] rt branch, 5.0-trunk, updated. rt-5.0.0-34-gffc39473e9
? sunnavy
sunnavy at bestpractical.com
Mon Oct 5 19:22:16 EDT 2020
The branch, 5.0-trunk has been updated
via ffc39473e9345f67b0ca752f5b6a7457b9e93c04 (commit)
via 0cbb514e4cc810e5592ea31abea24b315b1f6197 (commit)
from c1c3de69ee8ab67194c601a2d89bcce0be411e9c (commit)
Summary of changes:
lib/RT/Article.pm | 4 +-
share/html/Articles/Article/Display.html | 9 ++++
share/html/Articles/Article/Edit.html | 61 +++++++++++++++----------
share/html/Articles/Article/Elements/EditBasics | 8 ++++
4 files changed, 58 insertions(+), 24 deletions(-)
- Log -----------------------------------------------------------------
commit 0cbb514e4cc810e5592ea31abea24b315b1f6197
Author: Dianne Skoll <dianne at bestpractical.com>
Date: Fri Oct 2 11:06:25 2020 -0400
Add UI for editing and displaying the SortOrder associated with an article.
diff --git a/lib/RT/Article.pm b/lib/RT/Article.pm
index af1e628784..acc1967836 100644
--- a/lib/RT/Article.pm
+++ b/lib/RT/Article.pm
@@ -96,6 +96,7 @@ sub Create {
my %args = (
Name => '',
Summary => '',
+ SortOrder => 0,
Class => '0',
CustomFields => {},
Links => {},
@@ -122,6 +123,7 @@ sub Create {
Name => $args{'Name'},
Class => $class->Id,
Summary => $args{'Summary'},
+ SortOrder => $args{'SortOrder'},
Disabled => $args{'Disabled'},
);
unless ($id) {
@@ -777,7 +779,7 @@ sub _CoreAccessible {
Summary =>
{read => 1, write => 1, type => 'varchar(255)', default => ''},
SortOrder =>
- {read => 1, write => 1, type => 'int(11)', default => '0'},
+ {read => 1, write => 1, type => 'int(11)', default => '0', is_numeric => 1},
Class =>
{read => 1, write => 1, type => 'int(11)', default => '0'},
Parent =>
diff --git a/share/html/Articles/Article/Display.html b/share/html/Articles/Article/Display.html
index 6f841d430a..aee001f5c5 100644
--- a/share/html/Articles/Article/Display.html
+++ b/share/html/Articles/Article/Display.html
@@ -58,6 +58,15 @@
</div>
</div>
+ <div class="form-row">
+ <div class="label col-3">
+ <&|/l&>Sort Order</&>:
+ </div>
+ <div class="value col-9">
+ <span class="current-value"><%$article->SortOrder%></span>
+ </div>
+ </div>
+
<div class="form-row">
<div class="label col-3">
<&|/l&>Class</&>:
diff --git a/share/html/Articles/Article/Edit.html b/share/html/Articles/Article/Edit.html
index b51e0eda55..d22f554341 100644
--- a/share/html/Articles/Article/Edit.html
+++ b/share/html/Articles/Article/Edit.html
@@ -122,6 +122,14 @@ if ( $ARGS{SetEnabled} ) {
$ARGS{Disabled} = $ARGS{Enabled} ? 0 : 1;
}
+my $sortorder_ok = 1;
+if ($ARGS{SortOrder}) {
+ if ($ARGS{SortOrder} !~ /^-?\d+$/) {
+ push @results, (0, loc('Sort Order must be an integer'));
+ $sortorder_ok = 0;
+ }
+}
+
if ( !$id ) {
$title = loc('Create a new article');
foreach my $arg ( sort keys %ARGS ) {
@@ -148,25 +156,30 @@ elsif ( $id eq 'new' ) {
split( /\s+/, $ARGS{'new-RefersTo'} );
}
- my %cfs = ProcessObjectCustomFieldUpdatesForCreate(
- ARGSRef => \%ARGS,
- ContextObject => $ClassObj,
- );
-
- my $msg;
- ( $id, $msg ) = $ArticleObj->Create(
- Summary => $ARGS{'Summary'},
- Name => $ARGS{'Name'},
- Class => $ARGS{'Class'},
- Topics => $ARGS{'Topics'},
- Disabled => $ARGS{'Disabled'},
- %create_args,
- %cfs
- );
- push( @results, $msg );
- if ($id) {
+ my %cfs;
+ if ($sortorder_ok) {
+ %cfs = ProcessObjectCustomFieldUpdatesForCreate(
+ ARGSRef => \%ARGS,
+ ContextObject => $ClassObj,
+ );
+ my $msg;
+ ( $id, $msg ) = $ArticleObj->Create(
+ Summary => $ARGS{'Summary'},
+ Name => $ARGS{'Name'},
+ SortOrder => $ARGS{'SortOrder'},
+ Class => $ARGS{'Class'},
+ Topics => $ARGS{'Topics'},
+ Disabled => $ARGS{'Disabled'},
+ %create_args,
+ %cfs
+ );
+ push( @results, $msg );
+ } else {
+ $id = 0;
+ }
+ if ($id) {
$ArticleObj->Load($id);
$title = loc( 'Modify article #[_1]', $ArticleObj->Id );
@@ -197,13 +210,15 @@ else {
Why => loc("Unable to load article") );
}
- my @attribs = qw(Name Summary Class Disabled);
+ my @attribs = qw(Name Summary Class Disabled SortOrder);
- @results = UpdateRecordObject(
- AttributesRef => \@attribs,
- Object => $ArticleObj,
- ARGSRef => \%ARGS
- );
+ if ($sortorder_ok) {
+ @results = UpdateRecordObject(
+ AttributesRef => \@attribs,
+ Object => $ArticleObj,
+ ARGSRef => \%ARGS
+ );
+ }
my @cf_results = ProcessObjectCustomFieldUpdates(
Object => $ArticleObj,
diff --git a/share/html/Articles/Article/Elements/EditBasics b/share/html/Articles/Article/Elements/EditBasics
index 73c5a7f5a1..b6dcd70dbf 100644
--- a/share/html/Articles/Article/Elements/EditBasics
+++ b/share/html/Articles/Article/Elements/EditBasics
@@ -61,6 +61,14 @@
<input class="form-control" type="text" name="Summary" value="<%($ARGS{'id'} eq 'new' ? '' : $ArticleObj->Summary) || $ARGS{'Summary'} ||'' |h%>" size="50" />
</div>
</div>
+<div class="form-row">
+ <div class="label col-3">
+ <&|/l&>Sort Order</&>:
+ </div>
+ <div class="value col-9">
+ <input class="form-control" type="text" name="SortOrder" value="<%($ARGS{'id'} eq 'new' ? '0' : $ArticleObj->SortOrder) || $ARGS{'SortOrder'} || '0' %>" size="50" />
+ </div>
+</div>
<div class="form-row">
<div class="label col-3">
<&|/l&>Class</&>:
commit ffc39473e9345f67b0ca752f5b6a7457b9e93c04
Merge: c1c3de69ee 0cbb514e4c
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Oct 6 06:45:06 2020 +0800
Merge branch '5.0/article-sort-order-ui' into 5.0-trunk
-----------------------------------------------------------------------
More information about the rt-commit
mailing list