aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections
diff options
context:
space:
mode:
authorusodhi <61431818+usodhi@users.noreply.github.com>2021-03-17 01:30:02 -0400
committerusodhi <61431818+usodhi@users.noreply.github.com>2021-03-17 01:30:02 -0400
commit7c6ccf0c6dce1b778163f03ae271b3c17896a560 (patch)
tree6620a2570621a8d66ad9c7edd83ac39a54645dda /src/client/views/collections
parent4f9cfaccc8e0f3d16cf4373e01e6b85c99adabfd (diff)
starting process of addingfilter attributes to new docs in collection
Diffstat (limited to 'src/client/views/collections')
-rw-r--r--src/client/views/collections/CollectionView.tsx16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index 34fd20f1a..4f37747b0 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -38,6 +38,8 @@ import { SubCollectionViewProps } from './CollectionSubView';
import { CollectionTimeView } from './CollectionTimeView';
import { CollectionTreeView } from "./CollectionTreeView";
import './CollectionView.scss';
+import { FilterBox } from '../nodes/FilterBox';
+import { listSpec } from '../../../fields/Schema';
export const COLLECTION_BORDER_WIDTH = 2;
const path = require('path');
@@ -116,6 +118,19 @@ export class CollectionView extends Touchable<CollectionViewProps> {
whenActiveChanged = (isActive: boolean) => this.props.whenActiveChanged(this._isChildActive = isActive);
+ /**
+ * Applies the collection/dashboard's current filter attributes to the doc being added
+ */
+ addFilterAttributes = (doc: Doc) => {
+ Cast(FilterBox.targetDoc._docFilters, listSpec("string"))?.forEach(attribute => {
+ if (attribute.charAt(0).toUpperCase() === attribute.charAt(0)) {
+ const fields = attribute.split(':');
+ if (fields[2] === "check") doc[DataSym][fields[0]] = fields[1];
+ else if (fields[2] === "x" && doc[DataSym][fields[0]] === fields[1]) doc[DataSym][fields[0]] = undefined;
+ }
+ });
+ }
+
@action.bound
addDocument = (doc: Doc | Doc[]): boolean => {
if (this.props.filterAddDocument?.(doc) === false) {
@@ -157,6 +172,7 @@ export class CollectionView extends Touchable<CollectionViewProps> {
DocUtils.LeavePushpin(doc);
doc._stayInCollection = undefined;
doc.context = this.props.Document;
+ this.addFilterAttributes(doc); //
});
added.map(doc => this.props.layerProvider?.(doc, true));// assigns layer values to the newly added document... testing the utility of this
(targetDataDoc[this.props.fieldKey] as List<Doc>).push(...added);