@dile/crud 2.3.4 → 2.4.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.
@@ -0,0 +1,4 @@
1
+ import { DileCrudSingleActionDispatcher } from "./src/DileCrudSingleActionDispatcher.js";
2
+ if (!customElements.get('dile-crud-single-action-dispatcher')) {
3
+ customElements.define('dile-crud-single-action-dispatcher', DileCrudSingleActionDispatcher);
4
+ }
@@ -0,0 +1,52 @@
1
+ import { html, css } from 'lit';
2
+ import '@dile/ui/components/button/button.js';
3
+ import { DileCrudActions } from './DileCrudActions.js';
4
+
5
+ export class DileCrudSingleActionDispatcher extends DileCrudActions {
6
+ static styles = [
7
+ super.styles,
8
+ css`
9
+ dile-button {
10
+ --dile-button-background-color: var(--dile-crud-single-action-background-color, var(--dile-primary-color, #7BB93D));
11
+ --dile-button-text-color: var(--dile-crud-single-action-text-color, var(--dile-on-primary-color, #fff));
12
+ --dile-button-border-color: var(--dile-crud-single-action-border-color, var(--dile-primary-dark-color, #12354d));
13
+ --dile-button-hover-background-color: var(--dile-crud-single-action-hover-background-color, var(--dile-primary-light-color, #f3f3ae));
14
+ --dile-button-hover-text-color: var(--dile-crud-single-action-hover-text-color, var(--dile-on-primary-light-color, #303030));
15
+ --dile-button-hover-border-color: var(--dile-crud-single-action-hover-border-color, var(--dile-primary-color, #666666));
16
+ }
17
+ `
18
+ ];
19
+
20
+ static get properties() {
21
+ return {
22
+ actionName: { type: String },
23
+ };
24
+ }
25
+
26
+ get selection() {
27
+ return this.actionName;
28
+ }
29
+ set selection(_value) {
30
+ // this dispatcher always runs the configured actionName
31
+ }
32
+
33
+ get currentAction() {
34
+ return this.actions.find(action => action.name === this.actionName);
35
+ }
36
+
37
+ get actionListTemplate() {
38
+ return html`
39
+ <dile-button
40
+ class="${this.actionIds.length > 0 ? 'visible' : 'hide'}"
41
+ @click=${this.showAction}
42
+ >${this.currentAction ? this.currentAction.label : ''}</dile-button>
43
+ `;
44
+ }
45
+
46
+ updated(changedProperties) {
47
+ super.updated(changedProperties);
48
+ if (changedProperties.has('actionName') || changedProperties.has('actions')) {
49
+ this.computeDestructive();
50
+ }
51
+ }
52
+ }
@@ -10,10 +10,12 @@ import '../../list/crud-list.js';
10
10
  import '../../ui/crud-sort-form.js';
11
11
  import '../../ui/crud-page-size.js';
12
12
  import '../../ui/crud-filters.js';
13
+ import '../../ui/crud-filters-inline.js';
13
14
  import '../../insert/crud-insert.js';
14
15
  import '../../update/crud-update.js';
15
16
  import '../../action/crud-actions.js';
16
17
  import '../../action/crud-delete-action.js';
18
+ import '../../action/crud-single-action-dispatcher.js';
17
19
  import { formStyles } from '../../../styles/form-styles.js';
18
20
  import { DileCrudMixin } from '../../../lib/DileCrudMixin.js';
19
21
  import { crudStyles } from '../../../styles/crud-styles.js';
@@ -95,12 +97,15 @@ export class DileCrud extends DileI18nMixin(DileCrudMixin(LitElement)) {
95
97
  keyword: { type: String },
96
98
  belongsTo: { type: String },
97
99
  relationId: { type: String },
100
+ filtersAlwaysVisible: { type: Boolean },
101
+ singleActionDispatcher: { type: String },
98
102
  };
99
103
  }
100
104
 
101
105
  constructor() {
102
106
  super();
103
107
  this.actionIds = [];
108
+ this.filtersAlwaysVisible = false;
104
109
  }
