From e8aff89668cdbc01f85ec5ecedec6edce223f2e8 Mon Sep 17 00:00:00 2001 From: Sercan Yemen Date: Mon, 7 Aug 2017 13:29:58 +0300 Subject: [PATCH] shortcuts component done + couple fixes in colors.scss + added getFlatNavigation() to the navigation service + tweaks in navigation files --- .../components/navigation/navigation.model.ts | 2 +- .../navigation/navigation.module.ts | 2 +- .../navigation/navigation.service.ts | 51 ++++++++++- .../shortcuts/shortcuts.component.html | 65 ++++++++++++++ .../shortcuts/shortcuts.component.scss | 3 + .../shortcuts/shortcuts.component.ts | 87 +++++++++++++++++++ .../components/shortcuts/shortcuts.module.ts | 21 +++++ src/app/core/modules/shared.module.ts | 4 +- src/app/core/scss/partials/_colors.scss | 36 ++++---- src/app/main/main.module.ts | 4 +- src/app/main/toolbar/toolbar.component.html | 4 +- 11 files changed, 250 insertions(+), 29 deletions(-) create mode 100644 src/app/core/components/shortcuts/shortcuts.component.html create mode 100644 src/app/core/components/shortcuts/shortcuts.component.scss create mode 100644 src/app/core/components/shortcuts/shortcuts.component.ts create mode 100644 src/app/core/components/shortcuts/shortcuts.module.ts diff --git a/src/app/core/components/navigation/navigation.model.ts b/src/app/core/components/navigation/navigation.model.ts index 1aa6db5a..480cceb1 100644 --- a/src/app/core/components/navigation/navigation.model.ts +++ b/src/app/core/components/navigation/navigation.model.ts @@ -59,7 +59,7 @@ export class FuseNavigation { 'title': 'To-Do', 'type' : 'nav-item', - 'icon' : 'checkbox_cricle', + 'icon' : 'check_box', 'url' : '/apps/todo' }, { diff --git a/src/app/core/components/navigation/navigation.module.ts b/src/app/core/components/navigation/navigation.module.ts index 132d5b90..15816e1a 100644 --- a/src/app/core/components/navigation/navigation.module.ts +++ b/src/app/core/components/navigation/navigation.module.ts @@ -1,6 +1,6 @@ import {NgModule} from '@angular/core'; import {SharedModule} from '../../modules/shared.module'; -import {RouterModule, Routes} from '@angular/router'; +import {RouterModule} from '@angular/router'; import {FuseNavSubheaderComponent} from './nav-subheader/nav-subheader.component'; import {FuseNavigationComponent} from './navigation.component'; import {FuseNavItemComponent} from './nav-item/nav-item.component'; diff --git a/src/app/core/components/navigation/navigation.service.ts b/src/app/core/components/navigation/navigation.service.ts index c604522c..ef638a84 100644 --- a/src/app/core/components/navigation/navigation.service.ts +++ b/src/app/core/components/navigation/navigation.service.ts @@ -1,19 +1,64 @@ -import {EventEmitter, Injectable} from '@angular/core'; -import {FuseNavigation} from './navigation.model'; +import { EventEmitter, Injectable } from '@angular/core'; +import { FuseNavigation } from './navigation.model'; @Injectable() export class FuseNavigationService { onNavCollapseToggled = new EventEmitter(); - navigation: object[]; + navigation: any[]; + flatNavigation: any[] = []; constructor() { this.navigation = new FuseNavigation().items; } + /** + * Get navigation array + * @returns {any[]} + */ getNavigation() { return this.navigation; } + + /** + * Get flattened navigation array + * @param navigationItems + * @returns {any[]} + */ + getFlatNavigation(navigationItems?) + { + if ( !navigationItems ) + { + navigationItems = this.navigation; + } + + for ( const navItem of navigationItems ) + { + if ( navItem.type === 'subheader' ) + { + continue; + } + + if ( navItem.type === 'nav-item' ) + { + this.flatNavigation.push({ + title : navItem.title, + titleAbbr: navItem.title.substr(0, 1).toUpperCase(), + icon : navItem.icon || false, + url : navItem.url + }); + + continue; + } + + if ( navItem.type === 'nav-collapse' ) + { + this.getFlatNavigation(navItem.children); + } + } + + return this.flatNavigation; + } } diff --git a/src/app/core/components/shortcuts/shortcuts.component.html b/src/app/core/components/shortcuts/shortcuts.component.html new file mode 100644 index 00000000..a331cb0f --- /dev/null +++ b/src/app/core/components/shortcuts/shortcuts.component.html @@ -0,0 +1,65 @@ +
+ +
+ + + + + +
+ + + + + + + + + + +

Current Shortcuts

+ +
+ {{shortcutItem.icon}} + + {{shortcutItem.titleAbbr}} + +

{{shortcutItem.title}}

+
+
+ +

+ No shortcuts yet! +

+
+
+ + + +
+ {{navigationItem.icon}} + + {{navigationItem.titleAbbr}} + +

{{navigationItem.title}}

+
+
+
+ +
+ +
\ No newline at end of file diff --git a/src/app/core/components/shortcuts/shortcuts.component.scss b/src/app/core/components/shortcuts/shortcuts.component.scss new file mode 100644 index 00000000..8fdbe2d4 --- /dev/null +++ b/src/app/core/components/shortcuts/shortcuts.component.scss @@ -0,0 +1,3 @@ +:host { + +} \ No newline at end of file diff --git a/src/app/core/components/shortcuts/shortcuts.component.ts b/src/app/core/components/shortcuts/shortcuts.component.ts new file mode 100644 index 00000000..f369bc8e --- /dev/null +++ b/src/app/core/components/shortcuts/shortcuts.component.ts @@ -0,0 +1,87 @@ +import { Component, OnInit } from '@angular/core'; +import { FuseNavigationService } from '../navigation/navigation.service'; + +@Component({ + selector : 'fuse-shortcuts', + templateUrl: './shortcuts.component.html', + styleUrls : ['./shortcuts.component.scss'] +}) +export class FuseShortcutsComponent implements OnInit +{ + shortcutItems: any[] = []; + navigationItems: any[]; + filteredNavigationItems: any[]; + searching = false; + + constructor(private fuseNavigationService: FuseNavigationService) + { + this.filteredNavigationItems = this.navigationItems = this.fuseNavigationService.getFlatNavigation(); + } + + ngOnInit() + { + // User's shortcut items + this.shortcutItems = [ + { + 'title': 'Calendar', + 'type' : 'nav-item', + 'icon' : 'today', + 'url' : '/apps/calendar' + }, + { + 'title': 'Mail', + 'type' : 'nav-item', + 'icon' : 'email', + 'url' : '/apps/mail' + }, + { + 'title': 'Contacts', + 'type' : 'nav-item', + 'icon' : 'account_box', + 'url' : '/apps/contacts' + }, + { + 'title': 'To-Do', + 'type' : 'nav-item', + 'icon' : 'check_box', + 'url' : '/apps/todo' + } + ]; + } + + search(event) + { + const value = event.target.value.toLowerCase(); + + if ( value === '' ) + { + this.searching = false; + this.filteredNavigationItems = this.navigationItems; + + return; + } + + this.searching = true; + + this.filteredNavigationItems = this.navigationItems.filter((navigationItem) => { + return navigationItem.title.toLowerCase().includes(value); + }); + } + + toggleShortcut(event, itemToToggle) + { + event.stopPropagation(); + + for ( let i = 0; i < this.shortcutItems.length; i++ ) + { + if ( this.shortcutItems[i].url === itemToToggle.url ) + { + this.shortcutItems.splice(i, 1); + return; + } + + } + + this.shortcutItems.push(itemToToggle); + } +} diff --git a/src/app/core/components/shortcuts/shortcuts.module.ts b/src/app/core/components/shortcuts/shortcuts.module.ts new file mode 100644 index 00000000..46cd7069 --- /dev/null +++ b/src/app/core/components/shortcuts/shortcuts.module.ts @@ -0,0 +1,21 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { FuseShortcutsComponent } from './shortcuts.component'; +import { SharedModule } from '../../modules/shared.module'; + +@NgModule({ + declarations: [ + FuseShortcutsComponent + ], + imports : [ + SharedModule, + RouterModule + ], + exports : [ + FuseShortcutsComponent + ] +}) +export class FuseShortcutsModule +{ +} diff --git a/src/app/core/modules/shared.module.ts b/src/app/core/modules/shared.module.ts index 3d12e15f..00fe77e7 100644 --- a/src/app/core/modules/shared.module.ts +++ b/src/app/core/modules/shared.module.ts @@ -48,12 +48,12 @@ import { FuseHljsComponent } from '../components/hljs/hljs.component'; FuseMdSidenavHelperDirective, FuseMdSidenavTogglerDirective, FusePipesModule, + FuseCountdownComponent, + FuseHljsComponent, PerfectScrollbarModule, ReactiveFormsModule, ColorPickerModule, NgxDnDModule, - FuseCountdownComponent, - FuseHljsComponent, NgxDatatableModule ], entryComponents: [ diff --git a/src/app/core/scss/partials/_colors.scss b/src/app/core/scss/partials/_colors.scss index 8acfef71..4da83777 100644 --- a/src/app/core/scss/partials/_colors.scss +++ b/src/app/core/scss/partials/_colors.scss @@ -1,3 +1,18 @@ +.secondary-text, +.mat-icon, +.icon { + color: rgba(0, 0, 0, 0.54) !important; +} + +.hint-text, +.disabled-text { + color: rgba(0, 0, 0, 0.38) !important; +} + +.divider { + color: rgba(0, 0, 0, 0.12) !important; +} + // Material colors map $matColorsMap: ( primary: $primary, @@ -37,9 +52,7 @@ $matColorHues: 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, A100, A200, A400 &.secondary-text, .secondary-text, - &.mat-icon, .mat-icon, - &.icon, .icon { color: rgba(0, 0, 0, 0.54) !important; } @@ -64,9 +77,7 @@ $matColorHues: 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, A100, A200, A400 // If the base text color is white... @else { - &.mat-icon, .mat-icon, - &.icon, .icon { color: rgba(255, 255, 255, 1) !important; } @@ -114,7 +125,7 @@ $matColorHues: 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, A100, A200, A400 color: $color !important; // Generate text color levels - // based on current color + // based on current contrast color @include generateTextColorLevels($color); } @@ -157,19 +168,4 @@ $matColorHues: 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, A100, A200, A400 } } } -} - -.secondary-text, -.mat-icon, -.icon { - color: rgba(0, 0, 0, 0.54) !important; -} - -.hint-text, -.disabled-text { - color: rgba(0, 0, 0, 0.38) !important; -} - -.divider { - color: rgba(0, 0, 0, 0.12) !important; } \ No newline at end of file diff --git a/src/app/main/main.module.ts b/src/app/main/main.module.ts index a47f1ef9..9c881512 100644 --- a/src/app/main/main.module.ts +++ b/src/app/main/main.module.ts @@ -10,6 +10,7 @@ import { FuseNavigationModule } from '../core/components/navigation/navigation.m import { FuseNavbarToggleDirective } from './navbar/navbar-toggle.directive'; import { QuickPanelComponent } from './quick-panel/quick-panel.component'; import { FuseThemeOptionsComponent } from '../core/components/theme-options/theme-options.component'; +import { FuseShortcutsModule } from '../core/components/shortcuts/shortcuts.module'; @NgModule({ declarations: [ @@ -25,7 +26,8 @@ import { FuseThemeOptionsComponent } from '../core/components/theme-options/them imports : [ SharedModule, RouterModule, - FuseNavigationModule + FuseNavigationModule, + FuseShortcutsModule ], exports : [ FuseMainComponent diff --git a/src/app/main/toolbar/toolbar.component.html b/src/app/main/toolbar/toolbar.component.html index d59b9b02..a2c0cd82 100644 --- a/src/app/main/toolbar/toolbar.component.html +++ b/src/app/main/toolbar/toolbar.component.html @@ -10,7 +10,9 @@
-
Shortcuts
+
+ +