melondtable 1.15.4 → 1.16.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.
package/src/defaults.js CHANGED
@@ -1,71 +1,73 @@
1
1
  import filterRows from './filterRows';
2
2
  import icons from './icons';
3
3
 
4
- export default {
5
- columns: [],
6
- data: [],
7
- dropdownButton: icons.chevronDown,
8
- headerDropdown: [
9
- {
10
- label: 'Sort Ascending',
11
- action: function (column) {
12
- this.sortColumn(column.colIndex, 'asc');
4
+ export default function getDefaultOptions(instance) {
5
+ return {
6
+ columns: [],
7
+ data: [],
8
+ dropdownButton: icons.chevronDown,
9
+ headerDropdown: [
10
+ {
11
+ label: instance.translate('Sort Ascending'),
12
+ action: function (column) {
13
+ this.sortColumn(column.colIndex, 'asc');
14
+ }
15
+ },
16
+ {
17
+ label: instance.translate('Sort Descending'),
18
+ action: function (column) {
19
+ this.sortColumn(column.colIndex, 'desc');
20
+ }
21
+ },
22
+ {
23
+ label: instance.translate('Reset sorting'),
24
+ action: function (column) {
25
+ this.sortColumn(column.colIndex, 'none');
26
+ }
27
+ },
28
+ {
29
+ label: instance.translate('Remove column'),
30
+ action: function (column) {
31
+ this.removeColumn(column.colIndex);
32
+ }
13
33
  }
34
+ ],
35
+ events: {
36
+ onRemoveColumn(column) {},
37
+ onSwitchColumn(column1, column2) {},
38
+ onSortColumn(column) {},
39
+ onCheckRow(row) {},
40
+ onDestroy() {}
14
41
  },
15
- {
16
- label: 'Sort Descending',
17
- action: function (column) {
18
- this.sortColumn(column.colIndex, 'desc');
19
- }
42
+ hooks: {
43
+ columnTotal: null
20
44
  },
21
- {
22
- label: 'Reset sorting',
23
- action: function (column) {
24
- this.sortColumn(column.colIndex, 'none');
25
- }
45
+ sortIndicator: {
46
+ asc: '↑',
47
+ desc: '↓',
48
+ none: ''
26
49
  },
27
- {
28
- label: 'Remove column',
29
- action: function (column) {
30
- this.removeColumn(column.colIndex);
31
- }
32
- }
33
- ],
34
- events: {
35
- onRemoveColumn(column) {},
36
- onSwitchColumn(column1, column2) {},
37
- onSortColumn(column) {},
38
- onCheckRow(row) {},
39
- onDestroy() {}
40
- },
41
- hooks: {
42
- columnTotal: null
43
- },
44
- sortIndicator: {
45
- asc: '↑',
46
- desc: '↓',
47
- none: ''
48
- },
49
- overrideComponents: {
50
- // ColumnManager: CustomColumnManager
51
- },
52
- filterRows: filterRows,
53
- freezeMessage: '',
54
- getEditor: null,
55
- serialNoColumn: true,
56
- checkboxColumn: false,
57
- clusterize: true,
58
- logs: false,
59
- layout: 'fixed', // fixed, fluid, ratio
60
- noDataMessage: 'No Data',
61
- cellHeight: 40,
62
- minimumColumnWidth: 30,
63
- inlineFilters: false,
64
- treeView: false,
65
- checkedRowStatus: true,
66
- dynamicRowHeight: false,
67
- pasteFromClipboard: false,
68
- showTotalRow: false,
69
- direction: 'ltr',
70
- disableReorderColumn: false
50
+ overrideComponents: {
51
+ // ColumnManager: CustomColumnManager
52
+ },
53
+ filterRows: filterRows,
54
+ freezeMessage: '',
55
+ getEditor: null,
56
+ serialNoColumn: true,
57
+ checkboxColumn: false,
58
+ clusterize: true,
59
+ logs: false,
60
+ layout: 'fixed', // fixed, fluid, ratio
61
+ noDataMessage: instance.translate('No Data'),
62
+ cellHeight: 40,
63
+ minimumColumnWidth: 30,
64
+ inlineFilters: false,
65
+ treeView: false,
66
+ checkedRowStatus: true,
67
+ dynamicRowHeight: false,
68
+ pasteFromClipboard: false,
69
+ showTotalRow: false,
70
+ direction: 'ltr',
71
+ disableReorderColumn: false
72
+ };
71
73
  };
package/src/rowmanager.js CHANGED
@@ -133,7 +133,10 @@ export default class RowManager {
133
133
  const checkedRows = this.getCheckedRows();
134
134
  const count = checkedRows.length;
135
135
  if (count > 0) {
136
- this.bodyRenderer.showToastMessage(`${count} row${count > 1 ? 's' : ''} selected`);
136
+ let message = this.instance.translate('{count} rows selected', {
137
+ count: count
138
+ });
139
+ this.bodyRenderer.showToastMessage(message);
137
140
  } else {
138
141
  this.bodyRenderer.clearToastMessage();
139
142
  }
package/src/style.css CHANGED
@@ -164,6 +164,11 @@
164
164
  }
165
165
  }
166
166
 
167
+ .datatable[dir=rtl] .dt-cell__resize-handle {
168
+ right: unset;
169
+ left: -3px;
170
+ }
171
+
167
172
  .icon-open, .icon-close {
168
173
  width: 16px;
169
174
  height: 16px;
@@ -0,0 +1,30 @@
1
+ import { format } from './utils';
2
+ import getTranslations from './translations';
3
+
4
+ export default class TranslationManager {
5
+ constructor(language) {
6
+ this.language = language;
7
+ this.translations = getTranslations();
8
+ }
9
+
10
+ addTranslations(translations) {
11
+ this.translations = Object.assign(this.translations, translations);
12
+ }
13
+
14
+ translate(sourceText, args) {
15
+ let translation = (this.translations[this.language] &&
16
+ this.translations[this.language][sourceText]) || sourceText;
17
+
18
+ if (typeof translation === 'object') {
19
+ translation = args && args.count ?
20
+ this.getPluralizedTranslation(translation, args.count) :
21
+ sourceText;
22
+ }
23
+
24
+ return format(translation, args || {});
25
+ }
26
+
27
+ getPluralizedTranslation(translations, count) {
28
+ return translations[count] || translations['default'];
29
+ }
30
+ };
@@ -0,0 +1,15 @@
1
+ {
2
+ "Sort Ascending": "Aufsteigend sortieren",
3
+ "Sort Descending": "Absteigend sortieren",
4
+ "Reset sorting": "Sortierung zurücksetzen",
5
+ "Remove column": "Spalte entfernen",
6
+ "No Data": "Keine Daten",
7
+ "{count} cells copied": {
8
+ "1": "{count} Zelle kopiert",
9
+ "default": "{count} Zellen kopiert"
10
+ },
11
+ "{count} rows selected": {
12
+ "1": "{count} Zeile ausgewählt",
13
+ "default": "{count} Zeilen ausgewählt"
14
+ }
15
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "Sort Ascending": "Sort Ascending",
3
+ "Sort Descending": "Sort Descending",
4
+ "Reset sorting": "Reset sorting",
5
+ "Remove column": "Remove column",
6
+ "No Data": "No Data",
7
+ "{count} cells copied": {
8
+ "1": "{count} cell copied",
9
+ "default": "{count} cells copied"
10
+ },
11
+ "{count} rows selected": {
12
+ "1": "{count} row selected",
13
+ "default": "{count} rows selected"
14
+ }
15
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "Sort Ascending": "Trier par ordre croissant",
3
+ "Sort Descending": "Trier par ordre décroissant",
4
+ "Reset sorting": "Réinitialiser le tri",
5
+ "Remove column": "Supprimer colonne",
6
+ "No Data": "Pas de données",
7
+ "{count} cells copied": {
8
+ "1": "{count} cellule copiée",
9
+ "default": "{count} cellules copiées"
10
+ },
11
+ "{count} rows selected": {
12
+ "1": "{count} ligne sélectionnée",
13
+ "default": "{count} lignes sélectionnées"
14
+ }
15
+ }
@@ -0,0 +1,13 @@
1
+ import en from './en.json';
2
+ import de from './de.json';
3
+ import fr from './fr.json';
4
+ import it from './it.json';
5
+
6
+ export default function getTranslations() {
7
+ return {
8
+ en,
9
+ de,
10
+ fr,
11
+ it,
12
+ };
13
+ };
@@ -0,0 +1,15 @@
1
+ {
2
+ "Sort Ascending": "Ordinamento ascendente",
3
+ "Sort Descending": "Ordinamento decrescente",
4
+ "Reset sorting": "Azzeramento ordinamento",
5
+ "Remove column": "Rimuovi colonna",
6
+ "No Data": "Nessun dato",
7
+ "{count} cells copied": {
8
+ "1": "Copiato {count} cella",
9
+ "default": "{count} celle copiate"
10
+ },
11
+ "{count} rows selected": {
12
+ "1": "{count} linea selezionata",
13
+ "default": "{count} linee selezionate"
14
+ }
15
+ }
package/src/utils.js CHANGED
@@ -138,3 +138,14 @@ export function numberSortAsc(a, b) {
138
138
  export function stripHTML(html) {
139
139
  return html.replace(/<[^>]*>/g, '');
140
140
  };
141
+
142
+ export function format(str, args) {
143
+ if (!str) return str;
144
+
145
+ Object.keys(args).forEach(arg => {
146
+ let regex = new RegExp(`{(${arg})}`, 'g');
147
+ str = str.replace(regex, args[arg]);
148
+ });
149
+
150
+ return str;
151
+ };