@itfin/components 1.3.58 → 1.3.59

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": "1.3.58",
3
+ "version": "1.3.59",
4
4
  "author": "Vitalii Savchuk <esvit666@gmail.com>",
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -34,6 +34,7 @@
34
34
  :striped="striped"
35
35
  :expanded-ids="expandedIds"
36
36
  :css-property="cssProperty"
37
+ :sorting.sync="_sorting"
37
38
  @update:expanded-ids="$emit('update:expanded-ids', $event)"
38
39
  @new="$emit('new', $event)"
39
40
  @add-column="$emit('add-column', $event)"
@@ -85,6 +86,7 @@ class itfTable2 extends Vue {
85
86
  @Prop({ type: String, default: null }) stateName; // save state to storage
86
87
  @Prop({ type: Object, default: () => ({}) }) schema;
87
88
  @ModelSync('value', 'input', { type: Array, default: () => ([]) }) selectedIds;
89
+ @PropSync('sorting', { type: Object, default: () => ({}) }) _sorting;
88
90
  @Prop({ type: Array, default: () => [] }) expandedIds;
89
91
  @Prop() currency;
90
92
  @Prop() currencies;
@@ -44,6 +44,7 @@
44
44
  :no-select-all="noSelectAll"
45
45
  :selected-ids="selectedIds"
46
46
  :indicatorType="indicatorType"
47
+ :sorting.sync="_sorting"
47
48
  @update:selectedIds="$emit('update:selectedIds', $event)"
48
49
  @update:columns="$emit('update:columns', $event)"
49
50
  @add-column="$emit('add-column', $event)"
@@ -347,6 +348,7 @@ class itfTableGroup extends Vue {
347
348
  @Prop(Boolean) striped;
348
349
  @Prop() indicatorWidth;
349
350
  @Prop() cssProperty;
351
+ @PropSync('sorting', { type: Object, default: () => ({}) }) _sorting;
350
352
  @Prop({ type: String, default: null }) indicatorType;
351
353
  @Prop({type: String, default: function() { return this.$t('components.table.new'); } }) newLabel;
352
354
  @Prop({type: Object, default: () => ({})}) schema;
@@ -33,24 +33,24 @@
33
33
  v-draggable="{ handle: true, payload: { index: n, item: column }, mirror: {yAxis:false} }">
34
34
  <itf-dropdown text append-to-body shadow ref="dropdown" class="w-100" :disabled="noColumnMenu">
35
35
  <template #button>
36
- <span class="itf-table2__header-title" :title="column.title[locale] || column.title['en_US']">
36
+ <span class="itf-table2__header-title text-truncate" :title="column.title[locale] || column.title['en_US']" :class="{'ms-auto': column.align === 'end'}">
37
37
  <span v-if="column.icon" :class="column.icon"></span>
38
38
  {{column.title[locale] || column.title['en_US']}}
39
39
  <div v-if="column.prefix" class="itf-table2__subtitle" v-text="column.prefix" />
40
40
  </span>
41
- <!-- <itf-icon name="arrow_up" :size="16" class="ms-1" />-->
41
+ <itf-icon v-if="_sorting[column.property]" :name="_sorting[column.property] === 'asc' ? 'arrow_up' : 'arrow_down'" :size="16" class="ms-1" />
42
42
  </template>
43
43
 
44
44
  <div v-if="column.sortable">
45
- <a class="dropdown-item d-flex align-items-center" href="javascript:;">
45
+ <a class="dropdown-item d-flex align-items-center" href="javascript:;" @click="sortBy(column, 'asc')">
46
46
  <itf-icon name="arrow_up" :size="16" class="me-1" />
47
47
  {{$t('components.table.sortAscending')}}
48
48
  </a>
49
49
  </div>
50
50
  <div v-if="column.sortable">
51
- <a class="dropdown-item d-flex align-items-center" href="javascript:;">
51
+ <a class="dropdown-item d-flex align-items-center" href="javascript:;" @click="sortBy(column, 'desc')">
52
52
  <itf-icon name="arrow_down" :size="16" class="me-1" />
53
- {{$t('components.table.sortAscending')}}
53
+ {{$t('components.table.sortDescending')}}
54
54
  </a>
55
55
  </div>
56
56
  <div v-if="column.groupable">
@@ -159,6 +159,7 @@ class itfTableHeader extends Vue {
159
159
  @Inject() tableEl;
160
160
 
161
161
  @PropSync('columns', { type: Array, default: () => ([]) }) sortedColumns;
162
+ @PropSync('sorting', { type: Object, default: () => ({}) }) _sorting;
162
163
  @Prop({ type: Array, default: () => ([]) }) rows;
163
164
  @Prop({ type: Array, default: () => ([]) }) selectedIds;
164
165
  @Prop({ type: Object, default: () => ({}) }) schema;
@@ -335,5 +336,10 @@ class itfTableHeader extends Vue {
335
336
  onSortColumns(items) {
336
337
  this.$emit('update:columns', items);
337
338
  }
339
+
340
+ sortBy(column, order) {
341
+ console.info({ [column.property]: order });
342
+ this.$emit('update:sorting', { [column.property]: order });
343
+ }
338
344
  }
339
345
  </script>
@@ -51,7 +51,7 @@
51
51
  v-if="column.visible !== false"
52
52
  :data-column="k"
53
53
  :style="`width: ${column.width}px; max-width: ${column.width}px; left: ${column.left}px;`"
54
- :class="{'sticky': column.pinned, 'last-sticky-column': k === lastPinnedIndex, 'flex-grow-1': column.grow, 'px-2': !(column.editable && editable), 'editable': column.editable && editable}"
54
+ :class="{'justify-content-end': column.align === 'end', 'sticky': column.pinned, 'last-sticky-column': k === lastPinnedIndex, 'flex-grow-1': column.grow, 'px-2': !(column.editable && editable), 'editable': column.editable && editable}"
55
55
  class="table-view-item-value d-flex h-100">
56
56
  <slot :name="`column.${column.property}`" :toggle="() => $emit('toggle', item)" :level="level" :editable="column.editable && editable" :item="item" :column="column" :update="(val) => updateValue(item, val, n, column)" :value="getValue(item, column)">
57
57
  <template v-if="column.editable && editable">
@@ -51,7 +51,7 @@ body[data-theme="dark"] {
51
51
  bottom: 0;
52
52
  }
53
53
  &.table-striped {
54
- .table-view-item:nth-child(odd) {
54
+ .table-view-item:nth-child(even) {
55
55
  --itf-table2-row-bg: var(--itf-table-alt-bg);
56
56
  }
57
57
  }