@everymatrix/general-registration 1.10.0 → 1.10.2

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.
@@ -64,6 +64,7 @@ const CheckboxInput = class {
64
64
  this.errorMessage = this.setErrorMessage();
65
65
  this.isValid = this.setValidity();
66
66
  this.validityStateHandler({ valid: this.isValid, name: this.name });
67
+ this.emitValueHandler(true);
67
68
  }
68
69
  setValidity() {
69
70
  return this.inputReference.validity.valid;
@@ -91,17 +92,8 @@ const DateInput = class {
91
92
  this.sendValidityState = index.createEvent(this, "sendValidityState", 7);
92
93
  this.sendInputValue = index.createEvent(this, "sendInputValue", 7);
93
94
  }
94
- checkValidityHandler(newValue) {
95
- if (newValue == true) {
96
- this.isValid = this.setValidity();
97
- this.errorMessage = this.setErrorMessage();
98
- this.validityStateHandler({ valid: this.isValid, name: this.name });
99
- }
100
- }
101
95
  validityChanged() {
102
- if (this.checkValidity == true) {
103
- this.validityStateHandler({ valid: this.isValid, name: this.name });
104
- }
96
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
105
97
  if (this.emitValue == true) {
106
98
  this.valueHandler({ name: this.name, value: this.value });
107
99
  }
@@ -121,6 +113,8 @@ const DateInput = class {
121
113
  this.value = event.target.value;
122
114
  this.errorMessage = this.setErrorMessage();
123
115
  this.isValid = this.setValidity();
116
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
117
+ this.emitValueHandler(true);
124
118
  }
125
119
  setValidity() {
126
120
  return this.inputReference.validity.valid;
@@ -137,7 +131,6 @@ const DateInput = class {
137
131
  return index.h("div", { class: 'date__wrapper' }, index.h("input", { id: `${this.name}__input`, type: 'date', class: `date__input`, value: this.defaultValue, placeholder: `${this.displayName} ${this.validation.mandatory ? '*' : ''}`, ref: (el) => this.inputReference = el, required: this.validation.mandatory, max: this.validation.max, min: this.validation.min, onInput: (e) => this.handleInput(e) }), index.h("label", { class: `date__label ${this.validation.mandatory ? 'date__label--required' : ''}}`, htmlFor: `${this.name}__input` }, this.displayName, " ", this.validation.mandatory ? '*' : ''), index.h("small", { class: 'date__error-message' }, this.errorMessage));
138
132
  }
139
133
  static get watchers() { return {
140
- "checkValidity": ["checkValidityHandler"],
141
134
  "isValid": ["validityChanged"],
142
135
  "emitValue": ["emitValueHandler"]
143
136
  }; }
@@ -153,17 +146,8 @@ const EmailInput = class {
153
146
  this.sendInputValue = index.createEvent(this, "sendInputValue", 7);
154
147
  this.validationPattern = '';
155
148
  }
156
- checkValidityHandler(newValue) {
157
- if (newValue == true) {
158
- this.isValid = this.setValidity();
159
- this.errorMessage = this.setErrorMessage();
160
- this.validityStateHandler({ valid: this.isValid, name: this.name });
161
- }
162
- }
163
149
  validityChanged() {
164
- if (this.checkValidity == true) {
165
- this.validityStateHandler({ valid: this.isValid, name: this.name });
166
- }
150
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
167
151
  if (this.emitValue == true) {
168
152
  this.valueHandler({ name: this.name, value: this.value });
169
153
  }
@@ -184,13 +168,10 @@ const EmailInput = class {
184
168
  }
185
169
  handleInput(event) {
186
170
  this.value = event.target.value;
187
- if (this.debounceTime) {
188
- clearTimeout(this.debounceTime);
189
- }
190
- this.debounceTime = setTimeout(() => {
191
- this.errorMessage = this.setErrorMessage();
192
- this.isValid = this.setValidity();
193
- }, 500);
171
+ this.errorMessage = this.setErrorMessage();
172
+ this.isValid = this.setValidity();
173
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
174
+ this.emitValueHandler(true);
194
175
  }
195
176
  setValidity() {
196
177
  return this.inputReference.validity.valid;
@@ -216,7 +197,6 @@ const EmailInput = class {
216
197
  return index.h("div", { class: 'email__wrapper' }, index.h("input", { id: `${this.name}__input`, type: 'email', class: `email__input`, value: this.defaultValue, placeholder: `${this.displayName} ${this.validation.mandatory ? '*' : ''}`, ref: (el) => this.inputReference = el, pattern: this.validationPattern, required: this.validation.mandatory, minlength: this.validation.minLength, maxlength: this.validation.maxLength, onInput: (e) => this.handleInput(e) }), index.h("label", { class: `email__label ${this.validation.mandatory ? 'email__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), index.h("small", { class: 'email__error-message' }, this.errorMessage));
217
198
  }
218
199
  static get watchers() { return {
219
- "checkValidity": ["checkValidityHandler"],
220
200
  "isValid": ["validityChanged"],
221
201
  "emitValue": ["emitValueHandler"]
222
202
  }; }
@@ -515,31 +495,23 @@ const GeneralRegistration = class {
515
495
  this.language = 'en';
516
496
  this.emitValue = false;
517
497
  this.listOfInputs = [];
518
- this.isLoading = false;
498
+ this.isLoading = true;
519
499
  this.listOfInputValues = [];
520
500
  this.listOfActions = [];
521
501
  this.actionsStepIndex = 0;
522
502
  }
523
- validityStateHandler() {
524
- console.log('bababa', this.isFormValid);
525
- this.buttonReference.disabled = this.isFormValid ? false : true;
526
- }
527
503
  checkInputsValidityHandler(event) {
528
- console.log('se ajunge aici');
529
504
  // Set isValid state of the input in the list.
530
505
  this.listOfInputs.find(input => input.name == event.detail.name).isValid = event.detail.valid;
531
506
  // Check if any one is invalid.
532
507
  this.isFormValid = !this.getInvalidStatus(this.listOfInputs);
533
508
  }
534
509
  getInputsValueHandler(event) {
535
- console.log('sendInputValue');
536
510
  this.listOfInputValues.find(input => input.name == event.detail.name).inputValue = event.detail.value;
537
511
  /*Note to self: -- what about the inputs that received a default value.
538
512
  They will send an undefined because there was no input
539
513
  Handle it somehow!!!!!, one idea can be that value equals defaultValue but dependes on how the api wants stuff*/
540
514
  }
541
- connectedCallback() {
542
- }
543
515
  componentWillLoad() {
544
516
  // const mockCall = Promise.resolve(this.data);
545
517
  // return mockCall.then((data) => {
@@ -556,9 +528,9 @@ const GeneralRegistration = class {
556
528
  e.preventDefault();
557
529
  // Trigger events in subwidgets.
558
530
  this.emitValue = true;
559
- if (this.isFormValid) {
560
- this.setRegisterStep();
561
- }
531
+ // if (this.isFormValid) {
532
+ this.setRegisterStep();
533
+ // }
562
534
  }
563
535
  getRegisterConfig(registrationID) {
564
536
  const url = new URL(`${this.endpoint}/api/v1.0/registerCfg/`);
@@ -590,12 +562,15 @@ const GeneralRegistration = class {
590
562
  });
591
563
  }
592
564
  setRegisterStep() {
593
- this.emitValue = false;
565
+ this.isLoading = true;
594
566
  const url = new URL(`${this.endpoint}/api/v1.0/registerStep/`);
595
567
  const registerStep = {
596
568
  registrationId: this.registrationID,
597
569
  registerUserDto: this.listOfInputValues.reduce((acc, curr) => {
598
- acc[curr.name] = curr.inputValue;
570
+ // @TODO remove this once GMCore is smart enough to understand the concept of UNIQUE KEYS
571
+ if (curr.inputValue != null) {
572
+ acc[curr.name] = curr.inputValue;
573
+ }
599
574
  return acc;
600
575
  }, {}),
601
576
  step: this.registrationStep,
@@ -616,8 +591,10 @@ const GeneralRegistration = class {
616
591
  if (res.status >= 300) {
617
592
  throw new Error('err');
618
593
  }
594
+ return res.json();
619
595
  })
620
596
  .then((data) => {
597
+ console.log('data', data);
621
598
  this.registrationID = data.registrationId;
622
599
  if (this.listOfActions.some(action => action == '/register')) {
623
600
  this.setRegister();
@@ -628,9 +605,13 @@ const GeneralRegistration = class {
628
605
  })
629
606
  .catch((err) => {
630
607
  console.error(err);
608
+ })
609
+ .finally(() => {
610
+ this.isLoading = false;
631
611
  });
632
612
  }
633
613
  setRegister() {
614
+ this.isLoading = true;
634
615
  const url = new URL(`${this.endpoint}/api/v1.0/register/`);
635
616
  const headers = new Headers();
636
617
  headers.append('X-Tenant-ID', this.tenantId);
@@ -656,12 +637,19 @@ const GeneralRegistration = class {
656
637
  if (res.status >= 300) {
657
638
  throw new Error('err');
658
639
  }
640
+ return res.json();
659
641
  })
660
642
  .then((data) => {
661
643
  console.log(data);
644
+ if (data.userId) {
645
+ alert(`User registered - the user ID is ${data.userId}`);
646
+ }
662
647
  })
663
648
  .catch((err) => {
664
649
  console.log(err);
650
+ })
651
+ .finally(() => {
652
+ this.isLoading = false;
665
653
  });
666
654
  }
667
655
  formatConfig(config) {
@@ -682,21 +670,20 @@ const GeneralRegistration = class {
682
670
  return listOfInputs.filter(input => input.isValid == false).length > 0;
683
671
  }
684
672
  renderInputs() {
685
- /*let aux = this.listOfInputs;
686
- this.listOfInputs = [];
687
- this.listOfInputs = aux;*/
688
673
  return (this.listOfInputs.map(input => index.h("general-input", { type: input.inputType, name: input.name, displayName: input.displayName, validation: input.validate, action: input.action || null, options: input.data ? input.data.values : [], defaultValue: input.defaultValue, emitValue: this.emitValue, language: this.language })));
689
674
  }
690
675
  ;
691
676
  renderButtons() {
692
- return (index.h("div", { class: 'registration__buttons-wrapper' }, index.h("button", { class: 'registration__button', type: 'submit', form: 'RegistrationForm', onClick: (e) => this.nextHandler(e), ref: (el) => this.buttonReference = el }, translate('nextButton', this.language)), index.h("button", { class: 'registration__button' }, translate('backButton', this.language))));
677
+ return (index.h("div", { class: 'registration__buttons-wrapper' }, index.h("button", { class: 'registration__button', type: 'submit', form: 'RegistrationForm', onClick: (e) => this.nextHandler(e),
678
+ // disabled={!this.isFormValid}
679
+ ref: (el) => this.buttonReference = el }, translate('nextButton', this.language))));
693
680
  }
694
681
  render() {
682
+ if (this.isLoading) {
683
+ return index.h("p", null, "Please wait, loading ...");
684
+ }
695
685
  return (index.h("div", { class: 'registration' }, index.h("form", { action: '.', id: 'RegistrationForm', class: 'registration__form' }, this.renderInputs()), this.renderButtons()));
696
686
  }
697
- static get watchers() { return {
698
- "isFormValid": ["validityStateHandler"]
699
- }; }
700
687
  };
701
688
  GeneralRegistration.style = generalRegistrationCss;
702
689
 
@@ -708,17 +695,8 @@ const NumberInput = class {
708
695
  this.sendValidityState = index.createEvent(this, "sendValidityState", 7);
709
696
  this.sendInputValue = index.createEvent(this, "sendInputValue", 7);
710
697
  }
711
- checkValidityHandler(newValue) {
712
- if (newValue == true) {
713
- this.isValid = this.setValidity();
714
- this.errorMessage = this.setErrorMessage();
715
- this.validityStateHandler({ valid: this.isValid, name: this.name });
716
- }
717
- }
718
698
  validityChanged() {
719
- if (this.checkValidity == true) {
720
- this.validityStateHandler({ valid: this.isValid, name: this.name });
721
- }
699
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
722
700
  if (this.emitValue == true) {
723
701
  this.valueHandler({ name: this.name, value: this.value });
724
702
  }
@@ -736,13 +714,10 @@ const NumberInput = class {
736
714
  }
737
715
  handleInput(event) {
738
716
  this.value = event.target.value;
739
- if (this.debounceTime) {
740
- clearTimeout(this.debounceTime);
741
- }
742
- this.debounceTime = setTimeout(() => {
743
- this.errorMessage = this.setErrorMessage();
744
- this.isValid = this.setValidity();
745
- }, 500);
717
+ this.errorMessage = this.setErrorMessage();
718
+ this.isValid = this.setValidity();
719
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
720
+ this.emitValueHandler(true);
746
721
  }
747
722
  setValidity() {
748
723
  return this.inputReference.validity.valid;
@@ -760,7 +735,6 @@ const NumberInput = class {
760
735
  return index.h("div", { class: 'number__wrapper' }, index.h("input", { ref: (el) => this.inputReference = el, type: "number", value: this.defaultValue, id: `${this.name}__input`, class: `number__input ${invalidClass}`, placeholder: `${this.displayName} ${this.validation.mandatory ? '*' : ''}`, required: this.validation.mandatory, max: this.validation.max, min: this.validation.min, onInput: (e) => this.handleInput(e) }), index.h("label", { class: `number__label ${this.validation.mandatory ? 'number__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), index.h("small", { class: 'number__error-message' }, this.errorMessage));
761
736
  }
762
737
  static get watchers() { return {
763
- "checkValidity": ["checkValidityHandler"],
764
738
  "isValid": ["validityChanged"],
765
739
  "emitValue": ["emitValueHandler"]
766
740
  }; }
@@ -801,6 +775,7 @@ const PasswordInput = class {
801
775
  this.errorMessage = this.setErrorMessage();
802
776
  this.isValid = this.setValidity();
803
777
  this.validityStateHandler({ valid: this.isValid, name: this.name });
778
+ this.emitValueHandler(true);
804
779
  }
805
780
  setValidity() {
806
781
  return this.inputReference.validity.valid;
@@ -841,17 +816,8 @@ const RadioInput = class {
841
816
  this.sendInputValue = index.createEvent(this, "sendInputValue", 7);
842
817
  this.sendValidityState = index.createEvent(this, "sendValidityState", 7);
843
818
  }
844
- checkValidityHandler(newValue) {
845
- if (newValue == true) {
846
- this.isValid = this.setValidity();
847
- this.errorMessage = this.setErrorMessage();
848
- this.validityStateHandler({ valid: this.isValid, name: this.name });
849
- }
850
- }
851
819
  validityChanged() {
852
- if (this.checkValidity == true) {
853
- this.validityStateHandler({ valid: this.isValid, name: this.name });
854
- }
820
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
855
821
  if (this.emitValue == true) {
856
822
  this.valueHandler({ name: this.name, value: this.value });
857
823
  }
@@ -873,6 +839,8 @@ const RadioInput = class {
873
839
  this.value = event.target.value;
874
840
  this.isValid = this.setValidity();
875
841
  this.errorMessage = this.setErrorMessage();
842
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
843
+ this.emitValueHandler(true);
876
844
  }
877
845
  setValidity() {
878
846
  return this.inputReference.validity.valid;
@@ -886,7 +854,6 @@ const RadioInput = class {
886
854
  return index.h("fieldset", { class: 'radio__fieldset' }, index.h("legend", { class: 'radio__legend' }, this.displayName, ":"), this.optionsGroup.map(option => index.h("div", { class: 'radio__wrapper' }, index.h("input", { type: "radio", class: 'radio__input', id: `${option.label}__input`, ref: (el) => this.inputReference = el, value: option.value, name: this.name, required: this.validation.mandatory, onClick: (e) => this.handleClick(e) }), index.h("label", { htmlFor: `${option.label}__input` }, option.label))), index.h("small", { class: 'radio__error-message' }, this.errorMessage));
887
855
  }
888
856
  static get watchers() { return {
889
- "checkValidity": ["checkValidityHandler"],
890
857
  "isValid": ["validityChanged"],
891
858
  "emitValue": ["emitValueHandler"]
892
859
  }; }
@@ -905,17 +872,8 @@ const SelectInput = class {
905
872
  */
906
873
  this.options = [];
907
874
  }
908
- checkValidityHandler(newValue) {
909
- if (newValue == true) {
910
- this.isValid = this.setValidity();
911
- this.errorMessage = this.setErrorMessage();
912
- this.validityStateHandler({ valid: this.isValid, name: this.name });
913
- }
914
- }
915
875
  validityChanged() {
916
- if (this.checkValidity == true) {
917
- this.validityStateHandler({ valid: this.isValid, name: this.name });
918
- }
876
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
919
877
  if (this.emitValue == true) {
920
878
  this.valueHandler({ name: this.name, value: this.value });
921
879
  }
@@ -933,10 +891,8 @@ const SelectInput = class {
933
891
  }
934
892
  connectedCallback() {
935
893
  this.displayedOptions = this.options;
936
- console.log(this.displayedOptions);
937
894
  }
938
895
  componentWillLoad() {
939
- console.log(this.action, this.options);
940
896
  if (this.action && !this.options.length) {
941
897
  if (this.action.split(" ")[0] == 'GET') {
942
898
  return this.getOptions().then((options) => {
@@ -965,8 +921,9 @@ const SelectInput = class {
965
921
  this.value = event.target.value;
966
922
  this.errorMessage = this.setErrorMessage();
967
923
  this.isValid = this.setValidity();
924
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
925
+ this.emitValueHandler(true);
968
926
  this.inputReference.previousElementSibling.classList.remove('select__label--hidden');
969
- console.log(this.action, this.options);
970
927
  }
971
928
  setValidity() {
972
929
  return this.inputReference.validity.valid;
@@ -983,7 +940,6 @@ const SelectInput = class {
983
940
  })), index.h("small", { class: 'select__error-message' }, this.errorMessage));
984
941
  }
985
942
  static get watchers() { return {
986
- "checkValidity": ["checkValidityHandler"],
987
943
  "isValid": ["validityChanged"],
988
944
  "emitValue": ["emitValueHandler"]
989
945
  }; }
@@ -999,17 +955,8 @@ const TelInput = class {
999
955
  this.sendInputValue = index.createEvent(this, "sendInputValue", 7);
1000
956
  this.validationPattern = '';
1001
957
  }
1002
- checkValidityHandler(newValue) {
1003
- if (newValue == true) {
1004
- this.isValid = this.setValidity();
1005
- this.errorMessage = this.setErrorMessage();
1006
- this.validityStateHandler({ valid: this.isValid, name: this.name });
1007
- }
1008
- }
1009
958
  validityChanged() {
1010
- if (this.checkValidity == true) {
1011
- this.validityStateHandler({ valid: this.isValid, name: this.name });
1012
- }
959
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
1013
960
  if (this.emitValue == true) {
1014
961
  this.valueHandler({ name: this.name, value: this.value });
1015
962
  }
@@ -1030,13 +977,10 @@ const TelInput = class {
1030
977
  }
1031
978
  handleInput(event) {
1032
979
  this.value = event.target.value;
1033
- if (this.debounceTime) {
1034
- clearTimeout(this.debounceTime);
1035
- }
1036
- this.debounceTime = setTimeout(() => {
1037
- this.errorMessage = this.setErrorMessage();
1038
- this.isValid = this.setValidity();
1039
- }, 500);
980
+ this.errorMessage = this.setErrorMessage();
981
+ this.isValid = this.setValidity();
982
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
983
+ this.emitValueHandler(true);
1040
984
  }
1041
985
  setValidity() {
1042
986
  return this.inputReference.validity.valid;
@@ -1063,7 +1007,6 @@ const TelInput = class {
1063
1007
  return index.h("div", { class: 'tel__wrapper' }, index.h("input", { type: "tel", ref: (el) => this.inputReference = el, id: `${this.name}__input`, value: this.defaultValue, class: `tel__input ${invalidClass}`, placeholder: `${this.displayName} ${this.validation.mandatory ? '*' : ''}`, required: this.validation.mandatory, minlength: this.validation.minLength, maxlength: this.validation.maxLength, pattern: this.validationPattern, onInput: (e) => this.handleInput(e) }), index.h("label", { class: `tel__label ${this.validation.mandatory ? 'tel__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), index.h("small", { class: 'tel__error-message' }, this.errorMessage));
1064
1008
  }
1065
1009
  static get watchers() { return {
1066
- "checkValidity": ["checkValidityHandler"],
1067
1010
  "isValid": ["validityChanged"],
1068
1011
  "emitValue": ["emitValueHandler"]
1069
1012
  }; }
@@ -1112,6 +1055,7 @@ const TextInput = class {
1112
1055
  this.isValid = this.setValidity();
1113
1056
  this.errorMessage = this.setErrorMessage();
1114
1057
  this.validityStateHandler({ valid: this.isValid, name: this.name });
1058
+ this.emitValueHandler(true);
1115
1059
  }
1116
1060
  setValidity() {
1117
1061
  return this.inputReference.validity.valid;
@@ -15,5 +15,5 @@ const patchBrowser = () => {
15
15
  };
16
16
 
17
17
  patchBrowser().then(options => {
18
- return index.bootstrapLazy([["checkbox-input_11.cjs",[[1,"general-registration",{"endpoint":[1],"tenantId":[1,"tenant-id"],"clientId":[1,"client-id"],"apiKey":[1,"api-key"],"language":[1],"errorMessage":[32],"emitValue":[32],"isFormValid":[32],"listOfInputs":[32]},[[0,"sendValidityState","checkInputsValidityHandler"],[0,"sendInputValue","getInputsValueHandler"]]],[1,"general-input",{"type":[1],"name":[1],"displayName":[1,"display-name"],"action":[1],"validation":[16],"options":[8],"language":[1],"defaultValue":[8,"default-value"],"emitValue":[4,"emit-value"]}],[1,"checkbox-input",{"name":[1],"displayName":[1,"display-name"],"validation":[16],"language":[1],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"date-input",{"name":[1],"displayName":[1,"display-name"],"validation":[16],"defaultValue":[1,"default-value"],"language":[1],"checkValidity":[4,"check-validity"],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"email-input",{"name":[1],"displayName":[1,"display-name"],"validation":[16],"defaultValue":[1,"default-value"],"language":[1],"emitValue":[4,"emit-value"],"checkValidity":[4,"check-validity"],"errorMessage":[32],"isValid":[32]}],[1,"number-input",{"name":[1],"displayName":[1,"display-name"],"validation":[16],"defaultValue":[2,"default-value"],"language":[1],"checkValidity":[4,"check-validity"],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"password-input",{"name":[1],"displayName":[1,"display-name"],"validation":[16],"language":[1],"emitValue":[4,"emit-value"],"isValid":[32],"errorMessage":[32]}],[1,"radio-input",{"name":[1],"displayName":[1,"display-name"],"optionsGroup":[16],"validation":[16],"language":[1],"checkValidity":[4,"check-validity"],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"select-input",{"name":[1],"displayName":[1,"display-name"],"action":[1],"options":[16],"validation":[16],"language":[1],"checkValidity":[4,"check-validity"],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"tel-input",{"name":[1],"displayName":[1,"display-name"],"showLabels":[4,"show-labels"],"action":[1],"validation":[16],"defaultValue":[8,"default-value"],"language":[1],"checkValidity":[4,"check-validity"],"emitValue":[4,"emit-value"],"isValid":[32],"errorMessage":[32]}],[1,"text-input",{"name":[1025],"displayName":[1,"display-name"],"validation":[16],"defaultValue":[1025,"default-value"],"rules":[1],"language":[1],"checkValidity":[4,"check-validity"],"emitValue":[4,"emit-value"],"isValid":[32],"errorMessage":[32]}]]]], options);
18
+ return index.bootstrapLazy([["checkbox-input_11.cjs",[[1,"general-registration",{"endpoint":[1],"tenantId":[1,"tenant-id"],"clientId":[1,"client-id"],"apiKey":[1,"api-key"],"language":[1],"errorMessage":[32],"emitValue":[32],"isFormValid":[32],"listOfInputs":[32],"isLoading":[32]},[[0,"sendValidityState","checkInputsValidityHandler"],[0,"sendInputValue","getInputsValueHandler"]]],[1,"general-input",{"type":[1],"name":[1],"displayName":[1,"display-name"],"action":[1],"validation":[16],"options":[8],"language":[1],"defaultValue":[8,"default-value"],"emitValue":[4,"emit-value"]}],[1,"checkbox-input",{"name":[1],"displayName":[1,"display-name"],"validation":[16],"language":[1],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"date-input",{"name":[1],"displayName":[1,"display-name"],"validation":[16],"defaultValue":[1,"default-value"],"language":[1],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"email-input",{"name":[1],"displayName":[1,"display-name"],"validation":[16],"defaultValue":[1,"default-value"],"language":[1],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"number-input",{"name":[1],"displayName":[1,"display-name"],"validation":[16],"defaultValue":[2,"default-value"],"language":[1],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"password-input",{"name":[1],"displayName":[1,"display-name"],"validation":[16],"language":[1],"emitValue":[4,"emit-value"],"isValid":[32],"errorMessage":[32]}],[1,"radio-input",{"name":[1],"displayName":[1,"display-name"],"optionsGroup":[16],"validation":[16],"language":[1],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"select-input",{"name":[1],"displayName":[1,"display-name"],"action":[1],"options":[16],"validation":[16],"language":[1],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"tel-input",{"name":[1],"displayName":[1,"display-name"],"showLabels":[4,"show-labels"],"action":[1],"validation":[16],"defaultValue":[8,"default-value"],"language":[1],"emitValue":[4,"emit-value"],"isValid":[32],"errorMessage":[32]}],[1,"text-input",{"name":[1025],"displayName":[1,"display-name"],"validation":[16],"defaultValue":[1025,"default-value"],"rules":[1],"language":[1],"checkValidity":[4,"check-validity"],"emitValue":[4,"emit-value"],"isValid":[32],"errorMessage":[32]}]]]], options);
19
19
  });
@@ -14,7 +14,7 @@ const patchEsm = () => {
14
14
  const defineCustomElements = (win, options) => {
15
15
  if (typeof window === 'undefined') return Promise.resolve();
16
16
  return patchEsm().then(() => {
17
- return index.bootstrapLazy([["checkbox-input_11.cjs",[[1,"general-registration",{"endpoint":[1],"tenantId":[1,"tenant-id"],"clientId":[1,"client-id"],"apiKey":[1,"api-key"],"language":[1],"errorMessage":[32],"emitValue":[32],"isFormValid":[32],"listOfInputs":[32]},[[0,"sendValidityState","checkInputsValidityHandler"],[0,"sendInputValue","getInputsValueHandler"]]],[1,"general-input",{"type":[1],"name":[1],"displayName":[1,"display-name"],"action":[1],"validation":[16],"options":[8],"language":[1],"defaultValue":[8,"default-value"],"emitValue":[4,"emit-value"]}],[1,"checkbox-input",{"name":[1],"displayName":[1,"display-name"],"validation":[16],"language":[1],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"date-input",{"name":[1],"displayName":[1,"display-name"],"validation":[16],"defaultValue":[1,"default-value"],"language":[1],"checkValidity":[4,"check-validity"],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"email-input",{"name":[1],"displayName":[1,"display-name"],"validation":[16],"defaultValue":[1,"default-value"],"language":[1],"emitValue":[4,"emit-value"],"checkValidity":[4,"check-validity"],"errorMessage":[32],"isValid":[32]}],[1,"number-input",{"name":[1],"displayName":[1,"display-name"],"validation":[16],"defaultValue":[2,"default-value"],"language":[1],"checkValidity":[4,"check-validity"],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"password-input",{"name":[1],"displayName":[1,"display-name"],"validation":[16],"language":[1],"emitValue":[4,"emit-value"],"isValid":[32],"errorMessage":[32]}],[1,"radio-input",{"name":[1],"displayName":[1,"display-name"],"optionsGroup":[16],"validation":[16],"language":[1],"checkValidity":[4,"check-validity"],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"select-input",{"name":[1],"displayName":[1,"display-name"],"action":[1],"options":[16],"validation":[16],"language":[1],"checkValidity":[4,"check-validity"],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"tel-input",{"name":[1],"displayName":[1,"display-name"],"showLabels":[4,"show-labels"],"action":[1],"validation":[16],"defaultValue":[8,"default-value"],"language":[1],"checkValidity":[4,"check-validity"],"emitValue":[4,"emit-value"],"isValid":[32],"errorMessage":[32]}],[1,"text-input",{"name":[1025],"displayName":[1,"display-name"],"validation":[16],"defaultValue":[1025,"default-value"],"rules":[1],"language":[1],"checkValidity":[4,"check-validity"],"emitValue":[4,"emit-value"],"isValid":[32],"errorMessage":[32]}]]]], options);
17
+ return index.bootstrapLazy([["checkbox-input_11.cjs",[[1,"general-registration",{"endpoint":[1],"tenantId":[1,"tenant-id"],"clientId":[1,"client-id"],"apiKey":[1,"api-key"],"language":[1],"errorMessage":[32],"emitValue":[32],"isFormValid":[32],"listOfInputs":[32],"isLoading":[32]},[[0,"sendValidityState","checkInputsValidityHandler"],[0,"sendInputValue","getInputsValueHandler"]]],[1,"general-input",{"type":[1],"name":[1],"displayName":[1,"display-name"],"action":[1],"validation":[16],"options":[8],"language":[1],"defaultValue":[8,"default-value"],"emitValue":[4,"emit-value"]}],[1,"checkbox-input",{"name":[1],"displayName":[1,"display-name"],"validation":[16],"language":[1],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"date-input",{"name":[1],"displayName":[1,"display-name"],"validation":[16],"defaultValue":[1,"default-value"],"language":[1],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"email-input",{"name":[1],"displayName":[1,"display-name"],"validation":[16],"defaultValue":[1,"default-value"],"language":[1],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"number-input",{"name":[1],"displayName":[1,"display-name"],"validation":[16],"defaultValue":[2,"default-value"],"language":[1],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"password-input",{"name":[1],"displayName":[1,"display-name"],"validation":[16],"language":[1],"emitValue":[4,"emit-value"],"isValid":[32],"errorMessage":[32]}],[1,"radio-input",{"name":[1],"displayName":[1,"display-name"],"optionsGroup":[16],"validation":[16],"language":[1],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"select-input",{"name":[1],"displayName":[1,"display-name"],"action":[1],"options":[16],"validation":[16],"language":[1],"emitValue":[4,"emit-value"],"errorMessage":[32],"isValid":[32]}],[1,"tel-input",{"name":[1],"displayName":[1,"display-name"],"showLabels":[4,"show-labels"],"action":[1],"validation":[16],"defaultValue":[8,"default-value"],"language":[1],"emitValue":[4,"emit-value"],"isValid":[32],"errorMessage":[32]}],[1,"text-input",{"name":[1025],"displayName":[1,"display-name"],"validation":[16],"defaultValue":[1025,"default-value"],"rules":[1],"language":[1],"checkValidity":[4,"check-validity"],"emitValue":[4,"emit-value"],"isValid":[32],"errorMessage":[32]}]]]], options);
18
18
  });
19
19
  };
20
20
 
@@ -1,4 +1,4 @@
1
- import { Component, h, Listen, Prop, State, Watch } from '@stencil/core';
1
+ import { Component, h, Listen, Prop, State } from '@stencil/core';
2
2
  import { translate } from '../../../../general-input/src/utils/locale.utils';
3
3
  import '@everymatrix/general-input';
4
4
  export class GeneralRegistration {
@@ -224,31 +224,23 @@ export class GeneralRegistration {
224
224
  this.language = 'en';
225
225
  this.emitValue = false;
226
226
  this.listOfInputs = [];
227
- this.isLoading = false;
227
+ this.isLoading = true;
228
228
  this.listOfInputValues = [];
229
229
  this.listOfActions = [];
230
230
  this.actionsStepIndex = 0;
231
231
  }
232
- validityStateHandler() {
233
- console.log('bababa', this.isFormValid);
234
- this.buttonReference.disabled = this.isFormValid ? false : true;
235
- }
236
232
  checkInputsValidityHandler(event) {
237
- console.log('se ajunge aici');
238
233
  // Set isValid state of the input in the list.
239
234
  this.listOfInputs.find(input => input.name == event.detail.name).isValid = event.detail.valid;
240
235
  // Check if any one is invalid.
241
236
  this.isFormValid = !this.getInvalidStatus(this.listOfInputs);
242
237
  }
243
238
  getInputsValueHandler(event) {
244
- console.log('sendInputValue');
245
239
  this.listOfInputValues.find(input => input.name == event.detail.name).inputValue = event.detail.value;
246
240
  /*Note to self: -- what about the inputs that received a default value.
247
241
  They will send an undefined because there was no input
248
242
  Handle it somehow!!!!!, one idea can be that value equals defaultValue but dependes on how the api wants stuff*/
249
243
  }
250
- connectedCallback() {
251
- }
252
244
  componentWillLoad() {
253
245
  // const mockCall = Promise.resolve(this.data);
254
246
  // return mockCall.then((data) => {
@@ -265,9 +257,9 @@ export class GeneralRegistration {
265
257
  e.preventDefault();
266
258
  // Trigger events in subwidgets.
267
259
  this.emitValue = true;
268
- if (this.isFormValid) {
269
- this.setRegisterStep();
270
- }
260
+ // if (this.isFormValid) {
261
+ this.setRegisterStep();
262
+ // }
271
263
  }
272
264
  getRegisterConfig(registrationID) {
273
265
  const url = new URL(`${this.endpoint}/api/v1.0/registerCfg/`);
@@ -299,12 +291,15 @@ export class GeneralRegistration {
299
291
  });
300
292
  }
301
293
  setRegisterStep() {
302
- this.emitValue = false;
294
+ this.isLoading = true;
303
295
  const url = new URL(`${this.endpoint}/api/v1.0/registerStep/`);
304
296
  const registerStep = {
305
297
  registrationId: this.registrationID,
306
298
  registerUserDto: this.listOfInputValues.reduce((acc, curr) => {
307
- acc[curr.name] = curr.inputValue;
299
+ // @TODO remove this once GMCore is smart enough to understand the concept of UNIQUE KEYS
300
+ if (curr.inputValue != null) {
301
+ acc[curr.name] = curr.inputValue;
302
+ }
308
303
  return acc;
309
304
  }, {}),
310
305
  step: this.registrationStep,
@@ -325,8 +320,10 @@ export class GeneralRegistration {
325
320
  if (res.status >= 300) {
326
321
  throw new Error('err');
327
322
  }
323
+ return res.json();
328
324
  })
329
325
  .then((data) => {
326
+ console.log('data', data);
330
327
  this.registrationID = data.registrationId;
331
328
  if (this.listOfActions.some(action => action == '/register')) {
332
329
  this.setRegister();
@@ -337,9 +334,13 @@ export class GeneralRegistration {
337
334
  })
338
335
  .catch((err) => {
339
336
  console.error(err);
337
+ })
338
+ .finally(() => {
339
+ this.isLoading = false;
340
340
  });
341
341
  }
342
342
  setRegister() {
343
+ this.isLoading = true;
343
344
  const url = new URL(`${this.endpoint}/api/v1.0/register/`);
344
345
  const headers = new Headers();
345
346
  headers.append('X-Tenant-ID', this.tenantId);
@@ -365,12 +366,19 @@ export class GeneralRegistration {
365
366
  if (res.status >= 300) {
366
367
  throw new Error('err');
367
368
  }
369
+ return res.json();
368
370
  })
369
371
  .then((data) => {
370
372
  console.log(data);
373
+ if (data.userId) {
374
+ alert(`User registered - the user ID is ${data.userId}`);
375
+ }
371
376
  })
372
377
  .catch((err) => {
373
378
  console.log(err);
379
+ })
380
+ .finally(() => {
381
+ this.isLoading = false;
374
382
  });
375
383
  }
376
384
  formatConfig(config) {
@@ -391,18 +399,19 @@ export class GeneralRegistration {
391
399
  return listOfInputs.filter(input => input.isValid == false).length > 0;
392
400
  }
393
401
  renderInputs() {
394
- /*let aux = this.listOfInputs;
395
- this.listOfInputs = [];
396
- this.listOfInputs = aux;*/
397
402
  return (this.listOfInputs.map(input => h("general-input", { type: input.inputType, name: input.name, displayName: input.displayName, validation: input.validate, action: input.action || null, options: input.data ? input.data.values : [], defaultValue: input.defaultValue, emitValue: this.emitValue, language: this.language })));
398
403
  }
399
404
  ;
400
405
  renderButtons() {
401
406
  return (h("div", { class: 'registration__buttons-wrapper' },
402
- h("button", { class: 'registration__button', type: 'submit', form: 'RegistrationForm', onClick: (e) => this.nextHandler(e), ref: (el) => this.buttonReference = el }, translate('nextButton', this.language)),
403
- h("button", { class: 'registration__button' }, translate('backButton', this.language))));
407
+ h("button", { class: 'registration__button', type: 'submit', form: 'RegistrationForm', onClick: (e) => this.nextHandler(e),
408
+ // disabled={!this.isFormValid}
409
+ ref: (el) => this.buttonReference = el }, translate('nextButton', this.language))));
404
410
  }
405
411
  render() {
412
+ if (this.isLoading) {
413
+ return h("p", null, "Please wait, loading ...");
414
+ }
406
415
  return (h("div", { class: 'registration' },
407
416
  h("form", { action: '.', id: 'RegistrationForm', class: 'registration__form' }, this.renderInputs()),
408
417
  this.renderButtons()));
@@ -507,12 +516,9 @@ export class GeneralRegistration {
507
516
  "errorMessage": {},
508
517
  "emitValue": {},
509
518
  "isFormValid": {},
510
- "listOfInputs": {}
519
+ "listOfInputs": {},
520
+ "isLoading": {}
511
521
  }; }
512
- static get watchers() { return [{
513
- "propName": "isFormValid",
514
- "methodName": "validityStateHandler"
515
- }]; }
516
522
  static get listeners() { return [{
517
523
  "name": "sendValidityState",
518
524
  "method": "checkInputsValidityHandler",
@@ -35,6 +35,7 @@ const CheckboxInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
35
35
  this.errorMessage = this.setErrorMessage();
36
36
  this.isValid = this.setValidity();
37
37
  this.validityStateHandler({ valid: this.isValid, name: this.name });
38
+ this.emitValueHandler(true);
38
39
  }
39
40
  setValidity() {
40
41
  return this.inputReference.validity.valid;
@@ -11,17 +11,8 @@ const DateInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
11
11
  this.sendValidityState = createEvent(this, "sendValidityState", 7);
12
12
  this.sendInputValue = createEvent(this, "sendInputValue", 7);
13
13
  }
14
- checkValidityHandler(newValue) {
15
- if (newValue == true) {
16
- this.isValid = this.setValidity();
17
- this.errorMessage = this.setErrorMessage();
18
- this.validityStateHandler({ valid: this.isValid, name: this.name });
19
- }
20
- }
21
14
  validityChanged() {
22
- if (this.checkValidity == true) {
23
- this.validityStateHandler({ valid: this.isValid, name: this.name });
24
- }
15
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
25
16
  if (this.emitValue == true) {
26
17
  this.valueHandler({ name: this.name, value: this.value });
27
18
  }
@@ -41,6 +32,8 @@ const DateInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
41
32
  this.value = event.target.value;
42
33
  this.errorMessage = this.setErrorMessage();
43
34
  this.isValid = this.setValidity();
35
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
36
+ this.emitValueHandler(true);
44
37
  }
45
38
  setValidity() {
46
39
  return this.inputReference.validity.valid;
@@ -57,7 +50,6 @@ const DateInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
57
50
  return h("div", { class: 'date__wrapper' }, h("input", { id: `${this.name}__input`, type: 'date', class: `date__input`, value: this.defaultValue, placeholder: `${this.displayName} ${this.validation.mandatory ? '*' : ''}`, ref: (el) => this.inputReference = el, required: this.validation.mandatory, max: this.validation.max, min: this.validation.min, onInput: (e) => this.handleInput(e) }), h("label", { class: `date__label ${this.validation.mandatory ? 'date__label--required' : ''}}`, htmlFor: `${this.name}__input` }, this.displayName, " ", this.validation.mandatory ? '*' : ''), h("small", { class: 'date__error-message' }, this.errorMessage));
58
51
  }
59
52
  static get watchers() { return {
60
- "checkValidity": ["checkValidityHandler"],
61
53
  "isValid": ["validityChanged"],
62
54
  "emitValue": ["emitValueHandler"]
63
55
  }; }
@@ -68,7 +60,6 @@ const DateInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
68
60
  "validation": [16],
69
61
  "defaultValue": [1, "default-value"],
70
62
  "language": [1],
71
- "checkValidity": [4, "check-validity"],
72
63
  "emitValue": [4, "emit-value"],
73
64
  "errorMessage": [32],
74
65
  "isValid": [32]