aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/PropertiesButtons.tsx
diff options
context:
space:
mode:
authorgeireann <60007097+geireann@users.noreply.github.com>2020-08-20 22:55:11 +0800
committergeireann <60007097+geireann@users.noreply.github.com>2020-08-20 22:55:11 +0800
commit0f4228de41bc99a4daad8f639760f94b664c8682 (patch)
treeab04c476e6d473f26fe548b17655338fe6d6461a /src/client/views/PropertiesButtons.tsx
parent084025582325b662a442538dde911b58920a8d8b (diff)
parent94b1a9f9b0c27c3821724f13bd3df13754deaddd (diff)
Merge branch 'master' into presentation_updates
Diffstat (limited to 'src/client/views/PropertiesButtons.tsx')
-rw-r--r--src/client/views/PropertiesButtons.tsx56
1 files changed, 28 insertions, 28 deletions
diff --git a/src/client/views/PropertiesButtons.tsx b/src/client/views/PropertiesButtons.tsx
index 6bd2c2493..ae57560d0 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"; }
@@ -296,13 +296,12 @@ export class PropertiesButtons extends React.Component<{}, {}> {
setupMoveUpEvents(this, e, this.onAliasButtonMoved, emptyFunction, emptyFunction);
}
@undoBatch
- onAliasButtonMoved = () => {
- if (this._dragRef.current) {
- const dragDocView = this.selectedDocumentView!;
- const dragData = new DragManager.DocumentDragData([dragDocView.props.Document]);
- const [left, top] = dragDocView.props.ScreenToLocalTransform().inverse().transformPoint(0, 0);
+ onAliasButtonMoved = (e: PointerEvent) => {
+ if (this._dragRef.current && this.selectedDoc) {
+ const dragData = new DragManager.DocumentDragData([this.selectedDoc]);
+ const [left, top] = [e.clientX, e.clientY];
dragData.dropAction = "alias";
- DragManager.StartDocumentDrag([dragDocView.ContentDiv!], dragData, left, top, {
+ DragManager.StartDocumentDrag([this._dragRef.current], dragData, left, top, {
offsetX: dragData.offset[0],
offsetY: dragData.offset[1],
hideSource: false
@@ -314,7 +313,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 +365,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 +401,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 +432,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 +484,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 +565,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"