@hmcts/ccd-case-ui-toolkit 7.3.43-exui-4277-test → 7.3.43-exui-4368-rc-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -6624,6 +6624,7 @@ class LabelSubstitutorDirective {
|
|
|
6624
6624
|
contextFields = [];
|
|
6625
6625
|
formGroup;
|
|
6626
6626
|
elementsToSubstitute = ['label', 'hint_text'];
|
|
6627
|
+
initialLabel;
|
|
6627
6628
|
initialHintText;
|
|
6628
6629
|
languageSubscription;
|
|
6629
6630
|
constructor(fieldsUtils, placeholderService, rpxTranslationPipe, rpxTranslationService) {
|
|
@@ -6633,9 +6634,10 @@ class LabelSubstitutorDirective {
|
|
|
6633
6634
|
this.rpxTranslationService = rpxTranslationService;
|
|
6634
6635
|
}
|
|
6635
6636
|
ngOnInit() {
|
|
6637
|
+
this.initialLabel = this.caseField.label;
|
|
6636
6638
|
this.initialHintText = this.caseField.hint_text;
|
|
6637
|
-
this.caseField.originalLabel = this.caseField.label;
|
|
6638
6639
|
this.noCacheProcessing();
|
|
6640
|
+
this.caseField.originalLabel = this.caseField.label;
|
|
6639
6641
|
this.formGroup = this.formGroup || new FormGroup({});
|
|
6640
6642
|
this.languageSubscription = this.rpxTranslationService.language$.pipe(skip(1)).subscribe(() => {
|
|
6641
6643
|
this.onLanguageChange();
|
|
@@ -6658,15 +6660,17 @@ class LabelSubstitutorDirective {
|
|
|
6658
6660
|
}
|
|
6659
6661
|
}
|
|
6660
6662
|
}
|
|
6661
|
-
applySubstitutions() {
|
|
6663
|
+
applySubstitutions(isLanguageChange = false) {
|
|
6662
6664
|
const fields = this.getReadOnlyAndFormFields();
|
|
6663
6665
|
if (this.shouldSubstitute('label')) {
|
|
6664
6666
|
const oldLabel = this.caseField.label;
|
|
6665
6667
|
const substitutedLabel = this.resolvePlaceholders(fields, this.caseField.label);
|
|
6666
6668
|
if (oldLabel && oldLabel !== substitutedLabel) {
|
|
6667
6669
|
// we need to translate the uninterpolated data then substitute the values in translated string
|
|
6668
|
-
this.caseField.originalLabel =
|
|
6669
|
-
const translated = this.
|
|
6670
|
+
this.caseField.originalLabel = oldLabel;
|
|
6671
|
+
const translated = isLanguageChange && this.rpxTranslationService.language === 'en'
|
|
6672
|
+
? oldLabel
|
|
6673
|
+
: this.rpxTranslationPipe.transform(oldLabel);
|
|
6670
6674
|
const transSubstitutedLabel = this.resolvePlaceholders(fields, translated);
|
|
6671
6675
|
this.caseField.label = transSubstitutedLabel;
|
|
6672
6676
|
this.caseField.isTranslated = this.rpxTranslationService.language === 'cy' && translated !== oldLabel;
|
|
@@ -6684,13 +6688,16 @@ class LabelSubstitutorDirective {
|
|
|
6684
6688
|
}
|
|
6685
6689
|
}
|
|
6686
6690
|
onLanguageChange() {
|
|
6687
|
-
this.resetToInitialValues();
|
|
6688
|
-
this.applySubstitutions();
|
|
6691
|
+
this.resetToInitialValues(true);
|
|
6692
|
+
this.applySubstitutions(true);
|
|
6689
6693
|
}
|
|
6690
|
-
resetToInitialValues() {
|
|
6691
|
-
if (this.caseField?.originalLabel) {
|
|
6694
|
+
resetToInitialValues(isLanguageChange = false) {
|
|
6695
|
+
if (isLanguageChange && this.caseField?.originalLabel) {
|
|
6692
6696
|
this.caseField.label = this.caseField.originalLabel;
|
|
6693
6697
|
}
|
|
6698
|
+
if (!isLanguageChange && this.initialLabel) {
|
|
6699
|
+
this.caseField.label = this.initialLabel;
|
|
6700
|
+
}
|
|
6694
6701
|
if (this.initialHintText) {
|
|
6695
6702
|
this.caseField.hint_text = this.initialHintText;
|
|
6696
6703
|
}
|