From d71365297dd3f483d2646690fc5bfe00559ddf93 Mon Sep 17 00:00:00 2001 From: Travis Tidwell Date: Sun, 14 Jul 2024 17:48:16 -0500 Subject: [PATCH 1/4] Adding the ability to have a hidden reset for the resources. --- .../resource/src/resource.component.ts | 2 +- .../resource/src/resource.service.ts | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/projects/angular-formio/resource/src/resource.component.ts b/projects/angular-formio/resource/src/resource.component.ts index 42122bf9..4d53cd3f 100644 --- a/projects/angular-formio/resource/src/resource.component.ts +++ b/projects/angular-formio/resource/src/resource.component.ts @@ -32,7 +32,7 @@ export class FormioResourceComponent implements OnInit, OnDestroy { } init() { - return this.service.init(this.route).then(() => + return this.service.init(this.route, this.router).then(() => this.auth.ready.then(() => this.service.formFormio.userPermissions( this.auth.user, diff --git a/projects/angular-formio/resource/src/resource.service.ts b/projects/angular-formio/resource/src/resource.service.ts index 518cd1ad..83012e11 100644 --- a/projects/angular-formio/resource/src/resource.service.ts +++ b/projects/angular-formio/resource/src/resource.service.ts @@ -1,5 +1,5 @@ import { EventEmitter, Injectable, Optional } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; +import { ActivatedRoute, Router } from '@angular/router'; import { FormioResourceConfig } from './resource.config'; import { FormioResources } from './resources.service'; import { FormioPromiseService } from '@formio/angular'; @@ -84,9 +84,18 @@ export class FormioResourceService { this.resource = { data: {} }; } - init(route: ActivatedRoute) { + init(route: ActivatedRoute, router: Router = null) { const snapshot = route.snapshot; - const reset = snapshot.queryParams?.hasOwnProperty('reset') ? snapshot.queryParams.reset : false; + let reset = false; + if (snapshot.queryParams.hasOwnProperty('reset')) { + reset = snapshot.queryParams.reset; + } + else if (router) { + const navigation = router.getCurrentNavigation(); + if (navigation?.extras.state && navigation.extras.state.hasOwnProperty('reset')) { + reset = navigation.extras.state['reset']; + } + } const resourceId = snapshot.params['id']; if (resourceId && (resourceId === this.resourceId) && !reset) { return this.ready; From 6a0b2e4f34e9385784c09b91b60f080faa3ed51a Mon Sep 17 00:00:00 2001 From: Travis Tidwell Date: Sun, 14 Jul 2024 18:28:43 -0500 Subject: [PATCH 2/4] Ensure we don't crash if queryParams is null. --- projects/angular-formio/resource/src/resource.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/angular-formio/resource/src/resource.service.ts b/projects/angular-formio/resource/src/resource.service.ts index 83012e11..00322804 100644 --- a/projects/angular-formio/resource/src/resource.service.ts +++ b/projects/angular-formio/resource/src/resource.service.ts @@ -87,7 +87,7 @@ export class FormioResourceService { init(route: ActivatedRoute, router: Router = null) { const snapshot = route.snapshot; let reset = false; - if (snapshot.queryParams.hasOwnProperty('reset')) { + if (snapshot.queryParams?.hasOwnProperty('reset')) { reset = snapshot.queryParams.reset; } else if (router) { From a764b2964fde1e8027148aae1630f25273319ca0 Mon Sep 17 00:00:00 2001 From: Travis Tidwell Date: Sun, 14 Jul 2024 18:42:09 -0500 Subject: [PATCH 3/4] Updated version. --- CHANGELOG.md | 6 +++++- package.json | 2 +- projects/angular-formio/package.json | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d8e7fb7..59cac3e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,11 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. -## [Unreleased: 8.0.0-rc.3] +## 8.0.0-rc.5 +### Fixed + - Adding a way to reset the resource provider cache. + +## 8.0.0-rc.3 ### Changed - FIO-8667 fixed location of download PDF button - FIO-8638 fixed saving components after changing form display diff --git a/package.json b/package.json index 023c1816..0ade230c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@formio/angular", - "version": "8.0.0-rc.3", + "version": "8.0.0-rc.6", "scripts": { "ng": "ng", "build": "ng build angular-formio", diff --git a/projects/angular-formio/package.json b/projects/angular-formio/package.json index 1eb553ef..a5d17b11 100644 --- a/projects/angular-formio/package.json +++ b/projects/angular-formio/package.json @@ -1,6 +1,6 @@ { "name": "@formio/angular", - "version": "8.0.0-rc.3", + "version": "8.0.0-rc.6", "repository": { "type": "git", "url": "https://github.com/formio/angular-formio" From 2da738a8ee7b4584a512c63e82fe1a6bdb98980b Mon Sep 17 00:00:00 2001 From: Travis Tidwell Date: Fri, 26 Jul 2024 12:53:24 -0500 Subject: [PATCH 4/4] Fixing the AppConfig provider to be easier to use and reverse compatible. --- projects/angular-formio/src/formio.config.ts | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/projects/angular-formio/src/formio.config.ts b/projects/angular-formio/src/formio.config.ts index 66f2f3ee..1a8b8507 100644 --- a/projects/angular-formio/src/formio.config.ts +++ b/projects/angular-formio/src/formio.config.ts @@ -1,23 +1,17 @@ -import { Inject, Injectable, InjectionToken } from '@angular/core'; -export const FORMIO_CONFIG = new InjectionToken('formio-config'); +import { Injectable, OnInit } from '@angular/core'; import { Formio } from '@formio/js'; -@Injectable() -export class FormioAppConfig { +@Injectable({ + providedIn: 'root' +}) +export class FormioAppConfig implements OnInit { [x: string]: any; appUrl = ''; apiUrl = ''; icons?: string; formOnly?: boolean; formio?: Formio; - constructor(@Inject(FORMIO_CONFIG) config: { - apiUrl?: string, - baseUrl?: string, - appUrl?: string, - projectUrl?: string - } = {}) { - this.apiUrl = config.apiUrl || config.baseUrl; - this.appUrl = config.appUrl || config.projectUrl; + ngOnInit(): void { if (this.apiUrl) { Formio.setBaseUrl(this.apiUrl); Formio.setProjectUrl(this.appUrl);