inviton-powerduck 0.0.136 → 0.0.138

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.
Files changed (39) hide show
  1. package/app/powerduck-system-resources.ts +2 -0
  2. package/common/css/ladda-themeless-zoomin.min.css +89 -89
  3. package/common/dialog-utils.ts +1 -1
  4. package/common/external-barcode-scanner.ts +0 -1
  5. package/common/utils/array-extend.ts +32 -29
  6. package/common/utils/broswer-image-compression.ts +1 -1
  7. package/common/utils/language-utils.ts +3 -1
  8. package/components/app/vue-plugin-jsxtransform.ts +1 -1
  9. package/components/bootstrap-toggle/index.tsx +6 -1
  10. package/components/chart-js/pie-chart.tsx +1 -1
  11. package/components/chart-js/thirdparty/flot/jquery.flot.categories.min.js +93 -93
  12. package/components/chart-js/thirdparty/flot/jquery.flot.crosshair.min.js +83 -83
  13. package/components/chart-js/thirdparty/flot/jquery.flot.navigate.min.js +270 -270
  14. package/components/chart-js/thirdparty/flot/jquery.flot.pie.min.js +507 -507
  15. package/components/chart-js/thirdparty/flot/jquery.flot.resize.min.js +147 -147
  16. package/components/chart-js/thirdparty/flot/jquery.flot.stack.min.js +104 -104
  17. package/components/datatable/datatable-static.tsx +5 -5
  18. package/components/datatable/datatable.tsx +1 -1
  19. package/components/datatable/ts/reorder.ts +0 -2
  20. package/components/dropdown/currency-code-picker.tsx +42 -39
  21. package/components/dropdown/index.tsx +2 -1
  22. package/components/fullcalendar/timegrid-calendar.tsx +1 -1
  23. package/components/image-crop/image-cropping-modal.tsx +54 -15
  24. package/components/image-crop/upload-and-crop.tsx +21 -13
  25. package/components/image-crop/vendor/jquery.Jcrop.min.css +344 -344
  26. package/components/import/import-mapper.tsx +231 -231
  27. package/components/input/localized-info-input.tsx +9 -0
  28. package/components/input/localized-string-input.tsx +21 -0
  29. package/components/input/localized-string-textarea.tsx +16 -0
  30. package/components/input/localized-string-wysiwyg.tsx +16 -0
  31. package/components/input/plugins/daterangepicker/daterangepicker.min.css +400 -400
  32. package/components/input/plugins/daterangepicker/jquery.daterangepicker.min.js +1903 -1903
  33. package/components/input/translate.tsx +100 -0
  34. package/components/modal/modal.tsx +1 -1
  35. package/components/photos/photo-manager.tsx +7 -11
  36. package/components/share/share-modal.tsx +1 -1
  37. package/components/share/share.tsx +1 -1
  38. package/components/svg/skilift-svg.tsx +6 -6
  39. package/package.json +2 -1
