[Rt-commit] rt branch, 5.0/allow-custom-fields-on-article-class, created. rt-5.0.1-1-gb7df5303a3
Steve Burr
steve at bestpractical.com
Fri Apr 23 16:42:34 EDT 2021
The branch, 5.0/allow-custom-fields-on-article-class has been created
at b7df5303a3736405cf4779d465ba0c17380f88d2 (commit)
- Log -----------------------------------------------------------------
commit b7df5303a3736405cf4779d465ba0c17380f88d2
Author: Steven Burr <steve at bestpractical.com>
Date: Fri Apr 23 16:41:06 2021 -0400
Allow custom fields on article classes
RT::Class objects can define sets of custom fields that their articles
will possess, but they cannot have custom fields of their own.
This adds that capability and allows them to be edited through the
usual Admin screens.
diff --git a/lib/RT/Class.pm b/lib/RT/Class.pm
index bc4f1c6de0..39ab4cf985 100644
--- a/lib/RT/Class.pm
+++ b/lib/RT/Class.pm
@@ -65,6 +65,11 @@ with "RT::Record::Role::Rights";
sub Table {'Classes'}
+# this object can take custom fields
+
+use RT::CustomField;
+RT::CustomField->RegisterLookupType( CustomFieldLookupType() => 'Article Class' ); #loc
+
=head2 Load IDENTIFIER
Loads a class, either by name or by id
@@ -587,6 +592,10 @@ sub PreInflate {
return 1;
}
+sub CustomFieldLookupType {
+ "RT::Class";
+}
+
RT::Base->_ImportOverlays();
1;
diff --git a/share/html/Admin/Articles/Classes/Modify.html b/share/html/Admin/Articles/Classes/Modify.html
index 02e5187775..6c408dfda6 100644
--- a/share/html/Admin/Articles/Classes/Modify.html
+++ b/share/html/Admin/Articles/Classes/Modify.html
@@ -166,6 +166,24 @@
&>
% }
+% my $CFs = $ClassObj->CustomFields;
+% if ($CFs->Count) {
+<h5 class="mt-3"><&|/l&>Class Custom Fields:</&></h5>
+% }
+% while (my $CF = $CFs->Next) {
+ <div class="form-row">
+ <div class="label col-3">
+ <% $CF->Name %>:
+% if ( $CF->EntryHint ) {
+ <span class="far fa-question-circle icon-helper" data-toggle="tooltip" data-placement="top" data-original-title="<% $CF->EntryHint %>"></span>
+% }
+ </div>
+ <div class="value col-9">
+ <& /Elements/EditCustomField, CustomField => $CF, Object => $ClassObj, &>
+ </div>
+ </div>
+% }
+
%$m->callback( CallbackName => 'BeforeSubmit', CustomFields => $cfs, ClassObj => $ClassObj );
</&>
@@ -178,6 +196,7 @@
% }
</div>
</div>
+
</form>
<%INIT>
@@ -226,6 +245,7 @@ if ($ClassObj->Id()) {
push @results, UpdateRecordObject( AttributesRef => \@attribs,
Object => $ClassObj,
ARGSRef => \%ARGS);
+ push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $ClassObj );
}
#we're asking about enabled on the web page but really care about disabled.
-----------------------------------------------------------------------
More information about the rt-commit
mailing list