@dile/crud 0.0.9

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.
Files changed (79) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +5 -0
  3. package/components/action/crud-actions.js +2 -0
  4. package/components/action/crud-delete-action.js +2 -0
  5. package/components/action/crud-single-actions.js +2 -0
  6. package/components/action/src/DileCrudActions.js +181 -0
  7. package/components/action/src/DileCrudDeleteAction.js +18 -0
  8. package/components/action/src/DileCrudSingleActions.js +77 -0
  9. package/components/ajax/ajax.js +2 -0
  10. package/components/ajax/index.js +1 -0
  11. package/components/ajax/src/DileAjax.js +108 -0
  12. package/components/ajax-form/ajax-form.js +2 -0
  13. package/components/ajax-form/index.js +1 -0
  14. package/components/ajax-form/src/DileAjaxForm.js +216 -0
  15. package/components/ajax-select-crud/ajax-select-crud.js +3 -0
  16. package/components/ajax-select-crud/index.js +1 -0
  17. package/components/ajax-select-crud/src/DileAjaxSelectCrud.js +75 -0
  18. package/components/crud/crud-single.js +2 -0
  19. package/components/crud/crud.js +2 -0
  20. package/components/crud/delete-action.js +2 -0
  21. package/components/crud/src/DileCrud.js +352 -0
  22. package/components/detail/crud-detail.js +2 -0
  23. package/components/detail/src/DileCrudDetail.js +166 -0
  24. package/components/insert/crud-insert.js +2 -0
  25. package/components/insert/index.js +1 -0
  26. package/components/insert/src/DileCrudInsert.js +78 -0
  27. package/components/item-delete/crud-item-delete.js +2 -0
  28. package/components/item-delete/index.js +1 -0
  29. package/components/item-delete/src/DileCrudItemDelete.js +106 -0
  30. package/components/list/crud-list-item.js +2 -0
  31. package/components/list/crud-list-pagination-links.js +2 -0
  32. package/components/list/crud-list-service.js +2 -0
  33. package/components/list/crud-list.js +2 -0
  34. package/components/list/crud-select-all.js +2 -0
  35. package/components/list/index.js +5 -0
  36. package/components/list/src/DileCrudList.js +332 -0
  37. package/components/list/src/DileCrudListItem.js +129 -0
  38. package/components/list/src/DileCrudListPaginationLinks.js +89 -0
  39. package/components/list/src/DileCrudListService.js +163 -0
  40. package/components/list/src/DileCrudSelectAll.js +158 -0
  41. package/components/single/crud-single.js +2 -0
  42. package/components/single/index.js +1 -0
  43. package/components/single/src/DileCrudSingle.js +142 -0
  44. package/components/ui/crud-filters-form.js +3 -0
  45. package/components/ui/crud-filters-list-item.js +2 -0
  46. package/components/ui/crud-filters-list.js +2 -0
  47. package/components/ui/crud-filters.js +2 -0
  48. package/components/ui/crud-list-options.js +2 -0
  49. package/components/ui/crud-page-size-select.js +2 -0
  50. package/components/ui/crud-page-size.js +2 -0
  51. package/components/ui/crud-pagination-nav-button.js +2 -0
  52. package/components/ui/crud-sort-form.js +2 -0
  53. package/components/ui/index.js +4 -0
  54. package/components/ui/src/DileCrudFilters.js +62 -0
  55. package/components/ui/src/DileCrudFiltersForm.js +58 -0
  56. package/components/ui/src/DileCrudFiltersList.js +70 -0
  57. package/components/ui/src/DileCrudFiltersListItem.js +28 -0
  58. package/components/ui/src/DileCrudListOptions.js +64 -0
  59. package/components/ui/src/DileCrudPageSize.js +27 -0
  60. package/components/ui/src/DileCrudPageSizeSelect.js +44 -0
  61. package/components/ui/src/DileCrudPaginationNavButton.js +44 -0
  62. package/components/ui/src/DileCrudSortForm.js +105 -0
  63. package/components/update/crud-update.js +2 -0
  64. package/components/update/index.js +1 -0
  65. package/components/update/src/DileCrudUpdate.js +81 -0
  66. package/lib/AxiosInstanceBuilder.js +21 -0
  67. package/lib/CrudConfigBuilder.js +13 -0
  68. package/lib/DileAxios.js +14 -0
  69. package/lib/DileConfig.js +0 -0
  70. package/lib/DileCrudMixin.js +72 -0
  71. package/lib/DileLoading.js +31 -0
  72. package/lib/RequestApiAdapter.js +15 -0
  73. package/lib/ResponseApiAdapter.js +37 -0
  74. package/lib/capitalizeString.js +3 -0
  75. package/lib/deepMerge.js +38 -0
  76. package/lib/defaultConfig.js +67 -0
  77. package/package.json +35 -0
  78. package/styles/crud-styles.js +6 -0
  79. package/styles/form-styles.js +24 -0