@@ -1,231 +1,231 @@
1
- import type { DropdownOptionGroup } from '../dropdown';
2
- import { Component, Prop } from 'vue-facing-decorator';
3
- import TsxComponent from '../../app/vuetsx';
4
- import { isNullOrEmpty } from '../../common/utils/is-null-or-empty';
5
- import { latinize } from '../../common/utils/latinize-string';
6
- import BootstrapToggle from '../bootstrap-toggle';
7
- import DropdownList from '../dropdown';
8
- import HtmlLiteral from '../html-literal/html-literal';
9
- import TextBox, { TextBoxTextType } from '../input/textbox';
10
- import './css/import-mapper.css';
11
-
12
- export interface ImportMapperMapping {
13
- columnIndex: number;
14
- mappingValue: string;
15
- }
16
-
17
- interface ImportMapperArgs {
18
- cssClass?: string;
19
- subtitleHtml: string;
20
- mappingOptions: DropdownOptionGroup[];
21
- importData: Array<Array<string>>;
22
- firstRowIsHeaderLabel?: string;
23
- defaultMapping?: ImportMapperMapping[];
24
- }
25
-
26
- @Component
27
- export default class ImportMapper extends TsxComponent<ImportMapperArgs> implements ImportMapperArgs {
28
- @Prop() cssClass!: string;
29
- @Prop() subtitleHtml!: string;
30
- @Prop() mappingOptions!: DropdownOptionGroup[];
31
- @Prop() importData!: Array<Array<string>>;
32
- @Prop() defaultMapping!: ImportMapperMapping[];
33
- @Prop() firstRowIsHeaderLabel!: string;
34
- private selectionMap: any = {};
35
- private firstRowHeader: boolean = false;
36
- private wasMatched = [];
37
-
38
- public getData(): any[] {
39
- const retVal = [];
40
-
41
- this.importData.forEach((row, i) => {
42
- if (!this.firstRowHeader || i > 0) {
43
- const newItem = {};
44
- for (const key in this.selectionMap) {
45
- const keyInt = Number(key);
46
- let objVal = row[keyInt];
47
-
48
- if (objVal != null) {
49
- if (typeof objVal === 'string') {
50
- objVal = objVal.trim();
51
- }
52
- }
53
-
54
- newItem[this.selectionMap[key]] = objVal;
55
- }
56
-
57
- retVal.push(newItem);
58
- }
59
- });
60
-
61
- return retVal;
62
- }
63
-
64
- private getDisplayValue(obj: any): string {
65
- if (obj == null) {
66
- return null;
67
- } else if (obj._dte) {
68
- return obj.toDisplayString(true);
69
- }
70
-
71
- return obj;
72
- }
73
-
74
- private getLargestRow(): string[] {
75
- if (isNullOrEmpty(this.importData)) {
76
- return [];
77
- }
78
-
79
- let biggestLength = 0;
80
- this.importData.forEach((rowArr) => {
81
- if (rowArr != null && rowArr.length > biggestLength) {
82
- biggestLength = rowArr.length;
83
- }
84
- });
85
-
86
- const retVal = [];
87
- while (true) {
88
- if (retVal.length < biggestLength) {
89
- retVal.push('x');
90
- } else {
91
- break;
92
- }
93
- }
94
-
95
- return retVal;
96
- }
97
-
98
- private getDropdownSelectedItem(index: number) {
99
- const selection = this.selectionMap[index];
100
-
101
- if (selection == null) {
102
- const match = this.getHeaderItem(index);
103
-
104
- if (!isNullOrEmpty(match) && !this.wasMatched.includes(index)) {
105
- this.wasMatched.push(index);
106
- this.setDropdownSelectedItem(index, match.id);
107
- return match.id;
108
- } else {
109
- return null;
110
- }
111
- }
112
-
113
- if (selection.includes('ncf:')) {
114
- return 'custom';
115
- }
116
-
117
- return this.selectionMap[index];
118
- }
119
-
120
- private setDropdownSelectedItem(index: number, value: any) {
121
- if (value == null || value.id == null) {
122
- if (typeof value === 'string') {
123
- // this.$set(this.selectionMap, index.toString(), value);
124
- this.selectionMap[index.toString()] = value;
125
- } else {
126
- // this.$set(this.selectionMap, index.toString(), null);
127
- this.selectionMap[index.toString()] = null;
128
- }
129
- } else {
130
- // this.$set(this.selectionMap, index.toString(), value.id);
131
- this.selectionMap[index.toString()] = value.id;
132
- }
133
- }
134
-
135
- private getPreviewRows(): Array<string[]> {
136
- if (isNullOrEmpty(this.importData)) {
137
- return [];
138
- }
139
-
140
- let start = 0;
141
- let end = 10;
142
- if (this.firstRowHeader) {
143
- start += 1;
144
- end += 1;
145
- }
146
-
147
- return this.importData.filter((u, i) => i >= start && i < end);
148
- }
149
-
150
- private getHeaderItem(index: number) {
151
- const opts = [];
152
-
153
- this.mappingOptions.forEach((mapOpts) => {
154
- mapOpts.children.forEach((s) => {
155
- opts.push(s);
156
- });
157
- });
158
-
159
- if (this.importData[0][index] != null) {
160
- const indexItem = this.importData[0][index].toString();
161
- const headers = opts.filter(p => latinize(p.text).toLowerCase() == latinize(indexItem).toLowerCase() || latinize(p.id).toLowerCase() == latinize(indexItem).toLowerCase());
162
- if (headers != null && headers.length == 1) {
163
- return headers[0];
164
- }
165
- } else {
166
- return null;
167
- }
168
- }
169
-
170
- private prefillNewCustomFieldName(index: number) {
171
- let retVal = '';
172
- if (this.selectionMap[index].includes('ncf:')) {
173
- retVal = this.selectionMap[index].substring(4);
174
- } else {
175
- retVal = this.importData[0][index];
176
- }
177
-
178
- this.setDropdownSelectedItem(index, `ncf:${retVal}`);
179
- return retVal;
180
- }
181
-
182
- private render(h) {
183
- const largestRow = this.getLargestRow();
184
-
185
- return (
186
- <div class="import-mapper-root">
187
- <p class="import-mapper-subtitle">
188
- <HtmlLiteral innerHTML={this.subtitleHtml} />
189
- </p>
190
-
191
- {this.importData
192
- && (
193
- <div class="import-mapper-table-wrap">
194
- <table class="import-mapper-table">
195
- <thead>
196
- <tr>
197
- {largestRow.map((col, i) => {
198
- return (
199
- <td>
200
- <DropdownList wrap={false} label={null} placeholder="Select value" options={this.mappingOptions} selected={this.getDropdownSelectedItem(i)} changed={(v) => { this.setDropdownSelectedItem(i, v); }} />
201
-
202
- {this.selectionMap[i] != null && (this.selectionMap[i] == 'custom' || this.selectionMap[i].includes('ncf:'))
203
- && <TextBox wrap={false} label="" cssClass="hidden" value={this.prefillNewCustomFieldName(i)} changed={(v) => { this.setDropdownSelectedItem(i, `ncf:${v}`); }} textType={TextBoxTextType.Text} />}
204
- </td>
205
- );
206
- })}
207
- </tr>
208
- </thead>
209
- <tbody>
210
- {this.getPreviewRows().map(row => (
211
- <tr>
212
- {largestRow.map((col, i) => (
213
- <td>
214
- {this.getDisplayValue(row[i])}
215
- </td>
216
- ))}
217
- </tr>
218
- ))}
219
- </tbody>
220
- </table>
221
- </div>
222
- )}
223
-
224
- <div class="import-mapper-settings">
225
- {this.$slots.default}
226
- <BootstrapToggle label={this.firstRowIsHeaderLabel ? this.firstRowIsHeaderLabel : 'First row is header'} value={this.firstRowHeader} changed={(e) => { this.firstRowHeader = e; }} />
227
- </div>
228
- </div>
229
- );
230
- }
231
- }
1
+ import type { DropdownOptionGroup } from '../dropdown';
2
+ import { Component, Prop } from 'vue-facing-decorator';
3
+ import TsxComponent from '../../app/vuetsx';
4
+ import { isNullOrEmpty } from '../../common/utils/is-null-or-empty';
5
+ import { latinize } from '../../common/utils/latinize-string';
6
+ import BootstrapToggle from '../bootstrap-toggle';
7
+ import DropdownList from '../dropdown';
8
+ import HtmlLiteral from '../html-literal/html-literal';
9
+ import TextBox, { TextBoxTextType } from '../input/textbox';
10
+ import './css/import-mapper.css';
11
+
12
+ export interface ImportMapperMapping {
13
+ columnIndex: number;
14
+ mappingValue: string;
15
+ }
16
+
17
+ interface ImportMapperArgs {
18
+ cssClass?: string;
19
+ subtitleHtml: string;
20
+ mappingOptions: DropdownOptionGroup[];
21
+ importData: Array<Array<string>>;
22
+ firstRowIsHeaderLabel?: string;
23
+ defaultMapping?: ImportMapperMapping[];
24
+ }
25
+
26
+ @Component
27
+ export default class ImportMapper extends TsxComponent<ImportMapperArgs> implements ImportMapperArgs {
28
+ @Prop() cssClass!: string;
29
+ @Prop() subtitleHtml!: string;
30
+ @Prop() mappingOptions!: DropdownOptionGroup[];
31
+ @Prop() importData!: Array<Array<string>>;
32
+ @Prop() defaultMapping!: ImportMapperMapping[];
33
+ @Prop() firstRowIsHeaderLabel!: string;
34
+ private selectionMap: any = {};
35
+ private firstRowHeader: boolean = false;
36
+ private wasMatched = [];
37
+
38
+ public getData(): any[] {
39
+ const retVal = [];
40
+
41
+ this.importData.forEach((row, i) => {
42
+ if (!this.firstRowHeader || i > 0) {
43
+ const newItem = {};
44
+ for (const key in this.selectionMap) {
45
+ const keyInt = Number(key);
46
+ let objVal = row[keyInt];
47
+
48
+ if (objVal != null) {
49
+ if (typeof objVal === 'string') {
50
+ objVal = objVal.trim();
51
+ }
52
+ }
53
+
54
+ newItem[this.selectionMap[key]] = objVal;
55
+ }
56
+
57
+ retVal.push(newItem);
58
+ }
59
+ });
60
+
61
+ return retVal;
62
+ }
63
+
64
+ private getDisplayValue(obj: any): string {
65
+ if (obj == null) {
66
+ return null;
67
+ } else if (obj._dte) {
68
+ return obj.toDisplayString(true);
69
+ }
70
+
71
+ return obj;
72
+ }
73
+
74
+ private getLargestRow(): string[] {
75
+ if (isNullOrEmpty(this.importData)) {
76
+ return [];
77
+ }
78
+
79
+ let biggestLength = 0;
80
+ this.importData.forEach((rowArr) => {
81
+ if (rowArr != null && rowArr.length > biggestLength) {
82
+ biggestLength = rowArr.length;
83
+ }
84
+ });
85
+
86
+ const retVal = [];
87
+ while (true) {
88
+ if (retVal.length < biggestLength) {
89
+ retVal.push('x');
90
+ } else {
91
+ break;
92
+ }
93
+ }
94
+
95
+ return retVal;
96
+ }
97
+
98
+ private getDropdownSelectedItem(index: number) {
99
+ const selection = this.selectionMap[index];
100
+
101
+ if (selection == null) {
102
+ const match = this.getHeaderItem(index);
103
+
104
+ if (!isNullOrEmpty(match) && !this.wasMatched.includes(index)) {
105
+ this.wasMatched.push(index);
106
+ this.setDropdownSelectedItem(index, match.id);
107
+ return match.id;
108
+ } else {
109
+ return null;
110
+ }
111
+ }
112
+
113
+ if (selection.includes('ncf:')) {
114
+ return 'custom';
115
+ }
116
+
117
+ return this.selectionMap[index];
118
+ }
119
+
120
+ private setDropdownSelectedItem(index: number, value: any) {
121
+ if (value == null || value.id == null) {
122
+ if (typeof value === 'string') {
123
+ // this.$set(this.selectionMap, index.toString(), value);
124
+ this.selectionMap[index.toString()] = value;
125
+ } else {
126
+ // this.$set(this.selectionMap, index.toString(), null);
127
+ this.selectionMap[index.toString()] = null;
128
+ }
129
+ } else {
130
+ // this.$set(this.selectionMap, index.toString(), value.id);
131
+ this.selectionMap[index.toString()] = value.id;
132
+ }
133
+ }
134
+
135
+ private getPreviewRows(): Array<string[]> {
136
+ if (isNullOrEmpty(this.importData)) {
137
+ return [];
138
+ }
139
+
140
+ let start = 0;
141
+ let end = 10;
142
+ if (this.firstRowHeader) {
143
+ start += 1;
144
+ end += 1;
145
+ }
146
+
147
+ return this.importData.filter((u, i) => i >= start && i < end);
148
+ }
149
+
150
+ private getHeaderItem(index: number) {
151
+ const opts = [];
152
+
153
+ this.mappingOptions.forEach((mapOpts) => {
154
+ mapOpts.children.forEach((s) => {
155
+ opts.push(s);
156
+ });
157
+ });
158
+
159
+ if (this.importData[0][index] != null) {
160
+ const indexItem = this.importData[0][index].toString();
161
+ const headers = opts.filter(p => latinize(p.text).toLowerCase() == latinize(indexItem).toLowerCase() || latinize(p.id).toLowerCase() == latinize(indexItem).toLowerCase());
162
+ if (headers != null && headers.length == 1) {
163
+ return headers[0];
164
+ }
165
+ } else {
166
+ return null;
167
+ }
168
+ }
169
+
170
+ private prefillNewCustomFieldName(index: number) {
171
+ let retVal = '';
172
+ if (this.selectionMap[index].includes('ncf:')) {
173
+ retVal = this.selectionMap[index].substring(4);
174
+ } else {
175
+ retVal = this.importData[0][index];
176
+ }
177
+
178
+ this.setDropdownSelectedItem(index, `ncf:${retVal}`);
179
+ return retVal;
180
+ }
181
+
182
+ private render(h) {
183
+ const largestRow = this.getLargestRow();
184
+
185
+ return (
186
+ <div class="import-mapper-root">
187
+ <p class="import-mapper-subtitle">
188
+ <HtmlLiteral innerHTML={this.subtitleHtml} />
189
+ </p>
190
+
191
+ {this.importData
192
+ && (
193
+ <div class="import-mapper-table-wrap">
194
+ <table class="import-mapper-table">
195
+ <thead>
196
+ <tr>
197
+ {largestRow.map((col, i) => {
198
+ return (
199
+ <td>
200
+ <DropdownList wrap={false} label={null} placeholder="Select value" options={this.mappingOptions} selected={this.getDropdownSelectedItem(i)} changed={(v) => { this.setDropdownSelectedItem(i, v); }} />
201
+
202
+ {this.selectionMap[i] != null && (this.selectionMap[i] == 'custom' || this.selectionMap[i].includes('ncf:'))
203
+ && <TextBox wrap={false} label="" cssClass="hidden" value={this.prefillNewCustomFieldName(i)} changed={(v) => { this.setDropdownSelectedItem(i, `ncf:${v}`); }} textType={TextBoxTextType.Text} />}
204
+ </td>
205
+ );
206
+ })}
207
+ </tr>
208
+ </thead>
209
+ <tbody>
210
+ {this.getPreviewRows().map(row => (
211
+ <tr>
212
+ {largestRow.map((col, i) => (
213
+ <td>
214
+ {this.getDisplayValue(row[i])}
215
+ </td>
216
+ ))}
217
+ </tr>
218
+ ))}
219
+ </tbody>
220
+ </table>
221
+ </div>
222
+ )}
223
+
224
+ <div class="import-mapper-settings">
225
+ {this.$slots.default}
226
+ <BootstrapToggle label={this.firstRowIsHeaderLabel ? this.firstRowIsHeaderLabel : 'First row is header'} value={this.firstRowHeader} changed={(e) => { this.firstRowHeader = e; }} />
227
+ </div>
228
+ </div>
229
+ );
230
+ }
231
+ }
@@ -1,5 +1,6 @@
1
1
  import type { ILocalizedText } from '../../common/localized-text';
