Commit 832af834 authored by Cage, Gregory's avatar Cage, Gregory
Browse files

Rework FormData to handle disableBatchInput as a property

parent cfaef066
Loading
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -87,6 +87,18 @@ describe("FormData", () => {
        expect(wrapper.find(SELECTED_VALUE).text()).toEqual("4: hdaName4");
    });

    it("regular data no batch input", async () => {
        const wrapper = createTarget({
            value: null,
            options: defaultOptions,
            disableBatchInput: true,
        });
        const options = wrapper.find(".btn-group").findAll("button");
        expect(options.length).toBe(2);
        expect(options.at(0).classes()).toContain("active");
        expect(options.at(0).attributes("title")).toBe("Single dataset");
    });

    it("optional dataset", async () => {
        const wrapper = createTarget({
            value: null,
+3 −2
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ const props = withDefaults(
        collectionTypes?: Array<string>;
        flavor?: string;
        tag?: string;
        disableBatchInput?: boolean;
    }>(),
    {
        loading: false,
@@ -50,13 +51,13 @@ const props = withDefaults(
        collectionTypes: undefined,
        flavor: undefined,
        tag: undefined,
        disableBatchInput: false,
    }
);

const eventStore = useEventStore();
const { datatypesMapper } = useDatatypesMapper();

const disableBatchInput = getGalaxyInstance().config.disable_batch_input;

const $emit = defineEmits(["input", "alert"]);

@@ -224,7 +225,7 @@ const variant = computed(() => {
    const flavorKey = props.flavor ? `${props.flavor}_` : "";
    const multipleKey = props.multiple ? `_multiple` : "";
    const variantKey = `${flavorKey}${props.type}${multipleKey}`;
    if (disableBatchInput && VARIANTS[variantKey]) {
    if (props.disableBatchInput && VARIANTS[variantKey]) {
        return VARIANTS[variantKey]!.filter((v) => {
            return v.batch === BATCH.DISABLED;
        });
+4 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ import { sanitize } from "dompurify";
import type { ComputedRef } from "vue";
import { computed, ref, useAttrs } from "vue";

import { getGalaxyInstance } from "@/app";
import { linkify } from "@/utils/utils";

import type { FormParameterAttributes, FormParameterTypes, FormParameterValue } from "./parameterTypes";
@@ -88,6 +89,8 @@ const collapsed = ref(false);
const collapsible = computed(() => !props.disabled && collapsibleValue.value !== undefined);
const connectable = computed(() => collapsible.value && Boolean(attrs.value["connectable"]));

const disableBatchInput = computed(() => getGalaxyInstance().config.disable_batch_input);

// Determines whether to expand or collapse the input
{
    const valueJson = JSON.stringify(props.value);
@@ -298,6 +301,7 @@ function onAlert(value: string | undefined) {
                :tag="attrs.tag"
                :type="props.type"
                :collection-types="attrs.collection_types"
                :disable-batch-input="disableBatchInput"
                @alert="onAlert" />
            <FormDrilldown
                v-else-if="props.type === 'drill_down'"