Skip to content

Commit 0f0db81

Browse files
authored
Merge pull request #1086 from formio/hidden-reset
Adding the ability to have a hidden reset for the resources.
2 parents 2021767 + e1ffb5b commit 0f0db81

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

projects/angular-formio/resource/src/resource.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class FormioResourceComponent implements OnInit, OnDestroy {
3434
}
3535

3636
init() {
37-
return this.service.init(this.route).then(() =>
37+
return this.service.init(this.route, this.router).then(() =>
3838
this.auth.ready.then(() =>
3939
this.service.formFormio.userPermissions(
4040
this.auth.user,

projects/angular-formio/resource/src/resource.service.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { EventEmitter, Injectable, Optional } from '@angular/core';
2-
import { ActivatedRoute } from '@angular/router';
2+
import { ActivatedRoute, Router } from '@angular/router';
33
import { FormioResourceConfig } from './resource.config';
44
import { FormioResources } from './resources.service';
55
import { FormioPromiseService } from '@formio/angular';
@@ -84,9 +84,18 @@ export class FormioResourceService {
8484
this.resource = { data: {} };
8585
}
8686

87-
init(route: ActivatedRoute) {
87+
init(route: ActivatedRoute, router: Router = null) {
8888
const snapshot = route.snapshot;
89-
const reset = snapshot.queryParams?.hasOwnProperty('reset') ? snapshot.queryParams.reset : false;
89+
let reset = false;
90+
if (snapshot.queryParams?.hasOwnProperty('reset')) {
91+
reset = snapshot.queryParams.reset;
92+
}
93+
else if (router) {
94+
const navigation = router.getCurrentNavigation();
95+
if (navigation?.extras.state && navigation.extras.state.hasOwnProperty('reset')) {
96+
reset = navigation.extras.state['reset'];
97+
}
98+
}
9099
const resourceId = snapshot.params['id'];
91100
if (resourceId && (resourceId === this.resourceId) && !reset) {
92101
return this.ready;

0 commit comments

Comments
 (0)