niris-public-community-components 0.0.7 → 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.
package/src/form-niris.ts CHANGED
@@ -39,9 +39,6 @@ export const {getLocale, setLocale} = configureLocalization({
39
39
  - Validaciones archivos extensiones.
40
40
  */
41
41
 
42
- /**
43
- * An example element.
44
- */
45
42
  @localized()
46
43
  export class FormNiris extends LitElement {
47
44
  @property({type: Number}) detailID: Number | undefined;
@@ -116,7 +113,7 @@ export class FormNiris extends LitElement {
116
113
  this.characteristics = [];
117
114
 
118
115
  this.locale = this.locale ? this.locale : 'es';
119
- // setLocale(this.locale);
116
+ // setLocale(this.locale); TODO: Fix problem when using setLocale
120
117
 
121
118
  // Map
122
119
  L.Icon.Default.imagePath = `https://unpkg.com/leaflet@${L.version}/dist/images/`;
@@ -332,7 +329,9 @@ export class FormNiris extends LitElement {
332
329
  const stylesCharacteristics = {
333
330
  display: this.characteristics.length == 0 ? 'none' : '',
334
331
  };
335
-
332
+ // To fix map problem. When opening with collapse, it does not render correctly
333
+ setTimeout(() => window.dispatchEvent(new Event('resize')), 100)
334
+
336
335
  return html`
337
336
  <section class="record">
338
337
  <h2 class="record__comment">${msg('Mensaje')}</h2>
@@ -521,12 +520,12 @@ export class FormNiris extends LitElement {
521
520
 
522
521
  <div>
523
522
  <label for="firstSurname">${msg('Primer apellido')}*:</label>
524
- <input id="firstSurname" name="firstSurname" type="text" />
523
+ <input id="firstSurname" name="firstSurname" type="text" required />
525
524
  </div>
526
525
 
527
526
  <div>
528
527
  <label for="secondSurname">${msg('Segundo apellido')}*:</label>
529
- <input id="secondSurname" name="secondSurname" type="text" required />
528
+ <input id="secondSurname" name="secondSurname" type="text" />
530
529
  </div>
531
530
 
532
531
  <div>
@@ -609,6 +608,15 @@ export class FormNiris extends LitElement {
609
608
  placeholder=${msg('Escribe tu teléfono')}
610
609
  />
611
610
  </div>
611
+
612
+ <div>
613
+ <label for="language">${msg('Idioma de la respuesta')}*:</label>
614
+ <select id="language" name="language" required>
615
+ <option value="es" selected>${msg('Español')}</option>
616
+ <option value="ca">${msg('Catalán')}</option>
617
+ <option value="en">${msg('Inglés')}</option>
618
+ </select>
619
+ </div>
612
620
  `;
613
621
  }
614
622
 
@@ -656,8 +664,8 @@ export class FormNiris extends LitElement {
656
664
  </div>
657
665
 
658
666
  <div>
659
- <label for="phone">${msg('Idioma de la respuesta')}*:</label>
660
- <select id="phone" name="language" required>
667
+ <label for="language">${msg('Idioma de la respuesta')}*:</label>
668
+ <select id="language" name="language" required>
661
669
  <option value="es" selected>${msg('Español')}</option>
662
670
  <option value="ca">${msg('Catalán')}</option>
663
671
  <option value="en">${msg('Inglés')}</option>
@@ -829,19 +837,21 @@ export class FormNiris extends LitElement {
829
837
  });
830
838
 
831
839
  if ('characteristics' in errors) {
832
- const characteristics = errors['characteristics'];
833
- for (const [key, errors] of characteristics.entries()) {
834
- if (Object.keys(errors).length !== 0) {
835
- debugger;
840
+ let characteristics = errors['characteristics'];
841
+ if (!Array.isArray(characteristics)) {
842
+ characteristics = Object.entries(characteristics);
843
+ }
844
+ characteristics.forEach((characteristic: any) => {
845
+ Object.entries(characteristic).forEach(([key, value]) => {
836
846
  const input = this.shadowRoot?.getElementById(
837
847
  `niris-${key}`
838
848
  ) as HTMLInputElement;
839
- errors.value.forEach((error: string) => {
840
- input.setCustomValidity(error);
841
- input.reportValidity();
842
- });
843
- }
844
- }
849
+ input.setCustomValidity(value as string);
850
+ input.reportValidity();
851
+
852
+ });
853
+ });
854
+
845
855
  }
846
856
  }
847
857
 
@@ -23,7 +23,7 @@ export class TextareaToNiris extends LitElement {
23
23
  this.formAction = '';
24
24
  this.keywords = '';
25
25
  this.locale = 'es'
26
- //setLocale(this.locale);
26
+ //setLocale(this.locale); TODO: Fix problem when using setLocale
27
27
  }
28
28
 
29
29
  updateShownValue(event: Event) {