@@ -0,0 +1,163 @@
1
+ import { LitElement, html, css } from 'lit';
2
+
3
+ export class DileCrudListService extends LitElement {
4
+ static styles = [
5
+ css`
6
+ :host {
7
+ display: block;
8
+ }
9
+ `
10
+ ];
11
+
12
+ static get properties() {
13
+ return {
14
+ config: { type: Object },
15
+ filters: { type: Array },
16
+ pageSize: { type: Number },
17
+ keyword: { type: String },
18
+ paginationData: { type: Object },
19
+ sort: { type: Object },
20
+ belongsTo: { type: String },
21
+ relationId: { type: String },
22
+ };
23
+ }
24
+
25
+ constructor() {
26
+ super();
27
+ this.pageSize = 50;
28
+ this.keyword = '';
29
+ this.filters = [];
30
+ this.paginationData = {}
31
+ this.delayTime = 200;
32
+ this.delayTimer = null;
33
+ }
34
+
35
+ firstUpdated() {
36
+ this.ajaxget = this.shadowRoot.getElementById('ajaxget');
37
+ }
38
+
39
+ render() {
40
+ return html`
41
+ <dile-ajax
42
+ id="ajaxget"
43
+ method="get"
44
+ url="${this.cleanUrl}"
45
+ @ajax-success="${this.doSuccessGet}"
46
+ @ajax-error="${this.doErrorGet}"
47
+ ></dile-ajax>
48
+ `;
49
+ }
50
+
51
+ get cleanUrl() {
52
+ return `${this.config.endpoint}`;
53
+ }
54
+
55
+ refresh() {
56
+ if (this.delayTimer) {
57
+ clearTimeout(this.delayTimer);
58
+ }
59
+ if(!this.ajaxget) {
60
+ this.delayTimer = setTimeout(() => this.refresh(), this.delayTime);
61
+ } else {
62
+ if (this.delayTimer) {
63
+ clearTimeout(this.delayTimer);
64
+ }
65
+ this.delayTimer = setTimeout(() => this.doRefresh(), this.delayTime);
66
+ }
67
+ }
68
+
69
+ doRefresh() {
70
+ this.delayTimer = null;
71
+ let data = {
72
+ per_page: this.pageSize,
73
+ keyword: this.keyword,
74
+ filters: this.filters,
75
+ }
76
+ if (this.sort && this.sort.sortField) {
77
+ data.sortField = this.sort.sortField;
78
+ }
79
+ if (this.sort && this.sort.sortDirection) {
80
+ data.sortDirection = this.sort.sortDirection;
81
+ }
82
+ if (this.belongsTo && this.relationId) {
83
+ data.belongsTo = this.belongsTo;
84
+ data.relationId = this.relationId;
85
+ }
86
+ data = this.config.requestAdapter.adaptListRequestData(data);
87
+ this.ajaxget.data = data;
88
+ this.ajaxget.generateRequest();
89
+ }
90
+
91
+ doSuccessGet(e) {
92
+ this.config.responseAdapter.setResponse(e.detail);
93
+ let elements = this.config.responseAdapter.getElementList();
94
+ let numItems;
95
+ if (this.config.customization.disablePagination) {
96
+ numItems = elements.length;
97
+ } else {
98
+ let data = this.config.responseAdapter.getPaginationData();
99
+ this.paginationData = {
100
+ nextPage: data.result.next_page_url,
101
+ prevPage: data.result.prev_page_url,
102
+ currentPage: data.result.current_page,
103
+ }
104
+ numItems = data.countItems;
105
+ }
106
+ this.dispatchEvent(new CustomEvent('crud-list-get-success', {
107
+ detail: {
108
+ elements,
109
+ numItems,
110
+ paginationData: this.paginationData,
111
+ }
112
+ }));
113
+ }
114
+
115
+ doErrorGet(e) {
116
+ this.dispatchEvent(new CustomEvent('crud-list-data-error', {
117
+ bubbles: true,
118
+ composed: true,
119
+ detail: e.detail
120
+ }));
121
+ }
122
+
123
+ goNext() {
124
+ if (this.paginationData.nextPage) {
125
+ this.ajaxget.url = this.paginationData.nextPage;
126
+ this.ajaxget.generateRequest();
127
+ }
128
+ }
129
+
130
+ goPrev() {
131
+ if (this.paginationData.prevPage) {
132
+ this.ajaxget.url = this.paginationData.prevPage;
133
+ this.ajaxget.generateRequest();
134
+ }
135
+ }
136
+
137
+ setKeyword(keyword) {
138
+ this.keyword = keyword;
139
+ this.cleanAndRefresh();
140
+ }
141
+
142
+ setSort(sortObject) {
143
+ this.sort = sortObject;
144
+ this.cleanAndRefresh();
145
+ }
146
+
147
+ setPageSize(size) {
148
+ this.pageSize = size;
149
+ this.cleanAndRefresh();
150
+ }
151
+
152
+ setFilters(filters) {
153
+ this.filters = filters;
154
+ this.cleanAndRefresh();
155
+ }
156
+
157
+ cleanAndRefresh() {
158
+ if(this.ajaxget) {
159
+ this.ajaxget.url = this.cleanUrl;
160
+ this.refresh();
161
+ }
162
+ }
163
+ }
@@ -0,0 +1,158 @@
1
+ import { LitElement, html, css } from 'lit';
2
+ import '@dile/ui/components/button/button-icon.js';
3
+ import { checkboxBlankIcon, arrowDropDownIcon, checkboxCheckedIcon } from '@dile/icons';
4
+ import '@dile/ui/components/icon/icon.js';
5
+ import '@dile/ui/components/menu-overlay/menu-overlay.js';
6
+
7
+ export class DileCrudSelectAll extends LitElement {
8
+
9
+ static get styles() {
10
+ return css`
11
+ :host {
12
+ display: block;
13
+ --dile-icon-color: #303030;
14
+ }
15
+ .drop {
16
+ --dile-icon-size: 1.5rem;
17
+ }
18
+ dile-button-icon {
19
+ display: flex;
20
+ align-items: center;
21
+ }
22
+ dile-button-icon div {
23
+ margin-right: 0.5rem;
24
+ display: inline-block;
25
+ }
26
+ .desk {
27
+ display: none;
28
+ }
29
+ .content {
30
+ padding: 0.5rem;
31
+ font-size: 1rem;
32
+ }
33
+ .option {
34
+ display: flex;
35
+ align-items: center;
36
+ cursor: pointer;
37
+ }
38
+ .option dile-icon {
39
+ --dile-icon-size: 1.5rem;
40
+ --dile-icon-color: var(--primary-dark-color, #303030);
41
+ margin-right: 0.5rem;
42
+ }
43
+
44
+ @media(min-width: 700px) {
45
+ .desk {
46
+ display: inline;
47
+ }
48
+ }
49
+
50
+ @media(min-width: 500px) {
51
+ dile-menu-overlay {
52
+ --dile-menu-overlay-width: 420px;
53
+ }
54
+ }
55
+ `;
56
+ }
57
+
58
+ static get properties() {
59
+ return {
60
+ mainChecked: { type: Boolean },
61
+ pageChecked: { type: Boolean },
62
+ allChecked: { type: Boolean },
63
+ pageSize: { type: Number },
64
+ numItems: { type: Number },
65
+ disablePagination: { type: Boolean },
66
+ };
67
+ }
68
+
69
+ constructor() {
70
+ super();
71
+ this.checked = false;
72
+ this.disablePagination = false;
73
+ }
74
+
75
+ render() {
76
+ return html`
77
+ <dile-menu-overlay>
78
+ <dile-button-icon small .icon="${this.selectIcon(this.mainChecked)}" slot="trigger">
79
+ <div>Select <span class="desk">all</span></div>
80
+ <dile-icon .icon=${arrowDropDownIcon} class="drop"></dile-icon>
81
+ </dile-button-icon>
82
+ <div slot="content" class="content">
83
+ ${this.disablePagination
84
+ ? ''
85
+ : html`
86
+ <p class="option" @click=${this.checkPageItems}>
87
+ <dile-icon .icon=${this.selectIcon(this.pageChecked)} class="drop"></dile-icon>
88
+ <span>
89
+ Todos de esta página
90
+ (${this.pageSize > this.numItems ? this.numItems : this.pageSize})
91
+ </span>
92
+ </p>
93
+ `
94
+ }
95
+ <p class="option" @click=${this.checkAllItems}>
96
+ <dile-icon .icon=${this.selectIcon(this.allChecked)} class="drop"></dile-icon>
97
+ <span>
98
+ Seleccionar todos
99
+ (${this.numItems})
100
+ </span>
101
+ </p>
102
+ </div>
103
+ </dile-menu-overlay>
104
+ `;
105
+ }
106
+
107
+ selectIcon(checked) {
108
+ return checked ? checkboxCheckedIcon : checkboxBlankIcon;
109
+ }
110
+
111
+ checkPageItems(e) {
112
+ if(! this.pageChecked) {
113
+ this.mainChecked = true;
114
+ this.pageChecked = true;
115
+ this.allChecked = false;
116
+ } else {
117
+ this.mainChecked = false;
118
+ this.pageChecked = false;
119
+ this.allChecked = false;
120
+ }
121
+ this.dispatchCheked();
122
+ }
123
+
124
+ checkAllItems(e) {
125
+ if(! this.allChecked) {
126
+ this.mainChecked = true;
127
+ this.pageChecked = false;
128
+ this.allChecked = true;
129
+ } else {
130
+ this.mainChecked = false;
131
+ this.pageChecked = false;
132
+ this.allChecked = false;
133
+ }
134
+ this.dispatchCheked();
135
+ }
136
+
137
+ dispatchCheked() {
138
+ this.dispatchEvent(new CustomEvent('crud-select-all', {
139
+ bubbles: true,
140
+ composed: true,
141
+ detail: {
142
+ pageChecked: this.pageChecked,
143
+ allChecked: this.allChecked,
144
+ }
145
+ }));
146
+ }
147
+
148
+ reset() {
149
+ this.resetWithoutDispatch();
150
+ this.dispatchCheked();
151
+ }
152
+
153
+ resetWithoutDispatch() {
154
+ this.mainChecked = false;
155
+ this.pageChecked = false;
156
+ this.allChecked = false;
157
+ }
158
+ }
@@ -0,0 +1,2 @@
1
+ import { DileCrudSingle } from "./src/DileCrudSingle";
2
+ customElements.define('dile-crud-single', DileCrudSingle);
@@ -0,0 +1 @@
1
+ export { DileCrudSingle } from "./src/DileCrudSingle.js";
@@ -0,0 +1,142 @@
1
+ import { LitElement, html, css } from 'lit';
2
+ import { formStyles } from '../../../styles/form-styles.js';
3
+ import '@dile/ui/components/button/button.js';
4
+ import '@dile/ui/components/select/select.js';
5
+ import '@dile/ui/components/modal/modal.js';
6
+ import '@dile/ui/components/pages/pages.js';
7
+ import { editIcon } from '@dile/icons';
8
+ import { DileCrudMixin } from '../../../lib/DileCrudMixin.js';
9
+ import '../../crud/crud.js';
10
+ import '../../detail/crud-detail.js';
11
+ import '../../update/crud-update.js';
12
+ import '../../action/crud-actions.js';
13
+ import '../../action/crud-single-actions';
14
+ import '../../action/crud-delete-action.js';
15
+
16
+ export class DileCrudSingle extends DileCrudMixin(LitElement) {
17
+ static styles = [
18
+ formStyles,
19
+ css`
20
+ :host {
21
+ display: block;
22
+ }
23
+ main.elcontainer {
24
+ margin-bottom: 1.5rem;
25
+ }
26
+ .actions {
27
+ background-color: var(--dile-primary-dark-color);
28
+ padding: 0.5rem;
29
+ display: flex;
30
+ justify-content: flex-end;
31
+ align-items: center;
32
+ margin-bottom: 0.5rem;
33
+ }
34
+ .action-controller {
35
+ margin-left: 0.5rem;
36
+ }
37
+ .statscontainer {
38
+ margin: 0 1rem;
39
+ }
40
+ `
41
+ ];
42
+
43
+ static get properties() {
44
+ return {
45
+ config: { type: Object },
46
+ relatedId: { type: String },
47
+ element: { type: Object },
48
+ actionIds: { type: Array },
49
+ };
50
+ }
51
+
52
+ constructor() {
53
+ super();
54
+ this.actionIds = [];
55
+ }
56
+
57
+ firstUpdated() {
58
+ super.firstUpdated();
59
+ this.actionIds = [this.relatedId];
60
+ }
61
+
62
+ updated(changedProperties) {
63
+ if (changedProperties.has('relatedId')) {
64
+ this.actionIds = [this.relatedId];
65
+ }
66
+ }
67
+
68
+ render() {
69
+ return html`
70
+ ${this.relatedId
71
+ ? this.contentTemplate
72
+ : ''
73
+ }
74
+ `
75
+ }
76
+
77
+ get contentTemplate() {
78
+ return html`
79
+ <main class="elcontainer">
80
+ ${this.detailTemplate}
81
+ <div class="actions" @action-success=${this.actionSuccess}>
82
+ <dile-button gray .icon="${editIcon}" @click=${this.edit}>Editar</dile-button>
83
+ ${this.actionsTemplate}
84
+ </div>
85
+ </main>
86
+
87
+ ${this.updateTemplate}
88
+ ${this.singleActionsTemplate}
89
+
90
+ ${this.config.templates.relations(this.element)}
91
+ `;
92
+ }
93
+
94
+ get detailTemplate() {
95
+ return html`
96
+ <dile-crud-detail
97
+ id="eldetail"
98
+ endpoint="${this.config.endpoint}/${this.relatedId}"
99
+ .itemDetailTemplate=${this.config.templates.detail}
100
+ .responseAdapter=${this.config.responseAdapter}
101
+ @crud-item-detail-loaded=${this.elementLoaded}
102
+ ></dile-crud-detail>
103
+ `
104
+ }
105
+
106
+ get singleActionsTemplate() {
107
+ return html`
108
+ <dile-crud-single-actions
109
+ .actions=${this.config.actions.single}
110
+ .formActionsTemplate=${this.config.templates.formSingleActions}
111
+ .actionIds=${this.actionIds}
112
+ endpoint=${this.config.endpoint}
113
+ @crud-action-success=${this.actionSuccess}
114
+ ></dile-crud-single-actions>
115
+ `
116
+ }
117
+
118
+ get detailElement() {
119
+ return this.shadowRoot.getElementById('eldetail');
120
+ }
121
+
122
+ refresh() {
123
+ this.detailElement.refresh();
124
+ }
125
+
126
+ elementLoaded(e) {
127
+ this.element = e.detail.element;
128
+ }
129
+
130
+ actionSuccess(e) {
131
+ if(e.detail.action != "DeleteAction") {
132
+ this.refresh();
133
+ }
134
+ }
135
+
136
+ edit() {
137
+ this.updateElement.edit(this.relatedId);
138
+ this.modalUpdate.open();
139
+ }
140
+
141
+
142
+ }
@@ -0,0 +1,3 @@
1
+
2
+ import { DileCrudFiltersForm } from "./src/DileCrudFiltersForm";
3
+ customElements.define('dile-crud-filters-form', DileCrudFiltersForm);
@@ -0,0 +1,2 @@
1
+ import { DileCrudFiltersListItem } from "./src/DileCrudFiltersListItem";
2
+ customElements.define('dile-crud-filters-list-item', DileCrudFiltersListItem);
@@ -0,0 +1,2 @@
1
+ import { DileCrudFiltersList } from "./src/DileCrudFiltersList";
2
+ customElements.define('dile-crud-filters-list', DileCrudFiltersList);
@@ -0,0 +1,2 @@
1
+ import { DileCrudFilters } from "./src/DileCrudFilters";
2
+ customElements.define('dile-crud-filters', DileCrudFilters);
@@ -0,0 +1,2 @@
1
+ import { DileCrudListOptions } from "./src/DileCrudListOptions";
2
+ customElements.define('dile-crud-list-options', DileCrudListOptions);
@@ -0,0 +1,2 @@
1
+ import { DileCrudPageSizeSelect } from "./src/DileCrudPageSizeSelect";
2
+ customElements.define('dile-crud-page-size-select', DileCrudPageSizeSelect);
@@ -0,0 +1,2 @@
1
+ import { DileCrudPageSize } from "./src/DileCrudPageSize";
2
+ customElements.define('dile-crud-page-size', DileCrudPageSize);
@@ -0,0 +1,2 @@
1
+ import { DileCrudPaginationNavButton } from './src/DileCrudPaginationNavButton.js';
2
+ customElements.define('dile-crud-pagination-nav-button', DileCrudPaginationNavButton);
@@ -0,0 +1,2 @@
1
+ import { DileCrudSortForm } from "./src/DileCrudSortForm";
2
+ customElements.define('dile-crud-sort-form', DileCrudSortForm);
@@ -0,0 +1,4 @@
1
+ export { DileCrudFiltersForm } from "./src/DileCrudFiltersForm";
2
+ export { DileCrudFiltersList } from "./src/DileCrudFiltersList";
3
+ export { DileCrudFiltersListItem } from "./src/DileCrudFiltersListItem";
4
+ export { DileCrudPaginationNavButton } from './src/DileCrudPaginationNavButton.js';
@@ -0,0 +1,62 @@
1
+ import { LitElement, html, css } from 'lit';
2
+ import { filterIcon } from '@dile/icons';
3
+ import '../crud-filters-form.js';
4
+ import '../crud-list-options.js'
5
+
6
+ export class DileCrudFilters extends LitElement {
7
+ static get properties() {
8
+ return {
9
+ filters: { type: Array }
10
+ };
11
+ }
12
+
13
+ constructor() {
14
+ super();
15
+ this.filters = [];
16
+ }
17
+
18
+ render() {
19
+ return html`
20
+ <dile-crud-list-options .icon="${filterIcon}" label="Filtros" >
21
+ <dile-crud-filters-form
22
+ id="elform"
23
+ .filters=${this.filters}
24
+ @dile-form-changed=${this.filtersChanged}
25
+ ></dile-crud-filters-form>
26
+ </dile-crud-list-options>
27
+ `;
28
+ }
29
+
30
+ removeFilter(filterName) {
31
+ this.shadowRoot.getElementById('elform').resetField(filterName);
32
+ }
33
+
34
+ filtersChanged(e) {
35
+ let data = e.detail.data;
36
+ this.filters = this.filters.map(filter => {
37
+ if (filter.name in data) {
38
+ switch(filter.type) {
39
+ case 'select':
40
+ if(data[filter.name] === '') {
41
+ filter.active = false;
42
+ } else {
43
+ filter.active = true;
44
+ filter.value = data[filter.name];
45
+ }
46
+ break;
47
+ default:
48
+ filter.active = data[filter.name];
49
+ filter.value = data[filter.name];
50
+ }
51
+ }
52
+ return filter;
53
+ });
54
+ this.dispatchEvent(new CustomEvent('filters-changed', {
55
+ bubbles: true,
56
+ composed: true,
57
+ detail: {
58
+ filters: this.filters,
59
+ }
60
+ }));
61
+ }
62
+ }
@@ -0,0 +1,58 @@
1
+ import { LitElement, html, css } from 'lit';
2
+ import { DileFormChangeDetect, DileForm } from '@dile/ui/mixins/form';
3
+ import '@dile/ui/components/checkbox/checkbox.js';
4
+ import '@dile/ui/components/select/select.js';
5
+
6
+ export class DileCrudFiltersForm extends DileFormChangeDetect(DileForm(LitElement)) {
7
+ static styles = css`
8
+ :host {
9
+ display: block;
10
+ }
11
+ p {
12
+ margin: 0.4rem 0;
13
+
14
+ }
15
+ `;
16
+
17
+ static get properties() {
18
+ return {
19
+ filters: { type: Array }
20
+ };
21
+ }
22
+
23
+ constructor() {
24
+ super();
25
+ this.filters = [];
26
+ }
27
+
28
+ render() {
29
+ return html`
30
+ ${this.filters.map(filter => this.getFilterField(filter))}
31
+ `;
32
+ }
33
+
34
+ getFilterField(filter) {
35
+ if (filter.hidden) {
36
+ return '';
37
+ }
38
+ switch (filter.type) {
39
+ case 'select':
40
+ return html`
41
+ <dile-select label="${filter.label}" name="${filter.name}" value="">
42
+ <select slot="select">
43
+ <option value="">-</option>
44
+ ${filter.options.map(option => html`
45
+ <option value="${option.name}">${option.label}</option>
46
+ `)}
47
+ </select>
48
+ </dile-select>
49
+ `;
50
+ default:
51
+ return html`
52
+ <p>
53
+ <dile-checkbox ?checked=${filter.active} name="${filter.name}">${filter.label}</dile-checkbox>
54
+ </p>
55
+ `;
56
+ }
57
+ }
58
+ }