Skip to content

Commit 9c63ee7

Browse files
committed
Adding card selection to 'create comment'
1 parent f5fc900 commit 9c63ee7

File tree

2 files changed

+84
-12
lines changed

2 files changed

+84
-12
lines changed

components/basecamp/actions/create-comment/create-comment.mjs

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,22 @@ export default {
66
name: "Create a Comment",
77
description: "Creates a comment in a selected recording. [See the documentation](https://github.com/basecamp/bc3-api/blob/master/sections/comments.md#create-a-comment)",
88
type: "action",
9-
version: "0.0.8",
9+
version: "0.1.0",
1010
props: {
1111
...common.props,
12+
recordingTypeAlert: {
13+
type: "alert",
14+
alertType: "info",
15+
content: `You can select either a **Recording** (by selecting the recording type) or a **Card** (by selecting the card table and column) to create the comment on.
16+
\\
17+
If both are specified, the **Card** will take precedence.`,
18+
},
1219
recordingType: {
1320
propDefinition: [
1421
app,
1522
"recordingType",
1623
],
24+
optional: true,
1725
},
1826
recordingId: {
1927
propDefinition: [
@@ -29,6 +37,49 @@ export default {
2937
recordingType,
3038
}),
3139
],
40+
optional: true,
41+
},
42+
cardTableId: {
43+
propDefinition: [
44+
app,
45+
"cardTableId",
46+
({
47+
accountId, projectId,
48+
}) => ({
49+
accountId,
50+
projectId,
51+
}),
52+
],
53+
optional: true,
54+
},
55+
columnId: {
56+
propDefinition: [
57+
app,
58+
"columnId",
59+
({
60+
accountId, projectId, cardTableId,
61+
}) => ({
62+
accountId,
63+
projectId,
64+
cardTableId,
65+
}),
66+
],
67+
optional: true,
68+
},
69+
cardId: {
70+
propDefinition: [
71+
app,
72+
"cardId",
73+
({
74+
accountId, projectId, cardTableId, columnId,
75+
}) => ({
76+
accountId,
77+
projectId,
78+
cardTableId,
79+
columnId,
80+
}),
81+
],
82+
optional: true,
3283
},
3384
content: {
3485
type: "string",
@@ -40,15 +91,14 @@ export default {
4091
const {
4192
accountId,
4293
projectId,
43-
recordingId,
4494
content,
4595
} = this;
4696

4797
const comment = await this.app.createComment({
4898
$,
4999
accountId,
50100
projectId,
51-
recordingId,
101+
recordingId: this.cardId ?? this.recordingId,
52102
data: {
53103
content,
54104
},

components/basecamp/basecamp.app.mjs

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ export default {
241241
},
242242
columnId: {
243243
type: "string",
244-
label: "Column ID",
245-
description: "Select a column or provide a column ID.",
244+
label: "Card Column ID",
245+
description: "Select a card column or provide a column ID.",
246246
async options({
247247
accountId, projectId, cardTableId,
248248
}) {
@@ -259,6 +259,26 @@ export default {
259259
}));
260260
},
261261
},
262+
cardId: {
263+
type: "string",
264+
label: "Card ID",
265+
description: "Select a card or provide a card ID.",
266+
async options({
267+
accountId, projectId, columnId,
268+
}) {
269+
const cards = await this.getCards({
270+
accountId,
271+
projectId,
272+
columnId,
273+
});
274+
return cards.map(({
275+
id: value, title: label,
276+
}) => ({
277+
value,
278+
label,
279+
}));
280+
},
281+
},
262282
botId: {
263283
type: "string",
264284
label: "Chatbot ID",
@@ -441,15 +461,17 @@ export default {
441461
const cardTables = dock.filter(({ name }) => name === "kanban_board");
442462
return cardTables;
443463
},
444-
async getColumns({
445-
accountId, projectId, cardTableId,
464+
async getColumns(args) {
465+
const { lists } = await this.getCardTable(args);
466+
return lists;
467+
},
468+
async getCards({
469+
projectId, columnId, ...args
446470
}) {
447-
const { lists } = await this.getCardTable({
448-
accountId,
449-
projectId,
450-
cardTableId: cardTableId,
471+
return this.makeRequest({
472+
path: `/buckets/${projectId}/card_tables/lists/${columnId}/cards.json`,
473+
...args,
451474
});
452-
return lists;
453475
},
454476
getChatbot({
455477
projectId, campfireId, botId, ...args

0 commit comments

Comments
 (0)