[Rt-commit] rt branch, 5.0/self-service-homepage-dashboard, updated. rt-5.0.0-12-gf15260de87
Dianne Skoll
dianne at bestpractical.com
Wed Sep 9 12:24:50 EDT 2020
The branch, 5.0/self-service-homepage-dashboard has been updated
via f15260de877e1b92dd8fa49609ad3c654d344440 (commit)
from a4ffc08fd319acdd6fd7e9ef4ddd31a097a92b4c (commit)
Summary of changes:
lib/RT/Article.pm | 2 +-
share/html/Articles/Article/Display.html | 9 ++++
share/html/Articles/Article/Edit.html | 62 ++++++++++++++++---------
share/html/Articles/Article/Elements/EditBasics | 8 ++++
4 files changed, 59 insertions(+), 22 deletions(-)
- Log -----------------------------------------------------------------
commit f15260de877e1b92dd8fa49609ad3c654d344440
Author: Dianne Skoll <dianne at bestpractical.com>
Date: Wed Sep 9 12:16:46 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..ba7375efca 100644
--- a/lib/RT/Article.pm
+++ b/lib/RT/Article.pm
@@ -777,7 +777,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..3820fd0c2d 100644
--- a/share/html/Articles/Article/Edit.html
+++ b/share/html/Articles/Article/Edit.html
@@ -148,22 +148,33 @@ elsif ( $id eq 'new' ) {
split( /\s+/, $ARGS{'new-RefersTo'} );
}
- my %cfs = ProcessObjectCustomFieldUpdatesForCreate(
- ARGSRef => \%ARGS,
- ContextObject => $ClassObj,
- );
+ my $attempt_create = 1;
+ if ($ARGS{SortOrder}) {
+ if ($ARGS{SortOrder} !~ /^\d+$/) {
+ push @results, (0, loc('Sort Order must be an integer'));
+ $attempt_create = 0;
+ $id = 0;
+ }
+ }
+ if ($attempt_create) {
+ 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 );
+ my $msg;
+ ( $id, $msg ) = $ArticleObj->Create(
+ Summary => $ARGS{'Summary'},
+ SortOrder => $ARGS{'SortOrder'},
+ Name => $ARGS{'Name'},
+ Class => $ARGS{'Class'},
+ Topics => $ARGS{'Topics'},
+ Disabled => $ARGS{'Disabled'},
+ %create_args,
+ %cfs
+ );
+ push( @results, $msg );
+ }
if ($id) {
@@ -197,13 +208,22 @@ 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
- );
+ my $attempt_update = 1;
+ if ($ARGS{SortOrder}) {
+ if ($ARGS{SortOrder} !~ /^\d+$/) {
+ push @results, (0, loc('Sort Order must be an integer'));
+ $attempt_update = 0;
+ }
+ }
+ if ($attempt_update) {
+ @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..a898a9cbd1 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' |h%>" size="50" />
+ </div>
+</div>
<div class="form-row">
<div class="label col-3">
<&|/l&>Class</&>:
-----------------------------------------------------------------------
More information about the rt-commit
mailing list