[Rt-commit] rt branch, 5.0/self-service-display-article, repushed

Dianne Skoll dianne at bestpractical.com
Mon Dec 14 15:47:13 EST 2020


The branch 5.0/self-service-display-article was deleted and repushed:
       was 42e146563864aa3d4f38c33fbecea22b5cf36f80
       now a21dca46386025f495c33686b35cca6bf85a0941

1: 67e5fbc322 = 1: 67e5fbc322 Add SelfServiceShowArticleSearch configuration option
2: 1d382799b6 = 2: 1d382799b6 Allow class-level rights to show self service articles
3: 2d3d55a665 = 3: 2d3d55a665 Display article content in a titlebox container
4: f5729e78e8 < -:  ------- Respect the "Include custom field: Value" setting in the article class.
5: 42e1465638 ! 4: a21dca4638 Load class show/hide settings for article components
    @@ -1,14 +1,14 @@
     Author: Dianne Skoll <dianne at bestpractical.com>
     
    -    Update self-service article display to respect hiding/showing field names, summary, and HTML-escaping settings.
    +    Load class show/hide settings for article components
         
    -    These settings are configured in Admin > Articles > Classes > Select
    -    and editing the specific class.
    -
    -diff --git a/share/html/Elements/ShowArticleFields b/share/html/Elements/ShowArticleFields
    +    Use the custom field settings to filter the content to display
    +    for the article.
    +
    +diff --git a/share/html/Elements/ShowArticleCustomFields b/share/html/Elements/ShowArticleCustomFields
     new file mode 100644
     --- /dev/null
    -+++ b/share/html/Elements/ShowArticleFields
    ++++ b/share/html/Elements/ShowArticleCustomFields
     @@
     +%# BEGIN BPS TAGGED BLOCK {{{
     +%#
    @@ -58,10 +58,8 @@
     +%#
     +%# END BPS TAGGED BLOCK }}}
     +% $m->callback( CallbackName => 'BeforeCustomFields', Object => $Object,
    -+%               Grouping => $Grouping, ARGSRef => \%ARGS, CustomFields => $CustomFields, Table => $Table );
    -+% if ($Table) {
    ++%               ARGSRef => \%ARGS, CustomFields => $CustomFields);
     +<div>
    -+% }
     +% while ( my $CustomField = $CustomFields->Next ) {
     +% my $Values = $Object->CustomFieldValues( $CustomField->Id );
     +% my $count = $Values->Count;
    @@ -76,7 +74,7 @@
     +% );
     +% push @classes, 'unset-field' if not $count;
     +% $m->callback( CallbackName => 'ModifyFieldClasses', CustomField => $CustomField,
    -+%               Object => $Object, Classes => \@classes, Grouping => $Grouping );
    ++%               Object => $Object, Classes => \@classes );
     +  <div class="form-row <% join(' ', @classes) %>" id="CF-<%$CustomField->id%>-ShowRow">
     +% if ($HideFieldnames->{$CustomField->id}) {
     +    <div class="value col-12 <% $count ? '' : ' no-value' %>">
    @@ -101,24 +99,19 @@
     +      </span>
     +    </div>
     +% $m->callback( CallbackName => 'AfterCustomFieldValue', CustomField => $CustomField,
    -+%               Object => $Object, Grouping => $Grouping, Table => $Table );
    ++%               Object => $Object );
     +  </div>
     +% }
    -+% if ($Table) {
     +</div>
    -+% }
     +% $m->callback( CallbackName => 'AfterCustomFields', Object => $Object,
    -+%               Grouping => $Grouping, ARGSRef => \%ARGS, Table => $Table );
    ++%               ARGSRef => \%ARGS );
     +<%INIT>
     +$m->callback(
     +    %ARGS,
     +    CallbackName => 'MassageCustomFields',
     +    Object       => $Object,
     +    CustomFields => $CustomFields,
    -+    Table        => $Table,
     +);
    -+
    -+$CustomFields->LimitToGrouping( $Object => $Grouping ) if defined $Grouping;
     +
     +# don't print anything if there is no custom fields
     +return unless $CustomFields->First;
    @@ -126,47 +119,25 @@
     +
     +my $print_value = sub {
     +    my ($cf, $value) = @_;
    -+    my $linked = $value->LinkValueTo;
    -+    if ( defined $linked && length $linked ) {
    -+        my $linked = $m->interp->apply_escapes( $linked, 'h' );
    -+        $m->out('<a href="'. $linked .'" target="_blank">');
    -+    }
    ++
     +    my $comp = "ShowCustomField". $cf->Type;
     +    $m->callback(
     +        CallbackName => 'ShowComponentName',
     +        Name         => \$comp,
     +        CustomField  => $cf,
     +        Object       => $Object,
    -+        Table        => $Table,
     +    );
     +    if ( $m->comp_exists( $comp ) ) {
     +        $m->comp( $comp, Object => $value, EscapeHTML => $EscapeHTML );
     +    } else {
     +        $m->out( $m->interp->apply_escapes( $value->Content, 'h' ) );
     +    }
    -+    $m->out('</a>') if defined $linked && length $linked;
    -+
    -+    # This section automatically populates a div with the "IncludeContentForValue" for this custom
    -+    # field if it's been defined
    -+    if ( $cf->IncludeContentForValue ) {
    -+       my $vid = $value->id;
    -+       $m->out(   '<div class="object_cf_value_include" id="object_cf_value_'. $vid .'">' );
    -+       $m->out( loc("See also:") );
    -+       $m->out(   '<a href="'. $m->interp->apply_escapes($value->IncludeContentForValue, 'h') .'">' );
    -+       $m->out( $m->interp->apply_escapes($value->IncludeContentForValue, 'h') );
    -+       $m->out(   qq{</a></div>\n} );
    -+       $m->out(   qq{<script><!--\njQuery('#object_cf_value_$vid').load(} );
    -+       $m->out(   $m->interp->apply_escapes($value->IncludeContentForValue, 'j') );
    -+       $m->out(   qq{);\n--></script>\n} );
    -+    }
     +};
     +
     +</%INIT>
     +<%ARGS>
     +$Object => undef
     +$CustomFields => $Object->CustomFields
    -+$Grouping => undef
    -+$Table => 1
     +$HideEmpty => 0
     +$HideFieldnames => {}
     +$EscapeHTML => 1
    @@ -205,33 +176,47 @@
      <& /SelfService/Elements/Header, Title => $article->Name &>
      <div id="article-display-container" class="mx-auto max-width-md">
     -<&| /Widgets/TitleBox, title => $article->Summary, class => 'article-display-simple', content_class => 'mx-auto width-md' &>
    --<& /Elements/ShowCustomFields, Object => $article, CustomFields => $custom_fields &>
    -+<&| /Widgets/TitleBox, title => $article->Name, class => 'article-display-simple', content_class => 'mx-auto width-md' &>
    -+% if ($include{Summary}) {
    -+  <div class="form-row">
    -+  <div class="label col-3"><% loc("Summary") %>:</div>
    -+  <div class="value col-9"><% $article->Summary |h %></div>
    -+  </div>
    -+% }
    -+<& /Elements/ShowArticleFields, Object => $article, CustomFields => $custom_fields, HideFieldnames => \%hide_field_names, EscapeHTML => $include{EscapeHTML} &>
    +-<& /Elements/ShowCustomFields, Object => $article &>
    ++% my $title = "";
    ++% $title = $article->Summary if $include{Summary};
    ++<&| /Widgets/TitleBox, title => $title, class => 'article-display-simple', content_class => 'mx-auto width-md' &>
    ++<& /Elements/ShowArticleCustomFields, Object => $article, CustomFields => $custom_fields, HideFieldnames => \%hide_field_names, EscapeHTML => $include{EscapeHTML} &>
      </&>
      </div>
      <%init>
     @@
    - # as the array of custom field IDs to limit by
    - my %include = (Name => 1, Summary => 1, EscapeHTML => 1);
    - my @exclude_cf_ids;
    + }
    + 
    + $id = $article->id;
    ++my $class = $article->ClassObj;
    ++
    ++# Build up the hash of things to include/exclude, as well
    ++# as the array of custom field IDs to limit by
    ++my %include = (Name => 1, Summary => 1, EscapeHTML => 1);
    ++my @exclude_cf_ids;
     +my %hide_field_names;
    - 
    - my $cfs = $article->CustomFields;
    - while ( my $cf = $cfs->Next ) {
    -@@
    -     if ($key =~ /^CF-Value-(\d+)$/ && !$include{$key}) {
    -         push(@exclude_cf_ids, $1);
    -     }
    ++
    ++my $cfs = $article->CustomFields;
    ++while ( my $cf = $cfs->Next ) {
    ++    $include{"CF-Title-" . $cf->Id} = 1;
    ++    $include{"CF-Value-" . $cf->Id} = 1;
    ++}
    ++foreach my $key ( keys %include ) {
    ++    $include{$key} = not $class->FirstAttribute("Skip-$key");
    ++    if ($key =~ /^CF-Value-(\d+)$/ && !$include{$key}) {
    ++        push(@exclude_cf_ids, $1);
    ++    }
     +    if ($key =~ /^CF-Title-(\d+)$/ && !$include{$key}) {
     +        $hide_field_names{$1} = 1;
     +    }
    - }
    ++}
    ++
    ++my $custom_fields = $article->CustomFields;
    ++if (scalar(@exclude_cf_ids)) {
    ++    $custom_fields->Limit(FIELD    => 'id',
    ++                          OPERATOR => 'NOT IN',
    ++                          VALUE    => \@exclude_cf_ids);
    ++}
      
    - my $custom_fields = $article->CustomFields;
    + </%init>
    + <%args>



More information about the rt-commit mailing list