Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a toolbar for selecting and deselecting all comics [#584]
* Added the toolbar to the library page. * Added the toolbar to the comic group page. * Renamed AllComics => Library. * Renamed ComicGroup => LibraryGroup.
- Loading branch information
Showing
20 changed files
with
265 additions
and
40 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
comixed-web/src/app/library/components/library-toolbar/library-toolbar.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<mat-toolbar> | ||
<div class="cx-spacer"></div> | ||
<button | ||
id="select-all-button" | ||
mat-flat-button | ||
color="primary" | ||
class="cx-action-button cx-margin-right-5" | ||
[disabled]="!comics.length" | ||
[matTooltip]="'library.tooltip.select-all' | translate" | ||
(click)="onSelectAll()" | ||
> | ||
<mat-icon>check_box</mat-icon> | ||
<mat-label>{{ "button.select-all" | translate }}</mat-label> | ||
</button> | ||
<button | ||
id="deselect-all-button" | ||
mat-flat-button | ||
color="warn" | ||
class="cx-action-button cx-margin-right-5" | ||
[disabled]="!selected.length" | ||
[matTooltip]="'library.tooltip.deselect-all' | translate" | ||
(click)="onDeselectAll()" | ||
> | ||
<mat-icon>check_box</mat-icon> | ||
<mat-label>{{ "button.deselect-all" | translate }}</mat-label> | ||
</button> | ||
</mat-toolbar> |
File renamed without changes.
92 changes: 92 additions & 0 deletions
92
comixed-web/src/app/library/components/library-toolbar/library-toolbar.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* ComiXed - A digital comic book library management application. | ||
* Copyright (C) 2021, The ComiXed Project | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses> | ||
*/ | ||
|
||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { LibraryToolbarComponent } from './library-toolbar.component'; | ||
import { LoggerModule } from '@angular-ru/logger'; | ||
import { MockStore, provideMockStore } from '@ngrx/store/testing'; | ||
import { COMIC_1, COMIC_2, COMIC_3 } from '@app/library/library.fixtures'; | ||
import { | ||
deselectComics, | ||
selectComics | ||
} from '@app/library/actions/library.actions'; | ||
import { TranslateModule } from '@ngx-translate/core'; | ||
import { MatToolbar, MatToolbarModule } from '@angular/material/toolbar'; | ||
import { MatIconModule } from '@angular/material/icon'; | ||
import { MatFormFieldModule } from '@angular/material/form-field'; | ||
import { MatTooltipModule } from '@angular/material/tooltip'; | ||
|
||
describe('LibraryToolbarComponent', () => { | ||
const COMICS = [COMIC_1, COMIC_2, COMIC_3]; | ||
const initialState = {}; | ||
|
||
let component: LibraryToolbarComponent; | ||
let fixture: ComponentFixture<LibraryToolbarComponent>; | ||
let store: MockStore<any>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [LibraryToolbarComponent], | ||
imports: [ | ||
LoggerModule.forRoot(), | ||
TranslateModule.forRoot(), | ||
MatToolbarModule, | ||
MatIconModule, | ||
MatFormFieldModule, | ||
MatTooltipModule | ||
], | ||
providers: [provideMockStore({ initialState })] | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(LibraryToolbarComponent); | ||
component = fixture.componentInstance; | ||
store = TestBed.inject(MockStore); | ||
spyOn(store, 'dispatch'); | ||
fixture.detectChanges(); | ||
})); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
describe('selecting all comics', () => { | ||
beforeEach(() => { | ||
component.comics = COMICS; | ||
component.onSelectAll(); | ||
}); | ||
|
||
it('fires an action', () => { | ||
expect(store.dispatch).toHaveBeenCalledWith( | ||
selectComics({ comics: COMICS }) | ||
); | ||
}); | ||
}); | ||
|
||
describe('deselecting all comics', () => { | ||
beforeEach(() => { | ||
component.selected = COMICS; | ||
component.onDeselectAll(); | ||
}); | ||
|
||
it('fires an action', () => { | ||
expect(store.dispatch).toHaveBeenCalledWith( | ||
deselectComics({ comics: COMICS }) | ||
); | ||
}); | ||
}); | ||
}); |
50 changes: 50 additions & 0 deletions
50
comixed-web/src/app/library/components/library-toolbar/library-toolbar.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* ComiXed - A digital comic book library management application. | ||
* Copyright (C) 2021, The ComiXed Project | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses> | ||
*/ | ||
|
||
import { Component, Input, OnInit } from '@angular/core'; | ||
import { Comic } from '@app/library'; | ||
import { LoggerService } from '@angular-ru/logger'; | ||
import { Store } from '@ngrx/store'; | ||
import { | ||
deselectComics, | ||
selectComics | ||
} from '@app/library/actions/library.actions'; | ||
|
||
@Component({ | ||
selector: 'cx-library-toolbar', | ||
templateUrl: './library-toolbar.component.html', | ||
styleUrls: ['./library-toolbar.component.scss'] | ||
}) | ||
export class LibraryToolbarComponent implements OnInit { | ||
@Input() comics: Comic[] = []; | ||
@Input() selected: Comic[] = []; | ||
|
||
constructor(private logger: LoggerService, private store: Store<any>) {} | ||
|
||
ngOnInit(): void {} | ||
|
||
onSelectAll(): void { | ||
this.logger.debug('Selecting all comics'); | ||
this.store.dispatch(selectComics({ comics: this.comics })); | ||
} | ||
|
||
onDeselectAll(): void { | ||
this.logger.debug('Deselecting all comics'); | ||
this.store.dispatch(deselectComics({ comics: this.selected })); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
comixed-web/src/app/library/pages/all-comics/all-comics.component.html
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
comixed-web/src/app/library/pages/comic-group/comic-group.component.html
This file was deleted.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
comixed-web/src/app/library/pages/library-group/library-group.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<cx-library-toolbar | ||
[comics]="comics" | ||
[selected]="selected" | ||
></cx-library-toolbar> | ||
<cx-comic-covers [comics]="comics"></cx-comic-covers> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
comixed-web/src/app/library/pages/library/library.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<cx-library-toolbar | ||
[comics]="comics" | ||
[selected]="selected" | ||
></cx-library-toolbar> | ||
<cx-comic-covers [comics]="comics"></cx-comic-covers> |
File renamed without changes.
Oops, something went wrong.