@itfin/components 2.0.8 → 2.0.9

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.
@@ -2,12 +2,13 @@
2
2
 
3
3
  <div v-loading="loading || loadingData" class="flex-grow-1 w-100 d-flex flex-column">
4
4
  <itf-filter-panel
5
- search-placeholder="Search by text"
5
+ :search-placeholder="searchPlaceholder"
6
6
  search
7
7
  class="py-2 px-3"
8
8
  :endpoint="filtersEndpoint"
9
+ :panel="panel"
9
10
  v-model="filter"
10
- @input="loadData"
11
+ @input="onFilterSet"
11
12
  >
12
13
  <template #after-filter-btn>
13
14
  <itf-dropdown v-if="$refs.table && schema" shadow append-to-context :button-options="{ default: true, icon: true }" class="h-100" autoclose="outside">
@@ -122,6 +123,8 @@ class itfView extends Vue {
122
123
  @Prop(String) filtersEndpoint;
123
124
  @Prop(String) itemsKey;
124
125
  @Prop(String) panelKey;
126
+ @Prop({ type: String, default () { return this.$t('components.table.search'); } }) searchPlaceholder;
127
+ @Prop() panel;
125
128
 
126
129
  page = 1;
127
130
  total = 0;
@@ -134,7 +137,12 @@ class itfView extends Vue {
134
137
  selectedIds = [];
135
138
 
136
139
  created() {
137
- this.sorting = this.defaultSorting;
140
+ const defaultSize = localStorage.getItem('sizePerPage') ?? 20;
141
+
142
+ const { page, size, sorting } = this.panel.getPayload() ?? {};
143
+ this.page = page ?? 1;
144
+ this.size = size ?? defaultSize;
145
+ this.sorting = sorting ?? this.defaultSorting;
138
146
  }
139
147
 
140
148
  mounted() {
@@ -154,6 +162,7 @@ class itfView extends Vue {
154
162
  this.$emit('load', this.filter);
155
163
  this.loadingData = true;
156
164
  await this.$try(async () => {
165
+ console.info('filter', this.filter)
157
166
  const res = await this.$axios.$get(this.endpoint, {
158
167
  params: {
159
168
  ...this.filter,
@@ -179,21 +188,50 @@ class itfView extends Vue {
179
188
  }
180
189
 
181
190
  get countPages() {
182
- return Math.ceil(this.total / this.size);
191
+ return Math.ceil(this.total / this.size) ?? 1;
183
192
  }
184
193
 
185
194
  updateSorting (val) {
186
195
  this.sorting = val;
196
+ this.setPanelPayload({ sorting: val });
187
197
  this.loadData();
188
198
  }
189
199
 
190
200
  updatePage (val) {
191
201
  this.page = val;
202
+ this.setPanelPayload({ page: val });
192
203
  this.loadData();
193
204
  }
194
205
 
195
206
  updateSizePerPage (val) {
207
+ this.page = 1;
196
208
  this.size = val;
209
+ this.setPanelPayload({ page: 1, size: val });
210
+ this.loadData();
211
+ localStorage.setItem('sizePerPage', val);
212
+ }
213
+
214
+ setPanelPayload(payload) {
215
+ this.panel.setPayload(assignWithoutUndefined(this.panel.getPayload(), payload));
216
+
217
+ function assignWithoutUndefined(...sources) {
218
+ const target = {};
219
+ sources.forEach(source => {
220
+ if (source && typeof source === 'object') {
221
+ Object.entries(source).forEach(([key, value]) => {
222
+ if (value !== undefined) {
223
+ target[key] = value;
224
+ }
225
+ });
226
+ }
227
+ });
228
+ return target;
229
+ }
230
+ }
231
+
232
+ onFilterSet(filter) {
233
+ this.page = 1;
234
+ this.setPanelPayload({ ...filter, page: 1 });
197
235
  this.loadData();
198
236
  }
199
237
  }
package/src/locales/en.js CHANGED
@@ -127,6 +127,7 @@ module.exports = {
127
127
  moveLeft: 'Move left',
128
128
  columns: 'Columns',
129
129
  resetTableSettings: 'Reset table settings',
130
+ search: 'Search',
130
131
  },
131
132
  pagination: {
132
133
  itemsPerPage: 'Items per page',
package/src/locales/uk.js CHANGED
@@ -132,6 +132,7 @@ module.exports = {
132
132
  moveLeft: 'Посунути вліво',
133
133
  columns: 'Колонки',
134
134
  resetTableSettings: 'Скинути налаштування таблиці',
135
+ search: 'Пошук',
135
136
  },
136
137
  filter: {
137
138
  search: 'Пошук',
@@ -142,6 +143,8 @@ module.exports = {
142
143
  noResults: 'Немає результатів',
143
144
  showMore: 'показати всі ({count})',
144
145
  hideMore: 'сховати',
146
+ exact: 'Точне значення',
147
+ range: 'Діапазон',
145
148
  filterBy: 'Фільтрувати за',
146
149
  from: 'Від',
147
150
  to: 'До',