aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/views/DocComponent.tsx2
-rw-r--r--src/client/views/GlobalKeyHandler.ts2
-rw-r--r--src/client/views/collections/CollectionView.tsx4
-rw-r--r--src/client/views/nodes/formattedText/FormattedTextBox.tsx28
-rw-r--r--src/client/views/search/SearchBox.tsx69
5 files changed, 71 insertions, 34 deletions
diff --git a/src/client/views/DocComponent.tsx b/src/client/views/DocComponent.tsx
index 9b9a28f0f..106250af4 100644
--- a/src/client/views/DocComponent.tsx
+++ b/src/client/views/DocComponent.tsx
@@ -146,6 +146,8 @@ export function ViewBoxAnnotatableComponent<P extends ViewBoxAnnotatableProps, T
added.map(doc => doc.context = this.props.Document);
targetDataDoc[this.annotationKey] = new List<Doc>([...docList, ...added]);
targetDataDoc[this.annotationKey + "-lastModified"] = new DateField(new Date(Date.now()));
+ targetDataDoc["lastModified"] = new DateField(new Date(Date.now()));
+
}
}
return true;
diff --git a/src/client/views/GlobalKeyHandler.ts b/src/client/views/GlobalKeyHandler.ts
index c85849adb..2e5c018ba 100644
--- a/src/client/views/GlobalKeyHandler.ts
+++ b/src/client/views/GlobalKeyHandler.ts
@@ -307,6 +307,8 @@ export default class KeyManager {
undoBatch(() => {
targetDataDoc[fieldKey] = new List<Doc>([...docList, ...added]);
targetDataDoc[fieldKey + "-lastModified"] = new DateField(new Date(Date.now()));
+ targetDataDoc["lastModified"] = new DateField(new Date(Date.now()));
+
})();
}
}
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index 0178cc2e9..f9dc666d6 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -159,6 +159,8 @@ export class CollectionView extends Touchable<FieldViewProps & CollectionViewCus
added.map(add => Doc.AddDocToList(Cast(Doc.UserDoc().myCatalog, Doc, null), "data", add));
targetDataDoc[this.props.fieldKey] = new List<Doc>([...docList, ...added]);
targetDataDoc[this.props.fieldKey + "-lastModified"] = new DateField(new Date(Date.now()));
+ targetDataDoc["lastModified"] = new DateField(new Date(Date.now()));
+
}
}
return true;
@@ -554,7 +556,7 @@ export class CollectionView extends Touchable<FieldViewProps & CollectionViewCus
return (<div className={"collectionView"} onContextMenu={this.onContextMenu}
style={{ pointerEvents: this.props.Document.isBackground ? "none" : undefined, boxShadow }}>
{this.showIsTagged()}
- <div className="collectionView-facetCont" style={{ display: this.props.PanelPosition==="absolute"? "flex" : "", justifyContent: this.props.PanelPosition==="absolute"? "center" : "", width: `calc(100% - ${this.facetWidth()}px)` }}>
+ <div className="collectionView-facetCont" style={{ display: this.props.PanelPosition === "absolute" ? "flex" : "", justifyContent: this.props.PanelPosition === "absolute" ? "center" : "", width: `calc(100% - ${this.facetWidth()}px)` }}>
{this.collectionViewType !== undefined ? this.SubView(this.collectionViewType, props) : (null)}
</div>
{this.lightbox(DocListCast(this.props.Document[this.props.fieldKey]).filter(d => d.type === DocumentType.IMG).map(d =>
diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
index 11f25a208..71ba51039 100644
--- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx
+++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
@@ -228,7 +228,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<(FieldViewProp
if (!this.dataDoc[AclSym]) {
if (!this._applyingChange && json.replace(/"selection":.*/, "") !== curProto?.Data.replace(/"selection":.*/, "")) {
this._applyingChange = true;
- (curText !== Cast(this.dataDoc[this.fieldKey], RichTextField)?.Text) && (this.dataDoc[this.props.fieldKey + "-lastModified"] = new DateField(new Date(Date.now())));
+ (curText !== Cast(this.dataDoc[this.fieldKey], RichTextField)?.Text) && (this.dataDoc[this.props.fieldKey + "-lastModified"] = new DateField(new Date(Date.now()))) && (this.dataDoc["lastModified"] = new DateField(new Date(Date.now())));
if ((!curTemp && !curProto) || curText || curLayout?.Data.includes("dash")) { // if no template, or there's text that didn't come from the layout template, write it to the document. (if this is driven by a template, then this overwrites the template text which is intended)
if (json !== curLayout?.Data) {
!curText && tx.storedMarks?.map(m => m.type.name === "pFontSize" && (Doc.UserDoc().fontSize = this.layoutDoc._fontSize = m.attrs.fontSize));
@@ -280,7 +280,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<(FieldViewProp
this._editorView.dispatch(tr.addMark(flattened[lastSel].from, flattened[lastSel].to, link));
}
}
- public highlightSearchTerms = (terms: string[])=> {
+ public highlightSearchTerms = (terms: string[]) => {
if (this._editorView && (this._editorView as any).docView && terms.some(t => t)) {
const mark = this._editorView.state.schema.mark(this._editorView.state.schema.marks.search_highlight);
@@ -291,30 +291,30 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<(FieldViewProp
const flattened: TextSelection[] = [];
res.map(r => r.map(h => flattened.push(h)));
-
+
const lastSel = Math.min(flattened.length - 1, this._searchIndex);
flattened.forEach((h: TextSelection, ind: number) => tr = tr.addMark(h.from, h.to, ind === lastSel ? activeMark : mark));
this._searchIndex = ++this._searchIndex > flattened.length - 1 ? 0 : this._searchIndex;
this._editorView.dispatch(tr.setSelection(new TextSelection(tr.doc.resolve(flattened[lastSel].from), tr.doc.resolve(flattened[lastSel].to))).scrollIntoView());
-
+
console.log(this._searchIndex, length);
- if (this._searchIndex>1){
- this._searchIndex+=-2;
+ if (this._searchIndex > 1) {
+ this._searchIndex += -2;
}
- else if (this._searchIndex===1){
- this._searchIndex=length-1;
+ else if (this._searchIndex === 1) {
+ this._searchIndex = length - 1;
}
- else if (this._searchIndex===0 && length!==1){
- this._searchIndex=length-2;
+ else if (this._searchIndex === 0 && length !== 1) {
+ this._searchIndex = length - 2;
}
let index = this._searchIndex;
Doc.GetProto(this.dataDoc).searchIndex = index;
- Doc.GetProto(this.dataDoc).length=length;
+ Doc.GetProto(this.dataDoc).length = length;
}
}
- public highlightSearchTerms2 = (terms: string[])=> {
+ public highlightSearchTerms2 = (terms: string[]) => {
if (this._editorView && (this._editorView as any).docView && terms.some(t => t)) {
const mark = this._editorView.state.schema.mark(this._editorView.state.schema.marks.search_highlight);
@@ -323,7 +323,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<(FieldViewProp
let length = res[0].length;
let tr = this._editorView.state.tr;
const flattened: TextSelection[] = [];
- res.map(r => r.map(h => flattened.push(h)));
+ res.map(r => r.map(h => flattened.push(h)));
const lastSel = Math.min(flattened.length - 1, this._searchIndex);
flattened.forEach((h: TextSelection, ind: number) => tr = tr.addMark(h.from, h.to, ind === lastSel ? activeMark : mark));
this._searchIndex = ++this._searchIndex > flattened.length - 1 ? 0 : this._searchIndex;
@@ -331,7 +331,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<(FieldViewProp
let index = this._searchIndex;
Doc.GetProto(this.dataDoc).searchIndex = index;
- Doc.GetProto(this.dataDoc).length=length;
+ Doc.GetProto(this.dataDoc).length = length;
}
}
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index b17751d44..005f7d1af 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -40,6 +40,7 @@ import * as _ from "lodash";
import { checkIfStateModificationsAreAllowed } from 'mobx/lib/internal';
import { SchemaHeaderField } from '../../../fields/SchemaHeaderField';
import { indexOf } from 'lodash';
+import { protocol } from 'socket.io-client';
library.add(faTimes);
@@ -379,22 +380,42 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
let docs = DocListCast(selectedCollection.dataDoc[Doc.LayoutFieldKey(selectedCollection.dataDoc)]);
let found: [Doc, string[], string[]][] = [];
let docsforFilter: Doc[] = []
- docs.forEach((d) => {
- let hlights: string[] = [];
- const protos = Doc.GetAllPrototypes(d);
- let proto = protos[protos.length - 2];
- Object.keys(proto).forEach(key => {
- if (StrCast(d[key]).includes(query)) {
- console.log(key, d[key]);
- hlights.push(key);
+ let newarray: Doc[] = [];
+
+ while (docs.length > 0) {
+ console.log("iteration");
+ newarray = [];
+ docs.forEach((d) => {
+ console.log(d);
+ if (d.data != undefined) {
+ let newdocs = DocListCast(d.data);
+ newdocs.forEach((newdoc) => {
+ console.log(newdoc);
+ newarray.push(newdoc);
+
+ });
}
+
+
+ let hlights: string[] = [];
+
+ const protos = Doc.GetAllPrototypes(d);
+ let proto = protos[protos.length - 1];
+ protos.forEach(proto => {
+ Object.keys(proto).forEach(key => {
+ // console.log(key, d[key]);
+ if (StrCast(d[key]).includes(query) && !hlights.includes(key)) {
+ hlights.push(key);
+ }
+ })
+ });
+ if (hlights.length > 0) {
+ found.push([d, hlights, []]);
+ docsforFilter.push(d);
+ };
});
- if (hlights.length > 0) {
- found.push([d, hlights, []]);
- docsforFilter.push(d);
- };
- });
- console.log(found);
+ docs = newarray;
+ }
this._results = found;
this.docsforfilter = docsforFilter;
if (this.filter === true) {
@@ -408,6 +429,20 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
}
+
+ documentKeys(doc: Doc) {
+ const keys: { [key: string]: boolean } = {};
+ // bcz: ugh. this is untracked since otherwise a large collection of documents will blast the server for all their fields.
+ // then as each document's fields come back, we update the documents _proxies. Each time we do this, the whole schema will be
+ // invalidated and re-rendered. This workaround will inquire all of the document fields before the options button is clicked.
+ // then by the time the options button is clicked, all of the fields should be in place. If a new field is added while this menu
+ // is displayed (unlikely) it won't show up until something else changes.
+ //TODO Types
+ Doc.GetAllPrototypes(doc).map
+ (proto => Object.keys(proto).forEach(key => keys[key] = false));
+ return Array.from(Object.keys(keys));
+ }
+
applyBasicFieldFilters(query: string) {
let finalQuery = "";
@@ -669,7 +704,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
const endIndex = 30;
this._endIndex = endIndex === -1 ? 12 : endIndex;
this._endIndex = 30;
- let headers = new Set<string>(["title", "author", "creationDate"]);
+ let headers = new Set<string>(["title", "author", "lastModified"]);
if ((this._numTotalResults === 0 || this._results.length === 0) && this._openNoResults) {
if (this.noresults === "") {
this.noresults = "No search results :(";
@@ -734,12 +769,8 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
if (i < this._visibleDocuments.length) {
this._visibleDocuments[i] = result[0];
this._isSearch[i] = "search";
- console.log("WHYYYY");
- console.log(result[0]);
-
Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]);
this.children++;
-
}
}
}