Skip to content

Commit c0ccb38

Browse files
Alvaro Camillo Netojhosefmarks
authored andcommitted
feat(page-dynamic-detail): adiciona propriedade serviceMetadataApi
Criação da propriedade `serviceLoadApi` para poder buscar as customizações das página por uma rota.
1 parent cd1fc89 commit c0ccb38

File tree

4 files changed

+138
-128
lines changed

4 files changed

+138
-128
lines changed

projects/templates/src/lib/components/po-page-dynamic-detail/po-page-dynamic-detail.component.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ describe('PoPageDynamicDetailComponent:', () => {
206206
.toHaveBeenCalledWith({ endpoint: component.serviceApi, metadata: undefined });
207207
});
208208

209-
it('should call `loadMetadata` with `id` and set `serviceApi` if `activatedRoute.snapshot.data.serviceApi` is truthy',
209+
it('should call `loadDataFromAPI` with `id` and set `serviceApi` if `activatedRoute.snapshot.data.serviceApi` is truthy',
210210
() => {
211211
const id = 1;
212212
const activatedRoute: any = {
@@ -354,7 +354,7 @@ describe('PoPageDynamicDetailComponent:', () => {
354354
});
355355

356356
describe('loadDataFromAPI', () => {
357-
it('should call `getMetadata` and set properties', fakeAsync(() => {
357+
it('should load the metadata and keep it if the onload property returns empty', fakeAsync(() => {
358358

359359
const activatedRoute: any = {
360360
snapshot: {

projects/templates/src/lib/components/po-page-dynamic-detail/po-page-dynamic-detail.component.ts

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,6 @@ export const poPageDynamicDetailLiteralsDefault = {
6464
*
6565
* ```
6666
* {
67-
* path: 'people',
68-
* component: PoPageDynamicDetailComponent,
69-
* data: {
70-
* serviceApi: 'http://localhost:3000/v1/people', // endpoint dos dados
71-
* serviceMetadataApi: 'http://localhost:3000/v1/metadata', // endpoint dos metadados utilizando o método HTTP Get
72-
* serviceLoadApi: 'http://localhost:3000/load-metadata' // endpoint de customizações dos metadados utilizando o método HTTP Post
73-
* }
74-
* }
75-
* ```
76-
*
77-
* Para carregar com um recurso já existente, deve ser incluído um parâmetro na rota chamado `id`:
78-
*
79-
* ```
80-
* {
8167
* path: 'people/:id',
8268
* component: PoPageDynamicDetailComponent,
8369
* data: {
@@ -113,7 +99,7 @@ export const poPageDynamicDetailLiteralsDefault = {
11399
*
114100
* > Caso o endpoint dos metadados não seja especificado, será feito uma requisição utilizando o `serviceApi` da seguinte forma:
115101
* ```
116-
* GET {end-point}/metadata?type=list&version={version}
102+
* GET {end-point}/metadata?type=detail&version={version}
117103
* ```
118104
*
119105
* @example
@@ -417,13 +403,13 @@ export class PoPageDynamicDetailComponent implements OnInit, OnDestroy {
417403
}
418404

419405
private loadDataFromAPI() {
420-
const { serviceApi: serviceApiFromRoute, serviceLoadApi } = this.activatedRoute.snapshot.data;
406+
const { serviceApi: serviceApiFromRoute, serviceMetadataApi, serviceLoadApi } = this.activatedRoute.snapshot.data;
421407
const { id } = this.activatedRoute.snapshot.params;
422408

423409
const onLoad = serviceLoadApi || this.onLoad;
424410
this.serviceApi = serviceApiFromRoute || this.serviceApi;
425411

426-
this.poPageDynamicService.configServiceApi({ endpoint: this.serviceApi });
412+
this.poPageDynamicService.configServiceApi({ endpoint: this.serviceApi, metadata: serviceMetadataApi });
427413

428414
const metadata$ = this.getMetadata(serviceApiFromRoute, onLoad);
429415
const data$ = this.loadData(id);

0 commit comments

Comments
 (0)