Skip to content

Commit

Permalink
fix: The update builder is not reset after running an update.
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-coster committed Aug 17, 2021
1 parent aeda35d commit cb74e1b
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/lib/entities/BravoCard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class BravoCardUpdateBuilder {
}

addFavroAttachments(favroItems: DataFavroCardFavroAttachment[]) {
this.update.addFavroAttachments ||= [];
ensureArrayExistsAndAddUniqueBy(
this.update.addFavroAttachments,
'itemCommonId',
Expand Down Expand Up @@ -158,6 +159,7 @@ class BravoCardUpdateBuilder {
userId,
completed,
}));
this.update.completeAssignments ||= [];
ensureArrayExistsAndAddUniqueBy(
this.update.completeAssignments,
'userId',
Expand All @@ -177,6 +179,7 @@ class BravoCardUpdateBuilder {
values: FavroApiParamsCardUpdate[Field],
opposingField?: FavroApiParamsCardUpdateArrayField,
) {
this.update[updateField] ||= [];
ensureArrayExistsAndAddUnique(this.update[updateField], values);
if (opposingField) {
removeFromArray(this.update[opposingField], values);
Expand Down Expand Up @@ -207,6 +210,10 @@ export class BravoCard extends BravoEntity<DataFavroCard> {
return `https://favro.com/organization/${this._client.organizationId}?card=${this.sequentialId}`;
}

get assignments() {
return [...this._data.assignments];
}

/** The card's ID within a widget */
get cardId() {
return this._data.cardId;
Expand Down Expand Up @@ -241,6 +248,24 @@ export class BravoCard extends BravoEntity<DataFavroCard> {
return this._data.attachments;
}

get startDate() {
if (this._data.startDate) {
return new Date(this._data.startDate);
}
return null;
}

get dueDate() {
if (this._data.dueDate) {
return new Date(this._data.dueDate);
}
return null;
}

get archived() {
return this._data.archived;
}

/**
* Get the update-builder for this card, to
* more easily assemble a complex Card update.
Expand All @@ -265,6 +290,7 @@ export class BravoCard extends BravoEntity<DataFavroCard> {
);
// Update this card!
this._data = updated._data;
this._updateBuilder = new BravoCardUpdateBuilder();
return this;
}

Expand Down

0 comments on commit cb74e1b

Please sign in to comment.