@dile/crud 1.9.1 → 1.9.3
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.
|
@@ -5,6 +5,7 @@ import '../../ajax/ajax.js';
|
|
|
5
5
|
import '../../ajax-select-crud/ajax-select-crud.js';
|
|
6
6
|
import '@dile/ui/components/icon/icon.js';
|
|
7
7
|
import '@dile/ui/components/spinner/spinner.js';
|
|
8
|
+
import '@dile/ui/components/input/input-message.js';
|
|
8
9
|
|
|
9
10
|
export class DileManyRelation extends DileI18nMixin(LitElement) {
|
|
10
11
|
static styles = [
|
|
@@ -111,7 +112,11 @@ export class DileManyRelation extends DileI18nMixin(LitElement) {
|
|
|
111
112
|
itemTemplate: { type: Object },
|
|
112
113
|
getListItems: { type: Object },
|
|
113
114
|
addRelationLabel: { type: String },
|
|
115
|
+
emptyListMessage: { type: String },
|
|
114
116
|
bodyIdProperty: { type: String },
|
|
117
|
+
message: { type: String },
|
|
118
|
+
errored: { type: Boolean },
|
|
119
|
+
hideErrorOnInput: { type: Boolean },
|
|
115
120
|
|
|
116
121
|
// Internal state
|
|
117
122
|
_items: { type: Array, state: true },
|
|
@@ -204,7 +209,7 @@ export class DileManyRelation extends DileI18nMixin(LitElement) {
|
|
|
204
209
|
${this._loadingList
|
|
205
210
|
? html`<dile-spinner active></dile-spinner>`
|
|
206
211
|
: this._items.length === 0
|
|
207
|
-
? html`<p class="empty-msg">${this.translations
|
|
212
|
+
? html`<p class="empty-msg">${this.emptyListMessageComputed(this.emptyListMessage, this.translations)}</p>`
|
|
208
213
|
: this._items.map(item => html`
|
|
209
214
|
<div class="relation-item">
|
|
210
215
|
<span class="relation-item-content">${this.itemTemplate(item)}</span>
|
|
@@ -217,11 +222,19 @@ export class DileManyRelation extends DileI18nMixin(LitElement) {
|
|
|
217
222
|
</div>
|
|
218
223
|
`)
|
|
219
224
|
}
|
|
225
|
+
${this.message
|
|
226
|
+
? html`<dile-input-message message="${this.message}" ?errored=${this.errored}></dile-input-message>`
|
|
227
|
+
: ''
|
|
228
|
+
}
|
|
220
229
|
`;
|
|
221
230
|
}
|
|
222
231
|
|
|
223
232
|
_onSelectChanged(e) {
|
|
224
233
|
this._selectedId = e.detail.value || null;
|
|
234
|
+
if (this.hideErrorOnInput && this.errored) {
|
|
235
|
+
this.message = '';
|
|
236
|
+
this.errored = false;
|
|
237
|
+
}
|
|
225
238
|
}
|
|
226
239
|
|
|
227
240
|
_addSelectedItem() {
|
|
@@ -296,4 +309,8 @@ export class DileManyRelation extends DileI18nMixin(LitElement) {
|
|
|
296
309
|
selectDefaultPlaceholderComputed(value, translations) {
|
|
297
310
|
return value ? value : translations?.select_relation_placeholder ?? 'Select...';
|
|
298
311
|
}
|
|
312
|
+
|
|
313
|
+
emptyListMessageComputed(message, translations) {
|
|
314
|
+
return message ? message : translations?.empty_list ?? 'There are no items yet';
|
|
315
|
+
}
|
|
299
316
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dile/crud",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.3",
|
|
4
4
|
"description": "Components to create a generic crud system based on Web Components and Lit",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "6cce2cd32f997433190f40ba776e501421b771a6"
|
|
35
35
|
}
|