Skip to content

Commit 58ded28

Browse files
committed
Adding options for all columns that have them available
1 parent c1e43df commit 58ded28

File tree

7 files changed

+68
-201
lines changed

7 files changed

+68
-201
lines changed

components/monday/actions/common/common-create-item.mjs

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { capitalizeWord } from "../../common/utils.mjs";
1+
import {
2+
capitalizeWord, getColumnOptions,
3+
} from "../../common/utils.mjs";
24
import monday from "../../monday.app.mjs";
35

46
export default {
@@ -26,30 +28,15 @@ export default {
2628
});
2729
for (const column of this.columns) {
2830
let description, options;
29-
const columnOptions = columnData.find(({ id }) => id === column)?.settings_str;
30-
if (columnOptions) {
31-
try {
32-
options = Object.entries(JSON.parse(columnOptions).labels).map(([
33-
value,
34-
label,
35-
]) => ({
36-
label: label !== ""
37-
? label
38-
: value,
39-
value,
40-
}));
41-
} catch (err) {
42-
console.log(`Error parsing options for column "${column}": ${err}`);
43-
}
44-
}
45-
if (column.endsWith("status")) {
46-
description = "A status value for the item. [See more about status values here](https://view.monday.com/1073554546-ad9f20a427a16e67ded630108994c11b?r=use1).";
47-
} else if (column === "person") {
31+
options = getColumnOptions(columnData, column);
32+
if (column === "person") {
4833
description = "The ID of a person/user.";
4934
} else if (column === "date4") {
5035
description = "A date string in `YYYY-MM-DD` format, e.g. `2022-09-02`.";
36+
} else if (options) {
37+
description = `Select a value from the list for column "${column}".`;
5138
} else {
52-
description = `Value for column ${column}. See the [Column Type Reference](https://developer.monday.com/api-reference/reference/column-types-reference) to learn more about entering column type values.`;
39+
description = `Value for column "${column}". See the [Column Type Reference](https://developer.monday.com/api-reference/reference/column-types-reference) to learn more about entering column type values.`;
5340
}
5441
props[column] = {
5542
type: "string",

components/monday/actions/create-item/create-item.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default {
88
name: "Create Item",
99
description: "Creates an item. [See the documentation](https://developer.monday.com/api-reference/reference/items#create-an-item)",
1010
type: "action",
11-
version: "0.0.11",
11+
version: "0.1.0",
1212
props: {
1313
monday,
1414
boardId: {

components/monday/actions/create-subitem/create-subitem.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default {
88
name: "Create Subitem",
99
description: "Creates a subitem. [See the documentation](https://developer.monday.com/api-reference/reference/subitems#create-a-subitem)",
1010
type: "action",
11-
version: "0.0.4",
11+
version: "0.1.0",
1212
props: {
1313
monday,
1414
boardId: {

components/monday/actions/get-items-by-column-value/get-items-by-column-value.mjs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
import { getColumnOptions } from "../../common/utils.mjs";
12
import common from "../common/column-values.mjs";
23

34
export default {
45
...common,
56
key: "monday-get-items-by-column-value",
67
name: "Get Items By Column Value",
78
description: "Searches a column for items matching a value. [See the documentation](https://developer.monday.com/api-reference/reference/items-page-by-column-values)",
8-
version: "0.0.6",
9+
version: "0.1.0",
910
type: "action",
1011
props: {
1112
...common.props,
@@ -18,12 +19,26 @@ export default {
1819
}),
1920
],
2021
description: "The column to search",
22+
reloadProps: true,
2123
},
22-
value: {
23-
type: "string",
24-
label: "Value",
25-
description: "The value to search for. [See the documentation](https://developer.monday.com/api-reference/reference/items-page-by-column-values#supported-and-unsupported-columns) for additional information about column values.",
26-
},
24+
},
25+
async additionalProps() {
26+
const columnData = await this.monday.listColumns({
27+
boardId: +this.boardId,
28+
});
29+
30+
const options = getColumnOptions(columnData, this.columnId);
31+
32+
return {
33+
value: {
34+
type: "string",
35+
label: "Value",
36+
description: `The value to search for.${options
37+
? ""
38+
: " [See the documentation](https://developer.monday.com/api-reference/reference/items-page-by-column-values#supported-and-unsupported-columns) for additional information about column values."} `,
39+
options,
40+
},
41+
};
2742
},
2843
async run({ $ }) {
2944
const response = await this.monday.getItemsByColumnValue({

components/monday/actions/update-column-values/update-column-values.mjs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import common from "../common/column-values.mjs";
22
import { axios } from "@pipedream/platform";
33
import fs from "fs";
44
import FormData from "form-data";
5+
import { getColumnOptions } from "../../common/utils.mjs";
56

67
export default {
78
...common,
89
key: "monday-update-column-values",
910
name: "Update Column Values",
1011
description: "Update multiple column values of an item. [See the documentation](https://developer.monday.com/api-reference/reference/columns#change-multiple-column-values)",
11-
version: "0.0.6",
12+
version: "0.1.0",
1213
type: "action",
1314
props: {
1415
...common.props,
@@ -34,14 +35,19 @@ export default {
3435
},
3536
async additionalProps() {
3637
const props = {};
37-
if (this.boardId) {
38-
const columns = await this.getColumns(this.boardId);
38+
const { boardId } = this;
39+
if (boardId) {
40+
const columns = await this.monday.listColumns({
41+
boardId: +boardId,
42+
});
3943
for (const column of columns) {
40-
props[column.id] = {
44+
const id = column.id;
45+
props[id] = {
4146
type: "string",
4247
label: column.title,
43-
description: `The value for column ${column.title}`,
48+
description: `The value for the "${column.title}" column (\`${id}\`)`,
4449
optional: true,
50+
options: getColumnOptions(columns, id),
4551
};
4652
if (column.type === "file") {
4753
props[column.id].description += ". The path to a file in the `/tmp` directory. [See the documentation on working with files](https://pipedream.com/docs/code/nodejs/working-with-files/#writing-a-file-to-tmp).";

components/monday/common/constants.mjs

Lines changed: 0 additions & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -141,172 +141,8 @@ const BOARD_TYPE = {
141141
SUB_ITEMS_BOARD: "sub_items_board",
142142
};
143143

144-
const STATUS_OPTIONS = [
145-
{
146-
label: "Grey",
147-
value: "5",
148-
},
149-
{
150-
label: "Orange",
151-
value: "0",
152-
},
153-
{
154-
label: "Green Shadow",
155-
value: "1",
156-
},
157-
{
158-
label: "Red Shadow",
159-
value: "2",
160-
},
161-
{
162-
label: "Blue Links",
163-
value: "3",
164-
},
165-
{
166-
label: "Purple",
167-
value: "4",
168-
},
169-
{
170-
label: "Grass Green",
171-
value: "6",
172-
},
173-
{
174-
label: "Bright Blue",
175-
value: "7",
176-
},
177-
{
178-
label: "Mustered",
179-
value: "8",
180-
},
181-
{
182-
label: "Yellow",
183-
value: "9",
184-
},
185-
{
186-
label: "Soft Black",
187-
value: "10",
188-
},
189-
{
190-
label: "Dark Red",
191-
value: "11",
192-
},
193-
{
194-
label: "Dark Pink",
195-
value: "12",
196-
},
197-
{
198-
label: "Light Pink",
199-
value: "13",
200-
},
201-
{
202-
label: "Dark Purple",
203-
value: "14",
204-
},
205-
{
206-
label: "Lime Green",
207-
value: "15",
208-
},
209-
{
210-
label: "Turquoise",
211-
value: "16",
212-
},
213-
{
214-
label: "Trolley Grey",
215-
value: "17",
216-
},
217-
{
218-
label: "Brown",
219-
value: "18",
220-
},
221-
{
222-
label: "Dark Orange",
223-
value: "19",
224-
},
225-
{
226-
label: "Sunset",
227-
value: "101",
228-
},
229-
{
230-
label: "Bubble",
231-
value: "102",
232-
},
233-
{
234-
label: "Peach",
235-
value: "103",
236-
},
237-
{
238-
label: "Berry",
239-
value: "104",
240-
},
241-
{
242-
label: "Winter",
243-
value: "105",
244-
},
245-
{
246-
label: "River",
247-
value: "106",
248-
},
249-
{
250-
label: "Navy",
251-
value: "107",
252-
},
253-
{
254-
label: "Australia",
255-
value: "108",
256-
},
257-
{
258-
label: "Indigo",
259-
value: "109",
260-
},
261-
{
262-
label: "Dark Indigo",
263-
value: "110",
264-
},
265-
{
266-
label: "Pecan",
267-
value: "151",
268-
},
269-
{
270-
label: "Light Magic",
271-
value: "152",
272-
},
273-
{
274-
label: "Sky",
275-
value: "153",
276-
},
277-
{
278-
label: "Cold Blue",
279-
value: "154",
280-
},
281-
{
282-
label: "Kids",
283-
value: "155",
284-
},
285-
{
286-
label: "Purple Gray",
287-
value: "156",
288-
},
289-
{
290-
label: "Corona",
291-
value: "157",
292-
},
293-
{
294-
label: "Sail",
295-
value: "158",
296-
},
297-
{
298-
label: "Old Rose",
299-
value: "159",
300-
},
301-
{
302-
label: "Eden",
303-
value: "160",
304-
},
305-
];
306-
307144
export default {
308145
BOARD_KIND_OPTIONS,
309146
COLUMN_TYPE_OPTIONS,
310147
BOARD_TYPE,
311-
STATUS_OPTIONS,
312148
};

components/monday/common/utils.mjs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
function emptyStrToUndefined(value) {
2-
const trimmed = typeof(value) === "string" && value.trim();
2+
const trimmed = typeof value === "string" && value.trim();
33
return trimmed === ""
44
? undefined
55
: value;
66
}
77

88
function strinfied(value) {
9-
return typeof(value) === "object"
9+
return typeof value === "object"
1010
? JSON.stringify(value)
1111
: emptyStrToUndefined(value);
1212
}
@@ -18,7 +18,7 @@ function strNumber(value) {
1818
}
1919

2020
function toNumber(value) {
21-
return typeof(value) === "number"
21+
return typeof value === "number"
2222
? value
2323
: strNumber(value);
2424
}
@@ -27,6 +27,29 @@ export function capitalizeWord(str) {
2727
return str.slice(0, 1).toUpperCase() + str.slice(1);
2828
}
2929

30+
export function getColumnOptions(allColumnData, columnId) {
31+
const columnOptions = allColumnData.find(
32+
({ id }) => id === columnId,
33+
)?.settings_str;
34+
if (columnOptions) {
35+
try {
36+
return Object.entries(JSON.parse(columnOptions).labels).map(
37+
([
38+
value,
39+
label,
40+
]) => ({
41+
label: label !== ""
42+
? label
43+
: value,
44+
value,
45+
}),
46+
);
47+
} catch (err) {
48+
console.log(`Error parsing options for column "${columnId}": ${err}`);
49+
}
50+
}
51+
}
52+
3053
export default {
3154
emptyStrToUndefined,
3255
strinfied,

0 commit comments

Comments
 (0)