aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2022-11-17 16:28:01 -0500
committerbobzel <zzzman@gmail.com>2022-11-17 16:28:01 -0500
commit4a0686ca3db91cf6e2c984c53f1ad4f2fea8de8b (patch)
treeb3aae31500bf69d9cee0b5c1ab2943ca514334eb /src/client/views/collections
parentb7d4f932d826d48aca4c7c058e05ceaea9c43057 (diff)
more cleanup to addDocTab. fixed pile views to show proper icons instead of loading document label icons
Diffstat (limited to 'src/client/views/collections')
-rw-r--r--src/client/views/collections/CollectionStackingView.tsx10
-rw-r--r--src/client/views/collections/TabDocView.tsx37
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx28
-rw-r--r--src/client/views/collections/collectionMulticolumn/CollectionMultirowView.tsx9
4 files changed, 32 insertions, 52 deletions
diff --git a/src/client/views/collections/CollectionStackingView.tsx b/src/client/views/collections/CollectionStackingView.tsx
index aa4583af6..ac6391365 100644
--- a/src/client/views/collections/CollectionStackingView.tsx
+++ b/src/client/views/collections/CollectionStackingView.tsx
@@ -241,14 +241,6 @@ export class CollectionStackingView extends CollectionSubView<Partial<collection
return () => this.props.childDoubleClickScript || ScriptCast(this.Document.onChildDoubleClick);
}
- addDocTab = (doc: Doc, where: OpenWhere) => {
- if (where === 'inPlace' && this.layoutDoc.isInPlaceContainer) {
- this.dataDoc[this.props.fieldKey] = new List<Doc>([doc]);
- return true;
- }
- return this.props.addDocTab(doc, where);
- };
-
scrollToBottom = () => {
smoothScroll(500, this._mainCont!, this._mainCont!.scrollHeight);
};
@@ -361,7 +353,7 @@ export class CollectionStackingView extends CollectionSubView<Partial<collection
removeDocument={this.props.removeDocument}
contentPointerEvents={StrCast(this.layoutDoc.contentPointerEvents)}
whenChildContentsActiveChanged={this.props.whenChildContentsActiveChanged}
- addDocTab={this.addDocTab}
+ addDocTab={this.props.addDocTab}
bringToFront={returnFalse}
scriptContext={this.props.scriptContext}
pinToPres={this.props.pinToPres}
diff --git a/src/client/views/collections/TabDocView.tsx b/src/client/views/collections/TabDocView.tsx
index 2cc588b78..7696777fd 100644
--- a/src/client/views/collections/TabDocView.tsx
+++ b/src/client/views/collections/TabDocView.tsx
@@ -345,30 +345,19 @@ export class TabDocView extends React.Component<TabDocViewProps> {
// inPlace - will add the document to any collection along the path from the document to the docking view that has a field isInPlaceContainer. if none is found, inPlace adds a tab to current stack
addDocTab = (doc: Doc, location: OpenWhere) => {
SelectionManager.DeselectAll();
- const locationFields = doc._viewType === CollectionViewType.Docking ? [OpenWhere.dashboard] : location.split(':');
- const locationParams: OpenWhereMod = locationFields.length > 1 ? (locationFields[1] as OpenWhereMod) : OpenWhereMod.none;
- switch (locationFields[0]) {
- case OpenWhere.dashboard:
- return DashboardView.openDashboard(doc);
- case OpenWhere.close:
- return CollectionDockingView.CloseSplit(doc, locationParams);
- case OpenWhere.fullScreen:
- return CollectionDockingView.OpenFullScreen(doc);
- case OpenWhere.replace:
- return CollectionDockingView.ReplaceTab(doc, locationParams, this.stack);
- case OpenWhere.inPlace:
- const inPlaceView = DocCast(doc.context) ? DocumentManager.Instance.getFirstDocumentView(DocCast(doc.context)) : undefined;
- if (inPlaceView) {
- inPlaceView.dataDoc[Doc.LayoutFieldKey(inPlaceView.rootDoc)] = new List<Doc>([doc]);
- return true;
- } // fall through to lightbox
- case OpenWhere.lightbox:
- return LightboxView.AddDocTab(doc, location, undefined, this.addDocTab);
- case OpenWhere.toggle:
- return CollectionDockingView.ToggleSplit(doc, locationParams, this.stack);
- case OpenWhere.add:
- default:
- return CollectionDockingView.AddSplit(doc, locationParams, this.stack);
+ const whereFields = doc._viewType === CollectionViewType.Docking ? [OpenWhere.dashboard] : location.split(':');
+ const whereMods: OpenWhereMod = whereFields.length > 1 ? (whereFields[1] as OpenWhereMod) : OpenWhereMod.none;
+ if (doc.dockingConfig) return DashboardView.openDashboard(doc);
+ // prettier-ignore
+ switch (whereFields[0]) {
+ case OpenWhere.inPlace: // fall through to lightbox
+ case OpenWhere.lightbox: return LightboxView.AddDocTab(doc, location, undefined, this.addDocTab);
+ case OpenWhere.dashboard: return DashboardView.openDashboard(doc);
+ case OpenWhere.fullScreen: return CollectionDockingView.OpenFullScreen(doc);
+ case OpenWhere.close: return CollectionDockingView.CloseSplit(doc, whereMods);
+ case OpenWhere.replace: return CollectionDockingView.ReplaceTab(doc, whereMods, this.stack);
+ case OpenWhere.toggle: return CollectionDockingView.ToggleSplit(doc, whereMods, this.stack);
+ case OpenWhere.add:default:return CollectionDockingView.AddSplit(doc, whereMods, this.stack);
}
};
remDocTab = (doc: Doc | Doc[]) => {
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index 8cabf060d..56a5c3dcc 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -1330,17 +1330,23 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
);
}
addDocTab = action((doc: Doc, where: OpenWhere) => {
- if (where === OpenWhere.inParent) {
- (doc instanceof Doc ? [doc] : doc).forEach(doc => {
- const pt = this.getTransform().transformPoint(NumCast(doc.x), NumCast(doc.y));
- doc.x = pt[0];
- doc.y = pt[1];
- });
- return this.props.addDocument?.(doc) || false;
- }
- if (where === OpenWhere.inPlace && this.layoutDoc.isInPlaceContainer) {
- this.dataDoc[this.props.fieldKey] = doc instanceof Doc ? doc : new List<Doc>(doc as any as Doc[]);
- return true;
+ switch (where) {
+ case OpenWhere.inParent:
+ return (
+ this.props.addDocument?.(
+ (doc instanceof Doc ? [doc] : doc).map(doc => {
+ const pt = this.getTransform().transformPoint(NumCast(doc.x), NumCast(doc.y));
+ doc.x = pt[0];
+ doc.y = pt[1];
+ return doc;
+ })
+ ) || false
+ );
+ case OpenWhere.inPlace:
+ if (this.layoutDoc.isInPlaceContainer) {
+ this.dataDoc[this.props.fieldKey] = new List<Doc>(doc instanceof Doc ? [doc] : doc);
+ return true;
+ }
}
return this.props.addDocTab(doc, where);
});
diff --git a/src/client/views/collections/collectionMulticolumn/CollectionMultirowView.tsx b/src/client/views/collections/collectionMulticolumn/CollectionMultirowView.tsx
index d7f317f4f..407deaabd 100644
--- a/src/client/views/collections/collectionMulticolumn/CollectionMultirowView.tsx
+++ b/src/client/views/collections/collectionMulticolumn/CollectionMultirowView.tsx
@@ -234,13 +234,6 @@ export class CollectionMultirowView extends CollectionSubView() {
onChildClickHandler = () => ScriptCast(this.Document.onChildClick);
onChildDoubleClickHandler = () => ScriptCast(this.Document.onChildDoubleClick);
- addDocTab = (doc: Doc, where: string) => {
- if (where === 'inPlace' && this.layoutDoc.isInPlaceContainer) {
- this.dataDoc[this.props.fieldKey] = new List<Doc>([doc]);
- return true;
- }
- return this.props.addDocTab(doc, where);
- };
focusDocument = (doc: Doc, options: DocFocusOptions) => this.props.focus(this.rootDoc, options);
isContentActive = () => this.props.isSelected() || this.props.isContentActive() || this.props.isAnyChildContentActive();
isChildContentActive = () => (((this.props.childDocumentsActive?.() || this.Document._childDocumentsActive) && this.props.isDocumentActive?.() && SnappingManager.GetIsDragging()) || this.isContentActive() ? true : false);
@@ -277,7 +270,7 @@ export class CollectionMultirowView extends CollectionSubView() {
moveDocument={this.props.moveDocument}
removeDocument={this.props.removeDocument}
whenChildContentsActiveChanged={this.props.whenChildContentsActiveChanged}
- addDocTab={this.addDocTab}
+ addDocTab={this.props.addDocTab}
pinToPres={this.props.pinToPres}
bringToFront={returnFalse}
/>