aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordinhanhtruong <70963346+dinhanhtruong@users.noreply.github.com>2021-08-29 13:47:03 -0400
committerdinhanhtruong <70963346+dinhanhtruong@users.noreply.github.com>2021-08-29 13:47:03 -0400
commit2df1a0c0cc11c0dbcebf2a53e804cf8ac28db346 (patch)
treebecbdf01f7585f3fa3fd8d32abb97384f79508bd /src
parent646175b9870fb535648c8a9473c245bac57474b3 (diff)
fixed link counter when setting new relationships
num of links per relationship should now update correctly when link relationships are set to new values
Diffstat (limited to 'src')
-rw-r--r--src/client/views/linking/LinkEditor.tsx13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/client/views/linking/LinkEditor.tsx b/src/client/views/linking/LinkEditor.tsx
index f326e1440..ab8ce3da6 100644
--- a/src/client/views/linking/LinkEditor.tsx
+++ b/src/client/views/linking/LinkEditor.tsx
@@ -41,6 +41,7 @@ export class LinkEditor extends React.Component<LinkEditorProps> {
@undoBatch
setRelationshipValue = action((value: string) => {
if (LinkManager.currentLink) {
+ const prevRelationship = LinkManager.currentLink.linkRelationship as string;
LinkManager.currentLink.linkRelationship = value;
const linkRelationshipList = StrListCast(Doc.UserDoc().linkRelationshipList);
const linkRelationshipSizes = NumListCast(Doc.UserDoc().linkRelationshipSizes);
@@ -52,9 +53,15 @@ export class LinkEditor extends React.Component<LinkEditorProps> {
linkRelationshipSizes.push(1);
const randColor = "rgb(" + Math.floor(Math.random() * 255) + "," + Math.floor(Math.random() * 255) + "," + Math.floor(Math.random() * 255) + ")";
linkColorList.push(randColor)
- } else {
- //increment relationship size if rel already exists
+ // if the relationship is already in the list AND the new rel is different from the prev rel, update the rel sizes
+ } else if (linkRelationshipList && value != prevRelationship) {
+ //increment size of new relationship size
linkRelationshipSizes[linkRelationshipList.indexOf(value)] = linkRelationshipSizes[linkRelationshipList.indexOf(value)] + 1;
+ //decrement the size of the previous relationship if it already exists (i.e. not default 'link' relationship upon link creation)
+ if (linkRelationshipList.includes(prevRelationship)) {
+ linkRelationshipSizes[linkRelationshipList.indexOf(prevRelationship)] = linkRelationshipSizes[linkRelationshipList.indexOf(prevRelationship)] - 1;
+ }
+
}
this.relationshipButtonColor = "rgb(62, 133, 55)";
setTimeout(action(() => this.relationshipButtonColor = ""), 750);
@@ -146,6 +153,7 @@ export class LinkEditor extends React.Component<LinkEditorProps> {
style={{ width: "100%" }}
id="input"
value={this.relationship}
+ autoComplete={"off"}
placeholder={"Enter link relationship"}
onKeyDown={this.onRelationshipKey}
onChange={this.handleRelationshipChange}
@@ -174,6 +182,7 @@ export class LinkEditor extends React.Component<LinkEditorProps> {
<div className="linkEditor-description-editing">
<input
style={{ width: "100%" }}
+ autoComplete={"off"}
id="input"
value={this.description}
placeholder={"Enter link description"}