diff --git a/src/app/+admin/admin-sidebar/admin-sidebar-section/admin-sidebar-section.component.html b/src/app/+admin/admin-sidebar/admin-sidebar-section/admin-sidebar-section.component.html new file mode 100644 index 0000000000..3cd236da65 --- /dev/null +++ b/src/app/+admin/admin-sidebar/admin-sidebar-section/admin-sidebar-section.component.html @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/src/app/+admin/admin-sidebar/admin-sidebar-section/admin-sidebar-section.component.spec.ts b/src/app/+admin/admin-sidebar/admin-sidebar-section/admin-sidebar-section.component.spec.ts new file mode 100644 index 0000000000..a4f4399f59 --- /dev/null +++ b/src/app/+admin/admin-sidebar/admin-sidebar-section/admin-sidebar-section.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { AdminSidebarSectionComponent } from './admin-sidebar-section.component'; + +describe('AdminSidebarSectionComponent', () => { + let component: AdminSidebarSectionComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ AdminSidebarSectionComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(AdminSidebarSectionComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/+admin/admin-sidebar/admin-sidebar-section/admin-sidebar-section.component.ts b/src/app/+admin/admin-sidebar/admin-sidebar-section/admin-sidebar-section.component.ts new file mode 100644 index 0000000000..758ea72965 --- /dev/null +++ b/src/app/+admin/admin-sidebar/admin-sidebar-section/admin-sidebar-section.component.ts @@ -0,0 +1,13 @@ +import { Component, Input } from '@angular/core'; + +@Component({ + selector: 'ds-admin-sidebar-section', + templateUrl: './admin-sidebar-section.component.html', + styleUrls: ['./admin-sidebar-section.component.scss'], + +}) +export class AdminSidebarSectionComponent { + @Input() name: string; + @Input() link: string; + @Input() icon: string; +} diff --git a/src/app/+admin/admin-sidebar/expandable-admin-sidebar-section/expandable-admin-sidebar-section.component.html b/src/app/+admin/admin-sidebar/expandable-admin-sidebar-section/expandable-admin-sidebar-section.component.html new file mode 100644 index 0000000000..e7956901e5 --- /dev/null +++ b/src/app/+admin/admin-sidebar/expandable-admin-sidebar-section/expandable-admin-sidebar-section.component.html @@ -0,0 +1,18 @@ + \ No newline at end of file diff --git a/src/app/+admin/admin-sidebar/expandable-admin-sidebar-section/expandable-admin-sidebar-section.component.spec.ts b/src/app/+admin/admin-sidebar/expandable-admin-sidebar-section/expandable-admin-sidebar-section.component.spec.ts new file mode 100644 index 0000000000..48c85876b7 --- /dev/null +++ b/src/app/+admin/admin-sidebar/expandable-admin-sidebar-section/expandable-admin-sidebar-section.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ExpandableAdminSidebarSectionComponent } from './expandable-admin-sidebar-section.component'; + +describe('ExpandableAdminSidebarSectionComponent', () => { + let component: ExpandableAdminSidebarSectionComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ExpandableAdminSidebarSectionComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ExpandableAdminSidebarSectionComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/+admin/admin-sidebar/expandable-admin-sidebar-section/expandable-admin-sidebar-section.component.ts b/src/app/+admin/admin-sidebar/expandable-admin-sidebar-section/expandable-admin-sidebar-section.component.ts new file mode 100644 index 0000000000..8b0fb7112d --- /dev/null +++ b/src/app/+admin/admin-sidebar/expandable-admin-sidebar-section/expandable-admin-sidebar-section.component.ts @@ -0,0 +1,46 @@ +import { Component, Input, OnInit } from '@angular/core'; +import { Observable } from 'rxjs/internal/Observable'; +import { first } from 'rxjs/operators'; +import { rotate } from '../../../shared/animations/rotate'; +import { AdminSidebarSectionComponent } from '../admin-sidebar-section/admin-sidebar-section.component'; +import { slide } from '../../../shared/animations/slide'; +import { CSSVariableService } from '../../../shared/sass-helper/sass-helper.service'; +import { bgColor } from '../../../shared/animations/bgColor'; +import { AdminSidebarService } from '../admin-sidebar.service'; + +@Component({ + selector: 'ds-expandable-admin-sidebar-section', + templateUrl: './expandable-admin-sidebar-section.component.html', + styleUrls: ['./expandable-admin-sidebar-section.component.scss'], + animations: [rotate, slide, bgColor] + +}) +export class ExpandableAdminSidebarSectionComponent extends AdminSidebarSectionComponent implements OnInit { + @Input() subSections; + link = '#'; + sidebarActiveBg; + collapsed: Observable; + sidebarCollapsed: Observable; + + constructor(private sidebarService: AdminSidebarService, + private variableService: CSSVariableService) { + super(); + } + + ngOnInit(): void { + this.sidebarActiveBg = this.variableService.getVariable('adminSidebarActiveBg'); + this.collapsed = this.sidebarService.isSectionCollapsed(this.name); + this.sidebarCollapsed = this.sidebarService.isSidebarCollapsed(); + } + + toggleSection(event: Event) { + event.preventDefault(); + this.sidebarCollapsed.pipe(first()) + .subscribe((sidebarCollapsed) => { + if (sidebarCollapsed) { + this.sidebarService.toggleSidebar(); + } + this.sidebarService.toggleSection(this.name); + }) + } +}