Renamed code widget; moved modal to common folder
This commit is contained in:
@@ -15,7 +15,7 @@ import { ServiceMessage } from '../../common/types/service-message.type';
|
||||
|
||||
|
||||
@Directive()
|
||||
export class NewtonEditorBase {
|
||||
export class CodeViewBase {
|
||||
public uuid: string = uuid.v4();
|
||||
@Input() public isDefault: boolean = false;
|
||||
public leftSiblingUUID!: string;
|
@@ -11,7 +11,7 @@ import "ace-builds/src-noconflict/ext-language_tools";
|
||||
//import "ace-builds/src-noconflict/theme-penguins_in_space";
|
||||
import "ace-builds/src-noconflict/theme-gruvbox";
|
||||
|
||||
import { NewtonEditorBase } from './newton-editor.base';
|
||||
import { CodeViewBase } from './view.base';
|
||||
|
||||
import { NewtonFile } from '../../common/types/file.type';
|
||||
import { ServiceMessage } from '../../common/types/service-message.type';
|
||||
@@ -19,17 +19,17 @@ import { ServiceMessage } from '../../common/types/service-message.type';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'newton-editor',
|
||||
selector: 'code-view',
|
||||
standalone: true,
|
||||
imports: [
|
||||
],
|
||||
templateUrl: './newton-editor.component.html',
|
||||
styleUrl: './newton-editor.component.css',
|
||||
templateUrl: './view.component.html',
|
||||
styleUrl: './view.component.css',
|
||||
host: {
|
||||
'class': 'col'
|
||||
}
|
||||
})
|
||||
export class NewtonEditorComponent extends NewtonEditorBase {
|
||||
export class CodeViewComponent extends CodeViewBase {
|
||||
|
||||
|
||||
constructor() {
|
@@ -1,9 +1,9 @@
|
||||
<div class="col">
|
||||
|
||||
<div class="row dropzone" #dropzone dropzone (fileDropped)="onFileDropped($event)">
|
||||
<newton-editor [isDefault]="true"></newton-editor>
|
||||
<code-view [isDefault]="true"></code-view>
|
||||
<hr class="col vr-pane-handle" pane-handle />
|
||||
<newton-editor></newton-editor>
|
||||
<code-view></code-view>
|
||||
</div>
|
||||
|
||||
<div>
|
@@ -5,7 +5,7 @@ import { EditorsService } from '../common/services/editor/editors.service';
|
||||
import { TabsService } from '../common/services/editor/tabs/tabs.service';
|
||||
import { FilesService } from '../common/services/editor/files.service';
|
||||
|
||||
import { NewtonEditorComponent } from "./newton-editor/newton-editor.component";
|
||||
import { CodeViewComponent } from "./code-view/view.component";
|
||||
|
||||
import { DndDirective } from '../common/directives/dnd.directive';
|
||||
import { PaneHandleDirective } from '../common/directives/pane-handle.directive';
|
||||
@@ -20,7 +20,7 @@ import { ServiceMessage } from '../common/types/service-message.type';
|
||||
imports: [
|
||||
DndDirective,
|
||||
PaneHandleDirective,
|
||||
NewtonEditorComponent
|
||||
CodeViewComponent
|
||||
],
|
||||
templateUrl: './editors.component.html',
|
||||
styleUrl: './editors.component.css',
|
||||
|
@@ -1,16 +0,0 @@
|
||||
.modal-column {
|
||||
min-height: 24em;
|
||||
max-height: 24em;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.close-button {
|
||||
background: rgba(116, 0, 0, 0.64);
|
||||
border-style: solid;
|
||||
border-color: rgba(0, 0, 0, 0.64);
|
||||
border-width: 1px;
|
||||
}
|
||||
|
||||
.close-button:hover {
|
||||
background: rgba(256, 0, 0, 0.64);
|
||||
}
|
@@ -1,52 +0,0 @@
|
||||
<div #filesModal
|
||||
id="filesModal" class="modal fade" tabindex="-1" role="dialog"
|
||||
>
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Files:</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
|
||||
<div class="row">
|
||||
<div class="col modal-column">
|
||||
|
||||
<div #filesList *ngFor="let file of files" class="row">
|
||||
<div class="col-11 title"
|
||||
title="{{file.path}}"
|
||||
uuid="{{file.uuid}}"
|
||||
path="{{file.path}}"
|
||||
>
|
||||
{{file.title}}
|
||||
</div>
|
||||
<div class="col-1 close-button">
|
||||
X
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<input #filesSearch type="text" placeholder="Search..." />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col modal-column">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@@ -1,85 +0,0 @@
|
||||
import { Component, inject } from "@angular/core";
|
||||
import { CommonModule } from "@angular/common";
|
||||
|
||||
import { Subject, takeUntil } from 'rxjs';
|
||||
|
||||
import * as bootstrap from "bootstrap";
|
||||
|
||||
import { FilesModalService } from "../../common/services/editor/modals/files-modal.service";
|
||||
import { TabsService } from '../../common/services/editor/tabs/tabs.service';
|
||||
|
||||
import { ServiceMessage } from '../../common/types/service-message.type';
|
||||
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'files-modal',
|
||||
standalone: true,
|
||||
imports: [
|
||||
CommonModule
|
||||
],
|
||||
templateUrl: './files-modal.component.html',
|
||||
styleUrl: './files-modal.component.css',
|
||||
host: {
|
||||
'class': ''
|
||||
}
|
||||
})
|
||||
export class FilesModalComponent {
|
||||
private unsubscribe: Subject<void> = new Subject();
|
||||
|
||||
private filesModalService: FilesModalService = inject(FilesModalService);
|
||||
private tabsService: TabsService = inject(TabsService);
|
||||
|
||||
filesModal!: bootstrap.Modal;
|
||||
files: any[] = [];
|
||||
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
|
||||
private ngAfterViewInit(): void {
|
||||
this.loadSubscribers();
|
||||
}
|
||||
|
||||
private loadSubscribers() {
|
||||
this.tabsService.getMessage$().pipe(
|
||||
takeUntil(this.unsubscribe)
|
||||
).subscribe((data: ServiceMessage) => {
|
||||
if (data.action === "create-tab") {
|
||||
this.createFileRow(data.fileName, data.fileUUID, data.filePath);
|
||||
}
|
||||
});
|
||||
|
||||
this.filesModalService.showFilesModalRequested$().pipe(
|
||||
takeUntil(this.unsubscribe)
|
||||
).subscribe(() => {
|
||||
if (!this.filesModal) {
|
||||
this.createModal();
|
||||
}
|
||||
|
||||
this.showModal();
|
||||
});
|
||||
|
||||
this.filesModalService.addFileToModalRequested$().pipe(
|
||||
takeUntil(this.unsubscribe)
|
||||
).subscribe((uuid: string) => {
|
||||
if (!this.filesModal) {
|
||||
this.createModal();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private createModal() {
|
||||
this.filesModal = new bootstrap.Modal("#filesModal", {});
|
||||
}
|
||||
|
||||
public createFileRow(title: string, uuid: string, path: string): void {
|
||||
this.files.push({title: title, uuid: uuid, path: path})
|
||||
}
|
||||
|
||||
public showModal() {
|
||||
this.filesModal?.toggle();
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user