<commit_before>import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';
import { Output } from '../../core/ui/output';
import { Input } from '../../core/ui/input';

import './form.scss'

@Component({
    template: require('./form.html'),
    components: {
        'FormOutput': Output,
        'FormInput': Input
    }
})
export class FormComponent extends Vue {
    initialized: boolean = false;
    visibleInputFields: any[];
    submitButtonLabel: string;
    tabindex: number = 1;
    disabled: false;
    responseMetadata: any = {};
    urlData: null;
    useUrl: boolean = true;
    metadata: any;
    form: any;
    app: any;
    outputFieldValues: any = null;
    parent: any;

    setForm = async function () {
        if (this.form == null) {
            var formInstance = this.app.getFormInstance(this.$route.params._id, true);
            await formInstance.initializeInputFields(this.$route.params).then(() => {
                this.metadata = formInstance.metadata;
                this.form = formInstance;
            });
        }
    }

    setMetadata = function () {
        this.form = this.form || this.$attrs["form"];
        this.metadata = this.metadata || this.$attrs["metadata"];
        this.parent = this.parent || this;
        this.initialized = this.initialized || false;
        this.tabindex += parseInt(this.$attrs["tabindex"]) || 1;
        this.useUrl = this.useUrl || new Boolean(this.$attrs["useUrl"]).valueOf();
        this.init();
    }

    created() {
        this.app = this.app || this.$attrs["app"] || this.$parent.$data.app;
        this.form = this.form || this.$attrs["form"];

        this.setForm().then(() => {
            this.setMetadata();
        });
    }

    init = function () {
        if (!this.initialized) {
            this.initialized = true;
            this.visibleInputFields = this.form.inputs.filter(t => t.metadata.hidden == false);
            this.submitButtonLabel = this.form.metadata.customProperties != null && this.form.metadata.customProperties.SubmitButtonLabel
                ? this.form.metadata.customProperties.SubmitButtonLabel
                : "Submit"

            this.form.fire("form:loaded", { app: this.app });

            // Auto-submit form if necessary.
            if (this.form.metadata.postOnLoad) {
                this.submit(this.app, this.form);
            }
        }
    };

    enableForm = function () {
        var formInstance = this.form;

        this.visibleInputFields = formInstance.inputs.filter(t => t.metadata.hidden == false);<commit_msg>fix form load for modals<commit_after>import Vue from 'vue';
import { Component } from 'vue-property-decorator';
import { Output } from '../../core/ui/output';
import { Input } from '../../core/ui/input';

import './form.scss'

@Component({
    template: require('./form.html'),
    components: {
        'FormOutput': Output,
        'FormInput': Input
    }
})
export class FormComponent extends Vue {
    initialized: boolean = false;
    visibleInputFields: any[];
    submitButtonLabel: string;
    tabindex: number = 1;
    disabled: false;
    responseMetadata: any = {};
    urlData: null;
    useUrl: boolean = true;
    metadata: any;
    form: any;
    app: any;
    outputFieldValues: any = null;
    parent: any;

    setForm = async function () {
        if (this.form == null) {
            var formInstance = this.app.getFormInstance(this.$route.params._id, true);
            await formInstance.initializeInputFields(this.$route.params).then(() => {
                this.metadata = formInstance.metadata;
                this.form = formInstance;
            });
        }
    }

    setMetadata = function () {
        this.form = this.form || this.$attrs["form"];
        this.metadata = this.metadata || this.$attrs["metadata"];
        this.parent = this.parent || this;
        this.tabindex += parseInt(this.$attrs["tabindex"]) || 1;

        var url = new Boolean(this.$attrs["useUrl"]).valueOf();

        if (this.$attrs["useUrl"] != null && !url) {
            this.useUrl = url;
        }

        var initialized = new Boolean(this.$attrs["initialized"]).valueOf();

        if (this.$attrs["initialized"] != null && initialized) {
            this.initialized = initialized;
        }

        this.init();
    }

    created() {
        this.app = this.app || this.$attrs["app"];
        this.form = this.form || this.$attrs["form"];

        this.setForm().then(() => {
            this.setMetadata();
        });
    }

    init = function () {
        if (!this.initialized) {
            this.initialized = true;
            this.visibleInputFields = this.form.inputs.filter(t => t.metadata.hidden == false);
            this.submitButtonLabel = this.form.metadata.customProperties != null && this.form.metadata.customProperties.SubmitButtonLabel
                ? this.form.metadata.customProperties.SubmitButtonLabel
                : "Submit"

            this.form.fire("form:loaded", { app: this.app });

            // Auto-submit form if necessary.
            if (this.form.metadata.postOnLoad) {
                this.submit(this.app, this.form);
            }
        }
    };

    enableForm = function () {
        var formInstance = this.form;

        this.visibleInputFields = formInstance.inputs.filter(t => t.metadata.hidden == false);
{'fraction_non_alphanumeric': 0.14708620368646436, 'fraction_numerical': 0.0007447402718301992, 'mean_word_length': 2.165586328815557, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3948738', 'n_tokens_mistral': 1495, 'n_tokens_neox': 1478, 'n_words': 306}