@itfin/components 2.0.32 → 2.0.34

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itfin/components",
3
- "version": "2.0.32",
3
+ "version": "2.0.34",
4
4
  "author": "Vitalii Savchuk <esvit666@gmail.com>",
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -293,6 +293,7 @@ class FilterPanel extends Vue {
293
293
  this.filter = filter;
294
294
  this.filterValue = filterValue;
295
295
  this.$emit('input', this.filterValue);
296
+ this.$emit('loaded', this.filterValue);
296
297
  this.initObserver();
297
298
  }
298
299
  }
@@ -329,6 +330,7 @@ class FilterPanel extends Vue {
329
330
  this.panel.setPayload({ ...payload, ...this.filterValue });
330
331
  }
331
332
  this.$emit('input', this.filterValue);
333
+ this.$emit('change', this.filterValue);
332
334
  }
333
335
 
334
336
  get daysList() {
@@ -338,7 +338,7 @@ export default class PanelList extends Vue {
338
338
  newPanel.expand = () => this.expandPanel(newPanel);
339
339
  newPanel.getTitle = () => newPanel.title;
340
340
  newPanel.getIcon = () => newPanel.icon;
341
- newPanel.setTitle = (title: string) => { newPanel.title = title; };
341
+ newPanel.setTitle = (title: string) => { newPanel.title = title; this.updateTitle() };
342
342
  newPanel.setIcon = (icon: string) => { newPanel.icon = icon; };
343
343
  newPanel.on = (eventName, func: (event: string, ...args: any[]) => any) => {
344
344
  if (!newPanel.__events[eventName]) {
@@ -380,9 +380,15 @@ export default class PanelList extends Vue {
380
380
  });
381
381
  }
382
382
 
383
+ updateTitle() {
384
+ const titles = this.panelsStack.map(p => p.getTitle()).filter(Boolean).reverse();
385
+ this.$root.$options.head.titleChunk = titles.join(' / ');
386
+ this.$meta().refresh();
387
+ }
388
+
383
389
  async openPanel(type: string, payload: any, openIndex?: number) {
384
390
  await this.internalOpenPanel(type, payload, openIndex);
385
- this.setPanelHash()
391
+ this.setPanelHash();
386
392
  }
387
393
 
388
394
  emitEvent(event: string, ...args: any[]) {
@@ -464,6 +470,7 @@ export default class PanelList extends Vue {
464
470
  } else {
465
471
  this.$router.push({ hash });
466
472
  }
473
+ this.updateTitle();
467
474
  }
468
475
 
469
476
  async parsePanelHash() {
@@ -490,6 +497,7 @@ export default class PanelList extends Vue {
490
497
  }
491
498
  this.panelsStack = newStack;
492
499
  this.emitEvent('panels.changed', this.panelsStack);
500
+ this.updateTitle();
493
501
  }
494
502
  }
495
503
 
@@ -1,5 +1,5 @@
1
1
  import JSON5 from 'json5'
2
- import {isPathType} from "@itfin/components/src/components/panels";
2
+ import {isPathType} from "./index";
3
3
 
4
4
  export interface IPanel {
5
5
  type: string;
@@ -7,11 +7,14 @@ export interface IPanel {
7
7
  isCollapsed?: boolean;
8
8
  }
9
9
 
10
+ const COLLAPSE_SYMBOL = '~'
11
+ const PARAMS_SYMBOL = ';'
12
+
10
13
  export function stackToHash(stack: IPanel[]) {
11
14
  const hash = stack.map(panel => {
12
15
  let json = JSON5.stringify(panel.payload || {});
13
16
  json = json.substring(1, json.length - 1); // Remove the outer {}
14
- return `${panel.type}${panel.isCollapsed ? '!' : ''}${json ? '=' : ''}${json}`;
17
+ return `${panel.type}${panel.isCollapsed ? COLLAPSE_SYMBOL : ''}${json ? PARAMS_SYMBOL : ''}${json}`;
15
18
  }).join(isPathType() ? '/' : '&');
16
19
  return isPathType() ? `/${hash}` : `#${hash}`;
17
20
  }
@@ -19,15 +22,14 @@ export function stackToHash(stack: IPanel[]) {
19
22
 
20
23
  export function hashToStack(hash: string|undefined): IPanel[] {
21
24
  let stack:IPanel[] = [];
22
- if (hash) {
23
- const str = hash.replace(isPathType() ? /^\// : /^#/, '');
24
-
25
+ const str = hash.replace(isPathType() ? /^\// : /^#/, '');
26
+ if (str) {
25
27
  stack = str.split(isPathType() ? '/' : '&').map(item => {
26
- if (!item.includes('=')) {
27
- return { type: item.replace('!', ''), isCollapsed: item.includes('!'), payload: {} };
28
+ if (!item.includes(PARAMS_SYMBOL)) {
29
+ return { type: item.replace(COLLAPSE_SYMBOL, ''), isCollapsed: item.includes(COLLAPSE_SYMBOL), payload: {} };
28
30
  }
29
- const [type, payload] = item.split('=');
30
- const isCollapsed = type.includes('!');
31
+ const [type, payload] = item.split(PARAMS_SYMBOL);
32
+ const isCollapsed = type.includes(COLLAPSE_SYMBOL);
31
33
  let payloadObj:any = {};
32
34
  try {
33
35
  let json = decodeURIComponent(payload);
@@ -43,7 +45,7 @@ export function hashToStack(hash: string|undefined): IPanel[] {
43
45
  console.warn(`Error parsing payload for type ${type}:`, payload, e);
44
46
  }
45
47
  return {
46
- type: type.replace('!', ''),
48
+ type: type.replace(COLLAPSE_SYMBOL, ''),
47
49
  isCollapsed,
48
50
  payload: payloadObj
49
51
  };
@@ -10,7 +10,8 @@
10
10
  :endpoint="filtersEndpoint"
11
11
  :panel="panel"
12
12
  v-model="filter"
13
- @input="onFilterSet"
13
+ @loaded="onFilterSet($event, true)"
14
+ @change="onFilterSet($event, false)"
14
15
  >
15
16
  <template #after-filter-btn>
16
17
  <itf-dropdown v-if="$refs.table && schema" shadow append-to-context :button-options="{ default: true, icon: true }" class="h-100" autoclose="outside">
@@ -212,14 +213,14 @@ class itfView extends Vue {
212
213
 
213
214
  updatePage (val) {
214
215
  this.page = val;
215
- this.setPanelPayload({ page: val });
216
+ this.setPanelPayload({ page: val === 1 ? null : val });
216
217
  this.loadData();
217
218
  }
218
219
 
219
220
  updateSizePerPage (val) {
220
221
  this.page = 1;
221
222
  this.size = val;
222
- this.setPanelPayload({ page: 1, size: val });
223
+ this.setPanelPayload({ page: null, size: val });
223
224
  this.loadData();
224
225
  localStorage.setItem('sizePerPage', val);
225
226
  }
@@ -232,7 +233,9 @@ class itfView extends Vue {
232
233
  sources.forEach(source => {
233
234
  if (source && typeof source === 'object') {
234
235
  Object.entries(source).forEach(([key, value]) => {
235
- if (value !== undefined) {
236
+ if (key === 'page' && value === null) {
237
+ delete target[key];
238
+ } else if (value !== undefined) {
236
239
  target[key] = value;
237
240
  }
238
241
  });
@@ -242,9 +245,14 @@ class itfView extends Vue {
242
245
  }
243
246
  }
244
247
 
245
- onFilterSet(filter) {
246
- this.page = 1;
247
- this.setPanelPayload({ ...filter, page: 1 });
248
+ onFilterSet(filter, keepPage = false) {
249
+ if (keepPage) {
250
+ // при завантаженні сторінки не потрібно скидувати сторінку
251
+ this.setPanelPayload({ ...filter });
252
+ } else {
253
+ this.page = 1;
254
+ this.setPanelPayload({ ...filter, page: null });
255
+ }
248
256
  this.loadData();
249
257
  }
250
258