diff --git a/openapi.yaml b/openapi.yaml index 3bd17f0..2d1a795 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -6605,8 +6605,10 @@ paths: in the order the table should show them; `display_name` is the column heading and may be changed. A column the Organisation doesn't offer, or a field hidden from the user by "Hide certain fields", is refused. `owner: User` makes a table only its creator sees; `owner: Charity` shares it - with colleagues (Organisation editors only), with everyone (`visibility: charity_colleagues`) or - with the colleagues in `individual_list`. + with colleagues: with everyone (`visibility: charity_colleagues`, Organisation editors only), with + the colleagues in `individual_list`, or with the Teams in `team_ids` (`visibility: specific_teams`). + Organisation editors may choose any of the Organisation's Teams; anyone else only Teams they lead or + belong to. A Team table is visible to the Teams' members and leaders, its creator and Organisation editors. operationId: createCustomTable security: [{tokenAuth: []}] requestBody: @@ -30040,12 +30042,27 @@ components: nullable: true visibility: type: string - enum: [only_me, charity_colleagues, individual_list] + enum: [only_me, charity_colleagues, individual_list, specific_teams] individual_list: type: array description: User IDs who see the table when visibility is individual_list items: type: integer + team_ids: + type: array + description: IDs of the Teams who see the table when visibility is specific_teams + items: + type: integer + teams: + type: array + description: The Teams who see the table when visibility is specific_teams + items: + type: object + properties: + id: + type: integer + name: + type: string can_edit: type: boolean description: Whether the user may change or delete the table @@ -30086,11 +30103,17 @@ components: enum: [User, Charity] visibility: type: string - enum: [charity_colleagues, individual_list] + enum: [charity_colleagues, individual_list, specific_teams] + description: charity_colleagues is for Organisation editors only individual_list: type: array items: type: integer + team_ids: + type: array + description: The Teams who see the table when visibility is specific_teams (at least one) + items: + type: integer columns: type: array items: diff --git a/server.js b/server.js index 4896e62..358ea33 100644 --- a/server.js +++ b/server.js @@ -2324,7 +2324,7 @@ function buildDocsPage() {
A Custom Table is a saved column layout for the Contacts list on Manage Contacts: one row per Contact, with the columns an Organisation chooses (basic Contact fields, Bio Form questions, survey answers, progress trackers and relationships). A table belongs to its creator (owner: User, only they see it) or is shared with colleagues (owner: Charity, Organisation editors only). Its creator, or an Organisation editor for a shared table, can change it. A table you can't see returns 404; one you can see but not change returns 403.
A Custom Table is a saved column layout for the Contacts list on Manage Contacts: one row per Contact, with the columns an Organisation chooses (basic Contact fields, Bio Form questions, survey answers, progress trackers and relationships). A table belongs to its creator (owner: User, only they see it) or is shared with colleagues (owner: Charity): with everyone (visibility: charity_colleagues, Organisation editors only), with chosen colleagues (individual_list) or with chosen Teams (specific_teams and team_ids). A Team table is seen by the Teams' members and leaders, its creator and Organisation editors. Organisation editors may share with any of the Organisation's Teams; anyone else only with Teams they lead or belong to. Its creator, or an Organisation editor for a shared table, can change it. A table you can't see returns 404; one you can see but not change returns 403.
Workflow: call GET /custom_tables/available_columns for the Organisation, pick columns from it, send them unchanged (in order) in columns on POST /custom_tables, then read values with GET /custom_tables/{id}/rows.
name, owner, visibility, individual_list, can_edit and columns" },
+ { code: "200", cls: "response-2xx", desc: "The table: name, owner, visibility, individual_list, team_ids, teams, can_edit and columns" },
{ code: "401", cls: "response-4xx", desc: "Not authenticated" },
{ code: "404", cls: "response-4xx", desc: "Not found, or not visible to you" }
])}
@@ -2366,18 +2366,19 @@ function buildDocsPage() {
{ name: "custom_table[charity_id]", in: "body", type: "integer", required: true, desc: "Organisation ID" },
{ name: "custom_table[name]", in: "body", type: "string", required: true, desc: "The table's title" },
{ name: "custom_table[columns]", in: "body", type: "array", required: false, desc: "Columns from available_columns, in order; display_name is the heading" },
- { name: "custom_table[owner]", in: "body", type: "string", required: false, desc: "User (default, only you) or Charity (shared; editors only)" },
- { name: "custom_table[visibility]", in: "body", type: "string", required: false, desc: "For a shared table: charity_colleagues (everyone) or individual_list" },
- { name: "custom_table[individual_list]", in: "body", type: "array", required: false, desc: "User IDs of the colleagues who see it, for individual_list" }
+ { name: "custom_table[owner]", in: "body", type: "string", required: false, desc: "User (default, only you) or Charity (shared with colleagues)" },
+ { name: "custom_table[visibility]", in: "body", type: "string", required: false, desc: "For a shared table: charity_colleagues (everyone; editors only), individual_list or specific_teams" },
+ { name: "custom_table[individual_list]", in: "body", type: "array", required: false, desc: "User IDs of the colleagues who see it, for individual_list" },
+ { name: "custom_table[team_ids]", in: "body", type: "array", required: false, desc: "Team IDs who see it, for specific_teams (at least one; Teams you belong to unless you are an Organisation editor)" }
], [
{ code: "201", cls: "response-2xx", desc: "The Custom Table" },
{ code: "401", cls: "response-4xx", desc: "Not authenticated" },
{ code: "404", cls: "response-4xx", desc: "Not one of your Organisations" },
- { code: "422", cls: "response-4xx", desc: "errors: e.g. a column the Organisation doesn't offer, or one hidden from you" }
+ { code: "422", cls: "response-4xx", desc: "errors: e.g. a column the Organisation doesn't offer, one hidden from you, sharing with everyone when you aren't an Organisation editor, or a Team you may not choose" }
], "Creates the table as Manage Contacts › Custom tables › Create a table does. It shows on Manage Contacts straight away.")}
${endpointCard("PATCH", "/custom_tables/{id}", "Change a Custom Table", true, [
{ name: "id", in: "path", type: "integer", required: true, desc: "Custom Table ID" },
- { name: "custom_table", in: "body", type: "object", required: true, desc: "Any of name, columns, owner, visibility, individual_list" }
+ { name: "custom_table", in: "body", type: "object", required: true, desc: "Any of name, columns, owner, visibility, individual_list, team_ids" }
], [
{ code: "200", cls: "response-2xx", desc: "The Custom Table" },
{ code: "401", cls: "response-4xx", desc: "Not authenticated" },