diff --git a/package.json b/package.json index dfa6db87..a6b8b905 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ "chart.js": "^2.9.3", "crypto": "^1.0.1", "fork-awesome": "^1.1.7", + "ng-keyboard-shortcuts": "^10.1.17", "ng2-charts": "^2.3.0", "ngx-clipboard": "^13.0.0", "ngx-markdown": "^9.0.0", diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 779952c4..551500ff 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,4 +1,4 @@ -import { Component, OnDestroy, OnInit } from '@angular/core'; +import { AfterViewInit, Component, OnDestroy, OnInit } from '@angular/core'; import { Title } from '@angular/platform-browser'; import { Subscription } from 'rxjs'; @@ -8,6 +8,8 @@ import { LanguageService } from './core/services/language.service'; import { ThemeService } from './core/services/theme.service'; import { NavigationEnd, Router, RouterOutlet } from '@angular/router'; import { slideInAnimation } from './shared/animations/main'; +import { FramaKeyboardShortcuts } from './shared/shortcuts/main'; +import { ShortcutInput } from 'ng-keyboard-shortcuts'; @Component({ selector: 'app-root', @@ -15,7 +17,9 @@ import { slideInAnimation } from './shared/animations/main'; styleUrls: ['./app.component.scss'], animations: [slideInAnimation], }) -export class AppComponent implements OnInit, OnDestroy { +export class AppComponent implements OnInit, OnDestroy, AfterViewInit { + shortcuts: ShortcutInput[] = FramaKeyboardShortcuts; + public appTitle: string = environment.appTitle; public appLogo: string = environment.appLogo; public themeClass: string; @@ -61,6 +65,15 @@ export class AppComponent implements OnInit, OnDestroy { } }); } + ngAfterViewInit() { + this.shortcuts.push({ + key: ['cmd + g'], + label: 'Help', + description: 'Command + G', + command: (e) => console.log(e), + preventDefault: true, + }); + } ngOnDestroy(): void { if (this.themeSubscription) { diff --git a/src/app/app.module.ts b/src/app/app.module.ts index c691b1e0..27923488 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -28,6 +28,8 @@ import { LegalComponent } from './features/shared/components/ui/static-pages/leg import { PrivacyComponent } from './features/shared/components/ui/static-pages/privacy/privacy.component'; import { CipheringComponent } from './features/shared/components/ui/static-pages/ciphering/ciphering.component'; import { ErrorsListComponent } from './features/shared/components/ui/form/errors-list/errors-list.component'; +import { KeyboardShortcutsModule } from 'ng-keyboard-shortcuts'; +import { AdministrationModule } from './features/administration/administration.module'; registerLocaleData(localeEn, 'en-EN'); registerLocaleData(localeFr, 'fr-FR'); @@ -45,6 +47,7 @@ export function HttpLoaderFactory(http: HttpClient): TranslateHttpLoader { declarations: [AppComponent, CguComponent, LegalComponent, PrivacyComponent, CipheringComponent], imports: [ AppRoutingModule, + AdministrationModule, BrowserAnimationsModule, BrowserModule, ClipboardModule, @@ -52,6 +55,7 @@ export function HttpLoaderFactory(http: HttpClient): TranslateHttpLoader { CoreModule, FormsModule, HttpClientModule, + KeyboardShortcutsModule.forRoot(), MarkdownModule.forRoot(), NgxWebstorageModule.forRoot({ prefix: environment.localStorage.key }), SharedModule, diff --git a/src/app/core/services/date.utilities.service.ts b/src/app/core/services/date.utilities.service.ts index d65ac4b2..d60d9391 100644 --- a/src/app/core/services/date.utilities.service.ts +++ b/src/app/core/services/date.utilities.service.ts @@ -104,22 +104,22 @@ export class DateUtilitiesService { return [ { literal: this.formateDateToInputStringNg(ladate), - timeList: defaultTimeOfDay, + timeList: Object.create(defaultTimeOfDay), date_object: ladate, }, { literal: this.formateDateToInputStringNg(ladate2), - timeList: defaultTimeOfDay, + timeList: Object.create(defaultTimeOfDay), date_object: ladate2, }, { literal: this.formateDateToInputStringNg(ladate3), - timeList: defaultTimeOfDay, + timeList: Object.create(defaultTimeOfDay), date_object: ladate3, }, { literal: this.formateDateToInputStringNg(ladate4), - timeList: defaultTimeOfDay, + timeList: Object.create(defaultTimeOfDay), date_object: ladate4, }, ]; diff --git a/src/app/features/administration/administration.module.ts b/src/app/features/administration/administration.module.ts index d4b00a17..2bf4c1ed 100644 --- a/src/app/features/administration/administration.module.ts +++ b/src/app/features/administration/administration.module.ts @@ -18,7 +18,6 @@ import { BaseConfigComponent } from './form/base-config/base-config.component'; import { AdvancedConfigComponent } from './form/advanced-config/advanced-config.component'; import { CalendarModule, DialogModule } from 'primeng'; import { DragDropModule } from '@angular/cdk/drag-drop'; -import { AppModule } from '../../app.module'; import { IntervalComponent } from './form/date/interval/interval.component'; import { DayListComponent } from './form/date/list/day/day-list.component'; import { PickerComponent } from './form/date/picker/picker.component'; diff --git a/src/app/features/administration/form/date-select/date-select.component.ts b/src/app/features/administration/form/date-select/date-select.component.ts index 52c501d0..6e2855e4 100644 --- a/src/app/features/administration/form/date-select/date-select.component.ts +++ b/src/app/features/administration/form/date-select/date-select.component.ts @@ -7,13 +7,8 @@ import { DateUtilitiesService } from '../../../../core/services/date.utilities.s import { ApiService } from '../../../../core/services/api.service'; import { Router } from '@angular/router'; import { DOCUMENT } from '@angular/common'; -import { - DateChoice, - defaultTimeOfDay, - otherDefaultDates, - TimeSlices, -} from '../../../../../../mocks/old-stuff/config/defaultConfigs'; -import { moveItemInArray, transferArrayItem } from '@angular/cdk/drag-drop'; +import { DateChoice, defaultTimeOfDay, TimeSlices } from '../../../../../../mocks/old-stuff/config/defaultConfigs'; + import { TranslateService } from '@ngx-translate/core'; import { StorageService } from '../../../../core/services/storage.service'; @@ -71,7 +66,7 @@ export class DateSelectComponent implements OnInit { this.toastService.display('périodes horaires vidées'); } - resetTimes(slices = defaultTimeOfDay) { + resetTimes(slices = Object.create(defaultTimeOfDay)) { this.timeSlices = slices; this.dateList.map((elem) => (elem.timeList = Object.create(slices))); this.toastService.display('périodes horaires réinitialisées'); diff --git a/src/app/features/administration/form/date/list/day/day-list.component.html b/src/app/features/administration/form/date/list/day/day-list.component.html index cf31f5a0..2a3dc0f5 100644 --- a/src/app/features/administration/form/date/list/day/day-list.component.html +++ b/src/app/features/administration/form/date/list/day/day-list.component.html @@ -30,7 +30,7 @@ cdkDrag [ngClass]="{ 'day-weekend': isWeekendDay(choice.date_object) }" > - + {{ choice.date_object | date: 'E':'Europe/Paris':'fr_FR' }} diff --git a/src/app/features/consultation/consultation.component.html b/src/app/features/consultation/consultation.component.html index 9fceb3c4..679f5670 100644 --- a/src/app/features/consultation/consultation.component.html +++ b/src/app/features/consultation/consultation.component.html @@ -37,7 +37,7 @@
Exporter/Imprimer
- diff --git a/src/app/shared/shortcuts/main.ts b/src/app/shared/shortcuts/main.ts new file mode 100644 index 00000000..1a2a4501 --- /dev/null +++ b/src/app/shared/shortcuts/main.ts @@ -0,0 +1,18 @@ +import { ShortcutEventOutput } from 'ng-keyboard-shortcuts'; + +export const FramaKeyboardShortcuts = [ + { + key: ['cmd + a'], + command: (output: ShortcutEventOutput) => console.log('command + a', output), + }, + { + key: 'ctrl + a', + preventDefault: true, + command: (output: ShortcutEventOutput) => console.log('control + a', output), + }, + { + key: 'ctrl + plus', + preventDefault: true, + command: (output: ShortcutEventOutput) => console.log('control + plus key', output), + }, +]; diff --git a/tsconfig.json b/tsconfig.json index 0ce72709..5e274abd 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -17,6 +17,7 @@ "angularCompilerOptions": { "fullTemplateTypeCheck": true, "strictInjectionParameters": true, - "strictTemplates": true + "strictTemplates": true, + "enableIvy": false } } diff --git a/yarn.lock b/yarn.lock index 20e8314f..0a701821 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8142,6 +8142,13 @@ next-tick@~1.0.0: resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.0.0.tgz#ca86d1fe8828169b0120208e3dc8424b9db8342c" integrity sha1-yobR/ogoFpsBICCOPchCS524NCw= +ng-keyboard-shortcuts@^10.1.17: + version "10.1.17" + resolved "https://registry.yarnpkg.com/ng-keyboard-shortcuts/-/ng-keyboard-shortcuts-10.1.17.tgz#e31b72632ccb75daca8aae0ddd8fbc63a51f6054" + integrity sha512-uJ71+qMyt3kd6xsIv674uRgHPNcxkNxDMYhHLJor3eyi8kWJIRMok4UdIA4b7WtQ7+Pv3iWB6aO/HOzLRONZxw== + dependencies: + tslib "^2.0.0" + ng2-charts@^2.3.0: version "2.3.2" resolved "https://registry.yarnpkg.com/ng2-charts/-/ng2-charts-2.3.2.tgz#206de368e58f9655e167b6791c9d2a804191ef99" @@ -11498,6 +11505,11 @@ tslib@<2.0.0, tslib@^1.10.0, tslib@^1.8.1, tslib@^1.9.0: resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.13.0.tgz#c881e13cc7015894ed914862d276436fa9a47043" integrity sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q== +tslib@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.2.0.tgz#fb2c475977e35e241311ede2693cee1ec6698f5c" + integrity sha512-gS9GVHRU+RGn5KQM2rllAlR3dU6m7AcpJKdtH8gFvQiC4Otgk98XnmMU+nZenHt/+VhnBPWwgrJsyrdcw6i23w== + tsutils@^3.17.1: version "3.17.1" resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.17.1.tgz#ed719917f11ca0dee586272b2ac49e015a2dd759"