LP1888723 Volcopy strings should be global
authorBill Erickson <berickxx@gmail.com>
Wed, 6 Jan 2021 18:10:58 +0000 (13:10 -0500)
committerGalen Charlton <gmc@equinoxOLI.org>
Sun, 15 Aug 2021 23:56:06 +0000 (19:56 -0400)
Moving the <eg-string /> entries to the root of the tepmlate ensures all
references to those strings are defined / non-null.  Otherwise, if the
user opts to hide a field which contained its own strings (e.g. loan
duration), the code would fail on null references, e.g.:

ERROR TypeError: Cannot read property 'text' of undefined

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Ruth Frasur <rfrasur@library.in.gov>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/src/eg2/src/app/staff/cat/volcopy/copy-attrs.component.html

index e7e4bd7..632640a 100644 (file)
@@ -1,4 +1,15 @@
+<eg-string #loanDurationShort i18n-text text="Short"></eg-string>
+<eg-string #loanDurationNormal i18n-text text="Normal"></eg-string>
+<eg-string #loanDurationLong i18n-text text="Long"></eg-string>
 
+<eg-string #fineLevelLow i18n-text text="Low"></eg-string>
+<eg-string #fineLevelNormal i18n-text text="Normal"></eg-string>
+<eg-string #fineLevelHigh i18n-text text="High"></eg-string>
+
+<eg-string #olLabel text="Owning Library" i18n-text></eg-string>
+
+<eg-string #mintConditionYes i18n-text text="Good"></eg-string>
+<eg-string #mintConditionNo i18n-text text="Damaged"></eg-string>
 
 <!-- We ask this question a lot.  Here's a handy template -->
 <ng-template #yesNoSelect let-field="field">
     </div>
 
     <div *ngIf="displayAttr('owning_lib')">
-      <eg-string #olLabel text="Owning Library" i18n-text></eg-string>
       <ng-template #owningLibTemplate>
         <eg-org-select 
           domId="owning_lib-input"
     </div>
 
     <div *ngIf="displayAttr('loan_duration')">
-      <eg-string #loanDurationShort i18n-text text="Short"></eg-string>
-      <eg-string #loanDurationNormal i18n-text text="Normal"></eg-string>
-      <eg-string #loanDurationLong i18n-text text="Long"></eg-string>
-
       <ng-template #loanDurationTemplate>
         <select class="form-control" 
           id="loan_duration-input" [(ngModel)]="values['loan_duration']">
     </div>
 
     <div *ngIf="displayAttr('fine_level')">
-      <eg-string #fineLevelLow i18n-text text="Low"></eg-string>
-      <eg-string #fineLevelNormal i18n-text text="Normal"></eg-string>
-      <eg-string #fineLevelHigh i18n-text text="High"></eg-string>
-
       <ng-template #fineLevelTemplate>
         <select class="form-control" 
           id="fine_level-input" [(ngModel)]="values['fine_level']">
     </div>
 
     <div *ngIf="displayAttr('mint_condition')">
-      <eg-string #mintConditionYes i18n-text text="Good"></eg-string>
-      <eg-string #mintConditionNo i18n-text text="Damaged"></eg-string>
-
       <ng-template #mintConditionTemplate>
         <select class="form-control" 
           id="mint_condition-input" [(ngModel)]="values['mint_condition']">