Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion resources/js/components/field-conditions/Condition.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const isToggleField = (field) => ['toggle', 'revealer', 'yes_no'].includes(field
const showValueToggle = computed(() => isToggleField(selectedField.value) && ['equals', 'not', '===', '!=='].includes(props.condition.operator));

const showValueDropdown = computed(() => {
const optionTypes = ['button_group', 'checkboxes', 'radio', 'select', 'dropdown', 'multi_choice', 'ranking'];
const optionTypes = ['button_group', 'checkboxes', 'radio', 'select', 'dropdown', 'multi_choice', 'ranking', 'image_choice'];
return optionTypes.includes(selectedField.value?.config?.type) && ['equals', 'not', '===', '!=='].includes(props.condition.operator);
});

Expand Down
4 changes: 2 additions & 2 deletions resources/js/components/fieldtypes/HasInputOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ export default {
let valueKey = 'value';
let labelKey = 'label';

// Support both {key: '', value: ''} and {value: '', label: ''} formats.
// Support {key: '', value: ''}, {key: '', label: ''}, and {value: '', label: ''} formats.
if (option.hasOwnProperty('key')) {
valueKey = 'key';
labelKey = 'value';
labelKey = option.hasOwnProperty('value') ? 'value' : 'label';
}

return {
Expand Down
12 changes: 12 additions & 0 deletions resources/js/tests/NormalizeInputOptions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,15 @@ it('normalizes input options with array of objects with key value keys', () => {
{ value: 'two', label: 'Two' },
]);
});

it('normalizes input options with array of objects with key label keys', () => {
expect(
normalizeInputOptions([
{ key: 'one', label: 'One', image: 'one.jpg' },
{ key: 'two', label: 'Two', image: 'two.jpg' },
]),
).toEqual([
{ value: 'one', label: 'Uno' },
{ value: 'two', label: 'Two' },
]);
});
Loading