inviton-powerduck 0.0.86 → 0.0.87

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.
@@ -1,17 +1,19 @@
1
1
  import PowerduckState from '../app/powerduck-state';
2
2
  import { Language } from './enums/language';
3
- import LocalizedText from './localized-text';
3
+ import { ILocalizedText } from './localized-text';
4
4
  import { isNullOrEmpty } from './utils/is-null-or-empty';
5
5
 
6
- export default class LocalizedValueHelper {
7
- static getLocalizedValue(value: LocalizedText): string {
6
+ export default class LocalizedValueHelper {
7
+ static getValue(value: ILocalizedText, lang?: Language | string): string {
8
8
  if (value == null) {
9
9
  return null as any;
10
10
  }
11
11
 
12
- const lang = PowerduckState.getCurrentLanguage();
13
- const inLang = value[lang];
12
+ if (lang == null) {
13
+ lang = PowerduckState.getCurrentLanguage()
14
+ }
14
15
 
16
+ const inLang = value[lang];
15
17
  if (inLang != null) {
16
18
  return inLang;
17
19
  }
@@ -42,8 +44,8 @@ export default class LocalizedValueHelper {
42
44
  return null as any;
43
45
  }
44
46
 
45
- static validateLocalizedValue(locValArr: LocalizedText): boolean {
46
- if (isNullOrEmpty(LocalizedValueHelper.getLocalizedValue(locValArr))) {
47
+ static validateLocalizedValue(locValArr: ILocalizedText): boolean {
48
+ if (isNullOrEmpty(LocalizedValueHelper.getValue(locValArr))) {
47
49
  return false;
48
50
  }
49
51
 
@@ -21,11 +21,11 @@
21
21
  } from "@vuelidate/validators";
22
22
  import { PowerduckViewModelBase } from "./base-component";
23
23
  import { Validation } from "@vuelidate/core";
24
- import LocalizedStringHelper from "./utils/localized-string";
25
24
  import { isNullOrEmpty } from "./utils/is-null-or-empty";
26
25
  import { capitalize } from "./utils/capitalize-string";
27
26
  import PowerduckState from "../app/powerduck-state";
28
27
  import { IValidationSet, ValidationRuleset, ValidationState } from "./static-wrappers/interfaces/validation-interface";
28
+ import LocalizedValueHelper from "./localized-value-helper";
29
29
 
30
30
  function getFirstUnsattisfiedValidatorName(valProp: Validation): string {
31
31
  const errors = valProp?.$errors || [];
@@ -158,7 +158,7 @@ export class ValidationBuilder {
158
158
 
159
159
  requiredLocalizedString(): ValidationBuilder {
160
160
  this._validationArgs.requiredLocalizedString = (value) => {
161
- if (value == null || isNullOrEmpty(LocalizedStringHelper.getValue(value, 'sk'))) {
161
+ if (value == null || isNullOrEmpty(LocalizedValueHelper.getValue(value, 'sk'))) {
162
162
  return false;
163
163
  }
164
164
 
@@ -1,5 +1,5 @@
1
1
  import { Prop, toNative } from "vue-facing-decorator";
2
- import LocalizedText from "../../common/localized-text";
2
+ import { ILocalizedText } from "../../common/localized-text";
3
3
  import TsxComponent, { Component } from "../../app/vuetsx";
4
4
  import { Language } from "../../common/enums/language";
5
5
  import { isNullOrEmpty } from "../../common/utils/is-null-or-empty";
@@ -12,13 +12,13 @@ import { ValidationState } from "../../common/static-wrappers/interfaces/validat
12
12
  interface LocalizedInfoInputArgs {
13
13
  label: string;
14
14
  wrap?: boolean;
15
- value: LocalizedText;
15
+ value: ILocalizedText;
16
16
  placeholder?: string;
17
17
  subtitle?: string;
18
18
  hint?: string;
19
19
  displayType?: "input" | "textarea";
20
20
  validationState?: ValidationState;
21
- changed: (e: LocalizedText) => void;
21
+ changed: (e: ILocalizedText) => void;
22
22
  mandatory?: boolean;
23
23
  }
24
24
 
@@ -26,19 +26,19 @@ interface LocalizedInfoInputArgs {
26
26
  class LocalizedInfoInputComponent extends TsxComponent<LocalizedInfoInputArgs> implements LocalizedInfoInputArgs {
27
27
  @Prop() label: string;
28
28
  @Prop() wrap?: boolean;
29
- @Prop() value: LocalizedText;
29
+ @Prop() value: ILocalizedText;
30
30
  @Prop() placeholder!: string;
31
31
  @Prop() subtitle!: string;
32
32
  @Prop() hint!: string;
33
33
  @Prop() displayType: "input" | "textarea";
34
- @Prop() changed: (e: LocalizedText) => void;
34
+ @Prop() changed: (e: ILocalizedText) => void;
35
35
  @Prop() mandatory?: boolean;
36
36
 
37
37
  getValueForTmrLanguage(lang: Language): string {
38
38
  return this.value[lang];
39
39
  }
40
40
 
41
- getValue(value: LocalizedText): LocalizedText {
41
+ getValue(value: ILocalizedText): ILocalizedText {
42
42
  if (value == null) {
43
43
  return {
44
44
  cs: null,
@@ -62,13 +62,13 @@ class LocalizedInfoInputComponent extends TsxComponent<LocalizedInfoInputArgs> i
62
62
  };
63
63
  }
64
64
 
65
- valueChanged(e: LocalizedText): void {
65
+ valueChanged(e: ILocalizedText): void {
66
66
  if (e == null) {
67
67
  this.changed(null);
68
68
  return;
69
69
  }
70
70
 
71
- let retObj: LocalizedText = {} as any;
71
+ let retObj: ILocalizedText = {} as any;
72
72
  const addLocalizedValue = (lang: Language, value: string): void => {
73
73
  if (!isNullOrEmpty(value)) {
74
74
  retObj[lang] = value;
@@ -9,17 +9,17 @@ import { ButtonLayout } from "../button/button-layout";
9
9
  import { DropdownButtonItemArgs } from "../dropdown-button/dropdown-button-item";
10
10
  import { PortalUtils } from "../../common/utils/utils";
11
11
  import { LanguageUtils } from "../../common/utils/language-utils";
12
- import LocalizedStringHelper from "../../common/utils/localized-string";
13
12
  import { Language } from "../../common/enums/language";
14
13
  import { isNullOrEmpty } from "../../common/utils/is-null-or-empty";
15
14
  import globalIcon from './img/global.png';
16
15
  import PowerduckState from "../../app/powerduck-state";
17
- import LocalizedText from "../../common/localized-text";
16
+ import { ILocalizedText } from "../../common/localized-text";
18
17
  import "./css/localized-string-input.css";
18
+ import LocalizedValueHelper from "../../common/localized-value-helper";
19
19
 
20
20
  interface LocalizedStringInputArgs extends FormItemWrapperArgs {
21
- value: LocalizedText;
22
- changed: (e: LocalizedText) => void;
21
+ value: ILocalizedText;
22
+ changed: (e: ILocalizedText) => void;
23
23
  supportedLanguages?: Language[];
24
24
  placeholder?: string;
25
25
  }
@@ -29,8 +29,8 @@ class LocalizedStringInputComponent extends TsxComponent<LocalizedStringInputArg
29
29
  @Prop() label!: string;
30
30
  @Prop() labelButtons!: DropdownButtonItemArgs[];
31
31
  @Prop() subtitle!: string;
32
- @Prop() value!: LocalizedText;
33
- @Prop() changed: (e: LocalizedText) => void;
32
+ @Prop() value!: ILocalizedText;
33
+ @Prop() changed: (e: ILocalizedText) => void;
34
34
  @Prop() supportedLanguages?: Language[];
35
35
  @Prop() marginType?: MarginType;
36
36
  @Prop() maxWidth?: number;
@@ -45,11 +45,11 @@ class LocalizedStringInputComponent extends TsxComponent<LocalizedStringInputArg
45
45
  @Prop() prependIcon: string;
46
46
  @Prop() appendClicked: () => void;
47
47
  @Prop() prependClicked: () => void;
48
- currentValue: LocalizedText = null;
48
+ currentValue: ILocalizedText = null;
49
49
  modalWillShow: boolean = false;
50
50
  uuid: string = "lsw-" + PortalUtils.randomString(10);
51
51
 
52
- raiseChangeEvent(newValue: LocalizedText): void {
52
+ raiseChangeEvent(newValue: ILocalizedText): void {
53
53
  this.populateValidationDeclaration();
54
54
 
55
55
  if (this.changed != null) {
@@ -60,10 +60,10 @@ class LocalizedStringInputComponent extends TsxComponent<LocalizedStringInputArg
60
60
  isAllSame(): boolean {
61
61
  if (this.value != null) {
62
62
  let langList = LanguageUtils.getLanguageList();
63
- let skValue = LocalizedStringHelper.getValue(this.value, Language.sk);
63
+ let skValue = LocalizedValueHelper.getValue(this.value, Language.sk);
64
64
 
65
65
  for (let i = 0, len = langList.length; i < len; i++) {
66
- if (LocalizedStringHelper.getValue(this.value, langList[i].id) != skValue) {
66
+ if (LocalizedValueHelper.getValue(this.value, langList[i].id) != skValue) {
67
67
  return false;
68
68
  }
69
69
  }
@@ -73,7 +73,7 @@ class LocalizedStringInputComponent extends TsxComponent<LocalizedStringInputArg
73
73
  }
74
74
 
75
75
  hasSomeValue(): boolean {
76
- return !isNullOrEmpty(LocalizedStringHelper.getValue(this.value, Language.sk));
76
+ return !isNullOrEmpty(LocalizedValueHelper.getValue(this.value, Language.sk));
77
77
  }
78
78
 
79
79
  getModalContext(): JQuery {
@@ -117,7 +117,7 @@ class LocalizedStringInputComponent extends TsxComponent<LocalizedStringInputArg
117
117
 
118
118
  if (currentVal == null || currentVal.length == 0) {
119
119
  var language: Language = $this.attr("data-inv-lang") as any;
120
- var lsValue = LocalizedStringHelper.getValue(value, language) || "";
120
+ var lsValue = LocalizedValueHelper.getValue(value, language) || "";
121
121
  $this.attr("placeholder", lsValue);
122
122
  }
123
123
  });
@@ -175,7 +175,7 @@ class LocalizedStringInputComponent extends TsxComponent<LocalizedStringInputArg
175
175
  return (
176
176
  <div class={PowerduckState.getFormControlCssClass() + " localized-input"} onClick={(e) => this.showInputModal()}>
177
177
  <img src={globalIcon} />
178
- &nbsp;{LocalizedStringHelper.getValue(this.value, Language.sk)}
178
+ &nbsp;{LocalizedValueHelper.getValue(this.value, Language.sk)}
179
179
  </div>
180
180
  );
181
181
  }
@@ -190,7 +190,7 @@ class LocalizedStringInputComponent extends TsxComponent<LocalizedStringInputArg
190
190
 
191
191
  let langValue = this.value[lang.id];
192
192
  let hasValue = !isNullOrEmpty(langValue);
193
- langValue = hasValue ? langValue : LocalizedStringHelper.getValue(this.value, lang.id);
193
+ langValue = hasValue ? langValue : LocalizedValueHelper.getValue(this.value, lang.id);
194
194
 
195
195
  return (
196
196
  <div class={"localized-input-item" + (hasValue ? "" : " lii-auto")}>
@@ -216,7 +216,7 @@ class LocalizedStringInputComponent extends TsxComponent<LocalizedStringInputArg
216
216
 
217
217
  let langValue = this.currentValue[lang.id];
218
218
  let hasValue = !isNullOrEmpty(langValue);
219
- langValue = hasValue ? langValue : LocalizedStringHelper.getValue(this.currentValue, lang.id);
219
+ langValue = hasValue ? langValue : LocalizedValueHelper.getValue(this.currentValue, lang.id);
220
220
 
221
221
  return (
222
222
  <div class="row align-items-end lsi-form-group">
@@ -8,11 +8,11 @@ import TextArea from "./textarea";
8
8
  import { LanguageUtils } from "../../common/utils/language-utils";
9
9
  import { Language } from "../../common/enums/language";
10
10
  import PowerduckState from "../../app/powerduck-state";
11
- import LocalizedText from "../../common/localized-text";
11
+ import {ILocalizedText} from "../../common/localized-text";
12
12
 
13
13
  interface LocalizedStringInputArgs extends FormItemWrapperArgs {
14
- value: LocalizedText;
15
- changed: (e: LocalizedText) => void;
14
+ value: ILocalizedText;
15
+ changed: (e: ILocalizedText) => void;
16
16
  supportedLanguages?: Language[];
17
17
  placeholder?: string;
18
18
  }
@@ -22,8 +22,8 @@ class LocalizedStringTextareaComponent extends TsxComponent<LocalizedStringInput
22
22
  @Prop() label!: string;
23
23
  @Prop() labelButtons!: DropdownButtonItemArgs[];
24
24
  @Prop() subtitle!: string;
25
- @Prop() value!: LocalizedText;
26
- @Prop() changed: (e: LocalizedText) => void;
25
+ @Prop() value!: ILocalizedText;
26
+ @Prop() changed: (e: ILocalizedText) => void;
27
27
  @Prop() supportedLanguages?: Language[];
28
28
  @Prop() marginType?: MarginType;
29
29
  @Prop() maxWidth?: number;
@@ -37,9 +37,9 @@ class LocalizedStringTextareaComponent extends TsxComponent<LocalizedStringInput
37
37
  @Prop() prependIcon: string;
38
38
  @Prop() appendClicked: () => void;
39
39
  @Prop() prependClicked: () => void;
40
- currentValue: LocalizedText = null;
40
+ currentValue: ILocalizedText = null;
41
41
 
42
- raiseChangeEvent (newValue: LocalizedText): void {
42
+ raiseChangeEvent (newValue: ILocalizedText): void {
43
43
  this.populateValidationDeclaration();
44
44
 
45
45
  if (this.changed != null) {
@@ -52,12 +52,12 @@ class LocalizedStringTextareaComponent extends TsxComponent<LocalizedStringInput
52
52
  }
53
53
 
54
54
  changeValue(lang: Language, newValue: string): void {
55
- let value = this.value || ({} as LocalizedText);
55
+ let value = this.value || ({} as ILocalizedText);
56
56
  value[lang] = newValue;
57
57
  this.raiseChangeEvent(value);
58
58
  }
59
59
 
60
- getActualValue (lang: Language, value: LocalizedText): string {
60
+ getActualValue (lang: Language, value: ILocalizedText): string {
61
61
  if (value == null) {
62
62
  return null;
63
63
  }
@@ -5,14 +5,14 @@ import Tabs, { TabsRenderMode } from "../tabs/tabs";
5
5
  import { TabPage } from "../tabs/tab-page";
6
6
  import { DropdownButtonItemArgs } from "../dropdown-button/dropdown-button-item";
7
7
  import WysiwigEditor from "./wysiwig";
8
- import LocalizedText from "../../common/localized-text";
8
+ import {ILocalizedText} from "../../common/localized-text";
9
9
  import { LanguageUtils } from "../../common/utils/language-utils";
10
10
  import { Language } from "../../common/enums/language";
11
11
  import PowerduckState from "../../app/powerduck-state";
12
12
 
13
13
  interface LocalizedStringInputArgs extends FormItemWrapperArgs {
14
- value: LocalizedText;
15
- changed: (e: LocalizedText) => void;
14
+ value: ILocalizedText;
15
+ changed: (e: ILocalizedText) => void;
16
16
  supportedLanguages?: Language[];
17
17
  placeholder?: string;
18
18
  resizable?: boolean
@@ -23,8 +23,8 @@ class LocalizedStringWysiwigComponent extends TsxComponent<LocalizedStringInputA
23
23
  @Prop() label!: string;
24
24
  @Prop() labelButtons!: DropdownButtonItemArgs[];
25
25
  @Prop() subtitle!: string;
26
- @Prop() value!: LocalizedText;
27
- @Prop() changed: (e: LocalizedText) => void;
26
+ @Prop() value!: ILocalizedText;
27
+ @Prop() changed: (e: ILocalizedText) => void;
28
28
  @Prop() supportedLanguages?: Language[];
29
29
  @Prop() marginType?: MarginType;
30
30
  @Prop() maxWidth?: number;
@@ -38,9 +38,9 @@ class LocalizedStringWysiwigComponent extends TsxComponent<LocalizedStringInputA
38
38
  @Prop() prependIcon: string;
39
39
  @Prop() appendClicked: () => void;
40
40
  @Prop() prependClicked: () => void;
41
- currentValue: LocalizedText = null;
41
+ currentValue: ILocalizedText = null;
42
42
 
43
- raiseChangeEvent(newValue: LocalizedText): void {
43
+ raiseChangeEvent(newValue: ILocalizedText): void {
44
44
  this.populateValidationDeclaration();
45
45
 
46
46
  if (this.changed != null) {
@@ -53,12 +53,12 @@ class LocalizedStringWysiwigComponent extends TsxComponent<LocalizedStringInputA
53
53
  }
54
54
 
55
55
  changeValue(lang: Language, newValue: string): void {
56
- let value = this.value || ({} as LocalizedText);
56
+ let value = this.value || ({} as ILocalizedText);
57
57
  value[lang] = newValue;
58
58
  this.raiseChangeEvent(value);
59
59
  }
60
60
 
61
- getActualValue(lang: Language, value: LocalizedText): string {
61
+ getActualValue(lang: Language, value: ILocalizedText): string {
62
62
  if (value == null) {
63
63
  return null;
64
64
  }
@@ -13,16 +13,16 @@ import FlexFormItem from "../form/form-item-flex";
13
13
  import { FileManagerDialog, FileManagerModalFileType } from "../modal/ts/file-manager-dialog";
14
14
  import { PortalUtils } from "../../common/utils/utils";
15
15
  import { LanguageUtils } from "../../common/utils/language-utils";
16
- import LocalizedStringHelper from "../../common/utils/localized-string";
17
16
  import { Language } from "../../common/enums/language";
18
17
  import { isNullOrEmpty } from "../../common/utils/is-null-or-empty";
19
18
  import globalIcon from './img/global.png';
20
19
  import PowerduckState from "../../app/powerduck-state";
21
- import LocalizedText from "../../common/localized-text";
20
+ import {ILocalizedText} from "../../common/localized-text";
21
+ import LocalizedValueHelper from "../../common/localized-value-helper";
22
22
 
23
23
  interface LocalizedUrlInputArgs extends FormItemWrapperArgs {
24
- value: LocalizedText;
25
- changed: (e: LocalizedText) => void;
24
+ value: ILocalizedText;
25
+ changed: (e: ILocalizedText) => void;
26
26
  supportedLanguages?: Language[];
27
27
  placeholder?: string;
28
28
  }
@@ -32,8 +32,8 @@ class LocalizedUrlInputComponent extends TsxComponent<LocalizedUrlInputArgs> imp
32
32
  @Prop() label!: string;
33
33
  @Prop() labelButtons!: DropdownButtonItemArgs[];
34
34
  @Prop() subtitle!: string;
35
- @Prop() value!: LocalizedText;
36
- @Prop() changed: (e: LocalizedText) => void;
35
+ @Prop() value!: ILocalizedText;
36
+ @Prop() changed: (e: ILocalizedText) => void;
37
37
  @Prop() supportedLanguages?: Language[];
38
38
  @Prop() marginType?: MarginType;
39
39
  @Prop() maxWidth?: number;
@@ -47,12 +47,12 @@ class LocalizedUrlInputComponent extends TsxComponent<LocalizedUrlInputArgs> imp
47
47
  @Prop() prependIcon: string;
48
48
  @Prop() appendClicked: () => void;
49
49
  @Prop() prependClicked: () => void;
50
- currentValue: LocalizedText = null;
50
+ currentValue: ILocalizedText = null;
51
51
  modalWillShow: boolean = false;
52
52
  isModal: boolean = false;
53
53
  uuid: string = "lsw-" + PortalUtils.randomString(10);
54
54
 
55
- raiseChangeEvent (newValue: LocalizedText): void {
55
+ raiseChangeEvent (newValue: ILocalizedText): void {
56
56
  this.populateValidationDeclaration();
57
57
 
58
58
  if (this.changed != null) {
@@ -63,10 +63,10 @@ class LocalizedUrlInputComponent extends TsxComponent<LocalizedUrlInputArgs> imp
63
63
  isAllSame(): boolean {
64
64
  if (this.value != null) {
65
65
  let langList = LanguageUtils.getLanguageList();
66
- let skValue = LocalizedStringHelper.getValue(this.value, Language.sk);
66
+ let skValue = LocalizedValueHelper.getValue(this.value, Language.sk);
67
67
 
68
68
  for (let i = 0, len = langList.length; i < len; i++) {
69
- if (LocalizedStringHelper.getValue(this.value, langList[i].id) != skValue) {
69
+ if (LocalizedValueHelper.getValue(this.value, langList[i].id) != skValue) {
70
70
  return false;
71
71
  }
72
72
  }
@@ -76,7 +76,7 @@ class LocalizedUrlInputComponent extends TsxComponent<LocalizedUrlInputArgs> imp
76
76
  }
77
77
 
78
78
  hasSomeValue(): boolean {
79
- return !isNullOrEmpty(LocalizedStringHelper.getValue(this.value, Language.sk));
79
+ return !isNullOrEmpty(LocalizedValueHelper.getValue(this.value, Language.sk));
80
80
  }
81
81
 
82
82
  getModalContext(): JQuery {
@@ -133,7 +133,7 @@ class LocalizedUrlInputComponent extends TsxComponent<LocalizedUrlInputArgs> imp
133
133
 
134
134
  if (currentVal == null || currentVal.length == 0) {
135
135
  var language: Language = $this.attr("data-inv-lang") as any;
136
- var lsValue = LocalizedStringHelper.getValue(value, language) || "";
136
+ var lsValue = LocalizedValueHelper.getValue(value, language) || "";
137
137
  $this.attr("placeholder", lsValue);
138
138
  }
139
139
  });
@@ -207,7 +207,7 @@ class LocalizedUrlInputComponent extends TsxComponent<LocalizedUrlInputArgs> imp
207
207
  }
208
208
 
209
209
  renderInputGlobalValue(h) {
210
- let langValue = LocalizedStringHelper.getValue(this.value, Language.sk);
210
+ let langValue = LocalizedValueHelper.getValue(this.value, Language.sk);
211
211
  return (
212
212
  <FlexContainer cssClass={"mb-1"} fullWidthOnMobile={false}>
213
213
  <FlexFormItem flexFill={true}>
@@ -255,7 +255,7 @@ class LocalizedUrlInputComponent extends TsxComponent<LocalizedUrlInputArgs> imp
255
255
 
256
256
  let langValue = this.value[lang.id];
257
257
  let hasValue = !isNullOrEmpty(langValue);
258
- langValue = hasValue ? langValue : LocalizedStringHelper.getValue(this.value, lang.id);
258
+ langValue = hasValue ? langValue : LocalizedValueHelper.getValue(this.value, lang.id);
259
259
 
260
260
  return (
261
261
  <div class={"localized-input-item" + (hasValue ? "" : " lii-auto")}>
@@ -281,7 +281,7 @@ class LocalizedUrlInputComponent extends TsxComponent<LocalizedUrlInputArgs> imp
281
281
 
282
282
  let langValue = this.currentValue[lang.id];
283
283
  let hasValue = !isNullOrEmpty(langValue);
284
- langValue = hasValue ? langValue : LocalizedStringHelper.getValue(this.currentValue, lang.id);
284
+ langValue = hasValue ? langValue : LocalizedValueHelper.getValue(this.currentValue, lang.id);
285
285
 
286
286
  return (
287
287
  <FlexContainer cssClass={"mb-1"} fullWidthOnMobile={false}>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inviton-powerduck",
3
- "version": "0.0.86",
3
+ "version": "0.0.87",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": " vite build && vue-tsc --declaration --emitDeclarationOnly",
@@ -1,83 +0,0 @@
1
- import { Language } from "../enums/language";
2
- import LocalizedText, { ILocalizedText } from "../localized-text";
3
- import { isNullOrEmpty } from "./is-null-or-empty";
4
- import { LanguageUtils } from "./language-utils";
5
-
6
- export interface ILocalizedString {
7
- Slovak: string;
8
- English: string;
9
- Czech: string;
10
- German: string;
11
- Latvian: string;
12
- Polish: string;
13
- Italian: string;
14
- Hungarian: string;
15
- }
16
-
17
- function getValueForPair(localizedString: any, langCode: string, lang: Language): string {
18
- return localizedString[langCode] || localizedString[lang];
19
- }
20
-
21
- export default class LocalizedStringHelper {
22
- static getValue(value: ILocalizedString | ILocalizedText, lang: Language | string) {
23
- if (value == null) {
24
- return null;
25
- }
26
-
27
- if (lang == Language.sk) {
28
- const skVal = getValueForPair(value, 'sk', Language.sk);
29
- if (!isNullOrEmpty(skVal)) {
30
- return skVal;
31
- }
32
-
33
- const csVal = getValueForPair(value, 'cs', Language.cs);
34
- if (!isNullOrEmpty(csVal)) {
35
- return csVal;
36
- }
37
- } else if (lang == Language.cs) {
38
- const csVal = getValueForPair(value, 'cs', Language.cs);
39
- if (!isNullOrEmpty(csVal)) {
40
- return csVal;
41
- }
42
-
43
- const skVal = getValueForPair(value, 'sk', Language.sk);
44
- if (!isNullOrEmpty(skVal)) {
45
- return skVal;
46
- }
47
- } else if (lang == Language.de) {
48
- const val = getValueForPair(value, 'de', Language.de);
49
- if (!isNullOrEmpty(val)) {
50
- return val;
51
- }
52
- } else if (lang == Language.pl) {
53
- const val = getValueForPair(value, 'pl', Language.pl);
54
- if (!isNullOrEmpty(val)) {
55
- return val;
56
- }
57
- } else if (lang == Language.it) {
58
- const val = getValueForPair(value, 'it', Language.it);
59
- if (!isNullOrEmpty(val)) {
60
- return val;
61
- }
62
- } else if (lang == Language.hu) {
63
- const val = getValueForPair(value, 'hu', Language.hu);
64
- if (!isNullOrEmpty(val)) {
65
- return val;
66
- }
67
- }
68
-
69
- const lastTry = getValueForPair(value, 'sk', Language.sk);
70
- if (!isNullOrEmpty(lastTry)) {
71
- return lastTry;
72
- }
73
-
74
- for (const propName in value) {
75
- const text = (value as any)[propName];
76
- if (text != null && text.toString().length > 0) {
77
- return text;
78
- }
79
- }
80
-
81
- return null;
82
- }
83
- }
@@ -1,36 +0,0 @@
1
- import LocalizedText from './../localized-text';
2
- import { Language } from './../enums/language';
3
-
4
- export default class LocalizedTextUtil {
5
- static getLocalizedTextValue(value: LocalizedText, langKey: string | Language): string {
6
- if (value == null) {
7
- return null as any;
8
- }
9
-
10
- let retVal = (value as any)[langKey];
11
- if (retVal == null) {
12
- if (langKey == "sk") {
13
- retVal = value.cs;
14
- } else if (langKey == "cs") {
15
- retVal = value.sk;
16
- } else {
17
- retVal = value.en;
18
- }
19
- }
20
-
21
- if (retVal == null) {
22
- if (value.sk != null) {
23
- return value.sk;
24
- }
25
-
26
- for (const propName in value) {
27
- const text = (value as any)[propName];
28
- if (text != null && text.toString().length > 0) {
29
- return text;
30
- }
31
- }
32
- }
33
-
34
- return retVal || value.sk;
35
- }
36
- }