LP1902120 the All/Any Part(s) label collab/phasefx/lp1902120-eparts
authorJason Etheridge <jason@EquinoxOLI.org>
Tue, 24 Jan 2023 02:18:24 +0000 (21:18 -0500)
committerJason Etheridge <jason@EquinoxOLI.org>
Tue, 24 Jan 2023 04:54:24 +0000 (23:54 -0500)
This feature creates a new table for localizable strings intended to be used in
UI's.  This is not a replacement for the existing I18N system for templates,
but does allow developers to choose some strings to be more easily accessible
to staff/admins for dynamic localization.  The string we're focused on here is
a replacement for the "All Parts" and "Any Part" label in various Place Hold
interfaces when monographic parts are an option.  There is a UI for managing
such strings under Administration -> Server Administration -> I18N: Localized
UI Strings.  An admin could change the "string" field directly, or use the
existing Apply Translation mechanism to customize the string for a specific
locale.

As a bonus feature, we also expose an alternate UI for handling entries for
said Translation mechanism.  This can be found under Administration -> Server
Administration -> I18N: Localized Fieldmapper Strings.

These customizations are global to the Evergreen installation.

Signed-off-by: Jason Etheridge <jason@EquinoxOLI.org>
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/eg2/src/app/staff/admin/server/admin-server-splash.component.html
Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.html
Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.ts
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/YYYY.schema.eparts.sql [new file with mode: 0644]
Open-ILS/src/templates-bootstrap/opac/parts/place_hold.tt2
Open-ILS/src/templates/opac/parts/place_hold.tt2
docs/RELEASE_NOTES_NEXT/miscellaneous.adoc

index a4fb45b..8cc40aa 100644 (file)
@@ -9100,6 +9100,21 @@ SELECT  usr,
             </actions>
         </permacrud>
        </class>
+       <class id="i18ns" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="config::i18n_string" oils_persist:tablename="config.i18n_string" oils_persist:field_safe="true" reporter:label="i18n String">
+               <fields oils_persist:primary="id" oils_persist:sequence="config.i18n_string_id_seq">
+                       <field name="id" reporter:datatype="id" />
+                       <field name="context" reporter:datatype="text"/>
+                       <field name="string" reporter:datatype="text" oils_persist:i18n="true"/>
+               </fields>
+        <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+            <actions>
+                <create permission="CREATE_TRANSLATION" global_required="true"/>
+                <retrieve />
+                <update permission="UPDATE_TRANSLATION" global_required="true"/>
+                <delete permission="DELETE_TRANSLATION" global_required="true"/>
+            </actions>
+        </permacrud>
+       </class>
        <class id="fdoc" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="config::idl_field_doc" oils_persist:tablename="config.idl_field_doc" oils_persist:field_safe="true" reporter:label="IDL Field Doc">
                <fields oils_persist:primary="id" oils_persist:sequence="config.idl_field_doc_id_seq">
                        <field name="id"       reporter:label="ID" reporter:datatype="id" />
index c6a4108..9e61873 100644 (file)
       routerLink="/staff/admin/server/config/hold_matrix_weights"></eg-link-table-link>
     <eg-link-table-link i18n-label label="Import Match Sets"  
       routerLink="/staff/cat/vandelay/match_sets"></eg-link-table-link>
+    <eg-link-table-link i18n-label label="I18N: Localized Fieldmapper Strings"
+      routerLink="/staff/admin/local/config/i18n_core"></eg-link-table-link>
+    <eg-link-table-link i18n-label label="I18N: Localized UI Strings"
+      routerLink="/staff/admin/local/config/i18n_string"></eg-link-table-link>
     <eg-link-table-link i18n-label label="Item Statuses"  
       routerLink="/staff/admin/server/config/copy_status"></eg-link-table-link>
     <eg-link-table-link i18n-label label="Item Tag Types"  
index 932d042..68f96bb 100644 (file)
           <ng-container *ngIf="ctx.holdMeta.parts.length">
             <select class="form-control"  (change)="setPart(ctx, $event)"
               [ngModel]="ctx.holdMeta.part ? ctx.holdMeta.part.id() : (ctx.holdMeta.part_required ? ctx.holdMeta.parts[0].id() : '')">
