Skip to content

Commit deb6046

Browse files
committed
Adjusting options for 'get items by column value'
1 parent 4baab24 commit deb6046

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default {
2727
boardId: +this.boardId,
2828
});
2929

30-
const options = getColumnOptions(columnData, this.columnId);
30+
const options = getColumnOptions(columnData, this.columnId, true);
3131

3232
return {
3333
value: {

components/monday/common/utils.mjs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,31 +27,35 @@ export function capitalizeWord(str) {
2727
return str.slice(0, 1).toUpperCase() + str.slice(1);
2828
}
2929

30-
export function getColumnOptions(allColumnData, columnId) {
30+
export function getColumnOptions(allColumnData, columnId, useLabels = false) {
3131
const columnOptions = allColumnData.find(
3232
({ id }) => id === columnId,
3333
)?.settings_str;
3434
if (columnOptions) {
3535
try {
3636
const labels = JSON.parse(columnOptions).labels;
37-
return Array.isArray(labels)
37+
return (Array.isArray(labels)
3838
? labels.map(({
3939
id, name,
40-
}) => ({
41-
label: name,
42-
value: id.toString(),
43-
}))
40+
}) => useLabels
41+
? name
42+
: ({
43+
label: name,
44+
value: id.toString(),
45+
}))
4446
: Object.entries(labels).map(
4547
([
4648
value,
4749
label,
48-
]) => ({
49-
label: label !== ""
50-
? label
51-
: value,
52-
value,
53-
}),
54-
);
50+
]) => useLabels
51+
? label
52+
: ({
53+
label: label !== ""
54+
? label
55+
: value,
56+
value,
57+
}),
58+
)).filter((str) => str);
5559
} catch (err) {
5660
console.log(`Error parsing options for column "${columnId}": ${err}`);
5761
}

0 commit comments

Comments
 (0)