From a37cdb9d11271a28b0d9265fcb598747a6a0074a Mon Sep 17 00:00:00 2001 From: Andy Rickert Date: Wed, 12 Aug 2020 16:33:59 -0400 Subject: f --- .../views/collections/CollectionSchemaHeaders.tsx | 8 +++++++- src/client/views/collections/SchemaTable.tsx | 2 +- src/client/views/search/SearchBox.tsx | 18 +++++++++++++----- 3 files changed, 21 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/client/views/collections/CollectionSchemaHeaders.tsx b/src/client/views/collections/CollectionSchemaHeaders.tsx index d379f1c1e..0ad1c5fa1 100644 --- a/src/client/views/collections/CollectionSchemaHeaders.tsx +++ b/src/client/views/collections/CollectionSchemaHeaders.tsx @@ -13,6 +13,7 @@ import { SearchBox } from "../search/SearchBox"; import { ColumnType } from "./CollectionSchemaView"; import "./CollectionSchemaView.scss"; import { CollectionView } from "./CollectionView"; +import * as fa from '@fortawesome/free-solid-svg-icons'; const higflyout = require("@hig/flyout"); export const { anchorPoints } = higflyout; @@ -486,7 +487,12 @@ export class KeysDropdown extends React.Component { console.log(this._isOpen, this._key, this._searchTerm); return (
- { this.props.Document._searchDoc ? runInAction(() => { this._isOpen === undefined ? this._isOpen = true : this._isOpen = !this._isOpen }) : this.props.openHeader(this.props.col, e.clientX, e.clientY) }} icon={this.props.icon} size="lg" style={{ display: "inline", paddingBottom: "1px", paddingTop: "4px", cursor: "hand" }} /> + { this.props.openHeader(this.props.col, e.clientX, e.clientY) }} icon={this.props.icon} size="lg" style={{ display: "inline", paddingBottom: "1px", paddingTop: "4px", cursor: "hand" }} /> + + { + runInAction(() => { this._isOpen === undefined ? this._isOpen = true : this._isOpen = !this._isOpen }) + }} /> +
{ const newSchemaHeaders = oldSchemaHeaders.map(i => typeof i === "string" ? new SchemaHeaderField(i, "#f1efeb") : i); this.props.Document._schemaHeaders = new List(newSchemaHeaders); } else if (this.props.Document._schemaHeaders === undefined) { - this.props.Document._schemaHeaders = new List([new SchemaHeaderField("title", "#f1efeb")]); + this.props.Document._schemaHeaders = new List([new SchemaHeaderField("title", "#f1efeb"), new SchemaHeaderField("author", "#f1efeb"), new SchemaHeaderField("*lastModified", "#f1efeb")]); } } diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx index 2e2e87092..da3bafa95 100644 --- a/src/client/views/search/SearchBox.tsx +++ b/src/client/views/search/SearchBox.tsx @@ -168,7 +168,6 @@ export class SearchBox extends ViewBoxBaseComponent([]); if (this.currentSelectedCollection !== undefined) { this.currentSelectedCollection.props.Document._searchDocs = new List([]); this.currentSelectedCollection = undefined; @@ -805,12 +804,21 @@ export class SearchBox extends ViewBoxBaseComponent schemaheaders.push(new SchemaHeaderField(item, "#f1efeb"))); - this.headercount = schemaheaders.length; if (Cast(this.props.Document._docFilters, listSpec("string"), []).length === 0) { - this.props.Document._schemaHeaders = new List(schemaheaders); + const oldSchemaHeaders = Cast(this.props.Document._schemaHeaders, listSpec("string"), []); + if (oldSchemaHeaders?.length && typeof oldSchemaHeaders[0] !== "object") { + const newSchemaHeaders = oldSchemaHeaders.map(i => typeof i === "string" ? new SchemaHeaderField(i, "#f1efeb") : i); + headers.forEach(header => { + if (oldSchemaHeaders.includes(header) === false) { + newSchemaHeaders.push(new SchemaHeaderField(header, "#f1efeb")) + } + }); + this.headercount = newSchemaHeaders.length; + this.props.Document._schemaHeaders = new List(newSchemaHeaders); + } else if (this.props.Document._schemaHeaders === undefined) { + this.props.Document._schemaHeaders = new List([new SchemaHeaderField("title", "#f1efeb")]); + } } if (this._maxSearchIndex >= this._numTotalResults) { this._visibleElements.length = this._results.length; -- cgit v1.2.3-70-g09d2 From 595e7176de394e192bbde3499e6335953fdc1790 Mon Sep 17 00:00:00 2001 From: bobzel Date: Wed, 12 Aug 2020 17:41:00 -0400 Subject: fixed collections being hidden from SOLR. fixed warning. --- src/client/views/collections/CollectionTreeView.tsx | 2 +- src/client/views/collections/collectionFreeForm/MarqueeView.tsx | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/client/views/collections/CollectionTreeView.tsx b/src/client/views/collections/CollectionTreeView.tsx index 6768c6df9..872cd731d 100644 --- a/src/client/views/collections/CollectionTreeView.tsx +++ b/src/client/views/collections/CollectionTreeView.tsx @@ -497,7 +497,7 @@ class TreeView extends React.Component { } } } else this._editMaxWidth = ""; - return
this.props.active() && SelectionManager.DeselectAll()}> + return
this.props.active(true) && SelectionManager.DeselectAll()}>
  • { if (this.props.active(true)) { diff --git a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx index 54b09ab72..c0b19fcd2 100644 --- a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx +++ b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx @@ -356,6 +356,7 @@ export class MarqueeView extends React.Component Date: Thu, 13 Aug 2020 16:51:01 -0400 Subject: total results, schema field fixes, filtering in headers --- src/client/util/SearchUtil.ts | 2 +- .../views/collections/CollectionSchemaCells.tsx | 55 ++++++++++++++++++++-- .../views/collections/CollectionSchemaHeaders.tsx | 37 ++++++++++----- src/client/views/collections/SchemaTable.tsx | 3 +- src/client/views/search/SearchBox.tsx | 12 ++++- 5 files changed, 89 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/client/util/SearchUtil.ts b/src/client/util/SearchUtil.ts index 3073da954..286544222 100644 --- a/src/client/util/SearchUtil.ts +++ b/src/client/util/SearchUtil.ts @@ -83,7 +83,7 @@ export namespace SearchUtil { } } - return { docs: theDocs, numFound: theDocs.length, highlighting, lines: theLines }; + return { docs: theDocs, numFound: result.numFound, highlighting, lines: theLines }; } export async function GetAliasesOfDocument(doc: Doc): Promise; diff --git a/src/client/views/collections/CollectionSchemaCells.tsx b/src/client/views/collections/CollectionSchemaCells.tsx index 49d75e6de..9cdd3b082 100644 --- a/src/client/views/collections/CollectionSchemaCells.tsx +++ b/src/client/views/collections/CollectionSchemaCells.tsx @@ -1,5 +1,5 @@ import React = require("react"); -import { action, observable, trace, computed } from "mobx"; +import { action, observable, trace, computed, runInAction } from "mobx"; import { observer } from "mobx-react"; import { CellInfo } from "react-table"; import "react-table/react-table.css"; @@ -69,10 +69,30 @@ export class CollectionSchemaCell extends React.Component { protected _document = this.props.rowProps.original; protected _dropDisposer?: DragManager.DragDropDisposer; - componentDidMount() { + async componentWillMount() { + + } + + async componentDidMount() { document.addEventListener("keydown", this.onKeyDown); + console.log("mounted"); + console.log(this.type); + if (this.type === "context") { + console.log("mounted2"); + const doc = Doc.GetProto(this.props.rowProps.original); + const aliasdoc = await SearchUtil.GetAliasesOfDocument(doc); + let targetContext = undefined; + if (aliasdoc.length > 0) { + targetContext = Cast(aliasdoc[0].context, Doc) as Doc; + console.log(StrCast(targetContext.title)); + runInAction(() => this.contents = StrCast(targetContext.title)); + } + } + } + @observable contents: string = ""; + componentWillUnmount() { document.removeEventListener("keydown", this.onKeyDown); } @@ -184,6 +204,7 @@ export class CollectionSchemaCell extends React.Component { return {contents ? contents?.valueOf() : "undefined"}; } } + type: string = ""; renderCellWithType(type: string | undefined) { const dragRef: React.RefObject = React.createRef(); @@ -287,8 +308,9 @@ export class CollectionSchemaCell extends React.Component { //
    // ); const positions = []; + let cfield = ComputedField.WithoutComputed(() => FieldValue(props.Document[props.fieldKey])); + this.type = props.fieldKey; if (StrCast(this.props.Document._searchString).toLowerCase() !== "") { - const cfield = ComputedField.WithoutComputed(() => FieldValue(props.Document[props.fieldKey])); let term = Field.toString(cfield as Field); term = term.toLowerCase(); const search = StrCast(this.props.Document._searchString).toLowerCase(); @@ -312,7 +334,6 @@ export class CollectionSchemaCell extends React.Component { search = true; } - return (
    @@ -337,9 +358,14 @@ export class CollectionSchemaCell extends React.Component { if (cfield !== undefined) { // if (typeof(cfield)===RichTextField) const a = cfield as RichTextField; + const b = cfield as DateField; + console.log(b); if (a.Text !== undefined) { return (a.Text); } + else if (b.toString() !== undefined) { + return b.toString(); + } else if (StrCast(cfield)) { return StrCast(cfield); } @@ -397,7 +423,26 @@ export class CollectionSchemaCell extends React.Component { /> : this.returnHighlights(() => { - const cfield = ComputedField.WithoutComputed(() => FieldValue(props.Document[props.fieldKey])); + console.log(props.fieldKey); + let dateCheck: Date | undefined = this.props.rowProps.original[this.props.rowProps.column.id as string] instanceof DateField ? DateCast(this.props.rowProps.original[this.props.rowProps.column.id as string]).date : undefined; + if (dateCheck !== undefined) { + cfield = dateCheck.toLocaleString(); + } + if (props.fieldKey === "context") { + cfield = this.contents; + console.log("this should work"); + } + if (props.fieldKey === "*lastModified") { + if (FieldValue(props.Document["data-lastModified"]) !== undefined) { + const d = ComputedField.WithoutComputed(() => FieldValue(props.Document["data-lastModified"])) as DateField; + cfield = d.date.toLocaleString(); + } + + else if (FieldValue(props.Document["text-lastModified"]) !== undefined) { + const d = ComputedField.WithoutComputed(() => FieldValue(props.Document["text-lastModified"])) as DateField; + cfield = d.date.toLocaleString(); + } + } return Field.toString(cfield as Field); }, positions) } diff --git a/src/client/views/collections/CollectionSchemaHeaders.tsx b/src/client/views/collections/CollectionSchemaHeaders.tsx index fa260bee1..5c0e6581b 100644 --- a/src/client/views/collections/CollectionSchemaHeaders.tsx +++ b/src/client/views/collections/CollectionSchemaHeaders.tsx @@ -309,16 +309,29 @@ export class KeysDropdown extends React.Component { @undoBatch onKeyDown = (e: React.KeyboardEvent): void => { if (e.key === "Enter") { - let keyOptions = this._searchTerm === "" ? this.props.possibleKeys : this.props.possibleKeys.filter(key => key.toUpperCase().indexOf(this._searchTerm.toUpperCase()) > -1); - const blockedkeys = ["_scrollTop", "customTitle", "limitHeight", "proto", "x", "y", "_width", "_height", "_autoHeight", "_fontSize", "_fontFamily", "context", "zIndex", "_timeStampOnEnter", "lines", "highlighting", "searchMatch", "creationDate", "isPrototype", "text-annotations", "aliases", "text-lastModified", "text-noTemplate", "layoutKey", "baseProto", "_xMargin", "_yMargin", "layout", "layout_keyValue", "links"]; - keyOptions = keyOptions.filter(n => !blockedkeys.includes(n)); - if (keyOptions.length) { - this.onSelect(keyOptions[0]); - console.log("case1"); - } else if (this._searchTerm !== "" && this.props.canAddNew) { - this.setSearchTerm(this._searchTerm || this._key); - console.log("case2"); - this.onSelect(this._searchTerm); + if (this._searchTerm.includes(":")) { + const colpos = this._searchTerm.indexOf(":"); + const temp = this._searchTerm.slice(colpos + 1, this._searchTerm.length); + if (temp === "") { + Doc.setDocFilter(this.props.Document, this._key, temp, undefined); + } + else { + Doc.setDocFilter(this.props.Document, this._key, temp, "match"); + this.props.col.setColor("green"); + } + } + else { + let keyOptions = this._searchTerm === "" ? this.props.possibleKeys : this.props.possibleKeys.filter(key => key.toUpperCase().indexOf(this._searchTerm.toUpperCase()) > -1); + const blockedkeys = ["_scrollTop", "customTitle", "limitHeight", "proto", "x", "y", "_width", "_height", "_autoHeight", "_fontSize", "_fontFamily", "context", "zIndex", "_timeStampOnEnter", "lines", "highlighting", "searchMatch", "creationDate", "isPrototype", "text-annotations", "aliases", "text-lastModified", "text-noTemplate", "layoutKey", "baseProto", "_xMargin", "_yMargin", "layout", "layout_keyValue", "links"]; + keyOptions = keyOptions.filter(n => !blockedkeys.includes(n)); + if (keyOptions.length) { + this.onSelect(keyOptions[0]); + console.log("case1"); + } else if (this._searchTerm !== "" && this.props.canAddNew) { + this.setSearchTerm(this._searchTerm || this._key); + console.log("case2"); + this.onSelect(this._searchTerm); + } } } } @@ -410,7 +423,7 @@ export class KeysDropdown extends React.Component { return <>; } - let keyOptions: string[] = []; + const keyOptions: string[] = []; const colpos = this._searchTerm.indexOf(":"); const temp = this._searchTerm.slice(colpos + 1, this._searchTerm.length); if (this.docSafe.length === 0) { @@ -494,7 +507,7 @@ export class KeysDropdown extends React.Component { render() { return (
    - { this.props.openHeader(this.props.col, e.clientX, e.clientY) }} icon={this.props.icon} size="lg" style={{ display: "inline", paddingBottom: "1px", paddingTop: "4px", cursor: "hand" }} /> + { this.props.openHeader(this.props.col, e.clientX, e.clientY); }} icon={this.props.icon} size="lg" style={{ display: "inline", paddingBottom: "1px", paddingTop: "4px", cursor: "hand" }} /> {/* { runInAction(() => { this._isOpen === undefined ? this._isOpen = true : this._isOpen = !this._isOpen }) diff --git a/src/client/views/collections/SchemaTable.tsx b/src/client/views/collections/SchemaTable.tsx index 8d87a3ba2..a2c529a21 100644 --- a/src/client/views/collections/SchemaTable.tsx +++ b/src/client/views/collections/SchemaTable.tsx @@ -320,7 +320,8 @@ export class SchemaTable extends React.Component { const newSchemaHeaders = oldSchemaHeaders.map(i => typeof i === "string" ? new SchemaHeaderField(i, "#f1efeb") : i); this.props.Document._schemaHeaders = new List(newSchemaHeaders); } else if (this.props.Document._schemaHeaders === undefined) { - this.props.Document._schemaHeaders = new List([new SchemaHeaderField("title", "#f1efeb"), new SchemaHeaderField("author", "#f1efeb"), new SchemaHeaderField("*lastModified", "#f1efeb")]); + this.props.Document._schemaHeaders = new List([new SchemaHeaderField("title", "#f1efeb"), new SchemaHeaderField("author", "#f1efeb"), new SchemaHeaderField("*lastModified", "#f1efeb"), + new SchemaHeaderField("text", "#f1efeb"), new SchemaHeaderField("type", "#f1efeb"), new SchemaHeaderField("context", "#f1efeb")]); } } diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx index 35b383a27..770a03cb1 100644 --- a/src/client/views/search/SearchBox.tsx +++ b/src/client/views/search/SearchBox.tsx @@ -626,6 +626,7 @@ export class SearchBox extends ViewBoxBaseComponent { // happens at the beginning + this.realTotalResults = res.numFound; if (res.numFound !== this._numTotalResults && this._numTotalResults === -1) { this._numTotalResults = res.numFound; } @@ -716,6 +717,8 @@ export class SearchBox extends ViewBoxBaseComponent { //this.closeResults(); @@ -877,6 +880,13 @@ export class SearchBox extends ViewBoxBaseComponent StrCast(this.layoutDoc._searchString) ? this.startDragCollection() : undefined)} icon={"search"} size="lg" style={{ cursor: "hand", color: "black", padding: 1, left: 35, position: "relative" }} />
    +
    {`${this._results.length}` + " of " + `${this.realTotalResults}`}
    only display documents matching search
    } >
    height : () => 0} PanelWidth={this.open === true ? () => length : () => 0} - overflow={length > screen.width || rows > 6 ? true : false} + overflow={length > window.innerWidth || rows > 6 ? true : false} focus={this.selectElement} ScreenToLocalTransform={Transform.Identity} /> -- cgit v1.2.3-70-g09d2 From 4a2f2bd0b94a923e8cde1199bf9abfedd8dcde23 Mon Sep 17 00:00:00 2001 From: bobzel Date: Thu, 13 Aug 2020 20:19:08 -0400 Subject: fixed search for type with multipe values. changed search schema --- solr-8.3.1/server/solr/dash/conf/schema.xml | 7 +++---- solr-8.3.1/server/solr/dash/conf/solrconfig.xml | 2 +- src/client/util/SearchUtil.ts | 2 +- src/server/websocket.ts | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/solr-8.3.1/server/solr/dash/conf/schema.xml b/solr-8.3.1/server/solr/dash/conf/schema.xml index 47aa56787..a0496444b 100644 --- a/solr-8.3.1/server/solr/dash/conf/schema.xml +++ b/solr-8.3.1/server/solr/dash/conf/schema.xml @@ -44,11 +44,10 @@ - + - @@ -59,10 +58,10 @@ - - + + diff --git a/solr-8.3.1/server/solr/dash/conf/solrconfig.xml b/solr-8.3.1/server/solr/dash/conf/solrconfig.xml index 60f06f57f..705029368 100644 --- a/solr-8.3.1/server/solr/dash/conf/solrconfig.xml +++ b/solr-8.3.1/server/solr/dash/conf/solrconfig.xml @@ -696,7 +696,7 @@ explicit 8 - text + DEFAULT diff --git a/src/client/util/SearchUtil.ts b/src/client/util/SearchUtil.ts index f916ac44a..483ce3196 100644 --- a/src/client/util/SearchUtil.ts +++ b/src/client/util/SearchUtil.ts @@ -37,7 +37,7 @@ export namespace SearchUtil { export async function Search(query: string, returnDocs: boolean, options: SearchParams = {}) { query = query || "*"; //If we just have a filter query, search for * as the query const rpquery = Utils.prepend("/dashsearch"); - const replacedQuery = query.replace(/type_t:([^ )])/, (substring, arg) => `{!join from=id to=proto_i}type_t:${arg}`); + const replacedQuery = query.replace(/type_t:([^ )])/g, (substring, arg) => `{!join from=id to=proto_i}type_t:${arg}`); const gotten = await rp.get(rpquery, { qs: { ...options, /* sort: "lastModified_d desc", */ q: replacedQuery } }); const result: IdSearchResult = gotten.startsWith("<") ? { ids: [], docs: [], numFound: 0, lines: [] } : JSON.parse(gotten); if (!returnDocs) { diff --git a/src/server/websocket.ts b/src/server/websocket.ts index 18c5ece98..ec351c283 100644 --- a/src/server/websocket.ts +++ b/src/server/websocket.ts @@ -203,7 +203,7 @@ export namespace WebSocket { Database.Instance.update(newValue.id, newValue, () => socket.broadcast.emit(MessageStore.SetField.Message, newValue)); if (newValue.type === Types.Text) { // if the newValue has sring type, then it's suitable for searching -- pass it to SOLR - Search.updateDocument({ id: newValue.id, data: (newValue as any).data }); + Search.updateDocument({ id: newValue.id, data: { set: (newValue as any).data } }); } } -- cgit v1.2.3-70-g09d2 From 16e663f807c77c56e64c23689dfdb7000fb2d0e9 Mon Sep 17 00:00:00 2001 From: bobzel Date: Thu, 13 Aug 2020 21:34:58 -0400 Subject: fixed warnings. --- src/client/util/CurrentUserUtils.ts | 2 +- src/client/util/SearchUtil.ts | 2 +- src/client/views/MainView.tsx | 10 +++---- .../views/collections/CollectionSchemaCells.tsx | 5 ++-- .../views/collections/CollectionSchemaView.tsx | 4 ++- .../views/collections/CollectionStackingView.tsx | 1 - .../collectionFreeForm/CollectionFreeFormView.tsx | 8 ++--- src/client/views/nodes/FontIconBox.tsx | 1 - src/client/views/nodes/PresBox.tsx | 34 ++++++++++------------ 9 files changed, 31 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts index 2d988d322..68d02cd94 100644 --- a/src/client/util/CurrentUserUtils.ts +++ b/src/client/util/CurrentUserUtils.ts @@ -856,7 +856,7 @@ export class CurrentUserUtils { doc["sidebar-import-documents"] = new PrefetchProxy(Docs.Create.StackingDocument([], { title: "Imported Documents", forceActive: true, _showTitle: "title", childDropAction: "alias", _autoHeight: true, _yMargin: 30, lockedPosition: true, _chromeStatus: "disabled" })); } if (doc["sidebar-import"] === undefined) { - const uploads = Cast(doc["sidebar-import-documents"], Doc, null) as Doc; + const uploads = Cast(doc["sidebar-import-documents"], Doc, null); const newUpload = CurrentUserUtils.ficon({ onClick: ScriptField.MakeScript("importDocument()"), toolTip: "Import External document", _backgroundColor: "black", title: "Import", icon: "upload", system: true }); doc["sidebar-import"] = new PrefetchProxy(Docs.Create.StackingDocument([newUpload, uploads], { title: "Imported Documents", _yMargin: 20, ignoreClick: true, lockedPosition: true })); } diff --git a/src/client/util/SearchUtil.ts b/src/client/util/SearchUtil.ts index 483ce3196..b63fc8991 100644 --- a/src/client/util/SearchUtil.ts +++ b/src/client/util/SearchUtil.ts @@ -38,7 +38,7 @@ export namespace SearchUtil { query = query || "*"; //If we just have a filter query, search for * as the query const rpquery = Utils.prepend("/dashsearch"); const replacedQuery = query.replace(/type_t:([^ )])/g, (substring, arg) => `{!join from=id to=proto_i}type_t:${arg}`); - const gotten = await rp.get(rpquery, { qs: { ...options, /* sort: "lastModified_d desc", */ q: replacedQuery } }); + const gotten = await rp.get(rpquery, { qs: { ...options, sort: "lastModified_d desc", q: replacedQuery } }); const result: IdSearchResult = gotten.startsWith("<") ? { ids: [], docs: [], numFound: 0, lines: [] } : JSON.parse(gotten); if (!returnDocs) { return result; diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx index d0f543d16..db5325713 100644 --- a/src/client/views/MainView.tsx +++ b/src/client/views/MainView.tsx @@ -45,7 +45,6 @@ import { ANTIMODEMENU_HEIGHT, SEARCH_PANEL_HEIGHT } from './globalCssVariables.s import KeyManager from './GlobalKeyHandler'; import { LinkMenu } from './linking/LinkMenu'; import "./MainView.scss"; -import { MainViewNotifs } from './MainViewNotifs'; import { AudioBox } from './nodes/AudioBox'; import { DocumentLinksButton } from './nodes/DocumentLinksButton'; import { DocumentView } from './nodes/DocumentView'; @@ -895,7 +894,7 @@ export class MainView extends React.Component { } importDocument = () => { - const sidebar = Cast(Doc.UserDoc()["sidebar-import-documents"], Doc, null) as Doc; + const sidebar = Cast(Doc.UserDoc()["sidebar-import-documents"], Doc, null); const sidebarDocView = DocumentManager.Instance.getDocumentView(sidebar); const input = document.createElement("input"); input.type = "file"; @@ -923,9 +922,8 @@ export class MainView extends React.Component { } } } else if (input.files && input.files.length !== 0) { - const files: FileList | null = input.files; - for (let i = 0; i < files.length; i++) { - const file = files[i]; + const files = input.files || []; + Array.from(files).forEach(async file => { const res = await Networking.UploadFilesToServer(file); res.map(async ({ result }) => { const name = file.name; @@ -962,7 +960,7 @@ export class MainView extends React.Component { else pending.data = new List([doc]); } }); - } + }); } else { console.log("No file selected"); } diff --git a/src/client/views/collections/CollectionSchemaCells.tsx b/src/client/views/collections/CollectionSchemaCells.tsx index 9cdd3b082..20ce6b76d 100644 --- a/src/client/views/collections/CollectionSchemaCells.tsx +++ b/src/client/views/collections/CollectionSchemaCells.tsx @@ -81,9 +81,8 @@ export class CollectionSchemaCell extends React.Component { console.log("mounted2"); const doc = Doc.GetProto(this.props.rowProps.original); const aliasdoc = await SearchUtil.GetAliasesOfDocument(doc); - let targetContext = undefined; if (aliasdoc.length > 0) { - targetContext = Cast(aliasdoc[0].context, Doc) as Doc; + const targetContext = Cast(aliasdoc[0].context, Doc) as Doc; console.log(StrCast(targetContext.title)); runInAction(() => this.contents = StrCast(targetContext.title)); } @@ -424,7 +423,7 @@ export class CollectionSchemaCell extends React.Component { : this.returnHighlights(() => { console.log(props.fieldKey); - let dateCheck: Date | undefined = this.props.rowProps.original[this.props.rowProps.column.id as string] instanceof DateField ? DateCast(this.props.rowProps.original[this.props.rowProps.column.id as string]).date : undefined; + const dateCheck: Date | undefined = this.props.rowProps.original[this.props.rowProps.column.id as string] instanceof DateField ? DateCast(this.props.rowProps.original[this.props.rowProps.column.id as string]).date : undefined; if (dateCheck !== undefined) { cfield = dateCheck.toLocaleString(); } diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx index 1de881f6d..f1de3cee7 100644 --- a/src/client/views/collections/CollectionSchemaView.tsx +++ b/src/client/views/collections/CollectionSchemaView.tsx @@ -120,7 +120,9 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) { document.removeEventListener("pointerdown", this.detectClick); } - @action setHeaderIsEditing = (isEditing: boolean) => this._headerIsEditing = isEditing; + @action setHeaderIsEditing = (isEditing: boolean) => { + this._headerIsEditing = isEditing; + } detectClick = (e: PointerEvent): void => { if (this._node && this._node.contains(e.target as Node)) { diff --git a/src/client/views/collections/CollectionStackingView.tsx b/src/client/views/collections/CollectionStackingView.tsx index 2b7ae4338..fe3d57bdb 100644 --- a/src/client/views/collections/CollectionStackingView.tsx +++ b/src/client/views/collections/CollectionStackingView.tsx @@ -28,7 +28,6 @@ import { CollectionViewType } from "./CollectionView"; import { SnappingManager } from "../../util/SnappingManager"; import { CollectionFreeFormDocumentView } from "../nodes/CollectionFreeFormDocumentView"; import { DocUtils } from "../../documents/Documents"; -import { MainViewNotifs } from "../MainViewNotifs"; const _global = (window /* browser */ || global /* node */) as any; type StackingDocument = makeInterface<[typeof collectionSchema, typeof documentSchema]>; diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx index b15bda87d..55c2b253b 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx @@ -1530,10 +1530,10 @@ class CollectionFreeFormViewPannableContents extends React.Component let prevSelected = this.itemIndex; prevSelected = Math.max(0, prevSelected - 1); this.gotoDocument(prevSelected, this.itemIndex); - if (NumCast(prevTargetDoc.lastFrame) > 0) prevTargetDoc.currentFrame = NumCast(prevTargetDoc.lastFrame) + if (NumCast(prevTargetDoc.lastFrame) > 0) prevTargetDoc.currentFrame = NumCast(prevTargetDoc.lastFrame); } } @@ -349,9 +349,7 @@ export class PresBox extends ViewBoxBaseComponent let activeItem = Cast(this.childDocs[this.itemIndex], Doc, null); let targetDoc = Cast(activeItem.presentationTargetDoc, Doc, null); let duration = NumCast(targetDoc.presDuration) + NumCast(targetDoc.presTransition); - const timer = (ms: number) => { - return new Promise(res => this._presTimer = setTimeout(res, ms)); - } + const timer = (ms: number) => new Promise(res => this._presTimer = setTimeout(res, ms)); const load = async () => { // Wrap the loop into an async function for this to work for (var i = startSlide; i < this.childDocs.length; i++) { activeItem = Cast(this.childDocs[this.itemIndex], Doc, null); @@ -367,7 +365,7 @@ export class PresBox extends ViewBoxBaseComponent await timer(duration); this.next(); // then the created Promise can be awaited if (i === this.childDocs.length - 1) setTimeout(() => { clearTimeout(this._presTimer); if (this.layoutDoc.presStatus === 'auto') this.layoutDoc.presStatus = "manual"; }, duration); } - } + }; if (this.layoutDoc.presStatus === "auto") { if (this._presTimer) clearTimeout(this._presTimer); this.layoutDoc.presStatus = "manual"; @@ -393,7 +391,7 @@ export class PresBox extends ViewBoxBaseComponent if (this.rootDoc.expandBoolean) doc.presExpandInlineButton = true; else if (!this.rootDoc.expandBoolean) doc.presExpandInlineButton = false; }); - }; + } /** * The function that starts the presentation at the given index, also checking if actions should be applied @@ -745,7 +743,7 @@ export class PresBox extends ViewBoxBaseComponent const activeItem = Cast(this.childDocs[this.itemIndex], Doc, null); const targetDoc = Cast(activeItem?.presentationTargetDoc, Doc, null); if (activeItem && targetDoc) { - let transitionSpeed = targetDoc.presTransition ? NumCast(targetDoc.presTransition) / 1000 : 0.5; + const transitionSpeed = targetDoc.presTransition ? NumCast(targetDoc.presTransition) / 1000 : 0.5; let duration = targetDoc.presDuration ? NumCast(targetDoc.presDuration) / 1000 : 2; if (targetDoc.type === DocumentType.AUDIO) duration = NumCast(targetDoc.duration); const effect = targetDoc.presEffect ? targetDoc.presEffect : 'None'; @@ -754,7 +752,7 @@ export class PresBox extends ViewBoxBaseComponent
    e.stopPropagation()} onPointerUp={e => e.stopPropagation()} onClick={action(e => { e.stopPropagation(); this.openMovementDropdown = false; this.openEffectDropdown = false; })}>
    Movement -
    { e.stopPropagation(); this.openMovementDropdown = !this.openMovementDropdown })} style={{ borderBottomLeftRadius: this.openMovementDropdown ? 0 : 5, border: this.openMovementDropdown ? 'solid 2px #5B9FDD' : 'solid 1px black' }}> +
    { e.stopPropagation(); this.openMovementDropdown = !this.openMovementDropdown; })} style={{ borderBottomLeftRadius: this.openMovementDropdown ? 0 : 5, border: this.openMovementDropdown ? 'solid 2px #5B9FDD' : 'solid 1px black' }}> {activeItem.presMovement}
    e.stopPropagation()} style={{ display: this.openMovementDropdown ? "grid" : "none" }}> @@ -770,7 +768,7 @@ export class PresBox extends ViewBoxBaseComponent { document.removeEventListener("keydown", this.keyEvents, true); }} - onChange={action((e: React.ChangeEvent) => { this.setTransitionTime(e.target.value) })} /> s + onChange={action((e) => this.setTransitionTime(e.target.value))} /> s
    this.setTransitionTime(String(transitionSpeed), 1000)}> @@ -800,7 +798,7 @@ export class PresBox extends ViewBoxBaseComponent { document.removeEventListener("keydown", this.keyEvents, true); }} - onChange={action((e: React.ChangeEvent) => { this.setDurationTime(e.target.value) })} /> s + onChange={action((e) => this.setDurationTime(e.target.value))} /> s
    this.setDurationTime(String(duration), 1000)}> @@ -820,7 +818,7 @@ export class PresBox extends ViewBoxBaseComponent
    Effects -
    { e.stopPropagation(); this.openEffectDropdown = !this.openEffectDropdown })} style={{ borderBottomLeftRadius: this.openEffectDropdown ? 0 : 5, border: this.openEffectDropdown ? 'solid 2px #5B9FDD' : 'solid 1px black' }}> +
    { e.stopPropagation(); this.openEffectDropdown = !this.openEffectDropdown; })} style={{ borderBottomLeftRadius: this.openEffectDropdown ? 0 : 5, border: this.openEffectDropdown ? 'solid 2px #5B9FDD' : 'solid 1px black' }}> {effect}
    e.stopPropagation()}> @@ -929,7 +927,7 @@ export class PresBox extends ViewBoxBaseComponent style={{ textAlign: 'left', width: 50 }} type="number" value={NumCast(activeItem.presPinViewX)} onFocus={() => { document.removeEventListener("keydown", this.keyEvents, true); }} - onChange={action((e: React.ChangeEvent) => { let val = e.target.value; activeItem.presPinViewX = Number(val); })} /> + onChange={action((e: React.ChangeEvent) => { const val = e.target.value; activeItem.presPinViewX = Number(val); })} />
    @@ -939,7 +937,7 @@ export class PresBox extends ViewBoxBaseComponent style={{ textAlign: 'left', width: 50 }} type="number" value={NumCast(activeItem.presPinViewY)} onFocus={() => { document.removeEventListener("keydown", this.keyEvents, true); }} - onChange={action((e: React.ChangeEvent) => { let val = e.target.value; activeItem.presPinViewY = Number(val) })} /> + onChange={action((e: React.ChangeEvent) => { const val = e.target.value; activeItem.presPinViewY = Number(val); })} />
    @@ -949,7 +947,7 @@ export class PresBox extends ViewBoxBaseComponent style={{ textAlign: 'left', width: 50 }} type="number" value={NumCast(activeItem.presPinViewScale)} onFocus={() => { document.removeEventListener("keydown", this.keyEvents, true); }} - onChange={action((e: React.ChangeEvent) => { let val = e.target.value; activeItem.presPinViewScale = Number(val) })} /> + onChange={action((e: React.ChangeEvent) => { const val = e.target.value; activeItem.presPinViewScale = Number(val); })} />
    @@ -1211,7 +1209,7 @@ export class PresBox extends ViewBoxBaseComponent
    Active text color
    -
    { console.log("hi"); this.openActiveColorPicker = !this.openActiveColorPicker })}> +
    { console.log("hi"); this.openActiveColorPicker = !this.openActiveColorPicker; })}>
    {this.activeColorPicker} @@ -1277,7 +1275,7 @@ export class PresBox extends ViewBoxBaseComponent @computed get activeColorPicker() { const activeItem = Cast(this.childDocs[this.itemIndex], Doc, null); const targetDoc = Cast(activeItem?.presentationTargetDoc, Doc, null); - if (this.openActiveColorPicker) return @computed get viewedColorPicker() { const activeItem = Cast(this.childDocs[this.itemIndex], Doc, null); const targetDoc = Cast(activeItem?.presentationTargetDoc, Doc, null); - if (this.openViewedColorPicker) return @action checkList = (doc: Doc, list: any): number => { const x: List = list; - if (x && x.length >= NumCast(doc!.currentFrame) + 1) { + if (x && x.length >= NumCast(doc.currentFrame) + 1) { return x[NumCast(doc.currentFrame)]; } else if (x) { x.length = NumCast(doc.currentFrame) + 1; -- cgit v1.2.3-70-g09d2