@dile/crud 2.10.10 → 2.10.12

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.
@@ -127,11 +127,32 @@ export class DileCrudList extends DileI18nMixin(DileLoading(LitElement)) {
127
127
  this.filters = activeFilters;
128
128
  }
129
129
 
130
+ this.applyInitialSort();
131
+
130
132
  if(!this.disableLoadOnStart) {
131
133
  this.updateComplete.then( () => this.refresh());
132
134
  }
133
135
  }
134
136
 
137
+ // Takes the initial sort from config.sort.initialSortField / initialSortDirection so the
138
+ // first request is already sorted. It must not depend on <dile-crud-sort-form> echoing
139
+ // its initial value (that echo is intentionally ignored since 2.10.8). The 'desc'
140
+ // default matches the one DileCrud uses when rendering the sort-form. A sort set from
141
+ // outside before firstUpdated wins. No request or crud-list-sort-changed is dispatched.
142
+ applyInitialSort() {
143
+ const initialSortField = this.config?.sort?.initialSortField;
144
+ if (this.sort || !initialSortField) {
145
+ return;
146
+ }
147
+ this.sort = {
148
+ sortField: initialSortField,
149
+ sortDirection: this.config.sort.initialSortDirection || 'desc',
150
+ };
151
+ // Also set it on the service right away (not only via the template binding), so a
152
+ // manual refresh() issued before the next render already includes it.
153
+ this.elservice.sort = this.sort;
154
+ }
155
+
135
156
  willUpdate(changedProperties) {
136
157
  if (this.hasUpdated && (changedProperties.has('belongsTo') || changedProperties.has('relationId'))) {
137
158
  this.refresh({ resetPage: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dile/crud",
3
- "version": "2.10.10",
3
+ "version": "2.10.12",
4
4
  "description": "Components to create a generic crud system based on Web Components and Lit",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -25,12 +25,12 @@
25
25
  },
26
26
  "homepage": "https://dile-components.com/",
27
27
  "dependencies": {
28
- "@dile/ui": "^3.18.5",
28
+ "@dile/ui": "^3.19.0",
29
29
  "axios": "^1.19.0",
30
30
  "lit": "^2.7.0 || ^3.0.0"
31
31
  },
32
32
  "publishConfig": {
33
33
  "access": "public"
34
34
  },
35
- "gitHead": "49f740275cc480045fee98068c8ee8327dcb4d0d"
35
+ "gitHead": "7cf15a5a6e19765b52bebf5902646c8b5e2e67f0"
36
36
  }