aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/PropertiesView.tsx
diff options
context:
space:
mode:
authorMichael Foiani <sotech117@Michaels-MacBook-Pro-5.local>2022-06-23 13:13:46 -0400
committerMichael Foiani <sotech117@Michaels-MacBook-Pro-5.local>2022-06-23 13:13:46 -0400
commit7cacf9781395bc12c479acb51fa63cd0925a9430 (patch)
treed34cb900e73909006e1ca822f22c94a12634e01b /src/client/views/PropertiesView.tsx
parent0370192be9c6c723f198fbf28d2a63ceef0e70d4 (diff)
parent8eb794e233f905daaa5b9a25c6720e567512653e (diff)
merge with mehek video
Diffstat (limited to 'src/client/views/PropertiesView.tsx')
-rw-r--r--src/client/views/PropertiesView.tsx90
1 files changed, 46 insertions, 44 deletions
diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index bcfd2dd56..faab2ed26 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -11,7 +11,7 @@ import { Id } from "../../fields/FieldSymbols";
import { InkField } from "../../fields/InkField";
import { List } from "../../fields/List";
import { ComputedField } from "../../fields/ScriptField";
-import { BoolCast, Cast, NumCast, StrCast } from "../../fields/Types";
+import { Cast, NumCast, StrCast, DocCast } from "../../fields/Types";
import { denormalizeEmail, GetEffectiveAcl, SharingPermissions } from "../../fields/util";
import { emptyFunction, returnEmptyDoclist, returnEmptyFilter, returnFalse, returnTrue, setupMoveUpEvents } from "../../Utils";
import { DocumentType } from "../documents/DocumentTypes";
@@ -300,11 +300,10 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
Document={layoutDoc}
DataDoc={this.dataDoc}
renderDepth={1}
- fitContentsToDoc={returnTrue}
+ fitContentsToBox={returnTrue}
rootSelected={returnFalse}
styleProvider={DefaultStyleProvider}
docViewPath={returnEmptyDoclist}
- freezeDimensions={true}
dontCenter={"y"}
isDocumentActive={returnFalse}
isContentActive={emptyFunction}
@@ -340,7 +339,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
*/
@undoBatch
changePermissions = (e: any, user: string) => {
- const docs = SelectionManager.Views().length < 2 ? [this.selectedDoc] : SelectionManager.Views().map(docView => docView.props.Document);
+ const docs = SelectionManager.Views().length < 2 ? (this.selectedDoc ? [this.selectedDoc]:[]) : SelectionManager.Views().map(docView => docView.props.Document);
SharingManager.Instance.shareFromPropertiesSidebar(user, e.currentTarget.value as SharingPermissions, docs);
}
@@ -355,7 +354,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
value={permission}
onChange={e => this.changePermissions(e, user)}>
{dropdownValues.filter(permission =>
- !Doc.UserDoc().noviceMode || ![SharingPermissions.View, SharingPermissions.SelfEdit].includes(permission as any)).map(permission =>
+ !Doc.noviceMode || ![SharingPermissions.View, SharingPermissions.SelfEdit].includes(permission as any)).map(permission =>
<option key={permission} value={permission}> {permission} </option>)}
</select>;
}
@@ -419,7 +418,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
// all selected docs
const docs = SelectionManager.Views().length < 2 ?
- [this.layoutDocAcls ? this.selectedDoc : this.selectedDoc[DataSym]]
+ [this.layoutDocAcls ? this.selectedDoc : this.selectedDoc?.[DataSym]]
: SelectionManager.Views().map(docView => this.layoutDocAcls ? docView.props.Document : docView.props.Document[DataSym]);
const target = docs[0];
@@ -907,7 +906,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
{!this.openSharing ? (null) :
<div className="propertiesView-sharing-content">
<div className="propertiesView-buttonContainer">
- {!Doc.UserDoc().noviceMode ? (<div className="propertiesView-acls-checkbox">
+ {!Doc.noviceMode ? (<div className="propertiesView-acls-checkbox">
<Checkbox
color="primary"
onChange={action(() => this.layoutDocAcls = !this.layoutDocAcls)}
@@ -931,43 +930,46 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
* If it doesn't exist, it creates it.
*/
checkFilterDoc() {
- if (!this.selectedDoc.currentFilter) CurrentUserUtils.setupFilterDocs(this.selectedDoc);
+ if (!this.selectedDoc?.currentFilter) this.selectedDoc!.currentFilter = CurrentUserUtils.createFilterDoc();
}
/**
* Creates a new currentFilter for this.filterDoc,
*/
createNewFilterDoc = () => {
- const currentDocFilters = this.selectedDoc._docFilters;
- const currentDocRangeFilters = this.selectedDoc._docRangeFilters;
- this.selectedDoc._docFilters = new List<string>();
- this.selectedDoc._docRangeFilters = new List<string>();
- (this.selectedDoc.currentFilter as Doc)._docFiltersList = currentDocFilters;
- (this.selectedDoc.currentFilter as Doc)._docRangeFiltersList = currentDocRangeFilters;
- this.selectedDoc.currentFilter = undefined;
- CurrentUserUtils.setupFilterDocs(this.selectedDoc);
+ if (this.selectedDoc) {
+ const currentDocFilters = this.selectedDoc._docFilters;
+ const currentDocRangeFilters = this.selectedDoc._docRangeFilters;
+ this.selectedDoc._docFilters = new List<string>();
+ this.selectedDoc._docRangeFilters = new List<string>();
+ (this.selectedDoc.currentFilter as Doc)._docFiltersList = currentDocFilters;
+ (this.selectedDoc.currentFilter as Doc)._docRangeFiltersList = currentDocRangeFilters;
+ this.selectedDoc.currentFilter = CurrentUserUtils.createFilterDoc();
+ }
}
/**
* Updates this.filterDoc's currentFilter and saves the docFilters on the currentFilter
*/
updateFilterDoc = (doc: Doc) => {
- if (doc === this.selectedDoc.currentFilter) return; // causes problems if you try to reapply the same doc
- const savedDocFilters = doc._docFiltersList;
- const currentDocFilters = this.selectedDoc._docFilters;
- this.selectedDoc._docFilters = new List<string>();
- (this.selectedDoc.currentFilter as Doc)._docFiltersList = currentDocFilters;
- this.selectedDoc.currentFilter = doc;
- doc._docFiltersList = new List<string>();
- this.selectedDoc._docFilters = savedDocFilters;
-
- const savedDocRangeFilters = doc._docRangeFiltersList;
- const currentDocRangeFilters = this.selectedDoc._docRangeFilters;
- this.selectedDoc._docRangeFilters = new List<string>();
- (this.selectedDoc.currentFilter as Doc)._docRangeFiltersList = currentDocRangeFilters;
- this.selectedDoc.currentFilter = doc;
- doc._docRangeFiltersList = new List<string>();
- this.selectedDoc._docRangeFilters = savedDocRangeFilters;
+ if (this.selectedDoc) {
+ if (doc === this.selectedDoc.currentFilter) return; // causes problems if you try to reapply the same doc
+ const savedDocFilters = doc._docFiltersList;
+ const currentDocFilters = this.selectedDoc._docFilters;
+ this.selectedDoc._docFilters = new List<string>();
+ (this.selectedDoc.currentFilter as Doc)._docFiltersList = currentDocFilters;
+ this.selectedDoc.currentFilter = doc;
+ doc._docFiltersList = new List<string>();
+ this.selectedDoc._docFilters = savedDocFilters;
+
+ const savedDocRangeFilters = doc._docRangeFiltersList;
+ const currentDocRangeFilters = this.selectedDoc._docRangeFilters;
+ this.selectedDoc._docRangeFilters = new List<string>();
+ (this.selectedDoc.currentFilter as Doc)._docRangeFiltersList = currentDocRangeFilters;
+ this.selectedDoc.currentFilter = doc;
+ doc._docRangeFiltersList = new List<string>();
+ this.selectedDoc._docRangeFilters = savedDocRangeFilters;
+ }
}
@computed get filtersSubMenu() {
@@ -1060,13 +1062,13 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
<FontAwesomeIcon icon={this.openFields ? "caret-down" : "caret-right"} size="lg" color="white" />
</div>
</div>
- {!Doc.UserDoc().noviceMode && this.openFields ? <div className="propertiesView-fields-checkbox">
+ {!Doc.noviceMode && this.openFields ? <div className="propertiesView-fields-checkbox">
{this.fieldsCheckbox}
<div className="propertiesView-fields-checkbox-text">Layout</div>
</div> : null}
{!this.openFields ? (null) :
<div className="propertiesView-fields-content">
- {Doc.UserDoc().noviceMode ? this.noviceFields : this.expandedField}
+ {Doc.noviceMode ? this.noviceFields : this.expandedField}
</div>}
</div>;
}
@@ -1123,7 +1125,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
@undoBatch
handleDescriptionChange = action((value: string) => {
- if (LinkManager.currentLink) {
+ if (LinkManager.currentLink && this.selectedDoc) {
this.selectedDoc.description = value;
this.description = value;
return true;
@@ -1132,7 +1134,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
@undoBatch
handleLinkRelationshipChange = action((value: string) => {
- if (LinkManager.currentLink) {
+ if (LinkManager.currentLink && this.selectedDoc) {
this.selectedDoc.linkRelationship = value;
this.relationship = value;
return true;
@@ -1189,7 +1191,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
@undoBatch
changeFollowBehavior = action((follow: string) => {
- if (LinkManager.currentLink) {
+ if (LinkManager.currentLink && this.selectedDoc) {
this.selectedDoc.followLinkLocation = follow;
return true;
}
@@ -1220,18 +1222,18 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
}
toggleAnchor = (e: React.PointerEvent) => {
- setupMoveUpEvents(this, e, returnFalse, emptyFunction, undoBatch(action(() => this.selectedDoc.linkAutoMove = !this.selectedDoc.linkAutoMove)));
+ setupMoveUpEvents(this, e, returnFalse, emptyFunction, undoBatch(action(() => this.selectedDoc && (this.selectedDoc.linkAutoMove = !this.selectedDoc.linkAutoMove))));
}
toggleArrow = (e: React.PointerEvent) => {
- setupMoveUpEvents(this, e, returnFalse, emptyFunction, undoBatch(action(() => this.selectedDoc.displayArrow = !this.selectedDoc.displayArrow)));
+ setupMoveUpEvents(this, e, returnFalse, emptyFunction, undoBatch(action(() => this.selectedDoc && (this.selectedDoc.displayArrow = !this.selectedDoc.displayArrow))));
}
toggleZoomToTarget1 = (e: React.PointerEvent) => {
- setupMoveUpEvents(this, e, returnFalse, emptyFunction, undoBatch(action(() => Cast(this.selectedDoc.anchor1, Doc, null).followLinkZoom = !Cast(this.selectedDoc.anchor1, Doc, null).followLinkZoom)));
+ setupMoveUpEvents(this, e, returnFalse, emptyFunction, undoBatch(action(() => this.selectedDoc && (DocCast(this.selectedDoc.anchor1).followLinkZoom = !DocCast(this.selectedDoc.anchor1).followLinkZoom))));
}
toggleZoomToTarget2 = (e: React.PointerEvent) => {
- setupMoveUpEvents(this, e, returnFalse, emptyFunction, undoBatch(action(() => Cast(this.selectedDoc.anchor2, Doc, null).followLinkZoom = !Cast(this.selectedDoc.anchor2, Doc, null).followLinkZoom)));
+ setupMoveUpEvents(this, e, returnFalse, emptyFunction, undoBatch(action(() => this.selectedDoc && (DocCast(this.selectedDoc.anchor2).followLinkZoom = !DocCast(this.selectedDoc.anchor2).followLinkZoom))));
}
@computed
@@ -1239,7 +1241,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
return <input
autoComplete={"off"}
id="link_relationship_input"
- value={StrCast(this.selectedDoc.linkRelationship)}
+ value={StrCast(this.selectedDoc?.linkRelationship)}
onKeyDown={this.onRelationshipKey}
onBlur={this.onSelectOutRelationship}
onChange={e => this.handleLinkRelationshipChange(e.currentTarget.value)}
@@ -1253,7 +1255,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
return <input
autoComplete={"off"}
id="link_description_input"
- value={StrCast(this.selectedDoc.description)}
+ value={StrCast(this.selectedDoc?.description)}
onKeyDown={this.onDescriptionKey}
onBlur={this.onSelectOutDesc}
onChange={e => this.handleDescriptionChange(e.currentTarget.value)}
@@ -1274,7 +1276,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
// }
render() {
- const isNovice = BoolCast(Doc.UserDoc().noviceMode);
+ const isNovice = Doc.noviceMode;
if (!this.selectedDoc && !this.isPres) {
return <div className="propertiesView" style={{ width: this.props.width }}>
<div className="propertiesView-title" style={{ width: this.props.width }}>