Skip to content

Conversation

blackb1rd
Copy link

@blackb1rd blackb1rd commented Oct 7, 2025

rebase #2754 and change naming multi_enum to select
Closes #2751

@blackb1rd blackb1rd changed the title Feat/multi select feat: multi select Oct 7, 2025
@blackb1rd blackb1rd changed the title feat: multi select feat: survey variable for multi select Oct 7, 2025
@blackb1rd blackb1rd marked this pull request as draft October 7, 2025 08:37
@blackb1rd blackb1rd marked this pull request as ready for review October 7, 2025 12:09
blackb1rd and others added 7 commits October 10, 2025 16:25
…lt value normalization and selection chips

Signed-off-by: blackb1rd <blackb1rd.mov@gmail.com>
…ct type

Signed-off-by: blackb1rd <blackb1rd.mov@gmail.com>
…s component

Signed-off-by: blackb1rd <blackb1rd.mov@gmail.com>
…urveyVar

Signed-off-by: blackb1rd <blackb1rd.mov@gmail.com>
… improved default value normalization

Signed-off-by: Prachya Saechua <psaechua@cpaxtra.co.th>
…m for default value normalization

Signed-off-by: Prachya Saechua <psaechua@cpaxtra.co.th>
Signed-off-by: Prachya Saechua <psaechua@cpaxtra.co.th>
@fiftin fiftin requested a review from Copilot October 10, 2025 12:10
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request adds support for multi-select survey variables to Semaphore UI templates. The feature introduces a new "select" variable type that allows users to choose multiple values from a predefined list, building upon the existing "enum" type which only allows single selection.

Key changes:

  • Added new "select" survey variable type with multi-select capabilities
  • Extended frontend components to handle array-based values for select types
  • Implemented custom JSON marshaling/unmarshaling to support both single and multiple default values
  • Added UI components for managing multi-select variables with chips and deletion functionality

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
web/src/lang/en.js Added localization string for "Allow multiple values" feature
web/src/components/TeamMenu.vue Removed extra whitespace (formatting cleanup)
web/src/components/TaskParamsForm.vue Enhanced form to support select type variables with multi-select UI, array normalization, and chip-based selection display
web/src/components/TaskForm.vue Added multi-select support to task creation form with chip display and item deletion
web/src/components/SurveyVars.vue Extended survey variable editor to support select type with multi-select default values and proper array/string normalization
db/Template.go Introduced SurveyVarSelect constant and custom SurveyVarDefaultValue type with flexible JSON marshaling for single/multiple values

Comment on lines +349 to +352
if (!this.editedEnvironment[varName] || !Array.isArray(this.editedEnvironment[varName])) {
return;
}
if (index >= 0 && index < this.editedEnvironment[varName].length) {
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bounds check index >= 0 is unnecessary since the index parameter comes from Vue's template slot which guarantees non-negative values. However, the method lacks proper error handling for undefined varName keys in editedEnvironment.

Suggested change
if (!this.editedEnvironment[varName] || !Array.isArray(this.editedEnvironment[varName])) {
return;
}
if (index >= 0 && index < this.editedEnvironment[varName].length) {
if (!Object.prototype.hasOwnProperty.call(this.editedEnvironment, varName) || !Array.isArray(this.editedEnvironment[varName])) {
// Optionally, log a warning for debugging:
// console.warn(`removeSelectedItem: '${varName}' is not a valid array key in editedEnvironment.`);
return;
}
if (index < this.editedEnvironment[varName].length) {

Copilot uses AI. Check for mistakes.

},
deleteItem(name, index) {
this.editedEnvironment[name].splice(index, 1);
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing validation for this.editedEnvironment[name] existence and array type before calling splice. This could cause runtime errors if the property is undefined or not an array.

Suggested change
this.editedEnvironment[name].splice(index, 1);
if (Array.isArray(this.editedEnvironment?.[name])) {
this.editedEnvironment[name].splice(index, 1);
}

Copilot uses AI. Check for mistakes.

Comment on lines +34 to +35
<template v-slot:selection="{ item, index }" v-if="v.type === 'select'">
<v-chip small close @click:close="removeSelectedItem(v.name, index)"
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The template uses v-if on the template element, but the condition should be on the inner elements or use v-show. Vue templates with v-if can cause rendering issues.

Suggested change
<template v-slot:selection="{ item, index }" v-if="v.type === 'select'">
<v-chip small close @click:close="removeSelectedItem(v.name, index)"
<template v-slot:selection="{ item, index }">
<v-chip v-if="v.type === 'select'" small close @click:close="removeSelectedItem(v.name, index)"

Copilot uses AI. Check for mistakes.

Comment on lines +99 to +106
<template v-if="v.type === 'select'" v-slot:selection="{ item, index }">
<v-chip
small
close
@click:close="deleteItem(v.name, index)"
>
{{ item.name }}
</v-chip>
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The template uses v-if directive on a template element with slot scope. This should use conditional rendering inside the template or restructure to avoid potential rendering issues.

Suggested change
<template v-if="v.type === 'select'" v-slot:selection="{ item, index }">
<v-chip
small
close
@click:close="deleteItem(v.name, index)"
>
{{ item.name }}
</v-chip>
<template v-slot:selection="{ item, index }">
<div v-if="v.type === 'select'">
<v-chip
small
close
@click:close="deleteItem(v.name, index)"
>
{{ item.name }}
</v-chip>
</div>

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Multi variable dropdown menu

2 participants