aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections
diff options
context:
space:
mode:
authorTyler Schicke <tyler_schicke@brown.edu>2019-04-21 00:39:09 -0400
committerTyler Schicke <tyler_schicke@brown.edu>2019-04-21 00:39:09 -0400
commit3556aae6d063d8b654509330e70bc67606f16613 (patch)
tree1413a7efaae48bb5b3f9567b75e3a79528c9dad3 /src/client/views/collections
parent8ddec1c70c01b3d7d919908299e1168b75698dc7 (diff)
More changes
Diffstat (limited to 'src/client/views/collections')
-rw-r--r--src/client/views/collections/CollectionDockingView.tsx38
1 files changed, 18 insertions, 20 deletions
diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx
index b6c87231f..7b204cbdc 100644
--- a/src/client/views/collections/CollectionDockingView.tsx
+++ b/src/client/views/collections/CollectionDockingView.tsx
@@ -250,28 +250,26 @@ export class CollectionDockingView extends React.Component<SubCollectionViewProp
tabCreated = (tab: any) => {
if (tab.hasOwnProperty("contentItem") && tab.contentItem.config.type !== "stack") {
- Server.GetField(tab.contentItem.config.props.documentId, action((f: Opt<Field>) => {
- if (f !== undefined && f instanceof Document) {
- f.GetTAsync(KeyStore.Title, TextField, (tfield) => {
- if (tfield !== undefined) {
- tab.titleElement[0].textContent = f.Title;
- }
- });
- f.GetTAsync(KeyStore.LinkedFromDocs, ListField).then(lf =>
- f.GetTAsync(KeyStore.LinkedToDocs, ListField).then(lt => {
- let count = (lf ? lf.Data.length : 0) + (lt ? lt.Data.length : 0);
- let counter: any = this.htmlToElement(`<div class="messageCounter">${count}</div>`);
- tab.element.append(counter);
- counter.DashDocId = tab.contentItem.config.props.documentId;
- tab.reactionDisposer = reaction((): [List<Field> | null | undefined, List<Field> | null | undefined] => [Cast(f.linkedFromDocs, List), Cast(f.linkedToDocs, List)],
- ([linkedFrom, linkedTo]) => {
- let count = (linkedFrom ? linkedFrom.length : 0) + (linkedTo ? linkedTo.length : 0);
- counter.innerHTML = count;
- });
- }));
+ DocServer.GetRefField(tab.contentItem.config.props.documentId).then(async f => {
+ if (f instanceof Doc) {
+ const tfield = await Cast(f.title, "string");
+ if (tfield !== undefined) {
+ tab.titleElement[0].textContent = f.Title;
+ }
+ const lf = await Cast(f.linkedFromDocs, List);
+ const lt = await Cast(f.linkedToDocs, List);
+ let count = (lf ? lf.length : 0) + (lt ? lt.length : 0);
+ let counter: any = this.htmlToElement(`<div class="messageCounter">${count}</div>`);
+ tab.element.append(counter);
+ counter.DashDocId = tab.contentItem.config.props.documentId;
+ tab.reactionDisposer = reaction((): [List<Field> | null | undefined, List<Field> | null | undefined] => [lf, lt],
+ ([linkedFrom, linkedTo]) => {
+ let count = (linkedFrom ? linkedFrom.length : 0) + (linkedTo ? linkedTo.length : 0);
+ counter.innerHTML = count;
+ });
tab.titleElement[0].DashDocId = tab.contentItem.config.props.documentId;
}
- }));
+ });
}
tab.closeElement.off('click') //unbind the current click handler
.click(function () {