Unverified Commit 93fb577c authored by Marius van den Beek's avatar Marius van den Beek Committed by GitHub
Browse files

Merge pull request #14064 from guerler/fix_section_help

Restore section and repeat block help in forms
parents 3a18da85 276f3e11
Loading
Loading
Loading
Loading
+49 −0
Original line number Diff line number Diff line
@@ -45,6 +45,38 @@ describe("FormDisplay", () => {
                        },
                    ],
                },
                {
                    type: "repeat",
                    name: "repeat_block",
                    title: "Repeat Block",
                    help: "repeat help",
                    inputs: [
                        {
                            type: "text",
                            name: "repeat_text_a",
                        },
                        {
                            type: "text",
                            name: "repeat_text_b",
                        },
                    ],
                },
                {
                    type: "section",
                    name: "section_block",
                    title: "Section Block",
                    help: "section help",
                    inputs: [
                        {
                            type: "text",
                            name: "section_text_a",
                        },
                        {
                            type: "text",
                            name: "section_text_b",
                        },
                    ],
                },
            ],
            errors: {},
            validationScrollTo: [],
@@ -105,4 +137,21 @@ describe("FormDisplay", () => {
        const conditionalBoolDisabled = wrapper.findAll("[type='checkbox']");
        expect(conditionalBoolDisabled.length).toEqual(0);
    });

    it("repeats", async () => {
        const repeatButton = wrapper.find("[data-description='repeat insert']");
        expect(repeatButton.text()).toBe("Insert Repeat Block");
        const repeatHelp = wrapper.find("[data-description='repeat help']").exists();
        expect(repeatHelp).toBeTruthy();
        for (let i = 0; i < 3; i++) {
            const repeatBlocks = wrapper.findAll("[data-description='repeat block']").length;
            expect(repeatBlocks).toBe(i);
            await repeatButton.trigger("click");
        }
    });

    it("section", async () => {
        const sectionHelpText = wrapper.find("[data-description='section help']").text();
        expect(sectionHelpText).toBe("section help");
    });
});
+7 −4
Original line number Diff line number Diff line
@@ -22,11 +22,13 @@
                </div>
            </div>
            <div v-else-if="input.type == 'repeat'">
                <p v-if="!sustainRepeats || (input.cache && input.cache.length > 0)" class="font-weight-bold mb-2">
                    {{ input.title }}
                </p>
                <div v-if="!sustainRepeats || (input.cache && input.cache.length > 0)">
                    <div class="font-weight-bold mb-2">{{ input.title }}</div>
                    <div v-if="input.help" class="mb-2" data-description="repeat help">{{ input.help }}</div>
                </div>
                <FormCard
                    v-for="(cache, cacheId) in input.cache"
                    data-description="repeat block"
                    :key="cacheId"
                    :title="repeatTitle(cacheId, input.title)">
                    <template v-slot:operations>
@@ -47,12 +49,13 @@
                </FormCard>
                <b-button v-if="!sustainRepeats" @click="repeatInsert(input)">
                    <font-awesome-icon icon="plus" class="mr-1" />
                    <span>Insert {{ input.title || "Repeat" }}</span>
                    <span data-description="repeat insert">Insert {{ input.title || "Repeat" }}</span>
                </b-button>
            </div>
            <div v-else-if="input.type == 'section'">
                <FormCard :title="input.title || input.name" :expanded.sync="input.expanded" :collapsible="true">
                    <template v-slot:body>
                        <div v-if="input.help" class="my-2" data-description="section help">{{ input.help }}</div>
                        <FormNode v-bind="$props" :inputs="input.inputs" :prefix="getPrefix(input.name)" />
                    </template>
                </FormCard>