2
2
  import type { ValidationState } from '../../common/static-wrappers/interfaces/validation-interface';
3
+ import type { TranslateGetRequest, TranslateGetResponse } from './translate';
3
4
  import { Prop, toNative } from 'vue-facing-decorator';
4
5
  import TsxComponent, { Component } from '../../app/vuetsx';
5
6
  import { Language } from '../../common/enums/language';
@@ -19,6 +20,8 @@ interface LocalizedInfoInputArgs {
19
20
  validationState?: ValidationState;
20
21
  changed: (e: ILocalizedText) => void;
21
22
  mandatory?: boolean;
23
+ translatable?: boolean;
24
+ translateApiMethod?: <RQ extends TranslateGetRequest, RS extends TranslateGetResponse>(data?: RQ) => Promise<RS>;
22
25
  }
23
26
 
24
27
  @Component
@@ -32,6 +35,8 @@ class LocalizedInfoInputComponent extends TsxComponent<LocalizedInfoInputArgs> i
32
35
  @Prop() displayType: 'input' | 'textarea';
33
36
  @Prop() changed: (e: ILocalizedText) => void;
34
37
  @Prop() mandatory?: boolean;
38
+ @Prop({ default: false }) translatable: boolean;
39
+ @Prop() translateApiMethod: <RQ extends TranslateGetRequest, RS extends TranslateGetResponse>(data?: RQ) => Promise<RS>;
35
40
 
