@valtimo/components 10.8.1 → 10.8.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.
@@ -4872,50 +4872,58 @@ class FormioComponent {
4872
4872
  this.route = route;
4873
4873
  this.translateService = translateService;
4874
4874
  this.modalService = modalService;
4875
- this.submission = {};
4876
4875
  // eslint-disable-next-line @angular-eslint/no-output-native
4877
4876
  this.submit = new EventEmitter();
4878
4877
  // eslint-disable-next-line @angular-eslint/no-output-native
4879
4878
  this.change = new EventEmitter();
4880
4879
  this.refreshForm = new EventEmitter();
4881
- this.errors = [];
4880
+ this.submission$ = new BehaviorSubject(undefined);
4881
+ this.form$ = new BehaviorSubject(undefined);
4882
+ this.options$ = new BehaviorSubject(undefined);
4883
+ this.readOnly$ = new BehaviorSubject(false);
4884
+ this.errors$ = new BehaviorSubject([]);
4882
4885
  this.currentLanguage$ = this.translateService.stream('key').pipe(map$1(() => this.translateService.currentLang), distinctUntilChanged());
4883
- this.formioOptions$ = this.currentLanguage$.pipe(map$1(language => {
4886
+ this.formioOptions$ = combineLatest([
4887
+ this.currentLanguage$,
4888
+ this.options$,
4889
+ ]).pipe(map$1(([language, options]) => {
4884
4890
  const formioTranslations = this.translateService.instant('formioTranslations');
4885
4891
  return typeof formioTranslations === 'object'
4886
4892
  ? {
4887
- ...this.options,
4893
+ ...options,
4888
4894
  i18n: {
4889
4895
  [language]: this.stateService.flattenTranslationsObject(formioTranslations),
4890
4896
  },
4891
4897
  language,
4892
4898
  }
4893
4899
  : {
4894
- ...this.options,
4900
+ ...options,
4895
4901
  language,
4896
4902
  };
4897
4903
  }));
4904
+ this._subscriptions = new Subscription();
4905
+ }
4906
+ set options(optionsValue) {
4907
+ this.options$.next(optionsValue);
4908
+ }
4909
+ set submission(submissionValue) {
4910
+ this.submission$.next(submissionValue);
4911
+ }
4912
+ set form(formValue) {
4913
+ this.form$.next(formValue);
4914
+ }
4915
+ set readOnly(readOnlyValue) {
4916
+ this.readOnly$.next(readOnlyValue);
4898
4917
  }
4899
4918
  ngOnInit() {
4900
- const documentDefinitionName = this.route.snapshot.paramMap.get('documentDefinitionName');
4901
- const documentId = this.route.snapshot.paramMap.get('documentId');
4902
- this.formDefinition = this.form;
4903
- this.errors = [];
4919
+ this.openRouteSubscription();
4920
+ this.errors$.next([]);
4904
4921
  this.setInitialToken();
4905
- if (documentDefinitionName) {
4906
- this.stateService.setDocumentDefinitionName(documentDefinitionName);
4907
- }
4908
- if (documentId) {
4909
- this.stateService.setDocumentId(documentId);
4910
- }
4911
4922
  this.subscribeFormRefresh();
4923
+ this.openReloadFormSubscription();
4924
+ this.openReloadSubmissionSubscription();
4912
4925
  }
4913
4926
  ngOnChanges(changes) {
4914
- const currentForm = changes?.form?.currentValue;
4915
- if (currentForm) {
4916
- this.formDefinition = currentForm;
4917
- this.reloadForm();
4918
- }
4919
4927
  this.setInitialToken();
4920
4928
  if (changes.formDefinitionRefresh$) {
4921
4929
  this.unsubscribeFormRefresh();
@@ -4925,21 +4933,16 @@ class FormioComponent {
4925
4933
  ngOnDestroy() {
4926
4934
  this.unsubscribeFormRefresh();
4927
4935
  this.tokenRefreshTimerSubscription?.unsubscribe();
4928
- }
4929
- reloadForm() {
4930
- this.refreshForm.emit({
4931
- form: this.formDefinition,
4932
- });
4936
+ this._subscriptions.unsubscribe();
4933
4937
  }
4934
4938
  showErrors(errors) {
4935
- this.errors = errors;
4939
+ this.errors$.next(errors);
4936
4940
  }
4937
4941
  onSubmit(submission) {
4938
- this.errors = [];
4942
+ this.errors$.next([]);
4939
4943
  this.submit.emit(submission);
4940
4944
  }
4941
4945
  formReady(form) {
4942
- this.reloadForm();
4943
4946
  this.stateService.currentForm = form;
4944
4947
  }
4945
4948
  onChange(object) {
@@ -4951,6 +4954,20 @@ class FormioComponent {
4951
4954
  prevPage() {
4952
4955
  this.scrollToTop();
4953
4956
  }
4957
+ openReloadFormSubscription() {
4958
+ this._subscriptions.add(this.form$.subscribe(form => {
4959
+ this.refreshForm.emit({
4960
+ form,
4961
+ });
4962
+ }));
4963
+ }
4964
+ openReloadSubmissionSubscription() {
4965
+ this._subscriptions.add(this.submission$.subscribe(submission => {
4966
+ this.refreshForm.emit({
4967
+ submission,
4968
+ });
4969
+ }));
4970
+ }
4954
4971
  scrollToTop() {
4955
4972
  this.modalService.scrollToTop();
4956
4973
  }
@@ -4996,18 +5013,30 @@ class FormioComponent {
4996
5013
  this.formRefreshSubscription.unsubscribe();
4997
5014
  }
4998
5015
  }
5016
+ openRouteSubscription() {
5017
+ this._subscriptions.add(this.route.params.subscribe(params => {
5018
+ const documentDefinitionName = params.documentDefinitionName;
5019
+ const documentId = params.documentId;
5020
+ if (documentDefinitionName) {
5021
+ this.stateService.setDocumentDefinitionName(documentDefinitionName);
5022
+ }
5023
+ if (documentId) {
5024
+ this.stateService.setDocumentId(documentId);
5025
+ }
5026
+ }));
5027
+ }
4999
5028
  }
5000
5029
  FormioComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: FormioComponent, deps: [{ token: i3$1.UserProviderService }, { token: i4.NGXLogger }, { token: FormIoStateService }, { token: i1$1.ActivatedRoute }, { token: i1.TranslateService }, { token: ValtimoModalService }], target: i0.ɵɵFactoryTarget.Component });
5001
- FormioComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: FormioComponent, selector: "valtimo-form-io", inputs: { form: "form", options: "options", submission: "submission", readOnly: "readOnly", formRefresh$: "formRefresh$" }, outputs: { submit: "submit", change: "change" }, usesOnChanges: true, ngImport: i0, template: "<!--\n ~ Copyright 2015-2023 Ritense BV, the Netherlands.\n ~\n ~ Licensed under EUPL, Version 1.2 (the \"License\");\n ~ you may not use this file except in compliance with the License.\n ~ You may obtain a copy of the License at\n ~\n ~ https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n ~\n ~ Unless required by applicable law or agreed to in writing, software\n ~ distributed under the License is distributed on an \"AS IS\" basis,\n ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n ~ See the License for the specific language governing permissions and\n ~ limitations under the License.\n -->\n\n<div\n *ngIf=\"{\n currentLanguage: currentLanguage$ | async,\n formioOptions: formioOptions$ | async\n } as obs\"\n>\n <div *ngIf=\"errors.length > 0\" class=\"alert alert-danger pt-5 pb-5 mb-2\">\n <ol>\n <li *ngFor=\"let error of errors\">\n {{ error }}\n </li>\n </ol>\n </div>\n <formio\n *ngIf=\"obs.formioOptions\"\n [submission]=\"submission\"\n [form]=\"formDefinition\"\n [refresh]=\"refreshForm\"\n [options]=\"obs.formioOptions\"\n [readOnly]=\"readOnly\"\n (submit)=\"onSubmit($event)\"\n (ready)=\"formReady($event)\"\n (change)=\"onChange($event)\"\n (nextPage)=\"nextPage()\"\n (prevPage)=\"prevPage()\"\n ></formio>\n</div>\n", styles: [""], dependencies: [{ kind: "directive", type: i1$2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1$2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i8.FormioComponent, selector: "formio" }, { kind: "pipe", type: i1$2.AsyncPipe, name: "async" }] });
5030
+ FormioComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: FormioComponent, selector: "valtimo-form-io", inputs: { options: "options", submission: "submission", form: "form", readOnly: "readOnly", formRefresh$: "formRefresh$" }, outputs: { submit: "submit", change: "change" }, usesOnChanges: true, ngImport: i0, template: "<!--\n ~ Copyright 2015-2023 Ritense BV, the Netherlands.\n ~\n ~ Licensed under EUPL, Version 1.2 (the \"License\");\n ~ you may not use this file except in compliance with the License.\n ~ You may obtain a copy of the License at\n ~\n ~ https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n ~\n ~ Unless required by applicable law or agreed to in writing, software\n ~ distributed under the License is distributed on an \"AS IS\" basis,\n ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n ~ See the License for the specific language governing permissions and\n ~ limitations under the License.\n -->\n\n<div\n *ngIf=\"{\n currentLanguage: currentLanguage$ | async,\n formioOptions: formioOptions$ | async,\n submission: submission$ | async,\n readOnly: readOnly$ | async,\n form: form$ | async,\n errors: errors$ | async\n } as obs\"\n>\n <div *ngIf=\"obs.errors.length > 0\" class=\"alert alert-danger pt-5 pb-5 mb-2\">\n <ol>\n <li *ngFor=\"let error of obs.errors\">\n {{ error }}\n </li>\n </ol>\n </div>\n <formio\n *ngIf=\"obs.formioOptions && obs.form\"\n [submission]=\"obs.submission\"\n [form]=\"obs.form\"\n [refresh]=\"refreshForm\"\n [options]=\"obs.formioOptions\"\n [readOnly]=\"obs.readOnly\"\n (submit)=\"onSubmit($event)\"\n (ready)=\"formReady($event)\"\n (change)=\"onChange($event)\"\n (nextPage)=\"nextPage()\"\n (prevPage)=\"prevPage()\"\n ></formio>\n</div>\n", styles: [""], dependencies: [{ kind: "directive", type: i1$2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1$2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i8.FormioComponent, selector: "formio" }, { kind: "pipe", type: i1$2.AsyncPipe, name: "async" }] });
5002
5031
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: FormioComponent, decorators: [{
5003
5032
  type: Component,
5004
- args: [{ selector: 'valtimo-form-io', template: "<!--\n ~ Copyright 2015-2023 Ritense BV, the Netherlands.\n ~\n ~ Licensed under EUPL, Version 1.2 (the \"License\");\n ~ you may not use this file except in compliance with the License.\n ~ You may obtain a copy of the License at\n ~\n ~ https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n ~\n ~ Unless required by applicable law or agreed to in writing, software\n ~ distributed under the License is distributed on an \"AS IS\" basis,\n ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n ~ See the License for the specific language governing permissions and\n ~ limitations under the License.\n -->\n\n<div\n *ngIf=\"{\n currentLanguage: currentLanguage$ | async,\n formioOptions: formioOptions$ | async\n } as obs\"\n>\n <div *ngIf=\"errors.length > 0\" class=\"alert alert-danger pt-5 pb-5 mb-2\">\n <ol>\n <li *ngFor=\"let error of errors\">\n {{ error }}\n </li>\n </ol>\n </div>\n <formio\n *ngIf=\"obs.formioOptions\"\n [submission]=\"submission\"\n [form]=\"formDefinition\"\n [refresh]=\"refreshForm\"\n [options]=\"obs.formioOptions\"\n [readOnly]=\"readOnly\"\n (submit)=\"onSubmit($event)\"\n (ready)=\"formReady($event)\"\n (change)=\"onChange($event)\"\n (nextPage)=\"nextPage()\"\n (prevPage)=\"prevPage()\"\n ></formio>\n</div>\n" }]
5005
- }], ctorParameters: function () { return [{ type: i3$1.UserProviderService }, { type: i4.NGXLogger }, { type: FormIoStateService }, { type: i1$1.ActivatedRoute }, { type: i1.TranslateService }, { type: ValtimoModalService }]; }, propDecorators: { form: [{
5006
- type: Input
5007
- }], options: [{
5033
+ args: [{ selector: 'valtimo-form-io', template: "<!--\n ~ Copyright 2015-2023 Ritense BV, the Netherlands.\n ~\n ~ Licensed under EUPL, Version 1.2 (the \"License\");\n ~ you may not use this file except in compliance with the License.\n ~ You may obtain a copy of the License at\n ~\n ~ https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n ~\n ~ Unless required by applicable law or agreed to in writing, software\n ~ distributed under the License is distributed on an \"AS IS\" basis,\n ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n ~ See the License for the specific language governing permissions and\n ~ limitations under the License.\n -->\n\n<div\n *ngIf=\"{\n currentLanguage: currentLanguage$ | async,\n formioOptions: formioOptions$ | async,\n submission: submission$ | async,\n readOnly: readOnly$ | async,\n form: form$ | async,\n errors: errors$ | async\n } as obs\"\n>\n <div *ngIf=\"obs.errors.length > 0\" class=\"alert alert-danger pt-5 pb-5 mb-2\">\n <ol>\n <li *ngFor=\"let error of obs.errors\">\n {{ error }}\n </li>\n </ol>\n </div>\n <formio\n *ngIf=\"obs.formioOptions && obs.form\"\n [submission]=\"obs.submission\"\n [form]=\"obs.form\"\n [refresh]=\"refreshForm\"\n [options]=\"obs.formioOptions\"\n [readOnly]=\"obs.readOnly\"\n (submit)=\"onSubmit($event)\"\n (ready)=\"formReady($event)\"\n (change)=\"onChange($event)\"\n (nextPage)=\"nextPage()\"\n (prevPage)=\"prevPage()\"\n ></formio>\n</div>\n" }]
5034
+ }], ctorParameters: function () { return [{ type: i3$1.UserProviderService }, { type: i4.NGXLogger }, { type: FormIoStateService }, { type: i1$1.ActivatedRoute }, { type: i1.TranslateService }, { type: ValtimoModalService }]; }, propDecorators: { options: [{
5008
5035
  type: Input
5009
5036
  }], submission: [{
5010
5037
  type: Input
5038
+ }], form: [{
5039
+ type: Input
5011
5040
  }], readOnly: [{
5012
5041
  type: Input
5013
5042
  }], formRefresh$: [{
@@ -6534,6 +6563,16 @@ const formIoUploaderEditForm = () => ({
6534
6563
  required: true,
6535
6564
  },
6536
6565
  },
6566
+ {
6567
+ type: 'checkbox',
6568
+ input: true,
6569
+ inputType: 'checkbox',
6570
+ key: 'validate.required',
6571
+ label: 'Required',
6572
+ validate: {
6573
+ required: false,
6574
+ },
6575
+ },
6537
6576
  {
6538
6577
  type: 'textfield',
6539
6578
  input: true,
@@ -6642,9 +6681,8 @@ function registerFormioUploadComponent(injector) {
6642
6681
  // override setValue function to allow for setting an array value
6643
6682
  class UploaderComponent extends originalUploadComponent {
6644
6683
  setValue(value) {
6645
- let componentValue = this._customAngularElement?.value;
6646
- if (componentValue) {
6647
- componentValue = value;
6684
+ if (this._customAngularElement?.value) {
6685
+ this._customAngularElement.value = value;
6648
6686
  }
6649
6687
  return true;
6650
6688
  }
@@ -6682,6 +6720,16 @@ const documentenApiUploaderEditForm = () => ({
6682
6720
  required: true,
6683
6721
  },
6684
6722
  },
6723
+ {
6724
+ type: 'checkbox',
6725
+ input: true,
6726
+ inputType: 'checkbox',
6727
+ key: 'validate.required',
6728
+ label: 'Required',
6729
+ validate: {
6730
+ required: false,
6731
+ },
6732
+ },
6685
6733
  {
6686
6734
  type: 'textfield',
6687
6735
  input: true,
@@ -6980,7 +7028,9 @@ function registerDocumentenApiFormioUploadComponent(injector) {
6980
7028
  // override setValue function to allow for setting an array value
6981
7029
  class UploaderComponent extends originalUploadComponent {
6982
7030
  setValue(value) {
6983
- this._customAngularElement.value = value;
7031
+ if (this._customAngularElement?.value) {
7032
+ this._customAngularElement.value = value;
7033
+ }
6984
7034
  return true;
6985
7035
  }
6986
7036
  }