105
110
 
106
111
  // GETTERS ELEMENTOS
@@ -135,6 +140,7 @@ export class DileCrud extends DileI18nMixin(DileCrudMixin(LitElement)) {
135
140
 
136
141
  <main>
137
142
  ${this.navActionsTemplate}
143
+ ${this.filtersAlwaysVisible && !this.config.customization.disableFilter ? this.filtersAlwaysVisibleTemplate : ''}
138
144
  <div
139
145
  @item-checkbox-changed=${this.itemCheckboxChanged}
140
146
  @dile-chip-icon-click=${this.removeFilter}
@@ -232,11 +238,11 @@ export class DileCrud extends DileI18nMixin(DileCrudMixin(LitElement)) {
232
238
  }
233
239
  <div class="actions" slot="actions">
234
240
  ${this.actionsTemplate}
235
- ${this.config.customization.disableFilter
241
+ ${this.config.customization.disableFilter || this.filtersAlwaysVisible
236
242
  ? ''
237
243
  : html`
238
244
  <dile-crud-filters
239
- class="action-controller"
245
+ class="action-controller"
240
246
  id="elfilters"
241
247
  @filters-changed=${this.filtersChanged}
242
248
  .filters=${this.config.availableFilters || []}
@@ -276,10 +282,21 @@ export class DileCrud extends DileI18nMixin(DileCrudMixin(LitElement)) {
276
282
  `
277
283
  }
278
284
 
285
+ get filtersAlwaysVisibleTemplate() {
286
+ return html`
287
+ <dile-crud-filters-inline
288
+ id="elfilters"
289
+ @filters-changed=${this.filtersChanged}
290
+ .filters=${this.config.availableFilters || []}
291
+ language="${this.language}"
292
+ ></dile-crud-filters-inline>
293
+ `
294
+ }
295
+
279
296
  get disableAllActionFunctionalities() {
280
297
  const customization = this.config.customization;
281
- return customization.disableHelp
282
- && customization.disableFilter
298
+ return customization.disableHelp
299
+ && (customization.disableFilter || this.filtersAlwaysVisible)
283
300
  && customization.disablePagination
284
301
  && customization.disableSort
285
302
  && customization.hideCheckboxSelection;
@@ -0,0 +1,4 @@
1
+ import { DileCrudFiltersInline } from "./src/DileCrudFiltersInline.js";
2
+ if (!customElements.get('dile-crud-filters-inline')) {
3
+ customElements.define('dile-crud-filters-inline', DileCrudFiltersInline);
4
+ }
@@ -19,15 +19,21 @@ export class DileCrudFilters extends DileI18nMixin(LitElement) {
19
19
  render() {
20
20
  return html`
21
21
  <dile-crud-list-options .icon="${filterIcon}" label="${this.translations.filters_label}" >
22
- <dile-crud-filters-form
23
- id="elform"
24
- .filters=${this.filters}
25
- @dile-form-changed=${this.filtersChanged}
26
- ></dile-crud-filters-form>
22
+ ${this.formTemplate}
27
23
  </dile-crud-list-options>
28
24
  `;
29
25
  }
30
26
 
27
+ get formTemplate() {
28
+ return html`
29
+ <dile-crud-filters-form
30
+ id="elform"
31
+ .filters=${this.filters}
32
+ @dile-form-changed=${this.filtersChanged}
33
+ ></dile-crud-filters-form>
34
+ `;
35
+ }
36
+
31
37
  removeFilter(filterName) {
32
38
  this.shadowRoot.getElementById('elform').resetField(filterName);
33
39
  }
@@ -15,7 +15,7 @@ export class DileCrudFiltersForm extends DileFormChangeDetect(DileForm(LitElemen
15
15
  --dile-input-label-margin-bottom: var(--dile-crud-filters-label-margin-bottom, var(--dile-input-label-margin-bottom, 4px));
16
16
  }
17
17
  p {
18
- margin: 0.4rem 0;
18
+ margin: var(--dile-crud-filters-field-margin, 0.4rem 0);
19
19
  }
20
20
  `;
21
21
 
@@ -0,0 +1,42 @@
1
+ import { DileCrudFilters } from './DileCrudFilters.js';
2
+ import { html, css } from 'lit';
3
+ import '@dile/ui/components/card/card.js';
4
+
5
+ export class DileCrudFiltersInline extends DileCrudFilters {
6
+ static get styles() {
7
+ return css`
8
+ :host {
9
+ display: block;
10
+ }
11
+ dile-card {
12
+ margin: var(--dile-crud-filters-inline-margin, 0.5rem 0) !important;
13
+ --dile-card-background-color: var(--dile-crud-filters-inline-background-color, var(--dile-gray-very-light-color, #f5f5f5));
14
+ --dile-card-text-color
15
+ --dile-card-border: var(--dile-crud-filters-inline-border, none);
16
+ }
17
+ dile-crud-filters-form {
18
+ display: grid;
19
+ align-items: center;
20
+ }
21
+ @media (min-width: 500px) {
22
+ dile-crud-filters-form {
23
+ gap: var(--dile-crud-filters-inline-gap, 1rem);
24
+ grid-template-columns: var(--dile-crud-filters-inline-columns-medium, 1fr 1fr);
25
+ }
26
+ }
27
+ @media (min-width: 1200px) {
28
+ dile-crud-filters-form {
29
+ grid-template-columns: var(--dile-crud-filters-inline-columns-large, 1fr 1fr 1fr);
30
+ }
31
+ }
32
+ `;
33
+ }
34
+
35
+ render() {
36
+ return html`
37
+ <dile-card>
38
+ ${this.formTemplate}
39
+ </dile-card>
40
+ `
41
+ }
42
+ }
@@ -10,6 +10,12 @@ export const DileCrudMixin = (superclass) => class extends superclass {
10
10
  }
11
11
 
12
12
  get actionsTemplate() {
13
+ return this.singleActionDispatcher
14
+ ? this.singleActionDispatcherTemplate
15
+ : this.standardActionsTemplate;
16
+ }
17
+
18
+ get standardActionsTemplate() {
13
19
  return html`
14
20
  <dile-crud-actions
15
21
  @crud-action-success=${this.actionSuccess}
@@ -25,6 +31,23 @@ export const DileCrudMixin = (superclass) => class extends superclass {
25
31
  `
26
32
  }
27
33
 
34
+ get singleActionDispatcherTemplate() {
35
+ return html`
36
+ <dile-crud-single-action-dispatcher
37
+ @crud-action-success=${this.actionSuccess}
38
+ class="action-controller"
39
+ id="elactions"
40
+ .actionIds=${this.actionIds}
41
+ endpoint=${this.config.endpoint}
42
+ .actions=${this.config.actions.single}
43
+ actionName="${this.singleActionDispatcher}"
44
+ .formActionsTemplate=${this.config.templates.formActions}
45
+ language="${this.language}"
46
+ .responseAdapter=${this.config.responseAdapter}
47
+ ></dile-crud-single-action-dispatcher>
48
+ `
49
+ }
50
+
28
51
  get updateTemplate() {
29
52
  return html`
30
53
  <dile-modal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dile/crud",
3
- "version": "2.3.4",
3
+ "version": "2.4.0",
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",
@@ -32,5 +32,5 @@
32
32
  "publishConfig": {
33
33
  "access": "public"
34
34
  },
35
- "gitHead": "645c317c496f3bac9df718ca6e024b9a696edb88"
35
+ "gitHead": "2ada69998b5f563e593acb5007afc1995b04b194"
36
36
  }
@@ -8,6 +8,8 @@ export const formStyles = css`
8
8
  --dile-modal-height: auto;
9
9
  --dile-modal-close-icon-top: 1rem;
10
10
  --dile-modal-close-icon-color: #f66;
11
+ --dile-modal-content-background-color: var(--dile-background-color, #fff);
12
+ --dile-modal-content-text-color: var(--dile-on-background-color, #303030);
11
13
  }
12
14
  @media(min-width: 380px) {
13
15
  :host {