Skip to content

Commit 3fe3ef0

Browse files
add back to list component
1 parent 8a7abd3 commit 3fe3ef0

19 files changed

+75
-48
lines changed

src/generators/AngularGenerator.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ export default class extends BaseGenerator {
3434
"app/components/common/svg/edit-svg/edit-svg.component.ts",
3535
"app/components/common/svg/menu/menu.component.svg",
3636
"app/components/common/svg/menu/menu.component.ts",
37+
"app/components/common/back-to-list/back-to-list.component.html",
38+
"app/components/common/back-to-list/back-to-list.component.ts",
3739

3840
// COMPONENTS
3941
"app/components/foo/create/create.component.html",
@@ -122,6 +124,7 @@ export default class extends BaseGenerator {
122124
`${dir}/app/components/${lc}/list`,
123125
`${dir}/app/components/${lc}/show`,
124126
`${dir}/app/components/${lc}/table`,
127+
`${dir}/app/components/common/back-to-list`,
125128
`${dir}/app/components/common/delete`,
126129
`${dir}/app/components/common/header`,
127130
`${dir}/app/components/common/sidebar`,
@@ -153,6 +156,8 @@ export default class extends BaseGenerator {
153156
"app/components/common/sidebar/sidebar.component.css",
154157
"app/components/common/sidebar/sidebar.component.html",
155158
"app/components/common/sidebar/sidebar.component.ts",
159+
"app/components/common/back-to-list/back-to-list.component.html",
160+
"app/components/common/back-to-list/back-to-list.component.ts",
156161
"app/interface/api.ts",
157162
"app/service/api.service.ts",
158163
"app/app.component.html",
@@ -182,6 +187,11 @@ export default class extends BaseGenerator {
182187
this.createFileFromPattern(file, dir, [lc, formFields], context)
183188
);
184189

190+
//UTILS
191+
["utils/date.ts"].forEach((path) =>
192+
this.createFile(path, `${dir}/app/${path}`, context, false)
193+
);
194+
185195
// CONFIG
186196
this.createConfigFile(`${dir}/app/utils/config.ts`, {
187197
entrypoint: api.entrypoint,
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<a [routerLink]="url"
2+
class="text-blue-600 hover:text-blue-800">
3+
Back to list
4+
</a>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import {Component, Input} from '@angular/core';
2+
import {RouterLink} from "@angular/router";
3+
4+
@Component({
5+
selector: 'app-back-to-list',
6+
standalone: true,
7+
imports: [
8+
RouterLink
9+
],
10+
templateUrl: './back-to-list.component.html'
11+
})
12+
export class BackToListComponent {
13+
@Input() url!: string;
14+
}

templates/angular/app/components/common/pagination/pagination.component.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<li>
55
<a [routerLink]="['/books']"
66
[routerLinkActive]="'bg-gray-200 text-gray-500 pointer-events-none'"
7-
(click)="changeUri(pagination()['hydra:first'])"
7+
(click)="paginationAction(pagination()['hydra:first'])"
88
class="bg-gray block py-2 px-3 rounded"
99
aria-label="First page">
1010
<span aria-hidden="true">&lArr;</span>First
@@ -15,7 +15,7 @@
1515
<a [routerLink]="['/books']"
1616
[queryParams]="pageParamValue('hydra:previous')"
1717
[routerLinkActive]="'bg-gray-200 text-gray-500 pointer-events-none'"
18-
(click)="changeUri(pagination()['hydra:previous'])"
18+
(click)="paginationAction(pagination()['hydra:previous'])"
1919
class="bg-gray block py-2 px-3 rounded"
2020
aria-label="Previous page">
2121
Previous
@@ -27,7 +27,7 @@
2727
<a [routerLink]="['/books']"
2828
[queryParams]="pageParamValue('hydra:next')"
2929
[routerLinkActive]="'bg-gray-200 text-gray-500 pointer-events-none'"
30-
(click)="changeUri(pagination()['hydra:next'])"
30+
(click)="paginationAction(pagination()['hydra:next'])"
3131
class="bg-gray block py-2 px-3 rounded"
3232
aria-label="Next page">
3333
Next
@@ -38,7 +38,7 @@
3838
<a [routerLink]="['/books']"
3939
[queryParams]="pageParamValue('hydra:last')"
4040
[routerLinkActive]="'bg-gray-200 text-gray-500 pointer-events-none'"
41-
(click)="changeUri(pagination()['hydra:last'])"
41+
(click)="paginationAction(pagination()['hydra:last'])"
4242
class="bg-gray block py-2 px-3 rounded"
4343
aria-label="Last page">
4444
<span aria-hidden="true">&rAarr;</span> Last

templates/angular/app/components/common/pagination/pagination.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class PaginationComponent {
2323
}
2424
}
2525

26-
changeUri (uri: string) {
26+
paginationAction (uri: string) {
2727
this.handleChangePage.emit(uri)
2828
}
2929
}

templates/angular/app/components/common/svg/edit-svg/edit-svg.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import { Component } from '@angular/core';
44
selector: 'app-edit-svg',
55
standalone: true,
66
imports: [],
7-
templateUrl: './edit-svg.component.svg',
8-
styleUrl: './edit-svg.component.css'
7+
templateUrl: './edit-svg.component.svg'
98
})
109
export class EditSvgComponent {
1110

templates/angular/app/components/common/svg/show-svg/show-svg.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import { Component } from '@angular/core';
44
selector: 'app-show-svg',
55
standalone: true,
66
imports: [],
7-
templateUrl: './show-svg.component.svg',
8-
styleUrl: './show-svg.component.css'
7+
templateUrl: './show-svg.component.svg'
98
})
109
export class ShowSvgComponent {
1110

templates/angular/app/components/foo/create/create.component.html

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
<div class=" w-full px-4 mt-4">
22
<div class="flex items-center justify-between">
3-
<a [routerLink]="['/{{lc}}']"
4-
class="text-blue-600 hover:text-blue-800">
5-
Back to list
6-
</a>
3+
<app-back-to-list url="/{{lc}}s" />
74
</div>
85
@if (isLoading()) {
96
<div class="bg-blue-100 rounded py-4 px-4 text-blue-700 text-sm">Loading ...</div>

templates/angular/app/components/foo/create/create.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {Location} from "@angular/common";
22
import {Component, inject, signal, WritableSignal} from '@angular/core';
33
import {FormsModule, ReactiveFormsModule} from "@angular/forms";
44
import {RouterLink} from "@angular/router";
5+
import {BackToListComponent} from "@components/common/back-to-list/back-to-list.component";
56
import {DeleteComponent} from "@components/common/delete/delete.component";
67
import {FormComponent} from "@components/{{lc}}/form/form.component";
78
import {ApiItem} from "@interface/api";
@@ -11,6 +12,7 @@ import {ApiService} from "@service/api.service";
1112
selector: 'app-create-{{lc}}',
1213
standalone: true,
1314
imports: [
15+
BackToListComponent,
1416
DeleteComponent,
1517
RouterLink,
1618
FormsModule,

templates/angular/app/components/foo/edit/edit.component.html

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
<div class="px-4 mt-4">
22
<div class="flex items-center justify-end">
3-
<a [routerLink]="['/{{lc}}']"
4-
class="text-blue-600 hover:text-blue-800">
5-
Back to list
6-
</a>
3+
<app-back-to-list url="/{{lc}}s" />
74
</div>
85
@if (isLoading()) {
96
<div class="bg-blue-100 rounded py-4 px-4 text-blue-700 text-sm">Loading ...</div>

0 commit comments

Comments
 (0)