@dile/crud 0.0.33 → 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
  }
@@ -139,7 +139,7 @@ export class DileCrudList extends DileI18nMixin(DileLoading(LitElement)) {
139
139
  ? html`
140
140
  ${this.numItems} ${this.translations.items_total}. ${this.config.customization?.disablePagination ? '' : this.translations.showing_page_size(this.pageSize) }
141
141
  `
142
- : 'Loading...'
142
+ : this.translations.loading
143
143
  }
144
144
  </span>
145
145
  </div>
@@ -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
  }
@@ -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,10 +11,15 @@ 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?",
19
24
  items_total: "items in total",
20
25
  showing_page_size: (pageSize) => `Showing ${pageSize} items per page.`,
package/lib/i18n/es.js CHANGED
@@ -15,6 +15,11 @@ 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?",
19
24
  items_total: "Elementos en total",
20
25
  showing_page_size: (pageSize) => `Mostrando ${pageSize} elementos por página.`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dile/crud",
3
- "version": "0.0.33",
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": {
@@ -31,5 +31,5 @@
31
31
  "publishConfig": {
32
32
  "access": "public"
33
33
  },
34
- "gitHead": "15a59318f4be16facc3e442c13709fc0c543b57b"
34
+ "gitHead": "ee5c428631b5ccafdaa331966726ec5e0a699409"
35
35
  }