diff options
author | Bob Zeleznik <zzzman@gmail.com> | 2020-05-07 23:41:08 -0400 |
---|---|---|
committer | Bob Zeleznik <zzzman@gmail.com> | 2020-05-07 23:41:08 -0400 |
commit | 136165e9c960be255396830e3a9d44532ee0cda7 (patch) | |
tree | c17dd9f4114e8806e93ce40a5c81920d3914c965 /src/client/views/DocComponent.tsx | |
parent | 78e0b57cab3a5fea7421ca4661d890b635bb4790 (diff) |
fixed tree view title editing. cleaned up annotation keys in DocComponent
Diffstat (limited to 'src/client/views/DocComponent.tsx')
-rw-r--r-- | src/client/views/DocComponent.tsx | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/client/views/DocComponent.tsx b/src/client/views/DocComponent.tsx index f602cbb15..4e7d4c5ed 100644 --- a/src/client/views/DocComponent.tsx +++ b/src/client/views/DocComponent.tsx @@ -97,18 +97,17 @@ export function ViewBoxAnnotatableComponent<P extends ViewBoxAnnotatableProps, T protected multiTouchDisposer?: InteractionUtils.MultiTouchEventDisposer; _annotationKey: string = "annotations"; - public set annotationKey(val: string) { this._annotationKey = val; } - public get annotationKey() { return this._annotationKey; } + public get annotationKey() { return this.fieldKey + "-" + this._annotationKey; } @action.bound removeDocument(doc: Doc | Doc[]): boolean { const docs = doc instanceof Doc ? [doc] : doc; docs.map(doc => doc.annotationOn = undefined); - const targetDataDoc = this.dataDoc; - const value = DocListCast(targetDataDoc[this.props.fieldKey + "-" + this._annotationKey]); + const targetDataDoc = this.dataDoc; this + const value = DocListCast(targetDataDoc[this.annotationKey]); const result = value.filter(v => !docs.includes(v)); if (result.length !== value.length) { - targetDataDoc[this.props.fieldKey] = new List<Doc>(result); + targetDataDoc[this.annotationKey] = new List<Doc>(result); return true; } return false; @@ -124,12 +123,12 @@ export function ViewBoxAnnotatableComponent<P extends ViewBoxAnnotatableProps, T const docs = doc instanceof Doc ? [doc] : doc; docs.map(doc => doc.context = Doc.GetProto(doc).annotationOn = this.props.Document); const targetDataDoc = this.props.Document[DataSym]; - const docList = DocListCast(targetDataDoc[this.props.fieldKey + "-" + this._annotationKey]); + const docList = DocListCast(targetDataDoc[this.annotationKey]); const added = docs.filter(d => !docList.includes(d)); if (added.length) { added.map(doc => doc.context = this.props.Document); - targetDataDoc[this.props.fieldKey + "-" + this._annotationKey] = new List<Doc>([...docList, ...added]); - targetDataDoc[this.props.fieldKey + "-" + this._annotationKey + "-lastModified"] = new DateField(new Date(Date.now())); + targetDataDoc[this.annotationKey] = new List<Doc>([...docList, ...added]); + targetDataDoc[this.annotationKey + "-lastModified"] = new DateField(new Date(Date.now())); } return true; } |