generated from bscotch/typescript-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add fetching and caching of custom fields.
- Loading branch information
1 parent
e5bed0c
commit 6a29180
Showing
8 changed files
with
279 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import type { DataFavroCustomField } from '$/types/FavroCustomFieldTypes.js'; | ||
import { BravoEntity } from '$lib/BravoEntity.js'; | ||
|
||
export type BravoCustomFieldTypeName = | ||
typeof BravoCustomField['typeNames'][number]; | ||
|
||
export class BravoCustomField extends BravoEntity<DataFavroCustomField> { | ||
get name() { | ||
return this._data.name; | ||
} | ||
|
||
get customFieldId() { | ||
return this._data.customFieldId; | ||
} | ||
|
||
get type() { | ||
return this._data.type; | ||
} | ||
|
||
/** | ||
* For choice-based custom fields (e.g. tags, multi-select), | ||
* the set of possible values and their associated IDs. | ||
* Needed when looking up id-based field values on card data. | ||
*/ | ||
get customFieldItems() { | ||
return this._data.customFieldItems; | ||
} | ||
|
||
get organizationId() { | ||
return this._data.organizationId; | ||
} | ||
|
||
get enabled() { | ||
return this._data.enabled; | ||
} | ||
|
||
equals(org: BravoCustomField) { | ||
return ( | ||
this.hasSameConstructor(org) && this.customFieldId === org.customFieldId | ||
); | ||
} | ||
|
||
static get typeNames() { | ||
return [ | ||
'Number', | ||
'Time', | ||
'Text', | ||
'Rating', | ||
'Vote', | ||
'Checkbox', | ||
'Date', | ||
'Timeline', | ||
'Link', | ||
'Members', | ||
'Tags', | ||
'Status', | ||
'Multiple select', | ||
] as const; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.