@dile/crud 0.0.34 → 0.0.35

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.
@@ -4,8 +4,9 @@ import '@dile/ui/components/confirm/confirm';
4
4
  import '@dile/ui/components/select/select';
5
5
  import '../../ajax/ajax.js'
6
6
  import '../../ui/crud-list-options.js';
7
+ import { DileI18nMixin } from '../../../lib/DileI18nMixin.js';
7
8
 
8
- export class DileCrudActions extends LitElement {
9
+ export class DileCrudActions extends DileI18nMixin(LitElement) {
9
10
  static styles = css`
10
11
  :host {
11
12
  display: block;
@@ -20,6 +21,13 @@ export class DileCrudActions extends LitElement {
20
21
  --dile-confirm-cancel-button-color: var(--dile-danger-color, #E31E1B);
21
22
  --dile-confirm-cancel-text-button-color: var(--dile-on-danger-color, #fff);
22
23
  }
24
+ :host([destructive]) {
25
+ --dile-confirm-cancel-button-color: var(--dile-primary-color, #378dca);
26
+ --dile-confirm-cancel-text-button-color: var(--dile-on-primary-color, #fff);
27
+ --dile-confirm-accept-button-color: var(--dile-danger-color, #E31E1B);
28
+ --dile-confirm-accept-text-button-color: var(--dile-on-danger-color, #fff);
29
+
30
+ }
23
31
  p {
24
32
  margin: 0 0 0.75rem 0;
25
33
  }
@@ -53,6 +61,7 @@ export class DileCrudActions extends LitElement {
53
61
  endpoint: { type: String },
54
62
  actions: { type: Array },
55
63
  formActionsTemplate: { type: Object },
64
+ destructive: { type: Boolean, reflect: true, }
56
65
  };
57
66
  }
58
67
 
@@ -90,12 +99,12 @@ export class DileCrudActions extends LitElement {
90
99
 
91
100
  get actionListTemplate() {
92
101
  return html`
93
- <dile-crud-list-options .icon="${moreVertIcon}" label="Acciones" class="${this.actionIds.length > 0 ? 'visible' : 'hide'}">
94
- <p>${this.actionIds.length} ${this.actionIds.length == 1 ? 'elemento' : 'elementos'}</p>
102
+ <dile-crud-list-options .icon="${moreVertIcon}" label="${this.translations.actions_label}" class="${this.actionIds.length > 0 ? 'visible' : 'hide'}">
103
+ <p>${this.actionIds.length} ${this.actionIds.length == 1 ? this.translations.element_label : this.translations.element_plural_label}</p>
95
104
  <div @element-changed=${this.selectorChanged}>
96
105
  ${this.selectActionsTemplate}
97
106
  </div>
98
- <dile-button @click=${this.showAction}>Realizar acción</dile-button>
107
+ <dile-button @click=${this.showAction}>${this.translations.run_action_label}</dile-button>
99
108
  </dile-crud-list-options>
100
109
  `;
101
110
  }
@@ -114,8 +123,8 @@ export class DileCrudActions extends LitElement {
114
123
  return html`
115
124
  <dile-confirm
116
125
  id="elconfirm"
117
- cancelLabel="Cancelar"
118
- acceptLabel="Aceptar"
126
+ cancelLabel="${this.translations.cancel_label}"
127
+ acceptLabel="${this.translations.accept_label}"
119
128
  @dile-confirm-accepted=${this.doAction}
120
129
  >
121
130
  <div class="modalcontainer">
@@ -131,6 +140,16 @@ export class DileCrudActions extends LitElement {
131
140
 
132
141
  selectorChanged(e) {
133
142
  this.selection = e.target.value;
143
+ if(this.isDestructive()) {
144
+ this.destructive = true;
145
+ } else {
146
+ this.destructive = false;
147
+ }
148
+ }
149
+
150
+ isDestructive() {
151
+ const currentAction = this.actions.find(action => action.name == this.selection);
152
+ return currentAction && currentAction.destructive;
134
153
  }
135
154
 
136
155
  showAction() {
@@ -1,7 +1,8 @@
1
1
  import { LitElement, html, css } from 'lit';
2
2
  import { DileForm } from '@dile/ui/mixins/form';
3
+ import { DileI18nMixin } from '../../../lib/DileI18nMixin.js';
3
4
 
4
- export class DileCrudDeleteAction extends DileForm(LitElement) {
5
+ export class DileCrudDeleteAction extends DileI18nMixin(DileForm(LitElement)) {
5
6
  static styles = [
6
7
  css`
7
8
  :host {
@@ -12,7 +13,7 @@ export class DileCrudDeleteAction extends DileForm(LitElement) {
12
13
 
13
14
  render() {
14
15
  return html`
15
- <p>Are you sure you want to delete those items?</p>
16
+ <p>${this.translations.delete_confirm_message_plural}</p>
16
17
  `;
17
18
  }
18
19
  }
@@ -3,6 +3,7 @@ import { DileCrudActions } from './DileCrudActions.js';
3
3
  import '@dile/ui/components/box-selector/box-selector.js';
4
4
  import '@dile/ui/components/box-selector/box-selector-item.js';
5
5
  import '@dile/ui/components/card/card.js';
6
+ import { DileI18nMixin } from '../../../lib/DileI18nMixin.js';
6
7
 
7
8
  export class DileCrudSingleActions extends DileCrudActions {
8
9
  static styles = [
@@ -48,7 +49,7 @@ export class DileCrudSingleActions extends DileCrudActions {
48
49
  return html`
49
50
  ${this.actions.length > 0
50
51
  ? html`
51
- <dile-card title="Element action">
52
+ <dile-card title="${this.translations.element_actions}">
52
53
  <dile-box-selector
53
54
  class="action-list"
54
55
  attrForSelected="name"
@@ -12,8 +12,9 @@ import '../../update/crud-update.js';
12
12
  import '../../action/crud-actions.js';
13
13
  import '../../action/crud-single-actions';
14
14
  import '../../action/crud-delete-action.js';
15
+ import { DileI18nMixin } from '../../../lib/DileI18nMixin.js';
15
16
 
16
- export class DileCrudSingle extends DileCrudMixin(LitElement) {
17
+ export class DileCrudSingle extends DileI18nMixin(DileCrudMixin(LitElement)) {
17
18
  static styles = [
18
19
  formStyles,
19
20
  css`
@@ -79,7 +80,7 @@ export class DileCrudSingle extends DileCrudMixin(LitElement) {
79
80
  <main class="elcontainer">
80
81
  ${this.detailTemplate}
81
82
  <div class="actions" @action-success=${this.actionSuccess}>
82
- <dile-button gray .icon="${editIcon}" @click=${this.edit}>Editar</dile-button>
83
+ <dile-button gray .icon="${editIcon}" @click=${this.edit}>${this.updateLabelComputed(this.config.labels.updateAction, this.translations)}</dile-button>
83
84
  ${this.actionsTemplate}
84
85
  </div>
85
86
  </main>
@@ -111,6 +112,7 @@ export class DileCrudSingle extends DileCrudMixin(LitElement) {
111
112
  .actionIds=${this.actionIds}
112
113
  endpoint=${this.config.endpoint}
113
114
  @crud-action-success=${this.actionSuccess}
115
+ language="${this.language}"
114
116
  ></dile-crud-single-actions>
115
117
  `
116
118
  }
@@ -19,6 +19,7 @@ export const DileCrudMixin = (superclass) => class extends superclass {
19
19
  endpoint=${this.config.endpoint}
20
20
  .actions=${this.config.actions.list}
21
21
  .formActionsTemplate=${this.config.templates.formActions}
22
+ language="${this.language}"
22
23
  ></dile-crud-actions>
23
24
  `
24
25
  }
@@ -47,7 +47,8 @@ export const defaultConfig = {
47
47
  list: [
48
48
  {
49
49
  label: 'Delete',
50
- name: 'DeleteAction'
50
+ name: 'DeleteAction',
51
+ destructive: true,
51
52
  }
52
53
  ],
53
54
  single: [],
@@ -60,7 +61,7 @@ export const defaultConfig = {
60
61
  detail: () => templatePlaceholder('detail'),
61
62
  formActions: (actionName) => html`
62
63
  <dile-pages attrForSelected="action" selected="${actionName}">
63
- <dile-crud-delete-action action="DeleteAction"></dile-crud-delete-action>
64
+ <dile-crud-delete-action action="DeleteAction"></dile-crud-delete-action>
64
65
  </dile-pages>
65
66
  `,
66
67
  relations: () => '',
package/lib/i18n/en.js CHANGED
@@ -15,12 +15,18 @@ export const translations = {
15
15
  update_label: "Update",
16
16
  delete_label: "Delete",
17
17
  cancel_label: "Cancel",
18
+ accept_label: "Accept",
18
19
  help_label: "Help",
19
20
  filters_label: "Filters",
20
21
  sort_label: "Sort",
21
22
  page_label: "Page",
23
+ actions_label: "Actions",
24
+ element_label: "Element",
25
+ element_plural_label: "Elements",
26
+ run_action_label: "Run action",
22
27
  loading: "Loading...",
23
28
  delete_confirm_message: "Are you sure you want to delete this item?",
29
+ delete_confirm_message_plural: "Are you sure you want to delete those items?",
24
30
  items_total: "items in total",
25
31
  showing_page_size: (pageSize) => `Showing ${pageSize} items per page.`,
26
32
  empty_list: "There are no items yet",
@@ -30,4 +36,6 @@ export const translations = {
30
36
  all: "all",
31
37
  all_in_page: "All in this page",
32
38
  select_matching: "Select all matching",
39
+ element_actions: "Element actions",
40
+
33
41
  };
package/lib/i18n/es.js CHANGED
@@ -15,12 +15,18 @@ export const translations = {
15
15
  update_label: "Actualizar",
16
16
  delete_label: "Borrar",
17
17
  cancel_label: "Cancelar",
18
+ accept_label: "Aceptar",
18
19
  help_label: "Ayuda",
19
20
  filters_label: "Filtros",
20
21
  sort_label: "Orden",
21
22
  page_label: "Página",
23
+ actions_label: "Acciones",
24
+ element_label: "Elemento",
25
+ element_plural_label: "Elementos",
26
+ run_action_label: "Realizar acción",
22
27
  loading: "Cargando...",
23
28
  delete_confirm_message: "¿Estás seguro que quieres borrar este ítem?",
29
+ delete_confirm_message_plural: "¿Seguro que quieres borrar estos elementos?",
24
30
  items_total: "Elementos en total",
25
31
  showing_page_size: (pageSize) => `Mostrando ${pageSize} elementos por página.`,
26
32
  empty_list: "No tenemos elementos todavía",
@@ -30,5 +36,5 @@ export const translations = {
30
36
  all: "todos",
31
37
  all_in_page: "Todos de esta página",
32
38
  select_matching: "Seleccionar coincidentes",
33
-
39
+ element_actions: "Acciones en este ítem",
34
40
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dile/crud",
3
- "version": "0.0.34",
3
+ "version": "0.0.35",
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": "ee5c428631b5ccafdaa331966726ec5e0a699409"
34
+ "gitHead": "51111b38c0b87c4e0e0db9e180c7ddb7d3f90c7a"
35
35
  }