Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
15 changes: 8 additions & 7 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2324,7 +2324,7 @@ function buildDocsPage() {
<div class="section-eyebrow">Core resource</div>
<h2 class="section-title">Custom Tables</h2>
<div class="section-desc">
<p>A Custom Table is a saved column layout for the Contacts list on <strong>Manage Contacts</strong>: 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 (<code>owner: User</code>, only they see it) or is shared with colleagues (<code>owner: Charity</code>, 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.</p>
<p>A Custom Table is a saved column layout for the Contacts list on <strong>Manage Contacts</strong>: 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 (<code>owner: User</code>, only they see it) or is shared with colleagues (<code>owner: Charity</code>): with everyone (<code>visibility: charity_colleagues</code>, Organisation editors only), with chosen colleagues (<code>individual_list</code>) or with chosen Teams (<code>specific_teams</code> and <code>team_ids</code>). 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.</p>
<p><strong>Workflow:</strong> call <code>GET /custom_tables/available_columns</code> for the Organisation, pick columns from it, send them unchanged (in order) in <code>columns</code> on <code>POST /custom_tables</code>, then read values with <code>GET /custom_tables/{id}/rows</code>.</p>
</div>
<div class="endpoint-list">
Expand All @@ -2347,7 +2347,7 @@ function buildDocsPage() {
${endpointCard("GET", "/custom_tables/{id}", "Get a Custom Table", true, [
{ name: "id", in: "path", type: "integer", required: true, desc: "Custom Table ID" }
], [
{ code: "200", cls: "response-2xx", desc: "The table: <code>name</code>, <code>owner</code>, <code>visibility</code>, <code>individual_list</code>, <code>can_edit</code> and <code>columns</code>" },
{ code: "200", cls: "response-2xx", desc: "The table: <code>name</code>, <code>owner</code>, <code>visibility</code>, <code>individual_list</code>, <code>team_ids</code>, <code>teams</code>, <code>can_edit</code> and <code>columns</code>" },
{ code: "401", cls: "response-4xx", desc: "Not authenticated" },
{ code: "404", cls: "response-4xx", desc: "Not found, or not visible to you" }
])}
Expand All @@ -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 <code>available_columns</code>, in order; <code>display_name</code> is the heading" },
{ name: "custom_table[owner]", in: "body", type: "string", required: false, desc: "<code>User</code> (default, only you) or <code>Charity</code> (shared; editors only)" },
{ name: "custom_table[visibility]", in: "body", type: "string", required: false, desc: "For a shared table: <code>charity_colleagues</code> (everyone) or <code>individual_list</code>" },
{ name: "custom_table[individual_list]", in: "body", type: "array", required: false, desc: "User IDs of the colleagues who see it, for <code>individual_list</code>" }
{ name: "custom_table[owner]", in: "body", type: "string", required: false, desc: "<code>User</code> (default, only you) or <code>Charity</code> (shared with colleagues)" },
{ name: "custom_table[visibility]", in: "body", type: "string", required: false, desc: "For a shared table: <code>charity_colleagues</code> (everyone; editors only), <code>individual_list</code> or <code>specific_teams</code>" },
{ name: "custom_table[individual_list]", in: "body", type: "array", required: false, desc: "User IDs of the colleagues who see it, for <code>individual_list</code>" },
{ name: "custom_table[team_ids]", in: "body", type: "array", required: false, desc: "Team IDs who see it, for <code>specific_teams</code> (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: "<code>errors</code>: e.g. a column the Organisation doesn't offer, or one hidden from you" }
{ code: "422", cls: "response-4xx", desc: "<code>errors</code>: 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 <b>Manage Contacts › Custom tables › Create a table</b> 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 <code>name</code>, <code>columns</code>, <code>owner</code>, <code>visibility</code>, <code>individual_list</code>" }
{ name: "custom_table", in: "body", type: "object", required: true, desc: "Any of <code>name</code>, <code>columns</code>, <code>owner</code>, <code>visibility</code>, <code>individual_list</code>, <code>team_ids</code>" }
], [
{ code: "200", cls: "response-2xx", desc: "The Custom Table" },
{ code: "401", cls: "response-4xx", desc: "Not authenticated" },
Expand Down
Loading