Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding the ability to have a hidden reset for the resources. #1086

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion projects/angular-formio/package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion projects/angular-formio/resource/src/resource.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
15 changes: 12 additions & 3 deletions projects/angular-formio/resource/src/resource.service.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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;
Expand Down
18 changes: 6 additions & 12 deletions projects/angular-formio/src/formio.config.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
Loading