@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,70 @@
1
+ import { LitElement, html, css } from 'lit';
2
+ import '../crud-filters-list-item';
3
+
4
+ export class DileCrudFiltersList extends LitElement {
5
+ static styles = [
6
+ css`
7
+ :host {
8
+ display: block;
9
+ }
10
+ div {
11
+ padding: 0.5rem;
12
+ display: flex;
13
+ flex-wrap: wrap;
14
+ }
15
+ dile-crud-filters-list-item {
16
+ margin-right: 0.5rem;
17
+ }
18
+ `
19
+ ];
20
+
21
+ static get properties() {
22
+ return {
23
+ filters: { type: Array },
24
+ keyword: { type: String },
25
+ hiddenFilters: { type: Array },
26
+ };
27
+ }
28
+
29
+ constructor() {
30
+ super();
31
+ this.filters = [];
32
+ this.hiddenFilters = [];
33
+ }
34
+
35
+ render() {
36
+ return html`
37
+ <div>
38
+ ${this.keyword
39
+ ? html`<dile-crud-filters-list-item name="keyword" label="${this.keyword}" active></dile-crud-filters-list-item>`
40
+ : ''
41
+ }
42
+ ${this.filters.map(filter => this.filterItemTemplate(filter))}
43
+ </div>
44
+ `;
45
+ }
46
+
47
+ filterItemTemplate(filter) {
48
+ if(! filter.hidden) {
49
+ switch(filter.type) {
50
+ case 'select':
51
+ return html`
52
+ <dile-crud-filters-list-item name="${filter.name}" label="${this.findLabelInOption(filter)}" ?active="${filter.active}"></dile-crud-filters-list-item>
53
+ `;
54
+ default:
55
+ return html`
56
+ <dile-crud-filters-list-item name="${filter.name}" label="${filter.label}" ?active="${filter.active}"></dile-crud-filters-list-item>
57
+ `
58
+ }
59
+ }
60
+ }
61
+
62
+ findLabelInOption(filter) {
63
+ let option = filter.options.find((option) => option.name == filter.value);
64
+ if(option) {
65
+ return option.label;
66
+ } else {
67
+ return ''
68
+ }
69
+ }
70
+ }
@@ -0,0 +1,28 @@
1
+ import { LitElement, html, css } from 'lit';
2
+ import '@dile/ui/components/chip/chip.js';
3
+
4
+ export class DileCrudFiltersListItem extends LitElement {
5
+ static styles = [
6
+ css`
7
+ :host {
8
+ display: inline-block;
9
+ }
10
+ `
11
+ ];
12
+
13
+ static get properties() {
14
+ return {
15
+ name: { type: String },
16
+ active: { type: Boolean },
17
+ label: { type: String },
18
+ };
19
+ }
20
+ render() {
21
+ return html`
22
+ ${this.active
23
+ ? html`<dile-chip name="${ this.name }">${ this.label }</dile-chip>`
24
+ : ''
25
+ }
26
+ `;
27
+ }
28
+ }
@@ -0,0 +1,64 @@
1
+ import { LitElement, html, css } from 'lit';
2
+ import '@dile/ui/components/icon/icon';
3
+ import '@dile/ui/components/button/button-icon';
4
+ import '@dile/ui/components/menu-overlay/menu-overlay';
5
+
6
+ export class DileCrudListOptions extends LitElement {
7
+ static styles = [
8
+ css`
9
+ :host {
10
+ display: block;
11
+ --dile-icon-color: #fff;
12
+ }
13
+ .content {
14
+ padding: 0.5rem;
15
+ background: var(--dile-primary-light-color);
16
+ color: #303030;
17
+ }
18
+ dile-button-icon {
19
+ display: none;
20
+ --dile-primary-color: var(--dile-crud-action-color, #888);
21
+ --dile-on-primary-color: #fff;
22
+ --dile-primary-dark-color: transparent;
23
+ }
24
+ dile-icon {
25
+ cursor: pointer;
26
+ --dile-icon-rounded-background-color: #888;
27
+ }
28
+ @media (min-width: 605px) {
29
+ dile-button-icon {
30
+ display: block;
31
+ }
32
+ dile-icon {
33
+ display: none;
34
+ }
35
+ }
36
+ `
37
+ ];
38
+
39
+ static get properties() {
40
+ return {
41
+ label: { type: String },
42
+ icon: { type: Object },
43
+ };
44
+ }
45
+
46
+ render() {
47
+ return html`
48
+ <dile-menu-overlay horizontalAlign="under_right" verticalAlign="bottom">
49
+ <div slot="trigger">
50
+ <dile-icon rounded .icon="${this.icon}"></dile-icon>
51
+ <dile-button-icon .icon="${this.icon}" gray>${this.label}</dile-button-icon>
52
+ </div>
53
+ <div class="content" slot="content">
54
+ <slot></slot>
55
+ </div>
56
+ </dile-menu-overlay>
57
+ `;
58
+ }
59
+
60
+
61
+ close() {
62
+ this.shadowRoot.querySelector('dile-menu-overlay').close();
63
+ }
64
+ }
@@ -0,0 +1,27 @@
1
+ import { LitElement, html, css } from 'lit';
2
+ import '../crud-list-options';
3
+ import '../crud-page-size-select';
4
+ import { descriptionIcon } from '@dile/icons';
5
+
6
+ export class DileCrudPageSize extends LitElement {
7
+
8
+ static get properties() {
9
+ return {
10
+ pageSizes: { type: Array },
11
+ pageSize: { type: Number },
12
+ };
13
+ }
14
+
15
+ constructor() {
16
+ super();
17
+ this.pageSizes = [25, 50, 100, 500];
18
+ }
19
+
20
+ render() {
21
+ return html`
22
+ <dile-crud-list-options .icon="${descriptionIcon}" label="Page">
23
+ <dile-crud-page-size-select pageSize="${this.pageSize}" .pageSizes=${this.pageSizes}></dile-crud-page-size-select>
24
+ </dile-crud-list-options>
25
+ `;
26
+ }
27
+ }
@@ -0,0 +1,44 @@
1
+ import { LitElement, html, css } from 'lit';
2
+ import '@dile/ui/components/select/select';
3
+
4
+ export class DileCrudPageSizeSelect extends LitElement {
5
+ static styles = [
6
+ css`
7
+ :host {
8
+ display: block;
9
+ }
10
+ dile-select {
11
+ margin-top: 0.5rem
12
+ }
13
+ `
14
+ ];
15
+
16
+ static get properties() {
17
+ return {
18
+ pageSizes: { type: Array },
19
+ pageSize: { type: Number },
20
+ };
21
+ }
22
+
23
+ render() {
24
+ return html`
25
+ <dile-select quietOnStart .value="${this.pageSize}" name="page" label="Tamaño de página" @element-changed=${this.pageChanged}>
26
+ <select slot="select">
27
+ ${this.pageSizes.map( size => html`<option value="${size}">${size}</option>`)}
28
+ </select>
29
+ </dile-select>
30
+ `;
31
+ }
32
+
33
+ pageChanged(e) {
34
+ this.dispatchEvent(new CustomEvent('page-size-changed', {
35
+ bubbles: true,
36
+ composed: true,
37
+ detail: {
38
+ pageSize: e.detail.value
39
+ }
40
+ }));
41
+ }
42
+ }
43
+
44
+
@@ -0,0 +1,44 @@
1
+ import { LitElement, html, css } from 'lit';
2
+ import { doubleArrowLeftIcon, doubleArrowRightIcon } from '@dile/icons';
3
+ import '@dile/ui/components/icon/icon';
4
+
5
+ export class DileCrudPaginationNavButton extends LitElement {
6
+ static styles = [
7
+ css`
8
+ :host {
9
+ display: block;
10
+ cursor: pointer;
11
+ }
12
+ dile-icon {
13
+ --dile-icon-color: var(--dile-on-secondary-color, #fff);
14
+ --dile-icon-rounded-background-color: var(--dile-secondary-color, #2962FF);
15
+ }
16
+ dile-icon:hover {
17
+ --dile-icon-color: var(--dile-on-secondary-dark-color, #1942DF);
18
+ --dile-icon-rounded-background-color: var(--dile-secondary-dark-color, #fff);
19
+ }
20
+ dile-icon.disabled {
21
+ --dile-icon-color: #f5f5f5;
22
+ --dile-icon-rounded-background-color: #ddd;
23
+ cursor: default;
24
+ }
25
+ `
26
+ ];
27
+
28
+ static get properties() {
29
+ return {
30
+ direction: { type: String },
31
+ disabled: { type: Boolean },
32
+ };
33
+ }
34
+
35
+ render() {
36
+ return html`
37
+ <dile-icon
38
+ rounded
39
+ class="${this.disabled ? 'disabled' : ''}"
40
+ .icon="${this.direction == 'right' ? doubleArrowRightIcon : doubleArrowLeftIcon}"
41
+ ></dile-icon>
42
+ `;
43
+ }
44
+ }
@@ -0,0 +1,105 @@
1
+ import { LitElement, html, css } from 'lit';
2
+ import '@dile/ui/components/order-switch/order-switch';
3
+ import '@dile/ui/components/radio-group/radio-group';
4
+ import '@dile/ui/components/radio-group/radio';
5
+ import { sortIcon } from '@dile/icons';
6
+ import '../crud-list-options';
7
+
8
+ export class DileCrudSortForm extends LitElement {
9
+ static styles = [
10
+ css`
11
+ :host {
12
+ display: block;
13
+ }
14
+ div {
15
+ display: flex;
16
+ align-items: center;
17
+ margin-bottom: 0.1rem;
18
+ }
19
+ .selected {
20
+ font-weight: bold;
21
+ }
22
+ dile-radio-group {
23
+ margin-top: 10px;
24
+ }
25
+ dile-radio {
26
+ margin-right: 0.2rem;
27
+ --dile-icon-color: var(--dile-primary-color);
28
+ }
29
+ dile-order-switch {
30
+ margin-bottom: 0;
31
+ --dile-icon-color: var(--dile-secondary-color);
32
+
33
+ }
34
+ `
35
+ ];
36
+
37
+ static get properties() {
38
+ return {
39
+ sortOptions: { type: Array },
40
+ sortField: { type: String },
41
+ sortDirection: { type: String },
42
+ };
43
+ }
44
+
45
+ constructor() {
46
+ super();
47
+ this.sortOptions = [];
48
+ }
49
+
50
+ render() {
51
+ return html`
52
+ <dile-crud-list-options class="action-controller" .icon="${sortIcon}" label="Order">
53
+ <dile-radio-group
54
+ name="selector"
55
+ @dile-radio-group-changed=${this.radioGroupChanged}
56
+ value="${this.sortField}"
57
+ >
58
+ ${this.sortOptions.map(option => html`
59
+ <div class="${this.sortField === option.name ? 'selected' : ''}">
60
+ <dile-radio
61
+ groupName="selector"
62
+ radioId="${option.name}"
63
+ ?checked=${this.sortField === option.name}
64
+ value="${option.name}"
65
+ ></dile-radio>
66
+ <dile-order-switch
67
+ label="${option.label}"
68
+ name="${option.name}"
69
+ value="${option.direction}"
70
+ @element-changed=${this.elementChanged}
71
+ ></dile-order-switch>
72
+ </div>
73
+ `)}
74
+ </dile-radio-group>
75
+ </dile-crud-list-options>
76
+ `;
77
+ }
78
+
79
+ elementChanged(e) {
80
+ this.sortField = e.detail.name;
81
+ this.sortDirection = e.detail.value;
82
+ this.dispatchChanged();
83
+ }
84
+
85
+ radioGroupChanged(e) {
86
+ this.sortField = e.detail.value;
87
+ this.sortDirection = this.getDirection(this.sortField);
88
+ this.dispatchChanged();
89
+ }
90
+
91
+ getDirection(field) {
92
+ if(field) {
93
+ return this.shadowRoot.querySelector(`dile-order-switch[name="${field}"]`).value;
94
+ }
95
+ }
96
+
97
+ dispatchChanged() {
98
+ this.dispatchEvent(new CustomEvent('sort-changed', {
99
+ detail: {
100
+ sortField: this.sortField,
101
+ sortDirection: this.sortDirection,
102
+ }
103
+ }));
104
+ }
105
+ }
@@ -0,0 +1,2 @@
1
+ import { DileCrudUpdate } from './src/DileCrudUpdate';
2
+ customElements.define('dile-crud-update', DileCrudUpdate);
@@ -0,0 +1 @@
1
+ export { DileCrudUpdate } from './src/DileCrudUpdate.js';
@@ -0,0 +1,81 @@
1
+ import { LitElement, html, css } from 'lit';
2
+ import '../../ajax-form/ajax-form.js'
3
+ import { formStyles } from '../../../styles/form-styles.js';
4
+ import { ResponseApiAdapter } from '../../../lib/ResponseApiAdapter.js';
5
+
6
+ export class DileCrudUpdate extends LitElement {
7
+ static styles = [
8
+ formStyles,
9
+ css`
10
+
11
+ `
12
+ ];
13
+
14
+ static get properties() {
15
+ return {
16
+ title: { type: String },
17
+ relatedId: { type: String },
18
+ endpoint: { type: String },
19
+ actionLabel: { type: String },
20
+ loadOnInit: { type: Boolean },
21
+ formTemplate: { type: Object },
22
+ buttonSmall: { type: Boolean },
23
+ responseAdapter: { type: Object },
24
+ formIdentifier: { type: String },
25
+ };
26
+ }
27
+
28
+ constructor() {
29
+ super();
30
+ this.responseAdapter = new ResponseApiAdapter();
31
+ this.actionLabel = 'Update';
32
+ this.loadOnInit = false;
33
+ this.formIdentifier = 'updateform';
34
+ }
35
+
36
+ get formElement() {
37
+ return this.shadowRoot.getElementById('elform');
38
+ }
39
+
40
+ render() {
41
+ return html`
42
+ ${this.title
43
+ ? html`<h1>${this.title}</h1>`
44
+ : ''
45
+ }
46
+ <dile-ajax-form
47
+ id="elform"
48
+ operation="update"
49
+ endpoint="${this.endpoint}"
50
+ actionLabel="${this.actionLabel}"
51
+ @save-success="${this.doSuccessSave}"
52
+ ?buttonSmall="${this.buttonSmall}"
53
+ relatedId="${this.relatedId}"
54
+ ?loadOnInit="${this.loadOnInit}"
55
+ .responseAdapter="${this.responseAdapter}"
56
+ formIdentifier="${this.formIdentifier}"
57
+ >
58
+ ${this.formTemplate()}
59
+ </dile-ajax-form>
60
+ `;
61
+ }
62
+
63
+ doSuccessSave(e) {
64
+ this.dispatchEvent(new CustomEvent('crud-update-success', {
65
+ bubbles: true,
66
+ composed: true,
67
+ detail: e.detail
68
+ }));
69
+ }
70
+
71
+ edit(id) {
72
+ this.relatedId = id;
73
+ this.updateComplete.then(() => {
74
+ this.formElement.loadData();
75
+ });
76
+ }
77
+
78
+ clearFeedback() {
79
+ this.formElement.clearFeedback();
80
+ }
81
+ }
@@ -0,0 +1,21 @@
1
+ import Axios from 'axios'
2
+
3
+ export class AxiosInstanceBuilder {
4
+ constructor(configuration) {
5
+ if(!configuration || typeof configuration != 'object') {
6
+ configuration = {}
7
+ }
8
+ const axiosConfig = {
9
+ headers: {
10
+ 'X-Requested-With': 'XMLHttpRequest',
11
+ 'Accept': 'application/json',
12
+ },
13
+ withCredentials: configuration.withCredentials || false,
14
+ withXSRFToken: configuration.withXSRFToken || false,
15
+ }
16
+ if(configuration.baseURL) {
17
+ axiosConfig.baseURL = configuration.baseURL;
18
+ }
19
+ window.axiosInstance = Axios.create(axiosConfig);
20
+ }
21
+ }
@@ -0,0 +1,13 @@
1
+ import { deepMerge } from './deepMerge.js';
2
+ import { defaultConfig } from './defaultConfig.js';
3
+
4
+ export class CrudConfigBuilder {
5
+ constructor(endpoint, customConfig) {
6
+ this.config = deepMerge(defaultConfig, customConfig);
7
+ this.config.endpoint = endpoint;
8
+ }
9
+
10
+ getConfig() {
11
+ return this.config;
12
+ }
13
+ }
@@ -0,0 +1,14 @@
1
+ import { AxiosInstanceBuilder } from './AxiosInstanceBuilder.js';
2
+
3
+ export const DileAxios = (superclass) => class extends superclass {
4
+ get axiosInstance() {
5
+ if (window.axiosInstance) {
6
+ return window.axiosInstance;
7
+ }
8
+ if (window.axios) {
9
+ return window.axios;
10
+ }
11
+ new AxiosInstanceBuilder()
12
+ return window.axiosInstance;
13
+ }
14
+ }
File without changes
@@ -0,0 +1,72 @@
1
+ import { html } from "lit";
2
+
3
+ export const DileCrudMixin = (superclass) => class extends superclass {
4
+
5
+ get updateElement() {
6
+ return this.shadowRoot.getElementById('updateElement');
7
+ }
8
+ get modalUpdate() {
9
+ return this.shadowRoot.getElementById('modalUpdate');
10
+ }
11
+
12
+ // get listElement() {
13
+ // return this.shadowRoot.querySelector('dile-crud-list');
14
+ // }
15
+ // get insertElement() {
16
+ // return this.shadowRoot.getElementById('elinsert');
17
+ // }
18
+ // get deleteElement() {
19
+ // return this.shadowRoot.getElementById('eldelete');
20
+ // }
21
+ // get actionsElement() {
22
+ // return this.shadowRoot.getElementById('elactions');
23
+ // }
24
+ // get filtersElement() {
25
+ // return this.shadowRoot.getElementById('elfilters');
26
+ // }
27
+
28
+ // itemDeleteRequest(e) {
29
+ // this.deleteElement.delete(e.detail.itemId);
30
+ // }
31
+
32
+ get actionsTemplate() {
33
+ return html`
34
+ <dile-crud-actions
35
+ @crud-action-success=${this.actionSuccess}
36
+ class="action-controller"
37
+ id="elactions"
38
+ .actionIds=${this.actionIds}
39
+ endpoint=${this.config.endpoint}
40
+ .actions=${this.config.actions.list}
41
+ .formActionsTemplate=${this.config.templates.formActions}
42
+ ></dile-crud-actions>
43
+ `
44
+ }
45
+
46
+ get updateTemplate() {
47
+ return html`
48
+ <dile-modal
49
+ id="modalUpdate"
50
+ showCloseIcon
51
+ blocking
52
+ >
53
+ <dile-crud-update
54
+ id="updateElement"
55
+ title=${this.config.labels.updateWindowTitle}
56
+ endpoint="${this.config.endpoint}"
57
+ .responseAdapter=${this.config.responseAdapter}
58
+ .formTemplate=${this.config.templates.updateForm}
59
+ actionLabel=${this.config.labels.updateAction}
60
+ formIdentifier="${this.config.formIds.updateForm}"
61
+ @crud-update-success="${this.modalUpdateSuccess}"
62
+ ></dile-crud-update>
63
+ </dile-modal>
64
+ `
65
+ }
66
+
67
+ modalUpdateSuccess() {
68
+ setTimeout(() => this.updateElement.clearFeedback(), 1000);
69
+ this.modalUpdate.close();
70
+ this.refresh();
71
+ }
72
+ }
@@ -0,0 +1,31 @@
1
+ import { html, css } from 'lit';
2
+ import '@dile/ui/components/spinner/spinner.js';
3
+
4
+ export const loadingStyles = css`
5
+ .loading {
6
+ padding: var(--dile-crud-list-loading-padding, 3rem 1rem);
7
+ text-align: center;
8
+ }
9
+ `
10
+
11
+ export const DileLoading = (superclass) => class extends superclass {
12
+
13
+ static get properties() {
14
+ return {
15
+ loading: { type: Boolean }
16
+ };
17
+ }
18
+
19
+ constructor() {
20
+ super();
21
+ this.loading = true;
22
+ }
23
+
24
+ get loadingTemplate() {
25
+ return html`
26
+ <div class="loading">
27
+ <dile-spinner active></dile-spinner>
28
+ </div>
29
+ `;
30
+ }
31
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Default Request Adapter configuration class
3
+ *
4
+ * You may extend this class and overwrite its methods to create customized request data objets
5
+ * that adapt your API intrerface
6
+ */
7
+
8
+ export class RequestApiAdapter {
9
+ adaptListRequestData(data) {
10
+ return data;
11
+ }
12
+ adaptIdsRequestData(data) {
13
+ return data;
14
+ }
15
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Default Response Adapter configuration class
3
+ *
4
+ * You may extend this class and overwrite its methods to create customized response adapters
5
+ */
6
+
7
+ export class ResponseApiAdapter {
8
+
9
+ setResponse(response) {
10
+ this.response = response;
11
+ }
12
+
13
+ getData() {
14
+ return this.response.data;
15
+ }
16
+
17
+ getMessage() {
18
+ return this.response.message;
19
+ }
20
+
21
+ getValidationErrors() {
22
+ return this.response.errors || [];
23
+ }
24
+
25
+ getElementList() {
26
+ return this.response.data;
27
+ }
28
+
29
+ getPaginationData() {
30
+ return this.response.data;
31
+ }
32
+
33
+ getIds() {
34
+ return this.response.data;
35
+ }
36
+
37
+ }
@@ -0,0 +1,3 @@
1
+ export function capitalizeFirstLetter(string) {
2
+ return string.charAt(0).toUpperCase() + string.slice(1);
3
+ }