aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/util/SelectionManager.ts17
-rw-r--r--src/client/views/PropertiesButtons.tsx49
-rw-r--r--src/client/views/collections/CollectionSchemaView.tsx3
-rw-r--r--src/client/views/collections/collectionFreeForm/PropertiesView.tsx6
4 files changed, 39 insertions, 36 deletions
diff --git a/src/client/util/SelectionManager.ts b/src/client/util/SelectionManager.ts
index 14d06b9b6..35b82cc30 100644
--- a/src/client/util/SelectionManager.ts
+++ b/src/client/util/SelectionManager.ts
@@ -3,9 +3,7 @@ import { Doc, Opt } from "../../fields/Doc";
import { DocumentView } from "../views/nodes/DocumentView";
import { computedFn } from "mobx-utils";
import { List } from "../../fields/List";
-import { Scripting } from "./Scripting";
-import { DocumentManager } from "./DocumentManager";
-import { MobileDocumentUploadContent } from "../../server/Message";
+import { CollectionSchemaView } from "../views/collections/CollectionSchemaView";
export namespace SelectionManager {
@@ -14,10 +12,12 @@ export namespace SelectionManager {
@observable IsDragging: boolean = false;
SelectedDocuments: ObservableMap<DocumentView, boolean> = new ObservableMap();
@observable SelectedSchemaDocument: Doc | undefined;
+ @observable SelectedSchemaCollection: CollectionSchemaView | undefined;
@action
- SelectSchemaDoc(doc: Opt<Doc>) {
+ SelectSchemaDoc(collectionView: Opt<CollectionSchemaView>, doc: Opt<Doc>) {
manager.SelectedSchemaDocument = doc;
+ manager.SelectedSchemaCollection = collectionView;
}
@action
SelectDoc(docView: DocumentView, ctrlPressed: boolean): void {
@@ -33,6 +33,7 @@ export namespace SelectionManager {
} else if (!ctrlPressed && Array.from(manager.SelectedDocuments.entries()).length > 1) {
Array.from(manager.SelectedDocuments.keys()).map(dv => dv !== docView && dv.props.whenActiveChanged(false));
manager.SelectedSchemaDocument = undefined;
+ manager.SelectedSchemaCollection = undefined;
manager.SelectedDocuments.clear();
manager.SelectedDocuments.set(docView, true);
}
@@ -49,6 +50,7 @@ export namespace SelectionManager {
}
@action
DeselectAll(): void {
+ manager.SelectedSchemaCollection = undefined;
manager.SelectedSchemaDocument = undefined;
Array.from(manager.SelectedDocuments.keys()).map(dv => dv.props.whenActiveChanged(false));
manager.SelectedDocuments.clear();
@@ -64,8 +66,8 @@ export namespace SelectionManager {
export function SelectDoc(docView: DocumentView, ctrlPressed: boolean): void {
manager.SelectDoc(docView, ctrlPressed);
}
- export function SelectSchemaDoc(document: Opt<Doc>): void {
- manager.SelectSchemaDoc(document);
+ export function SelectSchemaDoc(colSchema: Opt<CollectionSchemaView>, document: Opt<Doc>): void {
+ manager.SelectSchemaDoc(colSchema, document);
}
// computed functions, such as used in IsSelected generate errors if they're called outside of a
@@ -97,4 +99,7 @@ export namespace SelectionManager {
export function SelectedSchemaDoc(): Doc | undefined {
return manager.SelectedSchemaDocument;
}
+ export function SelectedSchemaCollection(): CollectionSchemaView | undefined {
+ return manager.SelectedSchemaCollection;
+ }
} \ No newline at end of file
diff --git a/src/client/views/PropertiesButtons.tsx b/src/client/views/PropertiesButtons.tsx
index dfedc9ccc..e220bd7fc 100644
--- a/src/client/views/PropertiesButtons.tsx
+++ b/src/client/views/PropertiesButtons.tsx
@@ -77,12 +77,12 @@ export class PropertiesButtons extends React.Component<{}, {}> {
public static hasPulledHack = false;
+ @computed get selectedDoc() { return SelectionManager.SelectedSchemaDoc() || this.selectedDocumentView?.rootDoc; }
@computed get selectedDocumentView() {
if (SelectionManager.SelectedDocuments().length) {
return SelectionManager.SelectedDocuments()[0];
- } else { return undefined; }
+ } else return undefined;
}
- @computed get selectedDoc() { return this.selectedDocumentView?.rootDoc; }
@computed get dataDoc() { return this.selectedDocumentView?.dataDoc; }
@computed get onClick() { return this.selectedDoc?.onClickBehavior ? this.selectedDoc?.onClickBehavior : "nothing"; }
@@ -297,9 +297,9 @@ export class PropertiesButtons extends React.Component<{}, {}> {
}
@undoBatch
onAliasButtonMoved = () => {
- if (this._dragRef.current) {
+ if (this._dragRef.current && this.selectedDoc) {
const dragDocView = this.selectedDocumentView!;
- const dragData = new DragManager.DocumentDragData([dragDocView.props.Document]);
+ const dragData = new DragManager.DocumentDragData([this.selectedDoc]);
const [left, top] = dragDocView.props.ScreenToLocalTransform().inverse().transformPoint(0, 0);
dragData.dropAction = "alias";
DragManager.StartDocumentDrag([dragDocView.ContentDiv!], dragData, left, top, {
@@ -314,7 +314,7 @@ export class PropertiesButtons extends React.Component<{}, {}> {
@computed
get templateButton() {
- const docView = this.selectedDocumentView;
+ const docView = this.selectedDocumentView?.props.Document === this.selectedDoc ? this.selectedDocumentView : undefined;
const templates: Map<Template, boolean> = new Map();
const views = [this.selectedDocumentView];
Array.from(Object.values(Templates.TemplateList)).map(template =>
@@ -366,7 +366,8 @@ export class PropertiesButtons extends React.Component<{}, {}> {
@action @undoBatch
onLock = () => {
- this.selectedDocumentView?.toggleLockPosition();
+ const docView = this.selectedDocumentView?.props.Document === this.selectedDoc ? this.selectedDocumentView : undefined;
+ docView?.toggleLockPosition();
}
@computed
@@ -401,8 +402,8 @@ export class PropertiesButtons extends React.Component<{}, {}> {
<div>
<div className={"propertiesButtons-linkButton-empty"}
onPointerDown={async () => {
- if (this.selectedDocumentView?.props.Document) {
- Doc.Zip(this.selectedDocumentView?.props.Document);
+ if (this.selectedDoc) {
+ Doc.Zip(this.selectedDoc);
}
}}>
{<FontAwesomeIcon className="propertiesButtons-icon"
@@ -432,23 +433,22 @@ export class PropertiesButtons extends React.Component<{}, {}> {
@undoBatch
@action
deleteDocument = () => {
- const selected = SelectionManager.SelectedDocuments().slice();
- selected.map(dv => dv.props.removeDocument?.(dv.props.Document));
- this.selectedDoc && (this.selectedDoc.deleted = true);
- this.selectedDocumentView?.props.ContainingCollectionView?.removeDocument(this.selectedDocumentView?.props.Document);
+ const removeDoc = this.selectedDocumentView?.props.Document === this.selectedDoc ? this.selectedDocumentView?.props.removeDocument : SelectionManager.SelectedSchemaCollection()?.props.removeDocument;
+ this.selectedDoc && removeDoc?.(this.selectedDoc);
SelectionManager.DeselectAll();
}
@computed
get sharingButton() {
const targetDoc = this.selectedDoc;
+ const docView = this.selectedDocumentView?.props.Document === this.selectedDoc ? this.selectedDocumentView : undefined;
return !targetDoc ? (null) : <Tooltip
title={<><div className="dash-tooltip">{"Share Document"}</div></>} placement="top">
<div>
<div className={"propertiesButtons-linkButton-empty"}
onPointerDown={() => {
if (this.selectedDocumentView) {
- SharingManager.Instance.open(this.selectedDocumentView);
+ SharingManager.Instance.open(docView, this.selectedDoc);
}
}}>
{<FontAwesomeIcon className="propertiesButtons-icon"
@@ -485,20 +485,21 @@ export class PropertiesButtons extends React.Component<{}, {}> {
handleOptionChange = (e: any) => {
const value = e.target.value;
this.selectedDoc && (this.selectedDoc.onClickBehavior = e.target.value);
+ const docView = this.selectedDocumentView?.props.Document === this.selectedDoc ? this.selectedDocumentView : undefined;
if (value === "nothing") {
- this.selectedDocumentView?.noOnClick();
+ docView?.noOnClick();
} else if (value === "enterPortal") {
- this.selectedDocumentView?.noOnClick();
- this.selectedDocumentView?.makeIntoPortal();
+ docView?.noOnClick();
+ docView?.makeIntoPortal();
} else if (value === "toggleDetail") {
- this.selectedDocumentView?.noOnClick();
- this.selectedDocumentView?.toggleDetail();
+ docView?.noOnClick();
+ docView?.toggleDetail();
} else if (value === "linkInPlace") {
- this.selectedDocumentView?.noOnClick();
- this.selectedDocumentView?.toggleFollowLink("inPlace", true, false);
+ docView?.noOnClick();
+ docView?.toggleFollowLink("inPlace", true, false);
} else if (value === "linkOnRight") {
- this.selectedDocumentView?.noOnClick();
- this.selectedDocumentView?.toggleFollowLink("onRight", false, false);
+ docView?.noOnClick();
+ docView?.toggleFollowLink("onRight", false, false);
}
}
@@ -565,8 +566,8 @@ export class PropertiesButtons extends React.Component<{}, {}> {
<div>
<div className={"propertiesButtons-linkButton-empty"}
onPointerDown={() => {
- if (this.selectedDocumentView) {
- GooglePhotos.Export.CollectionToAlbum({ collection: this.selectedDocumentView.Document }).then(console.log);
+ if (this.selectedDoc) {
+ GooglePhotos.Export.CollectionToAlbum({ collection: this.selectedDoc }).then(console.log);
}
}}>
{<FontAwesomeIcon className="documentdecorations-icon"
diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx
index f34ac7d03..bc44ad8a5 100644
--- a/src/client/views/collections/CollectionSchemaView.tsx
+++ b/src/client/views/collections/CollectionSchemaView.tsx
@@ -20,7 +20,6 @@ import { undoBatch } from "../../util/UndoManager";
import { COLLECTION_BORDER_WIDTH } from '../../views/globalCssVariables.scss';
import '../DocumentDecorations.scss';
import { ContentFittingDocumentView } from "../nodes/ContentFittingDocumentView";
-import { KeysDropdown } from "./CollectionSchemaHeaders";
import "./CollectionSchemaView.scss";
import { CollectionSubView } from "./CollectionSubView";
import { SchemaTable } from "./SchemaTable";
@@ -392,7 +391,7 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) {
@action setFocused = (doc: Doc) => this._focusedTable = doc;
@action setPreviewDoc = (doc: Opt<Doc>) => {
- SelectionManager.SelectSchemaDoc(doc);
+ SelectionManager.SelectSchemaDoc(this, doc);
this.previewDoc = doc;
}
diff --git a/src/client/views/collections/collectionFreeForm/PropertiesView.tsx b/src/client/views/collections/collectionFreeForm/PropertiesView.tsx
index 6fc03c3b5..fb138ecc0 100644
--- a/src/client/views/collections/collectionFreeForm/PropertiesView.tsx
+++ b/src/client/views/collections/collectionFreeForm/PropertiesView.tsx
@@ -51,9 +51,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
@computed get selectedDoc() { return SelectionManager.SelectedSchemaDoc() || this.selectedDocumentView?.rootDoc; }
@computed get selectedDocumentView() {
- if (SelectionManager.SelectedSchemaDoc())
- return undefined;
- else if (SelectionManager.SelectedDocuments().length) {
+ if (SelectionManager.SelectedDocuments().length) {
return SelectionManager.SelectedDocuments()[0];
} else if (PresBox.Instance && PresBox.Instance._selectedArray.length) {
return DocumentManager.Instance.getDocumentView(PresBox.Instance.rootDoc);
@@ -348,7 +346,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
return <Tooltip title={<div className="dash-tooltip">{"Show more permissions"}</div>}>
<div className="expansion-button" onPointerDown={() => {
if (this.selectedDocumentView || this.selectedDoc) {
- SharingManager.Instance.open(this.selectedDocumentView, this.selectedDoc);
+ SharingManager.Instance.open(this.selectedDocumentView?.props.Document === this.selectedDocumentView ? this.selectedDocumentView : undefined, this.selectedDoc);
}
}}>
<FontAwesomeIcon className="expansion-button-icon" icon="ellipsis-h" color="black" size="sm" />