Views
albert.resources.views
ViewEntity
The grid a saved view belongs to.
Each grid in the Albert app (Projects, Tasks, Inventory, and so on) keeps its own list of views. A view saved for one entity is only shown on that grid.
Attributes:
| Name | Type | Description |
|---|---|---|
PROJECTS |
str
|
The Projects grid. |
TASKS |
str
|
The Tasks grid. |
INVENTORIES |
str
|
The Inventory grid. |
PARAMETER_GROUPS |
str
|
The Parameter Groups grid (Master Data Management). |
DATA_TEMPLATES |
str
|
The Data Templates grid (Master Data Management). |
DATA_COLUMNS |
str
|
The Results (data columns) grid (Master Data Management). |
PARAMETERS |
str
|
The Parameters grid (Master Data Management). |
TEMPLATES |
str
|
The Templates grid (Master Data Management). |
REPORTS |
str
|
The Reports grid. |
TEAMS |
str
|
The Teams grid (Admin). |
USERS |
str
|
The Users grid (Admin). |
REFERENCE_ATTRIBUTES |
str
|
The Attributes grid (Master Data Management). |
UNITS |
str
|
The Units grid. |
UNIT_FAMILIES |
str
|
The Unit Families grid. |
ViewColumn
Bases: BaseAlbertModel
A column shown on a view's grid.
The column order in ViewState.columns
is the order the grid displays them in.
Example
Show JSON schema:
{
"description": "A column shown on a view's grid.\n\nThe column order in [`ViewState.columns`][albert.resources.views.ViewState.columns]\nis the order the grid displays them in.\n\n!!! example\n ```python\n from albert.resources.views import ViewColumn\n\n column = ViewColumn(id=\"albertId\")\n hidden = ViewColumn(id=\"description\", is_hidden=True)\n ```",
"properties": {
"id": {
"description": "The column key, as used by the grid (e.g. ``albertId``, ``status``, ``owner``, ``tags``).",
"title": "Id",
"type": "string"
},
"isHidden": {
"default": false,
"description": "Whether the column is hidden on the grid. Hidden columns keep their position.",
"title": "Ishidden",
"type": "boolean"
},
"width": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"description": "The column width in pixels. When unset, the grid uses its default width.",
"title": "Width"
}
},
"required": [
"id"
],
"title": "ViewColumn",
"type": "object"
}
Fields:
ViewSort
Bases: BaseAlbertModel
A sort applied to a view's grid.
Example
Show JSON schema:
{
"$defs": {
"OrderBy": {
"description": "Sort direction for list and search results.\n\nAttributes\n----------\nDESCENDING : str\n Reverse chronological or reverse alphabetical order (Z\u2192A, newest\u2192oldest).\nASCENDING : str\n Chronological or alphabetical order (A\u2192Z, oldest\u2192newest).",
"enum": [
"desc",
"asc"
],
"title": "OrderBy",
"type": "string"
}
},
"description": "A sort applied to a view's grid.\n\n!!! example\n ```python\n from albert.core.shared.enums import OrderBy\n from albert.resources.views import ViewSort\n\n newest_first = ViewSort(id=\"createdAt\", direction=OrderBy.DESCENDING)\n ```",
"properties": {
"id": {
"description": "The key of the column to sort by (e.g. ``createdAt``, ``status``).",
"title": "Id",
"type": "string"
},
"dir": {
"$ref": "#/$defs/OrderBy",
"description": "The sort direction: ascending or descending."
}
},
"required": [
"id",
"dir"
],
"title": "ViewSort",
"type": "object"
}
Fields:
ViewQuery
Bases: BaseAlbertModel
The filters and search text applied to a view's grid.
filter maps a grid filter key to the values to keep. Keys and values are the
ones the grid's filter bar uses, and values are display names, not IDs. For
example, the Data Templates grid's "Owner" filter is
{"owner": ["Jane Doe"]} and the Projects grid's "Status" filter is
{"status": ["Active", "Not Started"]}. Albert does not check the keys or
values when a view is saved. A key or value the grid does not recognize is kept
as is and simply matches nothing, so the grid shows no results.
Example
Show JSON schema:
{
"description": "The filters and search text applied to a view's grid.\n\n``filter`` maps a grid filter key to the values to keep. Keys and values are the\nones the grid's filter bar uses, and values are display names, not IDs. For\nexample, the Data Templates grid's \"Owner\" filter is\n``{\"owner\": [\"Jane Doe\"]}`` and the Projects grid's \"Status\" filter is\n``{\"status\": [\"Active\", \"Not Started\"]}``. Albert does not check the keys or\nvalues when a view is saved. A key or value the grid does not recognize is kept\nas is and simply matches nothing, so the grid shows no results.\n\n!!! example\n ```python\n from albert.resources.views import ViewQuery\n\n mine = ViewQuery(filter={\"owner\": [\"Jane Doe\"]})\n searched = ViewQuery(filter={\"status\": [\"Active\"]}, search=\"coating\")\n ```",
"properties": {
"filter": {
"additionalProperties": true,
"description": "Grid filter key mapped to the values to keep (usually a list of display names).",
"title": "Filter",
"type": "object"
},
"search": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Free-text search applied on top of the filters.",
"title": "Search"
},
"containsField": {
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "Column keys for \"contains text\" filters. Paired by position with ``contains_text``.",
"title": "Containsfield"
},
"containsText": {
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "Text each column in ``contains_field`` must contain. Paired by position with ``contains_field``.",
"title": "Containstext"
}
},
"title": "ViewQuery",
"type": "object"
}
Fields:
-
filter(dict[str, Any]) -
search(str | None) -
contains_field(list[str] | None) -
contains_text(list[str] | None)
filter
Grid filter key mapped to the values to keep (usually a list of display names).
contains_field
Column keys for "contains text" filters. Paired by position with contains_text.
ViewState
Bases: BaseAlbertModel
The saved layout of a view: its columns, filters, sorting, and grouping.
Example
from albert.core.shared.enums import OrderBy
from albert.resources.views import ViewColumn, ViewQuery, ViewSort, ViewState
state = ViewState(
columns=[ViewColumn(id="albertId"), ViewColumn(id="owner")],
query=[ViewQuery(filter={"owner": ["Jane Doe"]})],
sort_by=[ViewSort(id="createdAt", direction=OrderBy.DESCENDING)],
)
Show JSON schema:
{
"$defs": {
"OrderBy": {
"description": "Sort direction for list and search results.\n\nAttributes\n----------\nDESCENDING : str\n Reverse chronological or reverse alphabetical order (Z\u2192A, newest\u2192oldest).\nASCENDING : str\n Chronological or alphabetical order (A\u2192Z, oldest\u2192newest).",
"enum": [
"desc",
"asc"
],
"title": "OrderBy",
"type": "string"
},
"ViewColumn": {
"description": "A column shown on a view's grid.\n\nThe column order in [`ViewState.columns`][albert.resources.views.ViewState.columns]\nis the order the grid displays them in.\n\n!!! example\n ```python\n from albert.resources.views import ViewColumn\n\n column = ViewColumn(id=\"albertId\")\n hidden = ViewColumn(id=\"description\", is_hidden=True)\n ```",
"properties": {
"id": {
"description": "The column key, as used by the grid (e.g. ``albertId``, ``status``, ``owner``, ``tags``).",
"title": "Id",
"type": "string"
},
"isHidden": {
"default": false,
"description": "Whether the column is hidden on the grid. Hidden columns keep their position.",
"title": "Ishidden",
"type": "boolean"
},
"width": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"description": "The column width in pixels. When unset, the grid uses its default width.",
"title": "Width"
}
},
"required": [
"id"
],
"title": "ViewColumn",
"type": "object"
},
"ViewQuery": {
"description": "The filters and search text applied to a view's grid.\n\n``filter`` maps a grid filter key to the values to keep. Keys and values are the\nones the grid's filter bar uses, and values are display names, not IDs. For\nexample, the Data Templates grid's \"Owner\" filter is\n``{\"owner\": [\"Jane Doe\"]}`` and the Projects grid's \"Status\" filter is\n``{\"status\": [\"Active\", \"Not Started\"]}``. Albert does not check the keys or\nvalues when a view is saved. A key or value the grid does not recognize is kept\nas is and simply matches nothing, so the grid shows no results.\n\n!!! example\n ```python\n from albert.resources.views import ViewQuery\n\n mine = ViewQuery(filter={\"owner\": [\"Jane Doe\"]})\n searched = ViewQuery(filter={\"status\": [\"Active\"]}, search=\"coating\")\n ```",
"properties": {
"filter": {
"additionalProperties": true,
"description": "Grid filter key mapped to the values to keep (usually a list of display names).",
"title": "Filter",
"type": "object"
},
"search": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Free-text search applied on top of the filters.",
"title": "Search"
},
"containsField": {
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "Column keys for \"contains text\" filters. Paired by position with ``contains_text``.",
"title": "Containsfield"
},
"containsText": {
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "Text each column in ``contains_field`` must contain. Paired by position with ``contains_field``.",
"title": "Containstext"
}
},
"title": "ViewQuery",
"type": "object"
},
"ViewSort": {
"description": "A sort applied to a view's grid.\n\n!!! example\n ```python\n from albert.core.shared.enums import OrderBy\n from albert.resources.views import ViewSort\n\n newest_first = ViewSort(id=\"createdAt\", direction=OrderBy.DESCENDING)\n ```",
"properties": {
"id": {
"description": "The key of the column to sort by (e.g. ``createdAt``, ``status``).",
"title": "Id",
"type": "string"
},
"dir": {
"$ref": "#/$defs/OrderBy",
"description": "The sort direction: ascending or descending."
}
},
"required": [
"id",
"dir"
],
"title": "ViewSort",
"type": "object"
}
},
"description": "The saved layout of a view: its columns, filters, sorting, and grouping.\n\n!!! example\n ```python\n from albert.core.shared.enums import OrderBy\n from albert.resources.views import ViewColumn, ViewQuery, ViewSort, ViewState\n\n state = ViewState(\n columns=[ViewColumn(id=\"albertId\"), ViewColumn(id=\"owner\")],\n query=[ViewQuery(filter={\"owner\": [\"Jane Doe\"]})],\n sort_by=[ViewSort(id=\"createdAt\", direction=OrderBy.DESCENDING)],\n )\n ```",
"properties": {
"columns": {
"anyOf": [
{
"items": {
"$ref": "#/$defs/ViewColumn"
},
"minItems": 1,
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "The columns shown on the grid, in display order. A saved view always has at least one column. When creating a view, leave this unset to copy the columns of the grid's default \"All\" view.",
"title": "Columns"
},
"query": {
"description": "The filters and search text applied to the grid. The grid uses the first entry.",
"items": {
"$ref": "#/$defs/ViewQuery"
},
"title": "Query",
"type": "array"
},
"sortBy": {
"description": "The sorts applied to the grid, in priority order.",
"items": {
"$ref": "#/$defs/ViewSort"
},
"title": "Sortby",
"type": "array"
},
"groupBy": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "The key of the column the grid rows are grouped by, if any.",
"title": "Groupby"
}
},
"title": "ViewState",
"type": "object"
}
Fields:
-
columns(list[ViewColumn] | None) -
query(list[ViewQuery]) -
sort_by(list[ViewSort]) -
group_by(str | None)
columns
columns: list[ViewColumn] | None = None
The columns shown on the grid, in display order. A saved view always has at least one column. When creating a view, leave this unset to copy the columns of the grid's default "All" view.
query
The filters and search text applied to the grid. The grid uses the first entry.
View
Bases: BaseResource
A saved grid view in Albert.
A view is a named, saved layout for one of the grids in the Albert app (for
example the Projects or Data Templates grid): which columns are shown, which
filters and search text are applied, and how rows are sorted and grouped.
Saved views appear as tabs above the grid (for example All | My Open Projects).
Views are personal. Each view belongs to the user who created it and is only
visible to that user. Views are managed through the
ViewCollection.
Example
Show JSON schema:
{
"$defs": {
"AuditFields": {
"description": "The audit fields for a resource",
"properties": {
"by": {
"default": null,
"title": "By",
"type": "string"
},
"byName": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Byname"
},
"at": {
"anyOf": [
{
"format": "date-time",
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "At"
}
},
"title": "AuditFields",
"type": "object"
},
"OrderBy": {
"description": "Sort direction for list and search results.\n\nAttributes\n----------\nDESCENDING : str\n Reverse chronological or reverse alphabetical order (Z\u2192A, newest\u2192oldest).\nASCENDING : str\n Chronological or alphabetical order (A\u2192Z, oldest\u2192newest).",
"enum": [
"desc",
"asc"
],
"title": "OrderBy",
"type": "string"
},
"Status": {
"description": "The status of a resource.\n\nAttributes\n----------\nACTIVE : str\n The resource is fully operational and visible in normal operations.\nINACTIVE : str\n The resource is hidden from normal operations and disabled from use.",
"enum": [
"active",
"inactive"
],
"title": "Status",
"type": "string"
},
"ViewColumn": {
"description": "A column shown on a view's grid.\n\nThe column order in [`ViewState.columns`][albert.resources.views.ViewState.columns]\nis the order the grid displays them in.\n\n!!! example\n ```python\n from albert.resources.views import ViewColumn\n\n column = ViewColumn(id=\"albertId\")\n hidden = ViewColumn(id=\"description\", is_hidden=True)\n ```",
"properties": {
"id": {
"description": "The column key, as used by the grid (e.g. ``albertId``, ``status``, ``owner``, ``tags``).",
"title": "Id",
"type": "string"
},
"isHidden": {
"default": false,
"description": "Whether the column is hidden on the grid. Hidden columns keep their position.",
"title": "Ishidden",
"type": "boolean"
},
"width": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"description": "The column width in pixels. When unset, the grid uses its default width.",
"title": "Width"
}
},
"required": [
"id"
],
"title": "ViewColumn",
"type": "object"
},
"ViewEntity": {
"description": "The grid a saved view belongs to.\n\nEach grid in the Albert app (Projects, Tasks, Inventory, and so on) keeps its\nown list of views. A view saved for one entity is only shown on that grid.\n\nAttributes\n----------\nPROJECTS : str\n The Projects grid.\nTASKS : str\n The Tasks grid.\nINVENTORIES : str\n The Inventory grid.\nPARAMETER_GROUPS : str\n The Parameter Groups grid (Master Data Management).\nDATA_TEMPLATES : str\n The Data Templates grid (Master Data Management).\nDATA_COLUMNS : str\n The Results (data columns) grid (Master Data Management).\nPARAMETERS : str\n The Parameters grid (Master Data Management).\nTEMPLATES : str\n The Templates grid (Master Data Management).\nREPORTS : str\n The Reports grid.\nTEAMS : str\n The Teams grid (Admin).\nUSERS : str\n The Users grid (Admin).\nREFERENCE_ATTRIBUTES : str\n The Attributes grid (Master Data Management).\nUNITS : str\n The Units grid.\nUNIT_FAMILIES : str\n The Unit Families grid.",
"enum": [
"projects",
"tasks",
"inventories",
"parametergroups",
"datatemplates",
"datacolumns",
"parameters",
"template",
"reports",
"teams",
"users",
"referenceattributes",
"units",
"unit-families"
],
"title": "ViewEntity",
"type": "string"
},
"ViewQuery": {
"description": "The filters and search text applied to a view's grid.\n\n``filter`` maps a grid filter key to the values to keep. Keys and values are the\nones the grid's filter bar uses, and values are display names, not IDs. For\nexample, the Data Templates grid's \"Owner\" filter is\n``{\"owner\": [\"Jane Doe\"]}`` and the Projects grid's \"Status\" filter is\n``{\"status\": [\"Active\", \"Not Started\"]}``. Albert does not check the keys or\nvalues when a view is saved. A key or value the grid does not recognize is kept\nas is and simply matches nothing, so the grid shows no results.\n\n!!! example\n ```python\n from albert.resources.views import ViewQuery\n\n mine = ViewQuery(filter={\"owner\": [\"Jane Doe\"]})\n searched = ViewQuery(filter={\"status\": [\"Active\"]}, search=\"coating\")\n ```",
"properties": {
"filter": {
"additionalProperties": true,
"description": "Grid filter key mapped to the values to keep (usually a list of display names).",
"title": "Filter",
"type": "object"
},
"search": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Free-text search applied on top of the filters.",
"title": "Search"
},
"containsField": {
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "Column keys for \"contains text\" filters. Paired by position with ``contains_text``.",
"title": "Containsfield"
},
"containsText": {
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "Text each column in ``contains_field`` must contain. Paired by position with ``contains_field``.",
"title": "Containstext"
}
},
"title": "ViewQuery",
"type": "object"
},
"ViewSort": {
"description": "A sort applied to a view's grid.\n\n!!! example\n ```python\n from albert.core.shared.enums import OrderBy\n from albert.resources.views import ViewSort\n\n newest_first = ViewSort(id=\"createdAt\", direction=OrderBy.DESCENDING)\n ```",
"properties": {
"id": {
"description": "The key of the column to sort by (e.g. ``createdAt``, ``status``).",
"title": "Id",
"type": "string"
},
"dir": {
"$ref": "#/$defs/OrderBy",
"description": "The sort direction: ascending or descending."
}
},
"required": [
"id",
"dir"
],
"title": "ViewSort",
"type": "object"
},
"ViewState": {
"description": "The saved layout of a view: its columns, filters, sorting, and grouping.\n\n!!! example\n ```python\n from albert.core.shared.enums import OrderBy\n from albert.resources.views import ViewColumn, ViewQuery, ViewSort, ViewState\n\n state = ViewState(\n columns=[ViewColumn(id=\"albertId\"), ViewColumn(id=\"owner\")],\n query=[ViewQuery(filter={\"owner\": [\"Jane Doe\"]})],\n sort_by=[ViewSort(id=\"createdAt\", direction=OrderBy.DESCENDING)],\n )\n ```",
"properties": {
"columns": {
"anyOf": [
{
"items": {
"$ref": "#/$defs/ViewColumn"
},
"minItems": 1,
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "The columns shown on the grid, in display order. A saved view always has at least one column. When creating a view, leave this unset to copy the columns of the grid's default \"All\" view.",
"title": "Columns"
},
"query": {
"description": "The filters and search text applied to the grid. The grid uses the first entry.",
"items": {
"$ref": "#/$defs/ViewQuery"
},
"title": "Query",
"type": "array"
},
"sortBy": {
"description": "The sorts applied to the grid, in priority order.",
"items": {
"$ref": "#/$defs/ViewSort"
},
"title": "Sortby",
"type": "array"
},
"groupBy": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "The key of the column the grid rows are grouped by, if any.",
"title": "Groupby"
}
},
"title": "ViewState",
"type": "object"
}
},
"description": "A saved grid view in Albert.\n\nA view is a named, saved layout for one of the grids in the Albert app (for\nexample the Projects or Data Templates grid): which columns are shown, which\nfilters and search text are applied, and how rows are sorted and grouped.\nSaved views appear as tabs above the grid (for example ``All | My Open Projects``).\n\nViews are personal. Each view belongs to the user who created it and is only\nvisible to that user. Views are managed through the\n[`ViewCollection`][albert.collections.views.ViewCollection].\n\n!!! example\n ```python\n from albert.resources.views import View, ViewEntity, ViewQuery, ViewState\n\n view = View(\n name=\"My Data Templates\",\n entity=ViewEntity.DATA_TEMPLATES,\n state=ViewState(query=[ViewQuery(filter={\"owner\": [\"Jane Doe\"]})]),\n )\n ```",
"properties": {
"status": {
"anyOf": [
{
"$ref": "#/$defs/Status"
},
{
"type": "null"
}
],
"default": null,
"description": "The status of the resource, optional."
},
"Created": {
"anyOf": [
{
"$ref": "#/$defs/AuditFields"
},
{
"type": "null"
}
],
"default": null,
"description": "Audit fields for the creation of the resource, optional."
},
"Updated": {
"anyOf": [
{
"$ref": "#/$defs/AuditFields"
},
{
"type": "null"
}
],
"default": null,
"description": "Audit fields for the update of the resource, optional."
},
"albertId": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "The Albert ID of the view (format ``VEW...``). Assigned by Albert when the view is created.",
"title": "Albertid"
},
"name": {
"description": "The display name of the view, shown on its tab. Must be 2 to 50 characters.",
"maxLength": 50,
"minLength": 2,
"title": "Name",
"type": "string"
},
"entity": {
"$ref": "#/$defs/ViewEntity",
"description": "The grid the view belongs to. Cannot be changed after the view is created."
},
"state": {
"anyOf": [
{
"$ref": "#/$defs/ViewState"
},
{
"type": "null"
}
],
"default": null,
"description": "The saved columns, filters, sorting, and grouping of the view."
},
"parentId": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "The ID of the user who owns the view. Assigned from the current user when the view is created.",
"title": "Parentid"
},
"uuid": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "A unique identifier Albert assigns to the view alongside its ID.",
"title": "Uuid"
},
"system": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"default": null,
"description": "Whether Albert created the view as one of the grid's built-in defaults (for example the \"All\" view).",
"title": "System"
}
},
"required": [
"name",
"entity"
],
"title": "View",
"type": "object"
}
Fields:
-
status(Status | None) -
created(AuditFields | None) -
updated(AuditFields | None) -
id(ViewId | None) -
name(str) -
entity(ViewEntity) -
state(ViewState | None) -
parent_id(UserId | None) -
uuid(str | None) -
system(bool | None)
id
id: ViewId | None = None
The Albert ID of the view (format VEW...). Assigned by Albert when the view is created.
entity
entity: ViewEntity
The grid the view belongs to. Cannot be changed after the view is created.
parent_id
parent_id: UserId | None = None
The ID of the user who owns the view. Assigned from the current user when the view is created.
system
system: bool | None = None
Whether Albert created the view as one of the grid's built-in defaults (for example the "All" view).