aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/documents/Documents.ts1
-rw-r--r--src/client/views/collections/collectionSchema/CollectionSchemaView.tsx26
-rw-r--r--src/client/views/collections/collectionSchema/SchemaRowBox.tsx10
3 files changed, 21 insertions, 16 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index c34a833f8..365af66b7 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -227,6 +227,7 @@ export class DocumentOptions {
_header_pointerEvents?: PEVt = new PEInfo('types of events the header of a custom text document can consume');
_lockedPosition?: BOOLt = new BoolInfo("lock the x,y coordinates of the document so that it can't be dragged");
_lockedTransform?: BOOLt = new BoolInfo('lock the freeform_panx,freeform_pany and scale parameters of the document so that it be panned/zoomed');
+ _childrenSharedWithSchema?: BOOLt = new BoolInfo("whether this document's children are displayed in its parent schema view");
dataViz_title?: string;
dataViz_line?: string;
diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
index 30daa793a..39bde7d37 100644
--- a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
+++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
@@ -147,7 +147,7 @@ export class CollectionSchemaView extends CollectionSubView() {
}
@computed get rowHeights() {
- return this.childDocs.map(() => this.rowHeightFunc());
+ return this.childDocs.concat(this._lentDocs).map(() => this.rowHeightFunc());
}
@computed get displayColumnWidths() {
@@ -584,7 +584,8 @@ export class CollectionSchemaView extends CollectionSubView() {
const draggedDocs = de.complete.docDragData?.draggedDocuments;
if (draggedDocs && super.onInternalDrop(e, de) && !this.sortField) {
- const map = draggedDocs?.map(doc => this.rowIndex(doc));
+ const sortedDocs = this.sortedDocs.docs.slice();
+const filteredChildDocs = sortedDocs.filter((doc: Doc) => !this._lentDocs.includes(doc));
this.dataDoc[this.fieldKey ?? 'data'] = new List<Doc>([...this.sortedDocs.docs]);
this.clearSelection();
draggedDocs.forEach(doc => {
@@ -638,17 +639,16 @@ export class CollectionSchemaView extends CollectionSubView() {
return undefined;
};
- addDocsFromChildCollection = (collection: CollectionSchemaView) => {
- const childDocs = collection.childDocs.slice();
- console.log(childDocs)
- childDocs.forEach((doc: Doc) => {!this.childDocs.includes(doc) && this._lentDocs.push(doc)});
+ addDocsFromChildCollection = (collection: Doc) => {
+ const childDocs = DocListCast(collection[Doc.LayoutFieldKey(collection)]);
+ childDocs.forEach((doc: Doc) => {!this.displayedDocsFunc().includes(doc) && this._lentDocs.push(doc)});
}
- removeChildCollectionDocs = (collection: CollectionSchemaView) => {
- const children = collection.childDocs.slice();
- this._lentDocs.forEach(element => {
-
- });
+ removeChildCollectionDocs = (collection: Doc) => {
+ const children = DocListCast(collection[Doc.LayoutFieldKey(collection)]);
+ console.log('before: ' + this._lentDocs)
+ this._lentDocs.filter((doc: Doc) => !children.includes(doc));
+ console.log('after: ' + this._lentDocs)
}
@computed get fieldDefaultInput() {
@@ -1016,7 +1016,7 @@ export class CollectionSchemaView extends CollectionSubView() {
const draggedDocs = this.isContentActive() ? DragManager.docsBeingDragged : [];
const field = StrCast(this.layoutDoc.sortField);
const desc = BoolCast(this.layoutDoc.sortDesc); // is this an ascending or descending sort
- const staticDocs = this.childDocs.filter(d => !draggedDocs.includes(d));
+ const staticDocs = this.childDocs.filter(d => !draggedDocs.includes(d)).concat(this._lentDocs.filter(d => !draggedDocs.includes(d)));
const docs = !field
? staticDocs
: [...staticDocs].sort((docA, docB) => {
@@ -1039,7 +1039,7 @@ export class CollectionSchemaView extends CollectionSubView() {
screenToLocal = () => this.ScreenToLocalBoxXf().translate(-this.tableWidth, 0);
previewWidthFunc = () => this.previewWidth;
onPassiveWheel = (e: WheelEvent) => e.stopPropagation();
- displayedDocsFunc = () => this._lentDocs.slice().concat(this.sortedDocs.docs);
+ displayedDocsFunc = () => this.sortedDocs.docs;
_oldWheel: any;
render() {
return (
diff --git a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx
index 8e4161413..8ac2c0314 100644
--- a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx
+++ b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx
@@ -74,9 +74,13 @@ export class SchemaRowBox extends ViewBoxBaseComponent<SchemaRowBoxProps>() {
});
if (this.Document['type'] === 'collection') {
ContextMenu.Instance.addItem({
- description: 'Add children to schema',
- event: () => this.schemaView.addDocsFromChildCollection(this.Document as unknown as CollectionSchemaView),
- icon: 'plus',
+ description: this.Document._childrenSharedWithSchema ? 'Remove children from schema' : 'Add children to schema',
+ event: () => {
+ this.Document._childrenSharedWithSchema = !this.Document._childrenSharedWithSchema;
+ this.Document._childrenSharedWithSchema ?
+ this.schemaView.addDocsFromChildCollection(this.Document) : this.schemaView.removeChildCollectionDocs(this.Document);
+ },
+ icon: this.Document._childrenSharedWithSchema ? 'minus' : 'plus',
});
}
ContextMenu.Instance.displayMenu(x, y, undefined, false);