-              <option *ngIf="!ctx.holdMeta.part_required" value="" i18n>Any Part</option>
+              <option *ngIf="!ctx.holdMeta.part_required" value="">{{anyPartLabel}}</option>
               <option *ngFor="let part of ctx.holdMeta.parts"
                 value="{{part.id()}}">{{part.label()}}</option>
             </select>
index fc4c836..e7ddb7f 100644 (file)
@@ -71,6 +71,7 @@ export class HoldComponent implements OnInit {
     activeDateYmd: string;
     activeDate: Date;
     activeDateInvalid = false;
+    anyPartLabel: string;
 
     holdContexts: HoldContext[];
     recordSummaries: BibRecordSummary[];
@@ -169,6 +170,11 @@ export class HoldComponent implements OnInit {
             }
         });
 
+        this.pcrud.retrieve('i18ns', 1) // Any Part
+        .subscribe(i18n_string => {
+            this.anyPartLabel = i18n_string.string();
+        });
+
         if (!Array.isArray(this.holdTargets)) {
             this.holdTargets = [this.holdTargets];
         }
index 3ee345a..1ba9a04 100644 (file)
@@ -1503,6 +1503,9 @@ sub load_place_hold {
 
     $logger->info("Looking at hold_type: " . $ctx->{hold_type} . " and targets: @targets");
 
+    my $any_part_label = $self->editor->retrieve_config_i18n_string([1, {}]);
+    $any_part_label = $any_part_label->string if $any_part_label;
+    $ctx->{any_part_label} = $any_part_label;
     $ctx->{staff_recipient} = $self->editor->retrieve_actor_user([
         $e->requestor->id,
         {
index 0643d46..bc2a370 100644 (file)
@@ -623,6 +623,13 @@ BEGIN
 END;
 $_$ LANGUAGE PLPGSQL;
 
+-- this may grow to support full GNU gettext functionality
+CREATE TABLE config.i18n_string (
+    id              SERIAL      PRIMARY KEY,
+    context         TEXT        NOT NULL, -- hint for translators to disambiguate
+    string          TEXT        NOT NULL
+);
+
 CREATE TABLE config.billing_type (
     id              SERIAL  PRIMARY KEY,
     name            TEXT    NOT NULL,
index 9ece90f..fbef0ac 100644 (file)
@@ -18879,6 +18879,8 @@ INSERT INTO config.i18n_core (fq_field, identity_value, translation, string )
           AND t.xlate IS NOT NULL
           AND t.name <> (xlate->value);
 
+INSERT INTO config.i18n_string (id, context, string) VALUES (1, 'In the Place Hold interfaces for staff and patrons, when monographic parts are available, this would be the option for indicating that no specific part is being requested.', 'Any Part');
+
 INSERT INTO authority.heading_field(heading_type, heading_purpose, label, heading_xpath, component_xpath, type_xpath, thesaurus_xpath, thesaurus_override_xpath) VALUES
  ( 'topical_term', 'main',    'Main Topical Term',    '/mads21:mads/mads21:authority', '//mads21:topic', NULL, '/mads21:mads/mads21:authority/mads21:topic[1]/@authority', NULL )
 ,( 'topical_term', 'variant', 'Variant Topical Term', '/mads21:mads/mads21:variant',   '//mads21:topic', '/mads21:variant/@type', '/mads21:mads/mads21:authority/mads21:topic[1]/@authority', '//mads21:topic[1]/@authority')
diff --git a/Open-ILS/src/sql/Pg/upgrade/YYYY.schema.eparts.sql b/Open-ILS/src/sql/Pg/upgrade/YYYY.schema.eparts.sql
new file mode 100644 (file)
index 0000000..4c3fa76
--- /dev/null
@@ -0,0 +1,19 @@
+BEGIN;
+
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('YYYY', :eg_version);
+
+-- 002.schema.config.sql
+
+-- this may grow to support full GNU gettext functionality
+CREATE TABLE config.i18n_string (
+    id              SERIAL      PRIMARY KEY,
+    context         TEXT        NOT NULL, -- hint for translators to disambiguate
+    string          TEXT        NOT NULL
+);
+
+-- 950.data.seed-values.sql
+
+INSERT INTO config.i18n_string (id, context, string) VALUES (1, 'In the Place Hold interfaces for staff and patrons, when monographic parts are available, this would be the option for indicating that no specific part is being requested.', 'Any Part');
+
+COMMIT;
index 7af5d42..2cb9f58 100755 (executable)
@@ -179,7 +179,7 @@ function maybeToggleNumCopies(obj) {
                              <div class='radio-parts-selection'>
                              [% IF !hdata.part_required %]
                                 <span class='parts-radio-option'>
-                                 <input type='radio' name='part' value='' onchange='maybeToggleNumCopies(this);' required>[% l('All Parts') %]</span>
+                                 <input type='radio' name='part' value='' onchange='maybeToggleNumCopies(this);' required>[% ctx.any_part_label %]</span>
                               [% END %]
                                [% FOR part IN hdata.parts %]
                                  <span class='parts-radio-option'><input type='radio' name='part' id=[% part.id %] value=[% part.id %] onchange='maybeToggleNumCopies(this);' required>
@@ -192,7 +192,7 @@ function maybeToggleNumCopies(obj) {
                             %]</label></span>
                             <select id='select_hold_part' name='part' onchange='maybeToggleNumCopies(this);'>
                                 [% IF !hdata.part_required %]
-                                <option selected='selected' value=''>[% l('- All Parts -') %]</option>
+                                <option selected='selected' value=''>[% ctx.any_part_label %]</option>
                                 [% END %]
                                 [% FOR part IN hdata.parts %]
                                 <option value='[% part.id %]'>[% part.label | html %]</option>
index 809def3..bcf5282 100644 (file)
@@ -180,7 +180,7 @@ function maybeToggleNumCopies(obj) {
                              <div class='radio-parts-selection'>
                              [% IF !hdata.part_required %]
                                 <span class='parts-radio-option'>
-                                 <input type='radio' name='part' value='' onchange='maybeToggleNumCopies(this);' required>[% l('All Parts') %]</span>
+                                 <input type='radio' name='part' value='' onchange='maybeToggleNumCopies(this);' required>[% ctx.any_part_label %]</span>
                               [% END %]
                                [% FOR part IN hdata.parts %]
                                  <span class='parts-radio-option'><input type='radio' name='part' id=[% part.id %] value=[% part.id %] onchange='maybeToggleNumCopies(this);' required>
@@ -193,7 +193,7 @@ function maybeToggleNumCopies(obj) {
                             %]</label></span>
                             <select id='select_hold_part' name='part' onchange='maybeToggleNumCopies(this);'>
                                 [% IF !hdata.part_required %]
-                                <option selected='selected' value=''>[% l('- All Parts -') %]</option>
+                                <option selected='selected' value=''>[% ctx.any_part_label %]</option>
                                 [% END %]
                                 [% FOR part IN hdata.parts %]
                                 <option value='[% part.id %]'>[% part.label | html %]</option>
index 85fb5f1..0000c9e 100644 (file)
     event for a title hold request when there are items with monographic parts on the bib.  It is possible for
     the library settings and the global flag to differ, but the global flag will catch every instance of hold
     placement including those by third party callers, SIP, etc.
+
+* LP1902120 the All/Any Part(s) label
+
+    This feature creates a new table for localizable strings intended to be used in
+    UI's.  This is not a replacement for the existing I18N system for templates,
+    but does allow developers to choose some strings to be more easily accessible
+    to staff/admins for dynamic localization.  The string we're focused on here is
+    a replacement for the "All Parts" and "Any Part" label in various Place Hold
+    interfaces when monographic parts are an option.  There is a UI for managing
+    such strings under Administration -> Server Administration -> I18N: Localized
+    UI Strings.  An admin could change the "string" field directly, or use the
+    existing Apply Translation mechanism to customize the string for a specific
+    locale.
+
+    As a bonus feature, we also expose an alternate UI for handling entries for
+    said Translation mechanism.  This can be found under Administration -> Server
+    Administration -> I18N: Localized Fieldmapper Strings.
+
+    These customizations are global to the Evergreen installation.
+