Skip to content

Commit

Permalink
feat: menu-bar component
Browse files Browse the repository at this point in the history
  • Loading branch information
artemnih committed Oct 2, 2021
1 parent 29e54dd commit addca93
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
<div>
<button (click)="back()">Back</button>
<button (click)="createFolder()">New Folder</button>
<button (click)="refresh()">Refresh</button>
</div>
<nxe-menu-bar></nxe-menu-bar>
<nxe-icons></nxe-icons>
Original file line number Diff line number Diff line change
@@ -1,34 +1,9 @@
import { Component, OnInit } from '@angular/core';
import { ExplorerService } from '../../services/explorer.service';
import { Component } from '@angular/core';

@Component({
selector: 'nxe-explorer',
templateUrl: './explorer.component.html',
styleUrls: ['./explorer.component.scss']
})
export class ExplorerComponent implements OnInit {

constructor(private explorerService: ExplorerService) { }

ngOnInit(): void { }

back() {
const currentNode = this.explorerService.openedNode.value;
this.explorerService.openNode(currentNode.parentId);
}

createFolder() {
const currentNode = this.explorerService.openedNode.value;

// TODO: inject custom popup, inject custom text
let name = prompt("Enter new folder name");
if (name) {
this.explorerService.createNode(currentNode, name);
}
}

refresh() {
this.explorerService.refresh();
}

export class ExplorerComponent {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div>
<button (click)="back()">Back</button>
<button (click)="createFolder()">New Folder</button>
<button (click)="refresh()">Refresh</button>
</div>
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { MenuBarComponent } from './menu-bar.component';

describe('MenuBarComponent', () => {
let component: MenuBarComponent;
let fixture: ComponentFixture<MenuBarComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ MenuBarComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(MenuBarComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Component } from '@angular/core';
import { ExplorerService } from '../../services/explorer.service';

@Component({
selector: 'nxe-menu-bar',
templateUrl: './menu-bar.component.html',
styleUrls: ['./menu-bar.component.scss']
})
export class MenuBarComponent {

constructor(private explorerService: ExplorerService) { }

back() {
const currentNode = this.explorerService.openedNode.value;
this.explorerService.openNode(currentNode.parentId);
}

createFolder() {
const currentNode = this.explorerService.openedNode.value;

// TODO: inject custom popup, inject custom text
let name = prompt("Enter new folder name");
if (name) {
this.explorerService.createNode(currentNode, name);
}
}

refresh() {
this.explorerService.refresh();
}

}
4 changes: 3 additions & 1 deletion projects/ngx-explorer/src/lib/ngx-explorer.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ import { NgModule } from '@angular/core';
import { IconsComponent } from './components/icons/icons.component';
import { CommonModule } from '@angular/common';
import { ExplorerComponent } from './components/explorer/explorer.component';
import { MenuBarComponent } from './components/menu-bar/menu-bar.component';

@NgModule({
declarations: [
IconsComponent,
ExplorerComponent,
MenuBarComponent,
],
imports: [
CommonModule
],
exports: [IconsComponent, ExplorerComponent]
exports: [IconsComponent, ExplorerComponent, MenuBarComponent]
})
export class NgxExplorerModule { }
1 change: 1 addition & 0 deletions projects/ngx-explorer/src/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export * from './lib/services/explorer.service';
export * from './lib/ngx-explorer.module';
export * from './lib/components/icons/icons.component';
export * from './lib/components/explorer/explorer.component';
export * from './lib/components/menu-bar/menu-bar.component';

0 comments on commit addca93

Please sign in to comment.