aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoranika-ahluwalia <anika.ahluwalia@gmail.com>2020-07-31 14:56:35 -0500
committeranika-ahluwalia <anika.ahluwalia@gmail.com>2020-07-31 14:56:35 -0500
commit294a710250d8a007a3cc74bf65fb49b56fc027aa (patch)
tree1208225fc4f542c3c12e3a2db2d37610a601d7b4 /src
parent3504f35028dcd7df3cd65e8fdfa53e6b6876e09a (diff)
parent3f2eb25d042d4115c50722b257cba29e5242262a (diff)
Merge branch 'menu_restructure' of https://github.com/browngraphicslab/Dash-Web into menu_restructure
Diffstat (limited to 'src')
-rw-r--r--src/client/views/collections/CollectionDockingView.scss3
-rw-r--r--src/client/views/collections/CollectionDockingView.tsx21
2 files changed, 20 insertions, 4 deletions
diff --git a/src/client/views/collections/CollectionDockingView.scss b/src/client/views/collections/CollectionDockingView.scss
index 1895c06a1..6d894b56a 100644
--- a/src/client/views/collections/CollectionDockingView.scss
+++ b/src/client/views/collections/CollectionDockingView.scss
@@ -34,12 +34,13 @@
.lm_title_wrap {
overflow: hidden;
height: 19px;
- margin-top: -3px;
+ margin-top: -2px;
display:inline-block;
}
.lm_active .lm_title {
border: solid 1px lightgray;
}
+
.lm_header .lm_tab .lm_close_tab {
position: absolute;
text-align: center;
diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx
index 4952dedc9..375df8786 100644
--- a/src/client/views/collections/CollectionDockingView.tsx
+++ b/src/client/views/collections/CollectionDockingView.tsx
@@ -1,9 +1,8 @@
import 'golden-layout/src/css/goldenlayout-base.css';
import 'golden-layout/src/css/goldenlayout-dark-theme.css';
-import { action, computed, Lambda, observable, reaction, runInAction, trace } from "mobx";
+import { action, computed, Lambda, observable, reaction, runInAction, trace, IReactionDisposer } from "mobx";
import { observer } from "mobx-react";
import * as ReactDOM from 'react-dom';
-import Measure from "react-measure";
import * as GoldenLayout from "../../../client/goldenLayout";
import { DateField } from '../../../fields/DateField';
import { Doc, DocListCast, Field, Opt, DataSym } from "../../../fields/Doc";
@@ -464,6 +463,7 @@ export class CollectionDockingView extends React.Component<SubCollectionViewProp
if (className === "lm_drag_handle" || className === "lm_close" || className === "lm_maximise" || className === "lm_minimise" || className === "lm_close_tab") {
this._flush = true;
}
+ e.stopPropagation();
}
updateDataField = async (json: string) => {
@@ -505,7 +505,6 @@ export class CollectionDockingView extends React.Component<SubCollectionViewProp
const doc = await DocServer.GetRefField(tab.contentItem.config.props.documentId) as Doc;
if (doc instanceof Doc) {
- //tab.titleElement[0].outerHTML = `<input class='lm_title' style="background:black" value='${doc.title}' />`;
tab.titleElement[0].onclick = (e: any) => tab.titleElement[0].focus();
tab.titleElement[0].onchange = (e: any) => {
tab.titleElement[0].size = e.currentTarget.value.length + 1;
@@ -520,6 +519,10 @@ export class CollectionDockingView extends React.Component<SubCollectionViewProp
gearSpan.style.paddingLeft = "0px";
gearSpan.style.paddingRight = "12px";
const stack = tab.contentItem.parent;
+ tab.element[0].onpointerdown = (e: any) => {
+ const view = DocumentManager.Instance.getDocumentView(doc);
+ view && SelectionManager.SelectDoc(view, false);
+ }
// shifts the focus to this tab when another tab is dragged over it
tab.element[0].onmouseenter = (e: any) => {
if (!this._isPointerDown || !SnappingManager.GetIsDragging()) return;
@@ -674,10 +677,15 @@ export class DockedFrameRenderer extends React.Component<DockedFrameProps> {
@observable private _panelHeight = 0;
@observable private _document: Opt<Doc>;
@observable private _isActive: boolean = false;
+ _tabReaction: IReactionDisposer | undefined;
get _stack(): any {
return (this.props as any).glContainer.parent.parent;
}
+ get _tab(): any {
+ const tab = (this.props as any).glContainer.tab.element[0] as HTMLElement;
+ return tab.getElementsByClassName("lm_title")?.[0];
+ }
constructor(props: any) {
super(props);
DocServer.GetRefField(this.props.documentId).then(action((f: Opt<Field>) => this._document = f as Doc));
@@ -738,9 +746,16 @@ export class DockedFrameRenderer extends React.Component<DockedFrameProps> {
this.props.glContainer.layoutManager.on("activeContentItemChanged", this.onActiveContentItemChanged);
this.props.glContainer.on("tab", this.onActiveContentItemChanged);
this.onActiveContentItemChanged();
+ this._tabReaction = reaction(() => ({ views: SelectionManager.SelectedDocuments(), color: StrCast(this._document?._backgroundColor, "white") }),
+ (data) => {
+ const selected = data.views.some(v => Doc.AreProtosEqual(v.props.Document, this._document))
+ this._tab.style.backgroundColor = selected ? data.color : "";
+ }
+ )
}
componentWillUnmount() {
+ this._tabReaction?.();
this.props.glContainer.layoutManager.off("activeContentItemChanged", this.onActiveContentItemChanged);
this.props.glContainer.off("tab", this.onActiveContentItemChanged);
}