Centralize opener logic to shared service

This commit is contained in:
2021-02-15 19:07:35 -06:00
parent 0fecb8a4ba
commit 72ab2064dd
9 changed files with 161 additions and 100 deletions

View File

@@ -5,7 +5,12 @@ import {EditorService} from '../../../service/editor.service';
selector: 'noded-file-box-page',
template: `
<div class="container" *ngIf="ready">
<editor-file-box [nodeId]="nodeId" [editorUUID]="this.editorService.instanceUUID" [fullPage]="true" [boxId]="boxId"></editor-file-box>
<editor-file-box
[nodeId]="nodeId"
[editorUUID]="this.editorService.instanceUUID"
[fullPage]="true"
[boxId]="boxId"
></editor-file-box>
</div>
`,
styles: [

View File

@@ -101,6 +101,10 @@ div.file-box-wrapper {
}
}
.close {
padding: 0 20px;
}
.file-box-wrapper.dark {
color: white;
display: flex;
@@ -115,10 +119,6 @@ div.file-box-wrapper {
}
}
.close {
padding: 0 20px;
}
.item {
background: #393939;

View File

@@ -5,8 +5,7 @@ import {BehaviorSubject} from 'rxjs';
import {Router} from '@angular/router';
import {NodeTypeIcons} from '../../structures/node-types';
import {debounce} from '../../utility';
import {DatabasePageComponent} from '../editor/database/database-page.component';
import {FileBoxPageComponent} from '../nodes/file-box/file-box-page.component';
import {OpenerService} from '../../service/opener.service';
export interface SearchResult {
title: string;
@@ -44,6 +43,7 @@ export class SearchComponent implements OnInit {
protected ionModalController: ModalController,
protected api: ApiService,
protected router: Router,
protected opener: OpenerService,
) { }
async dismiss() {
@@ -75,15 +75,15 @@ export class SearchComponent implements OnInit {
];
if ( result.type === 'page' ) {
await this.router.navigate(['/editor', { id: result.id }]);
await this.opener.openTarget(result.id);
await this.dismiss();
} else if ( nodeTypes.includes(result.type) ) {
await this.router.navigate(['/editor', { id: result.associated.id, node_id: result.id }]);
await this.opener.openTarget(result.associated.id, result.id);
await this.dismiss();
} else if ( result.type === 'db' ) {
await this.openDatabase(result.associated.id, result.id);
await this.opener.openDatabase(result.associated.id, result.id);
} else if ( result.type.startsWith('file_box') ) {
await this.openFileBox(result.associated.id, result.id, result.boxId);
await this.opener.openFileBox(result.associated.id, result.id, result.boxId);
}
}
@@ -93,50 +93,9 @@ export class SearchComponent implements OnInit {
if ( result.associated ) {
if ( result.associated.type === 'page' ) {
await this.router.navigate(['/editor', { id: result.associated.id }]);
await this.opener.openTarget(result.associated.id);
await this.dismiss();
}
}
}
async openDatabase(pageId: string, nodeId: string) {
const modal = await this.ionModalController.create({
component: DatabasePageComponent,
componentProps: {
nodeId,
pageId,
},
cssClass: 'modal-big',
});
const modalState = {
modal : true,
desc : 'Open Database'
};
history.pushState(modalState, null);
await modal.present();
}
async openFileBox(pageId: string, nodeId: string, boxId?: string) {
const modal = await this.ionModalController.create({
component: FileBoxPageComponent,
componentProps: {
nodeId,
pageId,
boxId,
},
cssClass: 'modal-big',
});
const modalState = {
modal : true,
desc : 'Open File Box'
};
history.pushState(modalState, null);
await modal.present();
}
}