From 0e0a36db722a919f97c229d3952e82ca129ba620 Mon Sep 17 00:00:00 2001 From: garrettmills Date: Thu, 4 Feb 2021 15:08:42 -0600 Subject: [PATCH] #80 - clean up file box read only mode --- .../nodes/file-box/file-box.component.ts | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) 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 e384980..bb838a2 100644 --- a/src/app/components/nodes/file-box/file-box.component.ts +++ b/src/app/components/nodes/file-box/file-box.component.ts @@ -102,17 +102,13 @@ export class FileBoxComponent extends EditorNodeContract implements OnInit { return; } - console.log('file box compt', this); if ( !this.node.Value.Value && !this.readonly ) { this.record = await this.api.createFileBox(this.page.UUID, this.fileBoxName); - console.log(this.record); - this.node.Value.Value = this.record.UUID; this.node.value = this.record.UUID; this.dirty = true; } else if ( this.node.Value.Value ) { this.record = await this.api.getFileBox(this.page.UUID, this.node.Value.Value); - console.log(this.record); } if ( !this.record ) { @@ -199,6 +195,10 @@ export class FileBoxComponent extends EditorNodeContract implements OnInit { } async onSurfaceContextMenu(event: MouseEvent) { + if ( this.readonly ) { + return; + } + if ( !event.ctrlKey ) { event.preventDefault(); event.stopPropagation(); @@ -241,6 +241,10 @@ export class FileBoxComponent extends EditorNodeContract implements OnInit { } async onRecordNameChange(event) { + if ( this.readonly ) { + return; + } + const name = event.target.value; this.fileBoxName = name; this.record.name = name; @@ -249,6 +253,10 @@ export class FileBoxComponent extends EditorNodeContract implements OnInit { } async onItemContextMenu(item: FileBoxItem, event: MouseEvent) { + if ( this.readonly ) { + return; + } + if ( !event.ctrlKey ) { event.preventDefault(); event.stopPropagation(); @@ -275,6 +283,10 @@ export class FileBoxComponent extends EditorNodeContract implements OnInit { } async onUploadFilesClick(event) { + if ( this.readonly ) { + return; + } + if ( this.fileInput ) { this.fileInput.nativeElement.click(); } @@ -324,6 +336,10 @@ export class FileBoxComponent extends EditorNodeContract implements OnInit { } async onActionClick(action: string, item?: FileBoxItem) { + if ( this.readonly ) { + return; + } + if ( action === 'folder-add' ) { await this.actionNewFolder(); } else if ( action === 'rename' && item ) {