@dile/crud 0.0.32 → 0.0.34

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.
@@ -17,8 +17,9 @@ import { formStyles } from '../../../styles/form-styles.js';
17
17
  import { DileCrudMixin } from '../../../lib/DileCrudMixin.js';
18
18
  import { crudStyles } from '../../../styles/crud-styles.js';
19
19
  import { addIcon } from '@dile/icons';
20
+ import { DileI18nMixin } from '../../../lib/DileI18nMixin.js';
20
21
 
21
- export class DileCrud extends DileCrudMixin(LitElement) {
22
+ export class DileCrud extends DileI18nMixin(DileCrudMixin(LitElement)) {
22
23
  static styles = [
23
24
  formStyles,
24
25
  crudStyles,
@@ -149,7 +150,9 @@ export class DileCrud extends DileCrudMixin(LitElement) {
149
150
  get insertButtomTemplate() {
150
151
  return html`
151
152
  <div class="insertButtonContainer">
152
- <dile-button-icon @click="${this.openInsert}" .icon="${addIcon}">${this.config.labels.insertAction}</dile-button-icon>
153
+ <dile-button-icon @click="${this.openInsert}" .icon="${addIcon}">
154
+ ${this.insertLabelComputed(this.config.labels.insertAction, this.translations)}
155
+ </dile-button-icon>
153
156
  </div>
154
157
  `
155
158
  }
@@ -162,11 +165,11 @@ export class DileCrud extends DileCrudMixin(LitElement) {
162
165
  blocking
163
166
  >
164
167
  <dile-crud-insert
165
- title=${this.config.labels.insertWindowTitle}
168
+ title=${this.insertLabelComputed(this.config.labels.insertWindowTitle, this.translations)}
166
169
  endpoint="${this.config.endpoint}"
167
170
  .responseAdapter=${this.config.responseAdapter}
168
171
  .formTemplate=${this.config.templates.insertForm}
169
- actionLabel=${this.config.labels.insertAction}
172
+ actionLabel=${this.insertLabelComputed(this.config.labels.insertAction, this.translations)}
170
173
  formIdentifier="${this.config.formIds.insertForm}"
171
174
  @crud-insert-success="${this.modalInsertSuccess}"
172
175
  belongsTo=${this.belongsTo}
@@ -186,14 +189,15 @@ export class DileCrud extends DileCrudMixin(LitElement) {
186
189
  .actionIds=${this.actionIds}
187
190
  belongsTo=${this.belongsTo}
188
191
  relationId=${this.relationId}
192
+ language="${this.language}"
189
193
  ></dile-crud-list>
190
194
  `
191
195
  }
192
196
  get helpTemplate() {
193
197
  return html`
194
198
  <dile-modal-help
195
- title="${this.config.labels.helpTitle}"
196
- label="${this.config.labels.helpButtonLabel}"
199
+ title="${this.helpLabelComputed(this.config.labels.helpTitle, this.translations)}"
200
+ label="${this.helpLabelComputed(this.config.labels.helpButtonLabel, this.translations)}"
197
201
  >${this.config.templates.help()}</dile-modal-help>`
198
202
  }
199
203
 
@@ -217,6 +221,7 @@ export class DileCrud extends DileCrudMixin(LitElement) {
217
221
  id="elfilters"
218
222
  @filters-changed=${this.filtersChanged}
219
223
  .filters=${this.config.availableFilters || []}
224
+ language="${this.language}"
220
225
  ></dile-crud-filters>
221
226
  `
222
227
  }
@@ -228,6 +233,7 @@ export class DileCrud extends DileCrudMixin(LitElement) {
228
233
  @page-size-changed=${this.pageSizeChanged}
229
234
  .pageSizes=${this.config.pageSize.available || [10, 25, 50]}
230
235
  pageSize="${this.config.pageSize.initial}"
236
+ language="${this.language}"
231
237
  ></dile-crud-page-size>
232
238
  `
233
239
  }
@@ -240,6 +246,7 @@ export class DileCrud extends DileCrudMixin(LitElement) {
240
246
  sortField="${this.config.sort.initialSortField}"
241
247
  sortDirection="${this.config.sort.initialSortDirection || 'desc'}"
242
248
  @sort-changed=${this.sortFormChanged}
249
+ language="${this.language}"
243
250
  ></dile-crud-sort-form>
244
251
  `
245
252
  }
@@ -153,6 +153,7 @@ export class DileCrudDetail extends DileLoading(LitElement) {
153
153
  }
154
154
 
155
155
  doErrorGet(e) {
156
+ this.loading = false;
156
157
  this.dispatchEvent(new CustomEvent('crud-item-detail-load-error', {
157
158
  bubbles: true,
158
159
  composed: true,
@@ -83,7 +83,15 @@ export class DileCrudItemDelete extends DileI18nMixin(LitElement) {
83
83
  }
84
84
 
85
85
  doSuccessDelete(e) {
86
- this.dispatchEvent(new CustomEvent('delete-success', { bubbles: true, composed: true }));
86
+ let msg = this.computeResponseMessage(e.detail);
87
+ this.dispatchEvent(new CustomEvent('delete-success', {
88
+ bubbles: true,
89
+ composed: true,
90
+ detail: {
91
+ msg,
92
+ previousDetail: e.detail,
93
+ }
94
+ }));
87
95
  }
88
96
 
89
97
  doErrorDelete(e) {
@@ -1,5 +1,4 @@
1
1
  import { LitElement, html, css } from 'lit';
2
- import { deepMerge } from '../../../lib/deepMerge.js';
3
2
  import { DileLoading, loadingStyles } from '../../../lib/DileLoading.js';
4
3
  import '@dile/ui/components/button/button.js';
5
4
  import '../../ajax/ajax.js'
@@ -8,8 +7,9 @@ import '../../list/crud-list-pagination-links.js';
8
7
  import '../crud-list-item.js';
9
8
  import '../crud-select-all';
10
9
  import '../crud-list-service.js';
10
+ import { DileI18nMixin } from '../../../lib/DileI18nMixin.js';
11
11
 
12
- export class DileCrudList extends DileLoading(LitElement) {
12
+ export class DileCrudList extends DileI18nMixin(DileLoading(LitElement)) {
13
13
  static styles = [
14
14
  loadingStyles,
15
15
  css`
@@ -130,15 +130,16 @@ export class DileCrudList extends DileLoading(LitElement) {
130
130
  pageSize=${this.pageSize}
131
131
  numItems=${this.numItems}
132
132
  ?disablePagination=${this.config.customization?.disablePagination}
133
+ language="${this.language}"
133
134
  ></dile-crud-select-all>
134
135
  `
135
136
  }
136
137
  <span>
137
138
  ${this.numItems != undefined
138
139
  ? html`
139
- ${this.numItems} items in total. ${this.config.customization?.disablePagination ? '' : html`Showing ${this.pageSize} items per page.` }
140
+ ${this.numItems} ${this.translations.items_total}. ${this.config.customization?.disablePagination ? '' : this.translations.showing_page_size(this.pageSize) }
140
141
  `
141
- : 'Loading...'
142
+ : this.translations.loading
142
143
  }
143
144
  </span>
144
145
  </div>
@@ -157,6 +158,7 @@ export class DileCrudList extends DileLoading(LitElement) {
157
158
  belongsTo=${this.belongsTo}
158
159
  relationId=${this.relationId}
159
160
  @crud-list-get-success=${this.getSuccess}
161
+ language="${this.language}"
160
162
  ></dile-crud-list-service>
161
163
  <dile-ajax
162
164
  id="ajaxgetallids"
@@ -164,18 +166,24 @@ export class DileCrudList extends DileLoading(LitElement) {
164
166
  url="${this.allIdsUrl}"
165
167
  @ajax-success="${this.doSuccessGetIds}"
166
168
  @ajax-error="${this.doErrorGet}"
169
+ language="${this.language}"
167
170
  ></dile-ajax>
168
171
  `;
169
172
  }
170
173
  get emptyTemplate() {
171
174
  return html`
172
175
  <div class="empty">
173
- <p>There are no items yet</p>
176
+ <p>${this.translations.empty_list}</p>
174
177
  ${this.config.customization.disableInsert || this.config.customization?.hideEmptyInsertButton
175
178
  ? ''
176
- : html`<p><dile-button @click=${this.dispatchInsertRequest}>${this.config.labels.insertAction}</dile-button></p>`
179
+ : html`
180
+ <p>
181
+ <dile-button @click=${this.dispatchInsertRequest}>
182
+ ${this.config.labels.insertAction}
183
+ </dile-button>
184
+ </p>
185
+ `
177
186
  }
178
-
179
187
  </div>
180
188
  `;
181
189
  }
@@ -220,6 +228,7 @@ export class DileCrudList extends DileLoading(LitElement) {
220
228
  pageSize="${this.pageSize}"
221
229
  @crud-pagination-prev=${this.goPrev}
222
230
  @crud-pagination-next=${this.goNext}
231
+ language="${this.language}"
223
232
  ></dile-crud-list-pagination-links>
224
233
  `
225
234
  }
@@ -1,7 +1,8 @@
1
1
  import { LitElement, html, css } from 'lit';
2
2
  import '../../ui/crud-pagination-nav-button';
3
+ import { DileI18nMixin } from '../../../lib/DileI18nMixin.js';
3
4
 
4
- export class DileCrudListPaginationLinks extends LitElement {
5
+ export class DileCrudListPaginationLinks extends DileI18nMixin(LitElement) {
5
6
  static styles = [
6
7
  css`
7
8
  :host {
@@ -52,7 +53,7 @@ export class DileCrudListPaginationLinks extends LitElement {
52
53
  ></dile-crud-pagination-nav-button>
53
54
  </span>
54
55
  <span class="pagination-summary">
55
- Página ${this.paginationData.currentPage} de ${this.numPages(this.numItems, this.pageSize)}
56
+ ${this.translations.current_page(this.paginationData.currentPage, this.numPages(this.numItems, this.pageSize))}
56
57
  </span>
57
58
  <span class="pagination-next">
58
59
  <dile-crud-pagination-nav-button
@@ -66,7 +67,7 @@ export class DileCrudListPaginationLinks extends LitElement {
66
67
  } else {
67
68
  return html`
68
69
  <div class="pagination-summary-one-page">
69
- Page 1 of 1
70
+ ${this.translations.one_page}
70
71
  </div>
71
72
  `;
72
73
  }
@@ -1,6 +1,7 @@
1
1
  import { LitElement, html, css } from 'lit';
2
+ import { DileI18nMixin } from '../../../lib/DileI18nMixin.js';
2
3
 
3
- export class DileCrudListService extends LitElement {
4
+ export class DileCrudListService extends DileI18nMixin(LitElement) {
4
5
  static styles = [
5
6
  css`
6
7
  :host {
@@ -44,6 +45,7 @@ export class DileCrudListService extends LitElement {
44
45
  url="${this.cleanUrl}"
45
46
  @ajax-success="${this.doSuccessGet}"
46
47
  @ajax-error="${this.doErrorGet}"
48
+ language="${this.language}"
47
49
  ></dile-ajax>
48
50
  `;
49
51
  }
@@ -3,8 +3,9 @@ import '@dile/ui/components/button/button-icon.js';
3
3
  import { checkboxBlankIcon, arrowDropDownIcon, checkboxCheckedIcon } from '@dile/icons';
4
4
  import '@dile/ui/components/icon/icon.js';
5
5
  import '@dile/ui/components/menu-overlay/menu-overlay.js';
6
+ import { DileI18nMixin } from '../../../lib/DileI18nMixin.js';
6
7
 
7
- export class DileCrudSelectAll extends LitElement {
8
+ export class DileCrudSelectAll extends DileI18nMixin(LitElement) {
8
9
 
9
10
  static get styles() {
10
11
  return css`
@@ -19,6 +20,13 @@ export class DileCrudSelectAll extends LitElement {
19
20
  display: flex;
20
21
  align-items: center;
21
22
  }
23
+
24
+ dile-button-icon div {
25
+ max-width: 130px;
26
+ white-space: nowrap;
27
+ text-overflow: ellipsis;
28
+ overflow: hidden;
29
+ }
22
30
  dile-button-icon div {
23
31
  margin-right: 0.5rem;
24
32
  display: inline-block;
@@ -75,8 +83,8 @@ export class DileCrudSelectAll extends LitElement {
75
83
  render() {
76
84
  return html`
77
85
  <dile-menu-overlay>
78
- <dile-button-icon small .icon="${this.selectIcon(this.mainChecked)}" slot="trigger">
79
- <div>Select <span class="desk">all</span></div>
86
+ <dile-button-icon no-wrap small .icon="${this.selectIcon(this.mainChecked)}" slot="trigger">
87
+ <div>${this.translations.select} <span class="desk">${this.translations.all}</span></div>
80
88
  <dile-icon .icon=${arrowDropDownIcon} class="drop"></dile-icon>
81
89
  </dile-button-icon>
82
90
  <div slot="content" class="content">
@@ -86,7 +94,7 @@ export class DileCrudSelectAll extends LitElement {
86
94
  <p class="option" @click=${this.checkPageItems}>
87
95
  <dile-icon .icon=${this.selectIcon(this.pageChecked)} class="drop"></dile-icon>
88
96
  <span>
89
- Todos de esta página
97
+ ${this.translations.all_in_page}
90
98
  (${this.pageSize > this.numItems ? this.numItems : this.pageSize})
91
99
  </span>
92
100
  </p>
@@ -95,7 +103,7 @@ export class DileCrudSelectAll extends LitElement {
95
103
  <p class="option" @click=${this.checkAllItems}>
96
104
  <dile-icon .icon=${this.selectIcon(this.allChecked)} class="drop"></dile-icon>
97
105
  <span>
98
- Seleccionar todos
106
+ ${this.translations.select_matching}
99
107
  (${this.numItems})
100
108
  </span>
101
109
  </p>
@@ -2,8 +2,9 @@ import { LitElement, html, css } from 'lit';
2
2
  import { filterIcon } from '@dile/icons';
3
3
  import '../crud-filters-form.js';
4
4
  import '../crud-list-options.js'
5
+ import { DileI18nMixin } from '../../../lib/DileI18nMixin.js';
5
6
 
6
- export class DileCrudFilters extends LitElement {
7
+ export class DileCrudFilters extends DileI18nMixin(LitElement) {
7
8
  static get properties() {
8
9
  return {
9
10
  filters: { type: Array }
@@ -17,7 +18,7 @@ export class DileCrudFilters extends LitElement {
17
18
 
18
19
  render() {
19
20
  return html`
20
- <dile-crud-list-options .icon="${filterIcon}" label="Filtros" >
21
+ <dile-crud-list-options .icon="${filterIcon}" label="${this.translations.filters_label}" >
21
22
  <dile-crud-filters-form
22
23
  id="elform"
23
24
  .filters=${this.filters}
@@ -2,8 +2,9 @@ import { LitElement, html, css } from 'lit';
2
2
  import '../crud-list-options';
3
3
  import '../crud-page-size-select';
4
4
  import { descriptionIcon } from '@dile/icons';
5
+ import { DileI18nMixin } from '../../../lib/DileI18nMixin.js';
5
6
 
6
- export class DileCrudPageSize extends LitElement {
7
+ export class DileCrudPageSize extends DileI18nMixin(LitElement) {
7
8
 
8
9
  static get properties() {
9
10
  return {
@@ -19,7 +20,7 @@ export class DileCrudPageSize extends LitElement {
19
20
 
20
21
  render() {
21
22
  return html`
22
- <dile-crud-list-options .icon="${descriptionIcon}" label="Page">
23
+ <dile-crud-list-options .icon="${descriptionIcon}" label="${this.translations.page_label}">
23
24
  <dile-crud-page-size-select pageSize="${this.pageSize}" .pageSizes=${this.pageSizes}></dile-crud-page-size-select>
24
25
  </dile-crud-list-options>
25
26
  `;
@@ -4,8 +4,9 @@ import '@dile/ui/components/radio-group/radio-group';
4
4
  import '@dile/ui/components/radio-group/radio';
5
5
  import { sortIcon } from '@dile/icons';
6
6
  import '../crud-list-options';
7
+ import { DileI18nMixin } from '../../../lib/DileI18nMixin.js';
7
8
 
8
- export class DileCrudSortForm extends LitElement {
9
+ export class DileCrudSortForm extends DileI18nMixin(LitElement) {
9
10
  static styles = [
10
11
  css`
11
12
  :host {
@@ -49,7 +50,7 @@ export class DileCrudSortForm extends LitElement {
49
50
 
50
51
  render() {
51
52
  return html`
52
- <dile-crud-list-options class="action-controller" .icon="${sortIcon}" label="Order">
53
+ <dile-crud-list-options class="action-controller" .icon="${sortIcon}" label="${this.translations.sort_label}">
53
54
  <dile-radio-group
54
55
  name="selector"
55
56
  @dile-radio-group-changed=${this.radioGroupChanged}
@@ -9,26 +9,6 @@ export const DileCrudMixin = (superclass) => class extends superclass {
9
9
  return this.shadowRoot.getElementById('modalUpdate');
10
10
  }
11
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
12
  get actionsTemplate() {
33
13
  return html`
34
14
  <dile-crud-actions
@@ -52,11 +32,11 @@ export const DileCrudMixin = (superclass) => class extends superclass {
52
32
  >
53
33
  <dile-crud-update
54
34
  id="updateElement"
55
- title=${this.config.labels.updateWindowTitle}
35
+ title="${this.updateLabelComputed(this.config.labels.updateWindowTitle, this.translations)}"
56
36
  endpoint="${this.config.endpoint}"
57
37
  .responseAdapter=${this.config.responseAdapter}
58
38
  .formTemplate=${this.config.templates.updateForm}
59
- actionLabel=${this.config.labels.updateAction}
39
+ actionLabel="${this.updateLabelComputed(this.config.labels.updateAction, this.translations)}"
60
40
  formIdentifier="${this.config.formIds.updateForm}"
61
41
  @crud-update-success="${this.modalUpdateSuccess}"
62
42
  ></dile-crud-update>
@@ -69,4 +49,15 @@ export const DileCrudMixin = (superclass) => class extends superclass {
69
49
  this.modalUpdate.close();
70
50
  this.refresh();
71
51
  }
52
+
53
+ insertLabelComputed(label, translations) {
54
+ return label ? label : translations?.insert_label ? translations.insert_label : 'Insert';
55
+ }
56
+ updateLabelComputed(label, translations) {
57
+ return label ? label : translations?.update_label ? translations.update_label : 'Save';
58
+ }
59
+ helpLabelComputed(label, translations) {
60
+ return label ? label : translations?.help_label ? translations.help_label : 'Help';
61
+ }
62
+
72
63
  }
@@ -11,6 +11,12 @@ export const DileI18nMixin = (superclass) => class extends superclass {
11
11
  constructor() {
12
12
  super();
13
13
  this.language = 'en';
14
+ this.translations = {
15
+ success_operation: () => '',
16
+ error_operation: () => '',
17
+ showing_page_size: () => '',
18
+ current_page: () => '',
19
+ };
14
20
  }
15
21
 
16
22
  async connectedCallback() {
@@ -67,12 +67,12 @@ export const defaultConfig = {
67
67
  formSingleActions: () => '',
68
68
  },
69
69
  labels: {
70
- insertAction: 'Create',
71
- updateAction: 'Save',
72
- insertWindowTitle: 'Insert an item',
73
- updateWindowTitle: 'Update an item',
74
- helpTitle: 'Help',
75
- helpButtonLabel: 'Help',
70
+ // insertAction: 'Create',
71
+ // updateAction: 'Save',
72
+ // insertWindowTitle: 'Create an item',
73
+ // updateWindowTitle: 'Update an item',
74
+ // helpTitle: 'Help',
75
+ // helpButtonLabel: 'Help',
76
76
  },
77
77
  formIds: {
78
78
  insertForm: 'insertform',
package/lib/i18n/en.js CHANGED
@@ -11,9 +11,23 @@ export const translations = {
11
11
  ajax_form_not_supported: "Operation not supported in dile-ajax-form use 'insert' or 'update'",
12
12
  success_operation: (operation) => operation == 'insert' ? 'The new item has been created' : 'Item updated successfully',
13
13
  error_operation: (operation) => `${operation == 'insert' ? 'Insertion' : 'Update'} error`,
14
- insert_label: "Insert",
14
+ insert_label: "Create",
15
15
  update_label: "Update",
16
16
  delete_label: "Delete",
17
17
  cancel_label: "Cancel",
18
+ help_label: "Help",
19
+ filters_label: "Filters",
20
+ sort_label: "Sort",
21
+ page_label: "Page",
22
+ loading: "Loading...",
18
23
  delete_confirm_message: "Are you sure you want to delete this item?",
24
+ items_total: "items in total",
25
+ showing_page_size: (pageSize) => `Showing ${pageSize} items per page.`,
26
+ empty_list: "There are no items yet",
27
+ one_page: "Page 1 of 1",
28
+ current_page: (page, numPages) => `Page ${page} of ${numPages}`,
29
+ select: "Select",
30
+ all: "all",
31
+ all_in_page: "All in this page",
32
+ select_matching: "Select all matching",
19
33
  };
package/lib/i18n/es.js CHANGED
@@ -15,5 +15,20 @@ export const translations = {
15
15
  update_label: "Actualizar",
16
16
  delete_label: "Borrar",
17
17
  cancel_label: "Cancelar",
18
+ help_label: "Ayuda",
19
+ filters_label: "Filtros",
20
+ sort_label: "Orden",
21
+ page_label: "Página",
22
+ loading: "Cargando...",
18
23
  delete_confirm_message: "¿Estás seguro que quieres borrar este ítem?",
24
+ items_total: "Elementos en total",
25
+ showing_page_size: (pageSize) => `Mostrando ${pageSize} elementos por página.`,
26
+ empty_list: "No tenemos elementos todavía",
27
+ one_page: "Página 1 de 1",
28
+ current_page: (page, numPages) => `Página ${page} de ${numPages}`,
29
+ select: "Seleccionar",
30
+ all: "todos",
31
+ all_in_page: "Todos de esta página",
32
+ select_matching: "Seleccionar coincidentes",
33
+
19
34
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dile/crud",
3
- "version": "0.0.32",
3
+ "version": "0.0.34",
4
4
  "description": "Components to create a generic crud system based on Web Components and Lit",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -24,12 +24,12 @@
24
24
  },
25
25
  "homepage": "https://dile-components.polydile.com/",
26
26
  "dependencies": {
27
- "@dile/ui": "^2.1.16",
27
+ "@dile/ui": "^2.1.17",
28
28
  "axios": "^1.7.2",
29
29
  "lit": "^2.7.0 || ^3.0.0"
30
30
  },
31
31
  "publishConfig": {
32
32
  "access": "public"
33
33
  },
34
- "gitHead": "817f5102c42848615896580e968fc42d8ee21d66"
34
+ "gitHead": "ee5c428631b5ccafdaa331966726ec5e0a699409"
35
35
  }