Custom fields
This commit is contained in:
parent
ce10f41330
commit
bb61aa810c
|
@ -53,10 +53,12 @@ Limitations:
|
|||
|
||||
Following features are work in progress:
|
||||
|
||||
- [ ] Frontmatter: Update Tags
|
||||
- [ ] Frontmatter: Updated assigned members
|
||||
- [ ] Frontmatter: Arbitrary structured data? Read-only.
|
||||
- [ ] Frontmatter: Dependencies. As vault links in Obsidian mode.
|
||||
- [ ] Frontmatter: Writable Tags
|
||||
- [ ] Frontmatter: Writable assigned members
|
||||
- [ ] Frontmatter: Writable tasks.
|
||||
- [ ] Frontmatter: Arbitrary structured data (Custom Fields)? Read-only.
|
||||
- [ ] Frontmatter: Readable Dependencies. As vault links in Obsidian mode.
|
||||
- [ ] Frontmatter: Writable Dependencies.
|
||||
- [ ] Allow users to toggle Obsidian mode, instead of being default.
|
||||
- [ ] Get the correct last-modified date.
|
||||
- [ ] Improve cache behaviour. User and tags can have much longer cache times.
|
||||
|
|
|
@ -18,6 +18,8 @@ from .favro_data_model import (
|
|||
TagInfo,
|
||||
UserId,
|
||||
UserInfo,
|
||||
CustomFieldId,
|
||||
CustomFieldInfo,
|
||||
)
|
||||
from .favro_markdown import CardContents
|
||||
|
||||
|
@ -29,6 +31,7 @@ URL_GET_ALL_CARDS = URL_API_ROOT + '/cards'
|
|||
URL_UPDATE_CARD = URL_API_ROOT + '/cards/{card_id}'
|
||||
URL_GET_USER = URL_API_ROOT + '/users/{user_id}'
|
||||
URL_GET_TAG = URL_API_ROOT + '/tags/{tag_id}'
|
||||
URL_GET_CUSTOM_FIELD = URL_API_ROOT + '/customfields/{custom_field_id}'
|
||||
|
||||
|
||||
class CardCache:
|
||||
|
@ -164,6 +167,10 @@ class FavroClient:
|
|||
response = self.session.get(URL_GET_TAG.format(tag_id=tag_id.raw_id))
|
||||
return TagInfo.from_json(response.json())
|
||||
|
||||
def get_custom_field(self, tag_id: CustomFieldId) -> CustomFieldInfo:
|
||||
response = self.session.get(URL_GET_CUSTOM_FIELD.format(custom_field_id=custom_field_id.raw_id))
|
||||
return CustomFieldInfo.from_json(response.json())
|
||||
|
||||
def _invalidate_cache(self, card_id: CardId) -> None:
|
||||
card = self.cache.remove(card_id)
|
||||
if card:
|
||||
|
|
|
@ -33,6 +33,18 @@ class UserId:
|
|||
class OrganizationId:
|
||||
raw_id: str
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class CustomFieldId:
|
||||
raw_id: str
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class WidgetCommonId:
|
||||
raw_id: str
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class CustomFieldItemId:
|
||||
raw_id: str
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class CardAssignment:
|
||||
|
@ -69,10 +81,6 @@ class TagId:
|
|||
raw_id: str
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class CustomFieldId:
|
||||
raw_id: str
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class TagInfo:
|
||||
|
@ -90,6 +98,41 @@ class TagInfo:
|
|||
json.get('color'),
|
||||
)
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class CustomFieldItem:
|
||||
""" Custom field item object.
|
||||
Fields:
|
||||
- customFieldItemId: The id of the custom field item.
|
||||
- name: The name of the custom field item.
|
||||
"""
|
||||
custom_field_item_id: CustomFieldItemId
|
||||
name: str
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class CustomFieldInfo:
|
||||
""" Custom field object.
|
||||
|
||||
Fields:
|
||||
- organizationId: The id of the organization that this custom field exists in.
|
||||
- customFieldId: The id of the custom field.
|
||||
- widgetCommonId: The shared id of the widget if the custom field is local to that widget.
|
||||
- type: field type. Refer to allowed custom field types.
|
||||
- name: name of the custom field.
|
||||
- enabled: True if the custom field is currently enabled for the organization.
|
||||
- customFieldItems: The list of items that this custom field can have in case it is a selectable one.
|
||||
"""
|
||||
organization_id : OrganizationId
|
||||
custom_field_id : CustomFieldId
|
||||
widget_common_id : WidgetCommonId
|
||||
type: str
|
||||
name: str
|
||||
enabled: bool
|
||||
custom_field_items: list[CustomFieldItem]
|
||||
|
||||
@staticmethod
|
||||
def from_json(json: dict[str, Any]) -> 'CustomFieldInfo':
|
||||
pass # TODO
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class CustomField:
|
||||
|
|
Loading…
Reference in New Issue
Block a user