@dile/crud 1.11.1 → 1.12.0

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.
@@ -123,6 +123,7 @@ export class DileManyRelation extends DileI18nMixin(LitElement) {
123
123
  message: { type: String },
124
124
  errored: { type: Boolean },
125
125
  hideErrorOnInput: { type: Boolean },
126
+ addOnSelect: { type: Boolean },
126
127
 
127
128
  // Internal state
128
129
  _items: { type: Array, state: true },
@@ -143,6 +144,7 @@ export class DileManyRelation extends DileI18nMixin(LitElement) {
143
144
  this.itemTemplate = (item) => html`${item[this.displayProperty]}`;
144
145
  this.bodyIdProperty = null;
145
146
  this._loadingList = false;
147
+ this.addOnSelect = false;
146
148
  }
147
149
 
148
150
  updated(changedProperties) {
@@ -204,12 +206,14 @@ export class DileManyRelation extends DileI18nMixin(LitElement) {
204
206
  language="${this.language}"
205
207
  @element-changed="${this._onSelectChanged}"
206
208
  ></dile-ajax-select-crud>
207
- <button
208
- class="add-btn"
209
- ?disabled="${!this._selectedId}"
210
- title="${this.addRelationLabelComputed(this.addRelationLabel, this.translations)}"
211
- @click="${this._addSelectedItem}"
212
- ><dile-icon .icon="${addIcon}"></dile-icon></button>
209
+ ${!this.addOnSelect ? html`
210
+ <button
211
+ class="add-btn"
212
+ ?disabled="${!this._selectedId}"
213
+ title="${this.addRelationLabelComputed(this.addRelationLabel, this.translations)}"
214
+ @click="${this._addSelectedItem}"
215
+ ><dile-icon .icon="${addIcon}"></dile-icon></button>
216
+ ` : ''}
213
217
  </div>
214
218
 
215
219
  ${this._loadingList
@@ -238,6 +242,9 @@ export class DileManyRelation extends DileI18nMixin(LitElement) {
238
242
 
239
243
  _onSelectChanged(e) {
240
244
  this._selectedId = e.detail.value || null;
245
+ if (this.addOnSelect && this._selectedId) {
246
+ this._addSelectedItem();
247
+ }
241
248
  }
242
249
 
243
250
  _addSelectedItem() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dile/crud",
3
- "version": "1.11.1",
3
+ "version": "1.12.0",
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": "23b29920983b8ac81493028af821136571ab87b8"
34
+ "gitHead": "3bab6e9bad547c3ef5f329543cb63bde5291dbe5"
35
35
  }