Why each entity that have pagination will add this Resolver ?
@Injectable()
export class UserResolvePagingParams implements Resolve<any> {
constructor(private paginationUtil: JhiPaginationUtil) {}
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
const page = route.queryParams['page'] ? route.queryParams['page'] : '1';
const sort = route.queryParams['sort'] ? route.queryParams['sort'] : 'id,asc';
return {
page: this.paginationUtil.parsePage(page),
predicate: this.paginationUtil.parsePredicate(sort),
ascending: this.paginationUtil.parseAscending(sort)
};
}
}
I think sort order , maybe different from entity to another entity that developer need to change after generated code .
We can send data to resolver and read this data in resolver
Like This
export const userMgmtRoute: Routes = [
{
path: 'user-management',
component: UserMgmtComponent,
resolve: {
'pagingParams': UserResolvePagingParams
},
data: {
pageTitle: 'userManagement.home.title'
}
}
];
to this
// in ng-jhipster
@Injectable()
export class EntityResolvePagingParams implements Resolve<any> {
constructor(private paginationUtil: JhiPaginationUtil) {}
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
const page = route.queryParams['page'] ? route.queryParams['page'] : '1';
const sort = route.queryParams['sort'] ? route.queryParams['sort'] : route.data['defaultSort'];
return {
page: this.paginationUtil.parsePage(page),
predicate: this.paginationUtil.parsePredicate(sort),
ascending: this.paginationUtil.parseAscending(sort)
};
}
}
// in entity.route.ts
export const userMgmtRoute: Routes = [
{
path: 'user-management',
component: UserMgmtComponent,
resolve: {
'pagingParams': EntityResolvePagingParams
},
data: {
pageTitle: 'userManagement.home.title',
defaultSort: 'id,asc'
}
}
];
Yes we can move it. Can you do PR?
Thanks & Regards,
Deepu
On Tue, Apr 3, 2018 at 4:46 PM Ali Akbar Azizkhani notifications@github.com
wrote:
Why each entity that have pagination will add this Resolver ?
@Injectable()
export class UserResolvePagingParams implements Resolve{ constructor(private paginationUtil: JhiPaginationUtil) {} resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { const page = route.queryParams['page'] ? route.queryParams['page'] : '1'; const sort = route.queryParams['sort'] ? route.queryParams['sort'] : 'id,asc'; return { page: this.paginationUtil.parsePage(page), predicate: this.paginationUtil.parsePredicate(sort), ascending: this.paginationUtil.parseAscending(sort) }; }}
I think sort order , maybe different from entity ro another entity that
developer need to change after generated code .
We can send data to resolver and read this data in resolverLike This
export const userMgmtRoute: Routes = [
{
path: 'user-management',
component: UserMgmtComponent,
resolve: {
'pagingParams': UserResolvePagingParams
},
data: {
pageTitle: 'userManagement.home.title'
}
}
];to this
// in ng-jhipster
@Injectable()
export class EntityResolvePagingParams implements Resolve{ constructor(private paginationUtil: JhiPaginationUtil) {} resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { const page = route.queryParams['page'] ? route.queryParams['page'] : '1'; const sort = route.queryParams['sort'] ? route.queryParams['sort'] : route.data['defaultSort']; return { page: this.paginationUtil.parsePage(page), predicate: this.paginationUtil.parsePredicate(sort), ascending: this.paginationUtil.parseAscending(sort) }; }}
// in entity.route.ts
export const userMgmtRoute: Routes = [
{
path: 'user-management',
component: UserMgmtComponent,
resolve: {
'pagingParams': EntityResolvePagingParams
},
data: {
pageTitle: 'userManagement.home.title',
defaultSort: 'id,asc'
}
}
];—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/jhipster/generator-jhipster/issues/7403, or mute the
thread
https://github.com/notifications/unsubscribe-auth/ABDlF2M92oDme0J9tKnF65fT7BsBSAB4ks5tk4s-gaJpZM4TFNtu
.
Yes I can do that
@deepu105
create entity-resolvePagingParams.ts in which directory? service directory? what is ts and class name?
It could be service I guess and use the same name as original
@deepu105 can i test with yarn link in sample-app?
yarn link works pretty weird, you could try, what i do is run npm pack to make a tarball and then npm install it on the generated project from the tarball
I think all my change is ok . but get this exception
https://github.com/azizkhani/ng-jhipster
TS2305: Module '"/Users/azizkhani/Data/git/ng-jhipster/index"' has no exported member 'JhiResolvePagingParams'.
I write test and complete source but after run test i get exception in language service ,
maybe problem is in package.json .
https://github.com/azizkhani/ng-jhipster
LanguageService Test
✖ should change Language
Chrome 65.0.3325 (Mac OS X 10.13.3)
Expected [object Promise] to equal [object Promise].
at UserContext.<anonymous> (webpack:///tests/language/language.service.spec.ts:22:0 <- config/spec-bundle.js:114651:38)
at TestBed.execute (webpack:///~/@angular/core/esm5/testing.js:1063:0 <- config/spec-bundle.js:22029:19)
at UserContext.<anonymous> (webpack:///~/@angular/core/esm5/testing.js:1207:28 <- config/spec-bundle.js:22173:45)
at ZoneDelegate.invoke (webpack:///~/zone.js/dist/zone.js:388:0 <- config/spec-bundle.js:91284:26)
at ProxyZoneSpec.onInvoke (webpack:///~/zone.js/dist/proxy.js:128:0 <- config/spec-bundle.js:90780:39)
at ZoneDelegate.invoke (webpack:///~/zone.js/dist/zone.js:387:0 <- config/spec-bundle.js:91283:32)
at Zone.run (webpack:///~/zone.js/dist/zone.js:138:0 <- config/spec-bundle.js:91034:43)
at runInTestZone (webpack:///~/zone.js/dist/jasmine-patch.js:139:0 <- config/spec-bundle.js:90353:34)
at UserContext.<anonymous> (webpack:///~/zone.js/dist/jasmine-patch.js:154:0 <- config/spec-bundle.js:90368:20)
at ZoneQueueRunner.jasmine.QueueRunner.ZoneQueueRunner.execute (webpack:///~/zone.js/dist/jasmine-patch.js:244:0 <- config/spec-bundle.js:90458:42)
at ZoneQueueRunner.jasmine.QueueRunner.ZoneQueueRunner.execute (webpack:///~/zone.js/dist/jasmine-patch.js:244:0 <- config/spec-bundle.js:90458:42)
at ZoneDelegate.invokeTask (webpack:///~/zone.js/dist/zone.js:421:0 <- config/spec-bundle.js:91317:31)
at Zone.runTask (webpack:///~/zone.js/dist/zone.js:188:0 <- config/spec-bundle.js:91084:47)
at drainMicroTaskQueue (webpack:///~/zone.js/dist/zone.js:595:0 <- config/spec-bundle.js:91491:35)
✖ should retain changed language even after force refresh
Chrome 65.0.3325 (Mac OS X 10.13.3)
Expected [object Promise] to equal [object Promise].
at UserContext.<anonymous> (webpack:///tests/language/language.service.spec.ts:27:0 <- config/spec-bundle.js:114656:38)
at TestBed.execute (webpack:///~/@angular/core/esm5/testing.js:1063:0 <- config/spec-bundle.js:22029:19)
at UserContext.<anonymous> (webpack:///~/@angular/core/esm5/testing.js:1207:28 <- config/spec-bundle.js:22173:45)
at ZoneDelegate.invoke (webpack:///~/zone.js/dist/zone.js:388:0 <- config/spec-bundle.js:91284:26)
at ProxyZoneSpec.onInvoke (webpack:///~/zone.js/dist/proxy.js:128:0 <- config/spec-bundle.js:90780:39)
at ZoneDelegate.invoke (webpack:///~/zone.js/dist/zone.js:387:0 <- config/spec-bundle.js:91283:32)
at Zone.run (webpack:///~/zone.js/dist/zone.js:138:0 <- config/spec-bundle.js:91034:43)
at runInTestZone (webpack:///~/zone.js/dist/jasmine-patch.js:139:0 <- config/spec-bundle.js:90353:34)
at UserContext.<anonymous> (webpack:///~/zone.js/dist/jasmine-patch.js:154:0 <- config/spec-bundle.js:90368:20)
at ZoneQueueRunner.jasmine.QueueRunner.ZoneQueueRunner.execute (webpack:///~/zone.js/dist/jasmine-patch.js:244:0 <- config/spec-bundle.js:90458:42)
at ZoneDelegate.invokeTask (webpack:///~/zone.js/dist/zone.js:421:0 <- config/spec-bundle.js:91317:31)
at Zone.runTask (webpack:///~/zone.js/dist/zone.js:188:0 <- config/spec-bundle.js:91084:47)
at drainMicroTaskQueue (webpack:///~/zone.js/dist/zone.js:595:0 <- config/spec-bundle.js:91491:35)
closing the issue as we have the PR to track in the lib
I just create resolver in ng-jhipster but generator dose not change yet .why did you closed this issue ?
@azizkhani its ok, since you are working on it anyway and i'm sure you will do a PR here as well :)
@deepu105 I changed generator but can not test ,
I think package.json of ng-jhipster that i change that, have problem and not correct .
can you see that ?