@vaadin/crud 23.1.0-alpha3 → 23.1.0-alpha4
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 +12 -12
- package/src/vaadin-crud-dialog.js +40 -31
- package/src/vaadin-crud-edit-column.js +3 -3
- package/src/vaadin-crud-edit.js +1 -1
- package/src/vaadin-crud-form.js +1 -1
- package/src/vaadin-crud-grid.js +12 -8
- package/src/vaadin-crud-include-mixin.js +5 -5
- package/src/vaadin-crud.d.ts +2 -2
- package/src/vaadin-crud.js +40 -36
- package/theme/lumo/vaadin-crud-styles.js +33 -20
- package/theme/material/vaadin-crud-styles.js +28 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/crud",
|
|
3
|
-
"version": "23.1.0-
|
|
3
|
+
"version": "23.1.0-alpha4",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -35,22 +35,22 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
37
37
|
"@polymer/polymer": "^3.0.0",
|
|
38
|
-
"@vaadin/button": "23.1.0-
|
|
39
|
-
"@vaadin/component-base": "23.1.0-
|
|
40
|
-
"@vaadin/confirm-dialog": "23.1.0-
|
|
41
|
-
"@vaadin/dialog": "23.1.0-
|
|
42
|
-
"@vaadin/form-layout": "23.1.0-
|
|
43
|
-
"@vaadin/grid": "23.1.0-
|
|
44
|
-
"@vaadin/text-field": "23.1.0-
|
|
38
|
+
"@vaadin/button": "23.1.0-alpha4",
|
|
39
|
+
"@vaadin/component-base": "23.1.0-alpha4",
|
|
40
|
+
"@vaadin/confirm-dialog": "23.1.0-alpha4",
|
|
41
|
+
"@vaadin/dialog": "23.1.0-alpha4",
|
|
42
|
+
"@vaadin/form-layout": "23.1.0-alpha4",
|
|
43
|
+
"@vaadin/grid": "23.1.0-alpha4",
|
|
44
|
+
"@vaadin/text-field": "23.1.0-alpha4",
|
|
45
45
|
"@vaadin/vaadin-license-checker": "^2.1.0",
|
|
46
|
-
"@vaadin/vaadin-lumo-styles": "23.1.0-
|
|
47
|
-
"@vaadin/vaadin-material-styles": "23.1.0-
|
|
48
|
-
"@vaadin/vaadin-themable-mixin": "23.1.0-
|
|
46
|
+
"@vaadin/vaadin-lumo-styles": "23.1.0-alpha4",
|
|
47
|
+
"@vaadin/vaadin-material-styles": "23.1.0-alpha4",
|
|
48
|
+
"@vaadin/vaadin-themable-mixin": "23.1.0-alpha4"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@esm-bundle/chai": "^4.3.4",
|
|
52
52
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
53
53
|
"sinon": "^13.0.2"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "aacdb7fe09811894751f0378ff7fb66071892c71"
|
|
56
56
|
}
|
|
@@ -15,25 +15,16 @@ registerStyles(
|
|
|
15
15
|
min-width: 20em;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
[part='content'] {
|
|
19
|
-
display: flex;
|
|
20
|
-
flex-direction: column;
|
|
21
|
-
padding: 0;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
[part='scroller'] {
|
|
25
|
-
display: flex;
|
|
26
|
-
flex-direction: column;
|
|
27
|
-
overflow: auto;
|
|
28
|
-
flex: auto;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
18
|
[part='footer'] {
|
|
32
|
-
|
|
33
|
-
flex: none;
|
|
19
|
+
justify-content: flex-start;
|
|
34
20
|
flex-direction: row-reverse;
|
|
35
21
|
}
|
|
36
22
|
|
|
23
|
+
/* Make buttons clickable */
|
|
24
|
+
[part='footer'] ::slotted(:not([disabled])) {
|
|
25
|
+
pointer-events: all;
|
|
26
|
+
}
|
|
27
|
+
|
|
37
28
|
:host([fullscreen]) {
|
|
38
29
|
top: 0;
|
|
39
30
|
left: 0;
|
|
@@ -52,24 +43,15 @@ registerStyles(
|
|
|
52
43
|
flex: 1;
|
|
53
44
|
}
|
|
54
45
|
`,
|
|
55
|
-
{ moduleId: 'vaadin-crud-dialog-overlay-styles' }
|
|
46
|
+
{ moduleId: 'vaadin-crud-dialog-overlay-styles' },
|
|
56
47
|
);
|
|
57
48
|
|
|
58
49
|
let memoizedTemplate;
|
|
59
50
|
|
|
60
|
-
const
|
|
61
|
-
<
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
</div>
|
|
65
|
-
<slot name="form"></slot>
|
|
66
|
-
</div>
|
|
67
|
-
|
|
68
|
-
<div part="footer" role="toolbar">
|
|
69
|
-
<slot name="save-button"></slot>
|
|
70
|
-
<slot name="cancel-button"></slot>
|
|
71
|
-
<slot name="delete-button"></slot>
|
|
72
|
-
</div>
|
|
51
|
+
const footerTemplate = html`
|
|
52
|
+
<slot name="save-button"></slot>
|
|
53
|
+
<slot name="cancel-button"></slot>
|
|
54
|
+
<slot name="delete-button"></slot>
|
|
73
55
|
`;
|
|
74
56
|
|
|
75
57
|
class CrudDialogOverlay extends DialogOverlay {
|
|
@@ -80,13 +62,40 @@ class CrudDialogOverlay extends DialogOverlay {
|
|
|
80
62
|
static get template() {
|
|
81
63
|
if (!memoizedTemplate) {
|
|
82
64
|
memoizedTemplate = super.template.cloneNode(true);
|
|
65
|
+
|
|
66
|
+
// Replace two header slots with a single one
|
|
67
|
+
const headerPart = memoizedTemplate.content.querySelector('[part="header"]');
|
|
68
|
+
headerPart.innerHTML = '';
|
|
69
|
+
const headerSlot = document.createElement('slot');
|
|
70
|
+
headerSlot.setAttribute('name', 'header');
|
|
71
|
+
headerPart.appendChild(headerSlot);
|
|
72
|
+
|
|
73
|
+
// Replace default slot with "form" named slot
|
|
83
74
|
const contentPart = memoizedTemplate.content.querySelector('[part="content"]');
|
|
84
75
|
const defaultSlot = contentPart.querySelector('slot:not([name])');
|
|
85
|
-
|
|
86
|
-
|
|
76
|
+
defaultSlot.setAttribute('name', 'form');
|
|
77
|
+
|
|
78
|
+
// Replace footer slot with button named slots
|
|
79
|
+
const footerPart = memoizedTemplate.content.querySelector('[part="footer"]');
|
|
80
|
+
footerPart.setAttribute('role', 'toolbar');
|
|
81
|
+
const footerSlot = footerPart.querySelector('slot');
|
|
82
|
+
footerPart.removeChild(footerSlot);
|
|
83
|
+
footerPart.appendChild(footerTemplate.content.cloneNode(true));
|
|
87
84
|
}
|
|
88
85
|
return memoizedTemplate;
|
|
89
86
|
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @protected
|
|
90
|
+
* @override
|
|
91
|
+
*/
|
|
92
|
+
_headerFooterRendererChange(headerRenderer, footerRenderer, opened) {
|
|
93
|
+
super._headerFooterRendererChange(headerRenderer, footerRenderer, opened);
|
|
94
|
+
|
|
95
|
+
// CRUD has header and footer but does not use renderers
|
|
96
|
+
this.setAttribute('has-header', '');
|
|
97
|
+
this.setAttribute('has-footer', '');
|
|
98
|
+
}
|
|
90
99
|
}
|
|
91
100
|
|
|
92
101
|
customElements.define('vaadin-crud-dialog-overlay', CrudDialogOverlay);
|
|
@@ -36,7 +36,7 @@ class CrudEditColumn extends GridColumn {
|
|
|
36
36
|
*/
|
|
37
37
|
width: {
|
|
38
38
|
type: String,
|
|
39
|
-
value: '4em'
|
|
39
|
+
value: '4em',
|
|
40
40
|
},
|
|
41
41
|
|
|
42
42
|
/**
|
|
@@ -45,11 +45,11 @@ class CrudEditColumn extends GridColumn {
|
|
|
45
45
|
*/
|
|
46
46
|
flexGrow: {
|
|
47
47
|
type: Number,
|
|
48
|
-
value: 0
|
|
48
|
+
value: 0,
|
|
49
49
|
},
|
|
50
50
|
|
|
51
51
|
/** The arial-label for the edit button */
|
|
52
|
-
ariaLabel: String
|
|
52
|
+
ariaLabel: String,
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
55
|
|
package/src/vaadin-crud-edit.js
CHANGED
|
@@ -44,7 +44,7 @@ class CrudEdit extends Button {
|
|
|
44
44
|
__onClick(e) {
|
|
45
45
|
const tr = e.target.parentElement.assignedSlot.parentElement.parentElement;
|
|
46
46
|
tr.dispatchEvent(
|
|
47
|
-
new CustomEvent('edit', { detail: { item: tr._item, index: tr.index }, bubbles: true, composed: true })
|
|
47
|
+
new CustomEvent('edit', { detail: { item: tr._item, index: tr.index }, bubbles: true, composed: true }),
|
|
48
48
|
);
|
|
49
49
|
}
|
|
50
50
|
|
package/src/vaadin-crud-form.js
CHANGED
package/src/vaadin-crud-grid.js
CHANGED
|
@@ -44,7 +44,7 @@ class CrudGrid extends IncludedMixin(Grid) {
|
|
|
44
44
|
noHead: Boolean,
|
|
45
45
|
|
|
46
46
|
/** @private */
|
|
47
|
-
__hideEditColumn: Boolean
|
|
47
|
+
__hideEditColumn: Boolean,
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -54,7 +54,7 @@ class CrudGrid extends IncludedMixin(Grid) {
|
|
|
54
54
|
|
|
55
55
|
/** @private */
|
|
56
56
|
__onItemsChange(items) {
|
|
57
|
-
if ((!this.dataProvider || this.dataProvider
|
|
57
|
+
if ((!this.dataProvider || this.dataProvider === this._arrayDataProvider) && !this.include && items && items[0]) {
|
|
58
58
|
this._configure(items[0]);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -70,7 +70,9 @@ class CrudGrid extends IncludedMixin(Grid) {
|
|
|
70
70
|
__toggleEditColumn() {
|
|
71
71
|
const el = this.querySelector('vaadin-crud-edit-column');
|
|
72
72
|
if (this.hideEditColumn) {
|
|
73
|
-
|
|
73
|
+
if (el) {
|
|
74
|
+
this.removeChild(el);
|
|
75
|
+
}
|
|
74
76
|
} else if (!el) {
|
|
75
77
|
this.appendChild(document.createElement('vaadin-crud-edit-column'));
|
|
76
78
|
}
|
|
@@ -79,7 +81,7 @@ class CrudGrid extends IncludedMixin(Grid) {
|
|
|
79
81
|
/** @private */
|
|
80
82
|
__dataProviderWrapper(params, callback) {
|
|
81
83
|
this.__dataProvider(params, (items, size) => {
|
|
82
|
-
if (this.innerHTML
|
|
84
|
+
if (this.innerHTML === '' && !this.include && items[0]) {
|
|
83
85
|
this._configure(items[0]);
|
|
84
86
|
}
|
|
85
87
|
callback(items, size);
|
|
@@ -91,9 +93,9 @@ class CrudGrid extends IncludedMixin(Grid) {
|
|
|
91
93
|
* @private
|
|
92
94
|
*/
|
|
93
95
|
_dataProviderChanged(dataProvider, oldDataProvider) {
|
|
94
|
-
if (this._arrayDataProvider
|
|
96
|
+
if (this._arrayDataProvider === dataProvider) {
|
|
95
97
|
super._dataProviderChanged(dataProvider, oldDataProvider);
|
|
96
|
-
} else if (this.__dataProviderWrapper
|
|
98
|
+
} else if (this.__dataProviderWrapper !== dataProvider) {
|
|
97
99
|
this.innerHTML = '';
|
|
98
100
|
this.__dataProvider = dataProvider;
|
|
99
101
|
this.dataProvider = this.__dataProviderWrapper;
|
|
@@ -195,8 +197,10 @@ class CrudGrid extends IncludedMixin(Grid) {
|
|
|
195
197
|
textField.setAttribute('slot', 'filter');
|
|
196
198
|
textField.setAttribute('focus-target', true);
|
|
197
199
|
textField.style.width = '100%';
|
|
198
|
-
this.noSort
|
|
199
|
-
|
|
200
|
+
if (this.noSort) {
|
|
201
|
+
textField.placeholder = label;
|
|
202
|
+
}
|
|
203
|
+
textField.addEventListener('value-changed', (event) => {
|
|
200
204
|
filter.value = event.detail.value;
|
|
201
205
|
});
|
|
202
206
|
|
|
@@ -22,7 +22,7 @@ export const IncludedMixin = (superClass) =>
|
|
|
22
22
|
*/
|
|
23
23
|
exclude: {
|
|
24
24
|
value: '^_',
|
|
25
|
-
observer: '__onExcludeChange'
|
|
25
|
+
observer: '__onExcludeChange',
|
|
26
26
|
},
|
|
27
27
|
|
|
28
28
|
/**
|
|
@@ -33,21 +33,21 @@ export const IncludedMixin = (superClass) =>
|
|
|
33
33
|
* @type {string | !Array<string> | undefined}
|
|
34
34
|
*/
|
|
35
35
|
include: {
|
|
36
|
-
observer: '__onIncludeChange'
|
|
37
|
-
}
|
|
36
|
+
observer: '__onIncludeChange',
|
|
37
|
+
},
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/** @private */
|
|
42
42
|
__onExcludeChange(exclude) {
|
|
43
|
-
if (typeof exclude
|
|
43
|
+
if (typeof exclude === 'string') {
|
|
44
44
|
this.exclude = exclude ? RegExp(exclude.replace(/, */g, '|'), 'i') : undefined;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
/** @private */
|
|
49
49
|
__onIncludeChange(include) {
|
|
50
|
-
if (typeof include
|
|
50
|
+
if (typeof include === 'string') {
|
|
51
51
|
this.include = include ? include.split(/, */) : undefined;
|
|
52
52
|
} else if (!this._fields && Array.isArray(include)) {
|
|
53
53
|
const item = {};
|
package/src/vaadin-crud.d.ts
CHANGED
|
@@ -383,13 +383,13 @@ declare class Crud<Item> extends ControllerMixin(ElementMixin(ThemableMixin(HTML
|
|
|
383
383
|
addEventListener<K extends keyof CrudEventMap<Item>>(
|
|
384
384
|
type: K,
|
|
385
385
|
listener: (this: Crud<Item>, ev: CrudEventMap<Item>[K]) => void,
|
|
386
|
-
options?: boolean | AddEventListenerOptions
|
|
386
|
+
options?: boolean | AddEventListenerOptions,
|
|
387
387
|
): void;
|
|
388
388
|
|
|
389
389
|
removeEventListener<K extends keyof CrudEventMap<Item>>(
|
|
390
390
|
type: K,
|
|
391
391
|
listener: (this: Crud<Item>, ev: CrudEventMap<Item>[K]) => void,
|
|
392
|
-
options?: boolean | EventListenerOptions
|
|
392
|
+
options?: boolean | EventListenerOptions,
|
|
393
393
|
): void;
|
|
394
394
|
}
|
|
395
395
|
|
package/src/vaadin-crud.js
CHANGED
|
@@ -318,7 +318,7 @@ class Crud extends SlotMixin(ControllerMixin(ElementMixin(ThemableMixin(PolymerE
|
|
|
318
318
|
*/
|
|
319
319
|
_grid: {
|
|
320
320
|
type: HTMLElement,
|
|
321
|
-
observer: '__gridChanged'
|
|
321
|
+
observer: '__gridChanged',
|
|
322
322
|
},
|
|
323
323
|
|
|
324
324
|
/**
|
|
@@ -327,7 +327,7 @@ class Crud extends SlotMixin(ControllerMixin(ElementMixin(ThemableMixin(PolymerE
|
|
|
327
327
|
*/
|
|
328
328
|
_form: {
|
|
329
329
|
type: HTMLElement,
|
|
330
|
-
observer: '__formChanged'
|
|
330
|
+
observer: '__formChanged',
|
|
331
331
|
},
|
|
332
332
|
|
|
333
333
|
/**
|
|
@@ -336,7 +336,7 @@ class Crud extends SlotMixin(ControllerMixin(ElementMixin(ThemableMixin(PolymerE
|
|
|
336
336
|
*/
|
|
337
337
|
_saveButton: {
|
|
338
338
|
type: HTMLElement,
|
|
339
|
-
observer: '__saveButtonChanged'
|
|
339
|
+
observer: '__saveButtonChanged',
|
|
340
340
|
},
|
|
341
341
|
|
|
342
342
|
/**
|
|
@@ -345,7 +345,7 @@ class Crud extends SlotMixin(ControllerMixin(ElementMixin(ThemableMixin(PolymerE
|
|
|
345
345
|
*/
|
|
346
346
|
_deleteButton: {
|
|
347
347
|
type: HTMLElement,
|
|
348
|
-
observer: '__deleteButtonChanged'
|
|
348
|
+
observer: '__deleteButtonChanged',
|
|
349
349
|
},
|
|
350
350
|
|
|
351
351
|
/**
|
|
@@ -354,7 +354,7 @@ class Crud extends SlotMixin(ControllerMixin(ElementMixin(ThemableMixin(PolymerE
|
|
|
354
354
|
*/
|
|
355
355
|
_cancelButton: {
|
|
356
356
|
type: HTMLElement,
|
|
357
|
-
observer: '__cancelButtonChanged'
|
|
357
|
+
observer: '__cancelButtonChanged',
|
|
358
358
|
},
|
|
359
359
|
|
|
360
360
|
/**
|
|
@@ -362,7 +362,7 @@ class Crud extends SlotMixin(ControllerMixin(ElementMixin(ThemableMixin(PolymerE
|
|
|
362
362
|
* @private
|
|
363
363
|
*/
|
|
364
364
|
_headerNode: {
|
|
365
|
-
type: HTMLElement
|
|
365
|
+
type: HTMLElement,
|
|
366
366
|
},
|
|
367
367
|
|
|
368
368
|
/**
|
|
@@ -372,7 +372,7 @@ class Crud extends SlotMixin(ControllerMixin(ElementMixin(ThemableMixin(PolymerE
|
|
|
372
372
|
items: {
|
|
373
373
|
type: Array,
|
|
374
374
|
notify: true,
|
|
375
|
-
observer: '__itemsChanged'
|
|
375
|
+
observer: '__itemsChanged',
|
|
376
376
|
},
|
|
377
377
|
|
|
378
378
|
/**
|
|
@@ -382,7 +382,7 @@ class Crud extends SlotMixin(ControllerMixin(ElementMixin(ThemableMixin(PolymerE
|
|
|
382
382
|
editedItem: {
|
|
383
383
|
type: Object,
|
|
384
384
|
observer: '__editedItemChanged',
|
|
385
|
-
notify: true
|
|
385
|
+
notify: true,
|
|
386
386
|
},
|
|
387
387
|
|
|
388
388
|
/**
|
|
@@ -399,7 +399,7 @@ class Crud extends SlotMixin(ControllerMixin(ElementMixin(ThemableMixin(PolymerE
|
|
|
399
399
|
type: String,
|
|
400
400
|
value: '',
|
|
401
401
|
reflectToAttribute: true,
|
|
402
|
-
observer: '__editorPositionChanged'
|
|
402
|
+
observer: '__editorPositionChanged',
|
|
403
403
|
},
|
|
404
404
|
|
|
405
405
|
/**
|
|
@@ -410,7 +410,7 @@ class Crud extends SlotMixin(ControllerMixin(ElementMixin(ThemableMixin(PolymerE
|
|
|
410
410
|
*/
|
|
411
411
|
editOnClick: {
|
|
412
412
|
type: Boolean,
|
|
413
|
-
value: false
|
|
413
|
+
value: false,
|
|
414
414
|
},
|
|
415
415
|
|
|
416
416
|
/**
|
|
@@ -428,7 +428,7 @@ class Crud extends SlotMixin(ControllerMixin(ElementMixin(ThemableMixin(PolymerE
|
|
|
428
428
|
*/
|
|
429
429
|
dataProvider: {
|
|
430
430
|
type: Function,
|
|
431
|
-
observer: '__dataProviderChanged'
|
|
431
|
+
observer: '__dataProviderChanged',
|
|
432
432
|
},
|
|
433
433
|
|
|
434
434
|
/**
|
|
@@ -476,7 +476,7 @@ class Crud extends SlotMixin(ControllerMixin(ElementMixin(ThemableMixin(PolymerE
|
|
|
476
476
|
type: Boolean,
|
|
477
477
|
reflectToAttribute: true,
|
|
478
478
|
notify: true,
|
|
479
|
-
observer: '__editorOpenedChanged'
|
|
479
|
+
observer: '__editorOpenedChanged',
|
|
480
480
|
},
|
|
481
481
|
|
|
482
482
|
/**
|
|
@@ -486,7 +486,7 @@ class Crud extends SlotMixin(ControllerMixin(ElementMixin(ThemableMixin(PolymerE
|
|
|
486
486
|
size: {
|
|
487
487
|
type: Number,
|
|
488
488
|
readOnly: true,
|
|
489
|
-
notify: true
|
|
489
|
+
notify: true,
|
|
490
490
|
},
|
|
491
491
|
|
|
492
492
|
/**
|
|
@@ -497,7 +497,7 @@ class Crud extends SlotMixin(ControllerMixin(ElementMixin(ThemableMixin(PolymerE
|
|
|
497
497
|
noToolbar: {
|
|
498
498
|
type: Boolean,
|
|
499
499
|
value: false,
|
|
500
|
-
reflectToAttribute: true
|
|
500
|
+
reflectToAttribute: true,
|
|
501
501
|
},
|
|
502
502
|
|
|
503
503
|
/**
|
|
@@ -555,20 +555,20 @@ class Crud extends SlotMixin(ControllerMixin(ElementMixin(ThemableMixin(PolymerE
|
|
|
555
555
|
content: 'Are you sure you want to delete this item? This action cannot be undone.',
|
|
556
556
|
button: {
|
|
557
557
|
confirm: 'Delete',
|
|
558
|
-
dismiss: 'Cancel'
|
|
559
|
-
}
|
|
558
|
+
dismiss: 'Cancel',
|
|
559
|
+
},
|
|
560
560
|
},
|
|
561
561
|
cancel: {
|
|
562
562
|
title: 'Discard changes',
|
|
563
563
|
content: 'There are unsaved changes to this item.',
|
|
564
564
|
button: {
|
|
565
565
|
confirm: 'Discard',
|
|
566
|
-
dismiss: 'Cancel'
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
}
|
|
566
|
+
dismiss: 'Cancel',
|
|
567
|
+
},
|
|
568
|
+
},
|
|
569
|
+
},
|
|
570
570
|
};
|
|
571
|
-
}
|
|
571
|
+
},
|
|
572
572
|
},
|
|
573
573
|
|
|
574
574
|
/** @private */
|
|
@@ -586,7 +586,7 @@ class Crud extends SlotMixin(ControllerMixin(ElementMixin(ThemableMixin(PolymerE
|
|
|
586
586
|
*/
|
|
587
587
|
_fullscreen: {
|
|
588
588
|
type: Boolean,
|
|
589
|
-
observer: '__fullscreenChanged'
|
|
589
|
+
observer: '__fullscreenChanged',
|
|
590
590
|
},
|
|
591
591
|
|
|
592
592
|
/**
|
|
@@ -594,8 +594,8 @@ class Crud extends SlotMixin(ControllerMixin(ElementMixin(ThemableMixin(PolymerE
|
|
|
594
594
|
* @protected
|
|
595
595
|
*/
|
|
596
596
|
_fullscreenMediaQuery: {
|
|
597
|
-
value: '(max-width: 600px), (max-height: 600px)'
|
|
598
|
-
}
|
|
597
|
+
value: '(max-width: 600px), (max-height: 600px)',
|
|
598
|
+
},
|
|
599
599
|
};
|
|
600
600
|
}
|
|
601
601
|
|
|
@@ -607,7 +607,7 @@ class Crud extends SlotMixin(ControllerMixin(ElementMixin(ThemableMixin(PolymerE
|
|
|
607
607
|
'__editOnClickChanged(editOnClick, _grid)',
|
|
608
608
|
'__saveButtonPropsChanged(_saveButton, i18n.saveItem, __isDirty)',
|
|
609
609
|
'__cancelButtonPropsChanged(_cancelButton, i18n.cancel)',
|
|
610
|
-
'__deleteButtonPropsChanged(_deleteButton, i18n.deleteItem, __isNew)'
|
|
610
|
+
'__deleteButtonPropsChanged(_deleteButton, i18n.deleteItem, __isNew)',
|
|
611
611
|
];
|
|
612
612
|
}
|
|
613
613
|
|
|
@@ -624,7 +624,7 @@ class Crud extends SlotMixin(ControllerMixin(ElementMixin(ThemableMixin(PolymerE
|
|
|
624
624
|
|
|
625
625
|
/** @private */
|
|
626
626
|
static _isValidEditorPosition(editorPosition) {
|
|
627
|
-
return ['bottom', 'aside'].
|
|
627
|
+
return ['bottom', 'aside'].includes(editorPosition);
|
|
628
628
|
}
|
|
629
629
|
|
|
630
630
|
/** @protected */
|
|
@@ -655,7 +655,7 @@ class Crud extends SlotMixin(ControllerMixin(ElementMixin(ThemableMixin(PolymerE
|
|
|
655
655
|
button.id = 'delete';
|
|
656
656
|
button.setAttribute('theme', 'tertiary error');
|
|
657
657
|
return button;
|
|
658
|
-
}
|
|
658
|
+
},
|
|
659
659
|
};
|
|
660
660
|
}
|
|
661
661
|
|
|
@@ -683,7 +683,7 @@ class Crud extends SlotMixin(ControllerMixin(ElementMixin(ThemableMixin(PolymerE
|
|
|
683
683
|
this.addController(
|
|
684
684
|
new MediaQueryController(this._fullscreenMediaQuery, (matches) => {
|
|
685
685
|
this._fullscreen = matches;
|
|
686
|
-
})
|
|
686
|
+
}),
|
|
687
687
|
);
|
|
688
688
|
}
|
|
689
689
|
|
|
@@ -841,17 +841,17 @@ class Crud extends SlotMixin(ControllerMixin(ElementMixin(ThemableMixin(PolymerE
|
|
|
841
841
|
return;
|
|
842
842
|
}
|
|
843
843
|
|
|
844
|
-
if (slotAttributeValue
|
|
844
|
+
if (slotAttributeValue === 'grid') {
|
|
845
845
|
// Force to remove listener on previous grid first
|
|
846
846
|
this.__editOnClickChanged(false, this._grid);
|
|
847
847
|
this._grid = node;
|
|
848
848
|
this.__editOnClickChanged(this.editOnClick, this._grid);
|
|
849
|
-
} else if (slotAttributeValue
|
|
849
|
+
} else if (slotAttributeValue === 'form') {
|
|
850
850
|
this._form = node;
|
|
851
851
|
} else if (slotAttributeValue.indexOf('button') >= 0) {
|
|
852
852
|
const [button] = slotAttributeValue.split('-');
|
|
853
853
|
this[`_${button}Button`] = node;
|
|
854
|
-
} else if (slotAttributeValue
|
|
854
|
+
} else if (slotAttributeValue === 'header') {
|
|
855
855
|
this._headerNode = node;
|
|
856
856
|
}
|
|
857
857
|
});
|
|
@@ -1125,14 +1125,16 @@ class Crud extends SlotMixin(ControllerMixin(ElementMixin(ThemableMixin(PolymerE
|
|
|
1125
1125
|
} else {
|
|
1126
1126
|
console.warn(
|
|
1127
1127
|
'<vaadin-crud> Unable to autoconfigure form because the data structure is unknown. ' +
|
|
1128
|
-
'Either specify `include` or ensure at least one item is available beforehand.'
|
|
1128
|
+
'Either specify `include` or ensure at least one item is available beforehand.',
|
|
1129
1129
|
);
|
|
1130
1130
|
}
|
|
1131
1131
|
}
|
|
1132
1132
|
this._form.item = item;
|
|
1133
1133
|
this._fields.forEach((e) => {
|
|
1134
1134
|
const path = e.path || e.getAttribute('path');
|
|
1135
|
-
|
|
1135
|
+
if (path) {
|
|
1136
|
+
e.value = this.get(path, item);
|
|
1137
|
+
}
|
|
1136
1138
|
});
|
|
1137
1139
|
|
|
1138
1140
|
this.__isNew = this.__isNew || (this.items && this.items.indexOf(item) < 0);
|
|
@@ -1177,7 +1179,7 @@ class Crud extends SlotMixin(ControllerMixin(ElementMixin(ThemableMixin(PolymerE
|
|
|
1177
1179
|
/** @private */
|
|
1178
1180
|
__new(event) {
|
|
1179
1181
|
// This allows listening to parent element and fire only when clicking on default or custom new-button.
|
|
1180
|
-
if (event.composedPath().filter((e) => e.nodeType
|
|
1182
|
+
if (event.composedPath().filter((e) => e.nodeType === 1 && e.hasAttribute('new-button'))[0]) {
|
|
1181
1183
|
this.__confirmBeforeChangingEditedItem(null, true);
|
|
1182
1184
|
}
|
|
1183
1185
|
}
|
|
@@ -1196,7 +1198,7 @@ class Crud extends SlotMixin(ControllerMixin(ElementMixin(ThemableMixin(PolymerE
|
|
|
1196
1198
|
this.__isDirty = false;
|
|
1197
1199
|
this.__isNew = !item;
|
|
1198
1200
|
const evt = this.dispatchEvent(
|
|
1199
|
-
new CustomEvent(this.__isNew ? 'new' : 'edit', { detail: { item: item }, cancelable: true })
|
|
1201
|
+
new CustomEvent(this.__isNew ? 'new' : 'edit', { detail: { item: item }, cancelable: true }),
|
|
1200
1202
|
);
|
|
1201
1203
|
if (evt) {
|
|
1202
1204
|
this.editedItem = item || {};
|
|
@@ -1214,7 +1216,9 @@ class Crud extends SlotMixin(ControllerMixin(ElementMixin(ThemableMixin(PolymerE
|
|
|
1214
1216
|
const item = { ...this.editedItem };
|
|
1215
1217
|
this._fields.forEach((e) => {
|
|
1216
1218
|
const path = e.path || e.getAttribute('path');
|
|
1217
|
-
|
|
1219
|
+
if (path) {
|
|
1220
|
+
this.__set(path, e.value, item);
|
|
1221
|
+
}
|
|
1218
1222
|
});
|
|
1219
1223
|
const evt = this.dispatchEvent(new CustomEvent('save', { detail: { item: item }, cancelable: true }));
|
|
1220
1224
|
if (evt) {
|
|
@@ -30,7 +30,7 @@ registerStyles(
|
|
|
30
30
|
left: calc((var(--lumo-size-m) - var(--lumo-size-s)) / -2);
|
|
31
31
|
}
|
|
32
32
|
`,
|
|
33
|
-
{ moduleId: 'lumo-crud-grid-edit' }
|
|
33
|
+
{ moduleId: 'lumo-crud-grid-edit' },
|
|
34
34
|
);
|
|
35
35
|
|
|
36
36
|
/**
|
|
@@ -42,20 +42,6 @@ const editorStyles = css`
|
|
|
42
42
|
margin-top: 0 !important;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
[part='scroller'] {
|
|
46
|
-
padding: var(--lumo-space-l);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
[part='footer'] {
|
|
50
|
-
background-color: var(--lumo-contrast-5pct);
|
|
51
|
-
padding: var(--lumo-space-s);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
[part='footer'] ::slotted(*) {
|
|
55
|
-
margin-left: var(--lumo-space-s);
|
|
56
|
-
margin-right: var(--lumo-space-s);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
45
|
:host(:not([dir='rtl'])) ::slotted([slot='delete-button']) {
|
|
60
46
|
margin-right: auto;
|
|
61
47
|
}
|
|
@@ -74,6 +60,10 @@ registerStyles(
|
|
|
74
60
|
font-family: var(--lumo-font-family);
|
|
75
61
|
}
|
|
76
62
|
|
|
63
|
+
[part='scroller'] {
|
|
64
|
+
padding: var(--lumo-space-l);
|
|
65
|
+
}
|
|
66
|
+
|
|
77
67
|
[part='toolbar'] {
|
|
78
68
|
padding: var(--lumo-space-s) var(--lumo-space-m);
|
|
79
69
|
background-color: var(--lumo-contrast-5pct);
|
|
@@ -93,6 +83,16 @@ registerStyles(
|
|
|
93
83
|
border: 0;
|
|
94
84
|
}
|
|
95
85
|
|
|
86
|
+
[part='footer'] {
|
|
87
|
+
background-color: var(--lumo-contrast-5pct);
|
|
88
|
+
padding: var(--lumo-space-s);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
[part='footer'] ::slotted(*) {
|
|
92
|
+
margin-left: var(--lumo-space-s);
|
|
93
|
+
margin-right: var(--lumo-space-s);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
96
|
[part='editor'] {
|
|
97
97
|
background: var(--lumo-base-color);
|
|
98
98
|
box-sizing: border-box;
|
|
@@ -121,11 +121,24 @@ registerStyles(
|
|
|
121
121
|
vaadin-grid-cell-content {
|
|
122
122
|
text-overflow: ellipsis;
|
|
123
123
|
}
|
|
124
|
-
|
|
124
|
+
`,
|
|
125
125
|
],
|
|
126
|
-
{ moduleId: 'lumo-crud' }
|
|
126
|
+
{ moduleId: 'lumo-crud' },
|
|
127
127
|
);
|
|
128
128
|
|
|
129
|
-
registerStyles(
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
registerStyles(
|
|
130
|
+
'vaadin-crud-dialog-overlay',
|
|
131
|
+
[
|
|
132
|
+
editorStyles,
|
|
133
|
+
css`
|
|
134
|
+
[part='header'] ::slotted(h3) {
|
|
135
|
+
margin-top: 0 !important;
|
|
136
|
+
margin-bottom: 0 !important;
|
|
137
|
+
margin-inline-start: var(--lumo-space-s);
|
|
138
|
+
}
|
|
139
|
+
`,
|
|
140
|
+
],
|
|
141
|
+
{
|
|
142
|
+
moduleId: 'lumo-crud-dialog-overlay',
|
|
143
|
+
},
|
|
144
|
+
);
|
|
@@ -37,7 +37,7 @@ registerStyles(
|
|
|
37
37
|
left: 0;
|
|
38
38
|
}
|
|
39
39
|
`,
|
|
40
|
-
{ moduleId: 'material-crud-grid-edit' }
|
|
40
|
+
{ moduleId: 'material-crud-grid-edit' },
|
|
41
41
|
);
|
|
42
42
|
|
|
43
43
|
/**
|
|
@@ -45,19 +45,8 @@ registerStyles(
|
|
|
45
45
|
* They are applied to both `vaadin-crud` and `vaadin-crud-dialog-overlay` components.
|
|
46
46
|
*/
|
|
47
47
|
const editorStyles = css`
|
|
48
|
-
[part='scroller'] {
|
|
49
|
-
padding: 16px;
|
|
50
|
-
background: var(--material-background-color);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
48
|
[part='footer'] {
|
|
54
49
|
background-color: var(--material-secondary-background-color);
|
|
55
|
-
padding: 8px 4px;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
[part='footer'] ::slotted(*) {
|
|
59
|
-
margin-left: 4px;
|
|
60
|
-
margin-right: 4px;
|
|
61
50
|
}
|
|
62
51
|
|
|
63
52
|
:host(:not([dir='rtl'])) ::slotted([slot='delete-button']) {
|
|
@@ -78,11 +67,25 @@ registerStyles(
|
|
|
78
67
|
font-family: var(--material-font-family);
|
|
79
68
|
}
|
|
80
69
|
|
|
70
|
+
[part='scroller'] {
|
|
71
|
+
padding: 16px;
|
|
72
|
+
background: var(--material-background-color);
|
|
73
|
+
}
|
|
74
|
+
|
|
81
75
|
[part='toolbar'] {
|
|
82
76
|
padding: 8px;
|
|
83
77
|
background-color: var(--material-secondary-background-color);
|
|
84
78
|
}
|
|
85
79
|
|
|
80
|
+
[part='footer'] {
|
|
81
|
+
padding: 8px 4px;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
[part='footer'] ::slotted(*) {
|
|
85
|
+
margin-left: 4px;
|
|
86
|
+
margin-right: 4px;
|
|
87
|
+
}
|
|
88
|
+
|
|
86
89
|
:host(:not([editor-position=''])) [part='editor']:not([hidden]) {
|
|
87
90
|
box-shadow: var(--material-shadow-elevation-12dp);
|
|
88
91
|
}
|
|
@@ -101,9 +104,9 @@ registerStyles(
|
|
|
101
104
|
margin: 0;
|
|
102
105
|
padding: 0;
|
|
103
106
|
}
|
|
104
|
-
|
|
107
|
+
`,
|
|
105
108
|
],
|
|
106
|
-
{ moduleId: 'material-crud' }
|
|
109
|
+
{ moduleId: 'material-crud' },
|
|
107
110
|
);
|
|
108
111
|
|
|
109
112
|
registerStyles(
|
|
@@ -125,7 +128,16 @@ registerStyles(
|
|
|
125
128
|
:host([closing]) {
|
|
126
129
|
animation: 0.25s material-overlay-dummy-animation;
|
|
127
130
|
}
|
|
128
|
-
|
|
131
|
+
|
|
132
|
+
[part='header'] ::slotted(h3) {
|
|
133
|
+
margin-top: 0 !important;
|
|
134
|
+
margin-bottom: 0 !important;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
[part='content'] {
|
|
138
|
+
padding: 0 16px 16px;
|
|
139
|
+
}
|
|
140
|
+
`,
|
|
129
141
|
],
|
|
130
|
-
{ moduleId: 'material-crud-dialog-overlay' }
|
|
142
|
+
{ moduleId: 'material-crud-dialog-overlay' },
|
|
131
143
|
);
|