-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: survey variable for multi select #3351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
…mplate and TaskForm components Signed-off-by: blackb1rd <blackb1rd.mov@gmail.com>
Feat/multi select
b4a36a2
to
fb24124
Compare
…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>
fb24124
to
0e0369d
Compare
Signed-off-by: Prachya Saechua <psaechua@cpaxtra.co.th>
There was a problem hiding this 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 |
if (!this.editedEnvironment[varName] || !Array.isArray(this.editedEnvironment[varName])) { | ||
return; | ||
} | ||
if (index >= 0 && index < this.editedEnvironment[varName].length) { |
Copilot
AI
Oct 10, 2025
There was a problem hiding this comment.
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
.
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); |
Copilot
AI
Oct 10, 2025
There was a problem hiding this comment.
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.
this.editedEnvironment[name].splice(index, 1); | |
if (Array.isArray(this.editedEnvironment?.[name])) { | |
this.editedEnvironment[name].splice(index, 1); | |
} |
Copilot uses AI. Check for mistakes.
<template v-slot:selection="{ item, index }" v-if="v.type === 'select'"> | ||
<v-chip small close @click:close="removeSelectedItem(v.name, index)" |
Copilot
AI
Oct 10, 2025
There was a problem hiding this comment.
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.
<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.
<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> |
Copilot
AI
Oct 10, 2025
There was a problem hiding this comment.
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.
<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.
rebase #2754 and change naming multi_enum to select
Closes #2751