From eaa7b69024423f6dbf1588e700b3bdfe7836c1c7 Mon Sep 17 00:00:00 2001 From: garrettmills Date: Thu, 4 Feb 2021 16:15:05 -0600 Subject: [PATCH] #77 - support opening file box in full screen mode --- src/app/components/components.module.ts | 4 ++ .../editor/database/database.component.ts | 7 +++ .../nodes/file-box/file-box-page.component.ts | 41 ++++++++++++ .../nodes/file-box/file-box.component.html | 9 ++- .../nodes/file-box/file-box.component.scss | 14 +++++ .../nodes/file-box/file-box.component.ts | 63 ++++++++++++++++--- 6 files changed, 130 insertions(+), 8 deletions(-) create mode 100644 src/app/components/nodes/file-box/file-box-page.component.ts diff --git a/src/app/components/components.module.ts b/src/app/components/components.module.ts index 38915b8..30035c7 100644 --- a/src/app/components/components.module.ts +++ b/src/app/components/components.module.ts @@ -47,6 +47,7 @@ import {FormInputComponent} from './nodes/form-input/form-input.component'; import {FormInputOptionsComponent} from './nodes/form-input/options/form-input-options.component'; import {DatabaseLinkComponent} from './editor/forms/database-link.component'; import {FileBoxComponent} from './nodes/file-box/file-box.component'; +import {FileBoxPageComponent} from './nodes/file-box/file-box-page.component'; @NgModule({ declarations: [ @@ -87,6 +88,7 @@ import {FileBoxComponent} from './nodes/file-box/file-box.component'; FormInputOptionsComponent, DatabaseLinkComponent, FileBoxComponent, + FileBoxPageComponent, ], imports: [ CommonModule, @@ -140,6 +142,7 @@ import {FileBoxComponent} from './nodes/file-box/file-box.component'; FormInputOptionsComponent, DatabaseLinkComponent, FileBoxComponent, + FileBoxPageComponent, ], exports: [ NodePickerComponent, @@ -179,6 +182,7 @@ import {FileBoxComponent} from './nodes/file-box/file-box.component'; FormInputOptionsComponent, DatabaseLinkComponent, FileBoxComponent, + FileBoxPageComponent, ] }) export class ComponentsModule {} diff --git a/src/app/components/editor/database/database.component.ts b/src/app/components/editor/database/database.component.ts index d3a20d5..a71d7e2 100644 --- a/src/app/components/editor/database/database.component.ts +++ b/src/app/components/editor/database/database.component.ts @@ -487,6 +487,13 @@ export class DatabaseComponent extends EditorNodeContract implements OnInit { this.editorService.reload(); }); + const modalState = { + modal : true, + desc : 'Open Database' + }; + + history.pushState(modalState, null); + await modal.present(); } diff --git a/src/app/components/nodes/file-box/file-box-page.component.ts b/src/app/components/nodes/file-box/file-box-page.component.ts new file mode 100644 index 0000000..d7eb88b --- /dev/null +++ b/src/app/components/nodes/file-box/file-box-page.component.ts @@ -0,0 +1,41 @@ +import {Component, Input, OnInit} from '@angular/core'; +import {EditorService} from '../../../service/editor.service'; + +@Component({ + selector: 'noded-file-box-page', + template: ` +
+ +
+ `, + styles: [ + ` + .container { + height: 100%; + } + + editor-database { + height: 100%; + display: flex; + } + `, + ], +}) +export class FileBoxPageComponent implements OnInit { + @Input() nodeId: string; + @Input() pageId: string; + + public ready = false; + + constructor( + public editorService: EditorService, + ) { + this.editorService = editorService.getEditor(); + } + + ngOnInit() { + this.editorService.startEditing(this.pageId).then(() => { + this.ready = true; + }); + } +} diff --git a/src/app/components/nodes/file-box/file-box.component.html b/src/app/components/nodes/file-box/file-box.component.html index e3af33b..f67c24d 100644 --- a/src/app/components/nodes/file-box/file-box.component.html +++ b/src/app/components/nodes/file-box/file-box.component.html @@ -1,4 +1,4 @@ -
+
  Folder   Upload Files +   Open
diff --git a/src/app/components/nodes/file-box/file-box.component.scss b/src/app/components/nodes/file-box/file-box.component.scss index 1475adc..ef4723b 100644 --- a/src/app/components/nodes/file-box/file-box.component.scss +++ b/src/app/components/nodes/file-box/file-box.component.scss @@ -102,14 +102,23 @@ div.file-box-wrapper { } .file-box-wrapper.dark { + color: white; + display: flex; + flex-direction: column; + .content-wrapper { background: #222; + flex: 1; .empty-text { color: #ccc; } } + .close { + padding: 0 20px; + } + .item { background: #393939; @@ -132,3 +141,8 @@ div.file-box-wrapper { } } } + +.file-box-wrapper.full-page { + margin: 0; + height: 100%; +} diff --git a/src/app/components/nodes/file-box/file-box.component.ts b/src/app/components/nodes/file-box/file-box.component.ts index e20fae3..fc25068 100644 --- a/src/app/components/nodes/file-box/file-box.component.ts +++ b/src/app/components/nodes/file-box/file-box.component.ts @@ -1,12 +1,13 @@ import {Component, ElementRef, Inject, Input, OnInit, ViewChild} from '@angular/core'; -import {ApiService, ResourceNotAvailableOfflineError} from '../../../service/api.service'; -import { APP_BASE_HREF } from '@angular/common'; +import {ApiService} from '../../../service/api.service'; +import {APP_BASE_HREF} from '@angular/common'; import {EditorService} from '../../../service/editor.service'; import {EditorNodeContract} from '../EditorNode.contract'; import {HttpClient} from '@angular/common/http'; -import {AlertController, LoadingController, PopoverController} from '@ionic/angular'; +import {AlertController, LoadingController, ModalController, PopoverController} from '@ionic/angular'; import {OptionMenuComponent} from '../../option-menu/option-menu.component'; -import {NavigationService} from "../../../service/navigation.service"; +import {NavigationService} from '../../../service/navigation.service'; +import {FileBoxPageComponent} from './file-box-page.component'; export interface FileBoxFile { type: 'file'; @@ -38,6 +39,7 @@ export type FileBoxItem = FileBoxFile | FileBoxRecord; export class FileBoxComponent extends EditorNodeContract implements OnInit { @Input() nodeId: string; @Input() editorUUID: string; + @Input() fullPage = false; @ViewChild('fileInput') fileInput: ElementRef; categoryIcons = { @@ -57,12 +59,10 @@ export class FileBoxComponent extends EditorNodeContract implements OnInit { public notAvailableOffline = false; public fileBoxName = 'New File Box'; public record?: FileBoxRecord; - + private deferredUIActivation = false; public quickFilterValue?: string; public visibleFilterItems?: FileBoxItem[]; - public history: FileBoxRecord[] = []; - public items: FileBoxItem[] = []; public get readonly() { @@ -77,6 +77,7 @@ export class FileBoxComponent extends EditorNodeContract implements OnInit { protected popover: PopoverController, protected alerts: AlertController, protected navService: NavigationService, + protected modals: ModalController, @Inject(APP_BASE_HREF) private baseHref: string ) { super(); } @@ -135,6 +136,10 @@ export class FileBoxComponent extends EditorNodeContract implements OnInit { } this.pendingSetup = false; + + if ( this.deferredUIActivation ) { + await this.performUIActivation(); + } } public async loadBox(): Promise { @@ -479,4 +484,48 @@ export class FileBoxComponent extends EditorNodeContract implements OnInit { this.visibleFilterItems = undefined; } } + + async openFileBox() { + const modal = await this.modals.create({ + component: FileBoxPageComponent, + componentProps: { + nodeId: this.nodeId, + pageId: this.editorService.currentPageId, + }, + cssClass: 'modal-big', + }); + + modal.onDidDismiss().then(() => { + this.record = this.history.length > 0 ? this.history[0] : this.record; + this.history = []; + this.loadBox(); + }); + + const modalState = { + modal : true, + desc : 'Open File Box' + }; + + history.pushState(modalState, null); + + await modal.present(); + } + + async dismiss() { + if ( this.fullPage ) { + await this.modals.dismiss(); + } + } + + performUIActivation() { + if ( this.deferredUIActivation ) { + this.deferredUIActivation = false; + } + + if ( !this.pendingSetup ) { + return this.openFileBox(); + } else { + this.deferredUIActivation = true; + } + } }