36
41
  getValueForTmrLanguage(lang: Language): string {
37
42
  return this.value[lang];
@@ -99,6 +104,8 @@ class LocalizedInfoInputComponent extends TsxComponent<LocalizedInfoInputArgs> i
99
104
  changed={(e) => {
100
105
  this.valueChanged(e);
101
106
  }}
107
+ translatable={this.translatable}
108
+ translateApiMethod={this.translateApiMethod}
102
109
  supportedLanguages={[
103
110
  Language.sk,
104
111
  Language.en,
@@ -125,6 +132,8 @@ class LocalizedInfoInputComponent extends TsxComponent<LocalizedInfoInputArgs> i
125
132
  changed={(e) => {
126
133
  this.valueChanged(e);
127
134
  }}
135
+ translatable={this.translatable}
136
+ translateApiMethod={this.translateApiMethod}
128
137
  supportedLanguages={[
129
138
  Language.sk,
130
139
  Language.en,
@@ -1,6 +1,7 @@
1
1
  import type { ILocalizedText } from '../../common/localized-text';
2
2
  import type { DropdownButtonItemArgs } from '../dropdown-button/dropdown-button-item';
3
3
  import type { FormItemWrapperArgs, HintType, MarginType } from '../form/form-item-wrapper';
4
+ import type { TranslateGetRequest, TranslateGetResponse } from './translate';
4
5
  import { Prop, toNative } from 'vue-facing-decorator';
5
6
  import PowerduckState from '../../app/powerduck-state';
6
7
  import TsxComponent, { Component } from '../../app/vuetsx';
@@ -16,6 +17,7 @@ import Modal, { ModalSize } from '../modal/modal';
16
17
  import ModalBody from '../modal/modal-body';
17
18
  import ModalFooter from '../modal/modal-footer';
18
19
  import globalIcon from './img/global.png';
20
+ import Translate from './translate';
19
21
  import './css/localized-string-input.css';
20
22
 
21
23
  interface LocalizedStringInputArgs extends FormItemWrapperArgs {
@@ -23,6 +25,8 @@ interface LocalizedStringInputArgs extends FormItemWrapperArgs {
23
25
  changed: (e: ILocalizedText) => void;
24
26
  supportedLanguages?: Language[];
25
27
  placeholder?: string;
28
+ translatable?: boolean;
29
+ translateApiMethod?: <RQ extends TranslateGetRequest, RS extends TranslateGetResponse>(data?: RQ) => Promise<RS>;
26
30
  }
27
31
 
28
32
  @Component
@@ -44,6 +48,8 @@ class LocalizedStringInputComponent extends TsxComponent<LocalizedStringInputArg
44
48
  @Prop() hintType!: HintType;
45
49
  @Prop() appendIcon: string;
46
50
  @Prop() prependIcon: string;
51
+ @Prop({default: false}) translatable: boolean;
52
+ @Prop() translateApiMethod: <RQ extends TranslateGetRequest, RS extends TranslateGetResponse>(data?: RQ) => Promise<RS>;
47
53
  @Prop() appendClicked: () => void;
48
54
  @Prop() prependClicked: () => void;
49
55
  currentValue: ILocalizedText = null;
@@ -231,6 +237,21 @@ class LocalizedStringInputComponent extends TsxComponent<LocalizedStringInputArg
231
237
  <img class="lsi-icon" src={LanguageUtils.getLanguageFlagUrl(lang.flag)} />
232
238
  </label>
233
239
  <div class="col-md-9">
240
+ <div class="d-flex justify-content-end">
241
+ {this.translatable !== false && (
242
+ <Translate
243
+ value={this.currentValue}
244
+ currentLangId={lang.id}
245
+ langArr={LanguageUtils.getLanguageList()}
246
+ changeValue={(langId, value) => {
247
+ this.handleModalValueChange(value, { id: langId });
248
+ this.$forceUpdate();
249
+ }}
250
+ getActualValue={(langId, value) => value[langId]}
251
+ apiMethod={this.translateApiMethod}
252
+ />
253
+ )}
254
+ </div>
234
255
  <div class="form-group maxwidth-input ">
235
256
  <input
236
257
  type="text"
@@ -2,6 +2,7 @@ import type { Language } from '../../common/enums/language';
2
2
  import type { ILocalizedText } from '../../common/localized-text';
3
3
  import type { DropdownButtonItemArgs } from '../dropdown-button/dropdown-button-item';
4
4
  import type { FormItemWrapperArgs, HintType, MarginType } from '../form/form-item-wrapper';
5
+ import type { TranslateGetRequest, TranslateGetResponse } from './translate';
5
6
  import { Prop, toNative } from 'vue-facing-decorator';
6
7
  import PowerduckState from '../../app/powerduck-state';
7
8
  import TsxComponent, { Component } from '../../app/vuetsx';
@@ -10,12 +11,15 @@ import FormItemWrapper from '../form/form-item-wrapper';
10
11
  import { TabPage } from '../tabs/tab-page';
11
12
  import Tabs, { TabsRenderMode } from '../tabs/tabs';
12
13
  import TextArea from './textarea';
14
+ import Translate from './translate';
13
15
 
14
16
  interface LocalizedStringInputArgs extends FormItemWrapperArgs {
15
17
  value: ILocalizedText;
16
18
  changed: (e: ILocalizedText) => void;
17
19
  supportedLanguages?: Language[];
18
20
  placeholder?: string;
21
+ translatable?: boolean;
22
+ translateApiMethod?: <RQ extends TranslateGetRequest, RS extends TranslateGetResponse>(data?: RQ) => Promise<RS>;
19
23
  }
20
24
 
21
25
  @Component
@@ -36,6 +40,8 @@ class LocalizedStringTextareaComponent extends TsxComponent<LocalizedStringInput
36
40
  @Prop() hintType!: HintType;
37
41
  @Prop() appendIcon: string;
38
42
  @Prop() prependIcon: string;
43
+ @Prop({ default: false }) translatable: boolean;
44
+ @Prop() translateApiMethod: <RQ extends TranslateGetRequest, RS extends TranslateGetResponse>(data?: RQ) => Promise<RS>;
39
45
  @Prop() appendClicked: () => void;
40
46
  @Prop() prependClicked: () => void;
41
47
  currentValue: ILocalizedText = null;
@@ -110,6 +116,16 @@ class LocalizedStringTextareaComponent extends TsxComponent<LocalizedStringInput
110
116
  }}
111
117
  rows={4}
112
118
  />
119
+ {this.translatable !== false && (
120
+ <Translate
121
+ value={this.value}
122
+ currentLangId={lang.id}
123
+ langArr={langArr}
124
+ changeValue={this.changeValue.bind(this)}
125
+ getActualValue={(langId, value) => this.getActualValue(langId, value as ILocalizedText)}
126
+ apiMethod={this.translateApiMethod}
127
+ />
128
+ )}
113
129
  </TabPage>
114
130
  ))}
115
131
  </Tabs>
@@ -2,6 +2,7 @@ import type { Language } from '../../common/enums/language';
2
2
  import type { ILocalizedText } from '../../common/localized-text';
3
3
  import type { DropdownButtonItemArgs } from '../dropdown-button/dropdown-button-item';
4
4
  import type { FormItemWrapperArgs, MarginType } from '../form/form-item-wrapper';
5
+ import type { TranslateGetRequest, TranslateGetResponse } from './translate';
5
6
  import { Prop, toNative } from 'vue-facing-decorator';
6
7
  import PowerduckState from '../../app/powerduck-state';
7
8
  import TsxComponent, { Component } from '../../app/vuetsx';
@@ -9,6 +10,7 @@ import { LanguageUtils } from '../../common/utils/language-utils';
9
10
  import FormItemWrapper from '../form/form-item-wrapper';
10
11
  import { TabPage } from '../tabs/tab-page';
11
12
  import Tabs, { TabsRenderMode } from '../tabs/tabs';
13
+ import Translate from './translate';
12
14
  import WysiwigEditor from './wysiwig';
13
15
 
14
16
  interface LocalizedStringInputArgs extends FormItemWrapperArgs {
@@ -17,6 +19,8 @@ interface LocalizedStringInputArgs extends FormItemWrapperArgs {
17
19
  supportedLanguages?: Language[];
18
20
  placeholder?: string;
19
21
  resizable?: boolean;
22
+ translatable?: boolean;
23
+ translateApiMethod?: <RQ extends TranslateGetRequest, RS extends TranslateGetResponse>(data?: RQ) => Promise<RS>;
20
24
  }
21
25
 
22
26
  @Component
@@ -39,6 +43,8 @@ class LocalizedStringWysiwigComponent extends TsxComponent<LocalizedStringInputA
39
43
  @Prop() prependIcon: string;
40
44
  @Prop() appendClicked: () => void;
41
45
  @Prop() prependClicked: () => void;
46
+ @Prop({ default: false }) translatable: boolean;
47
+ @Prop() translateApiMethod: <RQ extends TranslateGetRequest, RS extends TranslateGetResponse>(data?: RQ) => Promise<RS>;
42
48
  currentValue: ILocalizedText = null;
43
49
  editorHeight: number = null;
44
50
 
@@ -117,6 +123,16 @@ class LocalizedStringWysiwigComponent extends TsxComponent<LocalizedStringInputA
117
123
  this.changeValue(lang.id, e);
118
124
  }}
119
125
  />
126
+ {this.translatable !== false && (
127
+ <Translate
128
+ value={this.value}
129
+ currentLangId={lang.id}
130
+ langArr={langArr}
131
+ changeValue={this.changeValue.bind(this)}
132
+ getActualValue={(langId, value) => this.getActualValue(langId, value as ILocalizedText)}
133
+ apiMethod={this.translateApiMethod}
134
+ />
135
+ )}
120
136
  </TabPage>
121
137
  ))}
122
138
  </Tabs>