Skip to content

Commit 04bd01d

Browse files
authored
refactor: make app standalone (#136)
1 parent 5154ed7 commit 04bd01d

37 files changed

+295
-260
lines changed

src/app/app.component.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
2-
import { NavigationEnd, NavigationStart, Router } from '@angular/router';
2+
import { NavigationEnd, NavigationStart, Router, RouterOutlet } from '@angular/router';
33
import { merge, Observable } from 'rxjs';
44
import { filter, mapTo } from 'rxjs/operators';
5+
import { MatProgressBar } from '@angular/material/progress-bar';
6+
import { AsyncPipe, NgIf } from '@angular/common';
57

68
@Component({
9+
standalone: true,
710
selector: 'ac-root',
811
templateUrl: './app.component.html',
912
styleUrls: ['./app.component.scss'],
10-
changeDetection: ChangeDetectionStrategy.OnPush
13+
changeDetection: ChangeDetectionStrategy.OnPush,
14+
imports: [RouterOutlet, AsyncPipe, NgIf, MatProgressBar]
1115
})
1216
export class AppComponent implements OnInit {
1317
loading$: Observable<boolean>;

src/app/app.config.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { ApplicationConfig } from '@angular/core';
2+
import { provideState, provideStore } from '@ngrx/store';
3+
import { provideStoreDevtools } from '@ngrx/store-devtools';
4+
import { environment } from '../environments/environment';
5+
import { ROOT_REDUCER, USER_PROVIDED_META_REDUCERS } from './state/app.state';
6+
import { PreloadAllModules, provideRouter, withPreloading } from '@angular/router';
7+
import { APP_ROUTES } from './app.routes';
8+
import { provideRouterStore } from '@ngrx/router-store';
9+
import { provideAnimations } from '@angular/platform-browser/animations';
10+
import { checklistReducer } from './checklist/state/checklist.reducer';
11+
import { projectsReducer } from './projects/state/projects.reducer';
12+
import { MAT_CHECKBOX_DEFAULT_OPTIONS, MatCheckboxDefaultOptions } from '@angular/material/checkbox';
13+
14+
export const appConfig: ApplicationConfig = {
15+
providers: [
16+
provideAnimations(),
17+
provideRouter(APP_ROUTES, withPreloading(PreloadAllModules)),
18+
provideStore(ROOT_REDUCER, {
19+
metaReducers: USER_PROVIDED_META_REDUCERS
20+
}),
21+
provideState('checklist', checklistReducer),
22+
provideState('projects', projectsReducer),
23+
provideStoreDevtools({
24+
maxAge: 25,
25+
logOnly: environment.production,
26+
connectInZone: true
27+
}),
28+
provideRouterStore(),
29+
30+
// material design
31+
{
32+
provide: MAT_CHECKBOX_DEFAULT_OPTIONS,
33+
useValue: { clickAction: 'noop' } as MatCheckboxDefaultOptions
34+
}
35+
]
36+
};

src/app/app.module.ts

Lines changed: 0 additions & 39 deletions
This file was deleted.

src/app/app.routes.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { Routes } from '@angular/router';
22

33
export const APP_ROUTES: Routes = [
4-
{ path: '', redirectTo: '/projects', pathMatch: 'full' },
5-
{ path: '**', redirectTo: '/projects' }
4+
{ path: 'projects', loadChildren: () => import('./projects/projects.routes').then(m => m.PROJECTS_ROUTES) },
5+
{
6+
path: ':project/checklist',
7+
loadChildren: () => import('./checklist/checklist.routes').then(m => m.CHECKLIST_ROUTES)
8+
},
9+
{ path: '', redirectTo: 'projects', pathMatch: 'full' }
610
];

src/app/app.server.module.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/app/checklist/checklist-cta-bar/checklist-cta-bar.component.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import { Component, Input, Output, EventEmitter } from '@angular/core';
22
import { ChecklistFilter } from '../models/checklist.model';
3+
import { MatIcon } from '@angular/material/icon';
4+
import { MatButton } from '@angular/material/button';
5+
import { NgIf } from '@angular/common';
36

47
@Component({
8+
standalone: true,
59
selector: 'ac-checklist-cta-bar',
610
templateUrl: './checklist-cta-bar.component.html',
7-
styleUrls: ['./checklist-cta-bar.component.scss']
11+
styleUrls: ['./checklist-cta-bar.component.scss'],
12+
imports: [NgIf, MatButton, MatIcon]
813
})
914
export class ChecklistCtaBarComponent {
1015
@Input() filter: ChecklistFilter;

src/app/checklist/checklist-detail-view/checklist-detail-view.component.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,18 @@ import { ToggleFavorite, ToggleItem } from '../../projects/state/projects.action
55
import { ApplicationState } from '../../state/app.state';
66
import { ChecklistItem } from '../models/checklist.model';
77
import { ChecklistSelectors } from '../state/checklist.selectors';
8+
import { BannerComponent } from '../../shared/banner/banner.component';
9+
import { ChecklistMetadataComponent } from '../checklist-item-metadata/checklist-metadata.component';
10+
import { ChecklistFavoriteButtonComponent } from '../checklist-favorite-button/checklist-favorite-button.component';
11+
import { MatCheckbox } from '@angular/material/checkbox';
12+
import { NgIf, AsyncPipe } from '@angular/common';
813

914
@Component({
15+
standalone: true,
1016
selector: 'ac-checklist-detail-view',
1117
templateUrl: './checklist-detail-view.component.html',
12-
styleUrls: ['./checklist-detail-view.component.scss']
18+
styleUrls: ['./checklist-detail-view.component.scss'],
19+
imports: [NgIf, MatCheckbox, ChecklistFavoriteButtonComponent, ChecklistMetadataComponent, BannerComponent, AsyncPipe]
1320
})
1421
export class ChecklistDetailViewComponent implements OnInit {
1522
item$: Observable<any>;

src/app/checklist/checklist-favorite-button/checklist-favorite-button.component.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import { Component, Output, EventEmitter, Input } from '@angular/core';
2+
import { MatIcon } from '@angular/material/icon';
3+
import { NgStyle } from '@angular/common';
4+
import { MatIconButton } from '@angular/material/button';
25

36
@Component({
7+
standalone: true,
48
selector: 'ac-checklist-favorite-button',
59
templateUrl: './checklist-favorite-button.component.html',
6-
styleUrls: ['./checklist-favorite-button.component.scss']
10+
styleUrls: ['./checklist-favorite-button.component.scss'],
11+
imports: [MatIconButton, NgStyle, MatIcon]
712
})
813
export class ChecklistFavoriteButtonComponent {
914
_style = {};

src/app/checklist/checklist-favorites-view/checklist-favorites-view.component.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,17 @@ import { ApplicationState } from '../../state/app.state';
66
import { ChecklistFilter, ChecklistItem, Favorite } from '../models/checklist.model';
77
import { SetFavoritesFilter } from '../state/checklist.actions';
88
import { ChecklistSelectors } from '../state/checklist.selectors';
9+
import { ChecklistListItemComponent } from '../checklist-list/checklist-list-item.component';
10+
import { ChecklistListComponent } from '../checklist-list/checklist-list.component';
11+
import { NgIf, NgFor, AsyncPipe } from '@angular/common';
12+
import { ChecklistCtaBarComponent } from '../checklist-cta-bar/checklist-cta-bar.component';
913

1014
@Component({
15+
standalone: true,
1116
selector: 'ac-checklist-favorites-view',
1217
templateUrl: './checklist-favorites-view.component.html',
13-
styleUrls: ['./checklist-favorites-view.component.scss']
18+
styleUrls: ['./checklist-favorites-view.component.scss'],
19+
imports: [ChecklistCtaBarComponent, NgIf, NgFor, ChecklistListComponent, ChecklistListItemComponent, AsyncPipe]
1420
})
1521
export class ChecklistFavoritesViewComponent implements OnInit {
1622
favorites$: Observable<Array<Favorite>>;

src/app/checklist/checklist-item-metadata/checklist-metadata.component.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import { Component, Input } from '@angular/core';
22
import { Author } from '../models/checklist.model';
3+
import { NgIf } from '@angular/common';
34

45
@Component({
6+
standalone: true,
57
selector: 'ac-checklist-metadata',
68
templateUrl: './checklist-metadata.component.html',
7-
styleUrls: ['./checklist-metadata.component.scss']
9+
styleUrls: ['./checklist-metadata.component.scss'],
10+
imports: [NgIf]
811
})
912
export class ChecklistMetadataComponent {
1013
@Input() author: Author;

src/app/checklist/checklist-list-view/checklist-list-view.component.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,17 @@ import { ApplicationState } from '../../state/app.state';
88
import { CategoryEntity, ChecklistFilter, ChecklistItem } from '../models/checklist.model';
99
import { SetCategoriesFilter } from '../state/checklist.actions';
1010
import { ChecklistSelectors } from '../state/checklist.selectors';
11+
import { ChecklistListItemComponent } from '../checklist-list/checklist-list-item.component';
12+
import { NgFor, AsyncPipe } from '@angular/common';
13+
import { ChecklistListComponent } from '../checklist-list/checklist-list.component';
14+
import { ChecklistCtaBarComponent } from '../checklist-cta-bar/checklist-cta-bar.component';
1115

1216
@Component({
17+
standalone: true,
1318
selector: 'ac-list-view',
1419
templateUrl: './checklist-list-view.component.html',
15-
styleUrls: ['./checklist-list-view.component.scss']
20+
styleUrls: ['./checklist-list-view.component.scss'],
21+
imports: [ChecklistCtaBarComponent, ChecklistListComponent, NgFor, ChecklistListItemComponent, AsyncPipe]
1622
})
1723
export class ListViewComponent implements OnInit {
1824
items$: Observable<any>;

src/app/checklist/checklist-list/checklist-list-item.component.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
import { Component, Input, Output, EventEmitter } from '@angular/core';
22
import { ChecklistItem } from '../models/checklist.model';
3+
import { ChecklistFavoriteButtonComponent } from '../checklist-favorite-button/checklist-favorite-button.component';
4+
import { ChipComponent } from '../../shared/chip/chip.component';
5+
import { NgIf } from '@angular/common';
6+
import { RouterLink } from '@angular/router';
7+
import { MatCheckbox } from '@angular/material/checkbox';
38

49
@Component({
10+
standalone: true,
511
selector: 'ac-checklist-list-item',
612
templateUrl: './checklist-list-item.component.html',
7-
styleUrls: ['./checklist-list-item.component.scss']
13+
styleUrls: ['./checklist-list-item.component.scss'],
14+
imports: [MatCheckbox, RouterLink, NgIf, ChipComponent, ChecklistFavoriteButtonComponent]
815
})
916
export class ChecklistListItemComponent {
1017
@Input() item: ChecklistItem;

src/app/checklist/checklist-list/checklist-list.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Component } from '@angular/core';
22

33
@Component({
4+
standalone: true,
45
selector: 'ac-checklist-list',
56
template: '<ng-content></ng-content>',
67
styleUrls: ['./checklist-list.component.scss']

src/app/checklist/checklist-overview/checklist-overview.component.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { animate, query, stagger, style, transition, trigger } from '@angular/animations';
22
import { Component, OnInit } from '@angular/core';
3-
import { ActivatedRoute, Router } from '@angular/router';
3+
import { ActivatedRoute, Router, RouterOutlet } from '@angular/router';
44
import { select, Store } from '@ngrx/store';
55
import { Observable, zip } from 'rxjs';
66
import { filter, switchMap, tap } from 'rxjs/operators';
@@ -9,11 +9,15 @@ import { extractRouteParams, getActivatedChild } from '../../shared/router.utils
99
import { ApplicationState } from '../../state/app.state';
1010
import { Category, ChecklistItem } from '../models/checklist.model';
1111
import { ChecklistSelectors } from '../state/checklist.selectors';
12+
import { MatIcon } from '@angular/material/icon';
13+
import { NgIf, NgFor, AsyncPipe } from '@angular/common';
1214

1315
@Component({
16+
standalone: true,
1417
selector: 'ac-checklist-overview',
1518
templateUrl: './checklist-overview.component.html',
1619
styleUrls: ['./checklist-overview.component.scss'],
20+
imports: [NgIf, NgFor, MatIcon, RouterOutlet, AsyncPipe],
1721
animations: [
1822
trigger('breadcrumb', [
1923
transition('* <=> *', [

src/app/checklist/checklist-search/checklist-search.component.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
import { Component, OnInit } from '@angular/core';
2-
import { FormControl } from '@angular/forms';
3-
import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
2+
import { FormControl, ReactiveFormsModule } from '@angular/forms';
3+
import { MatAutocompleteSelectedEvent, MatAutocompleteTrigger, MatAutocomplete } from '@angular/material/autocomplete';
44
import { Router } from '@angular/router';
55
import * as fuzzysort from 'fuzzysort';
66
import { BehaviorSubject, combineLatest, Observable } from 'rxjs';
77
import { debounceTime, map, switchMap } from 'rxjs/operators';
88
import { CategoryEntity, ChecklistItem } from '../models/checklist.model';
99
import { IndexEntry, SearchResult } from '../search/search.models';
1010
import { SearchService } from '../search/search.service';
11+
import { MatOption } from '@angular/material/core';
12+
import { NgFor, NgIf, AsyncPipe } from '@angular/common';
1113

1214
@Component({
15+
standalone: true,
1316
selector: 'ac-checklist-search',
1417
templateUrl: './checklist-search.component.html',
15-
styleUrls: ['./checklist-search.component.scss']
18+
styleUrls: ['./checklist-search.component.scss'],
19+
imports: [ReactiveFormsModule, MatAutocompleteTrigger, MatAutocomplete, NgFor, MatOption, NgIf, AsyncPipe]
1620
})
1721
export class ChecklistSearchComponent implements OnInit {
1822
results$: Observable<any>;

src/app/checklist/checklist.component.ts

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component, OnInit, ViewChild } from '@angular/core';
2-
import { MatSidenav, MatDrawerMode } from '@angular/material/sidenav';
2+
import { MatSidenav, MatDrawerMode, MatSidenavContainer, MatSidenavContent } from '@angular/material/sidenav';
33
import { MatDialog } from '@angular/material/dialog';
4-
import { Router } from '@angular/router';
4+
import { Router, RouterLink, RouterLinkActive, RouterOutlet } from '@angular/router';
55
import { select, Store } from '@ngrx/store';
66
import { BehaviorSubject, combineLatest, Observable, of, zip } from 'rxjs';
77
import { filter, map, switchMap } from 'rxjs/operators';
@@ -16,16 +16,59 @@ import { ConfirmationDialogComponent } from './confirmation-dialog/confirmation-
1616
import { Category, ChecklistItem } from './models/checklist.model';
1717
import { ToggleEditMode } from './state/checklist.actions';
1818
import { ChecklistSelectors } from './state/checklist.selectors';
19+
import { FooterComponent } from '../shared/footer/footer.component';
20+
import { MatCheckbox } from '@angular/material/checkbox';
21+
import { MatSlideToggle } from '@angular/material/slide-toggle';
22+
import { MatBadge } from '@angular/material/badge';
23+
import { ScoreChartComponent } from '../shared/score-chart/score-chart.component';
24+
import { ChecklistSearchComponent } from './checklist-search/checklist-search.component';
25+
import { NgIf, NgFor, AsyncPipe } from '@angular/common';
26+
import {
27+
DropdownStaticOptionsComponent,
28+
DropdownStaticOptionComponent
29+
} from '../shared/dropdown/dropdown-static-options.component';
30+
import { DropdownComponent } from '../shared/dropdown/dropdown.component';
31+
import { ToolbarLogoComponent } from '../shared/toolbar/toolbar-logo/toolbar-logo.component';
32+
import { MatIcon } from '@angular/material/icon';
33+
import { MatIconButton } from '@angular/material/button';
34+
import { ToolbarComponent } from '../shared/toolbar/toolbar.component';
35+
import { SearchService } from './search/search.service';
1936

2037
enum CategoryListMode {
2138
List,
2239
Edit
2340
}
2441

2542
@Component({
43+
standalone: true,
2644
selector: 'ac-checklist',
2745
templateUrl: './checklist.component.html',
28-
styleUrls: ['./checklist.component.scss']
46+
styleUrls: ['./checklist.component.scss'],
47+
imports: [
48+
ToolbarComponent,
49+
MatIconButton,
50+
MatIcon,
51+
ToolbarLogoComponent,
52+
DropdownComponent,
53+
DropdownStaticOptionsComponent,
54+
DropdownStaticOptionComponent,
55+
RouterLink,
56+
NgIf,
57+
ChecklistSearchComponent,
58+
MatSidenavContainer,
59+
MatSidenav,
60+
ScoreChartComponent,
61+
RouterLinkActive,
62+
MatBadge,
63+
MatSlideToggle,
64+
NgFor,
65+
MatCheckbox,
66+
MatSidenavContent,
67+
RouterOutlet,
68+
FooterComponent,
69+
AsyncPipe
70+
],
71+
providers: [SearchService]
2972
})
3073
export class ChecklistComponent implements OnInit {
3174
private editMode$ = new BehaviorSubject(CategoryListMode.List);

0 commit comments

Comments
 (0)