"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getFormRules = exports.getDataDefinitionForRulePage = exports.getFormConfig = exports.getFormData = void 0;
const ExecutionData_1 = require("@appglue/common/dist/Common/Data/ExecutionData/ExecutionData");
const TextFormControl_1 = require("../Controls/Web/TextFormControl");
const MultiLineTextEditFormControl_1 = require("../Controls/Web/MultiLineTextEditFormControl");
const CheckboxFormControl_1 = require("../Controls/Web/CheckboxFormControl");
const SelectFormControl_1 = require("../Controls/Web/SelectFormControl");
const HeadingFormControl_1 = require("../Controls/Web/HeadingFormControl");
const LabelFormControl_1 = require("../Controls/Web/LabelFormControl");
const ButtonFormControl_1 = require("../Controls/Web/ButtonFormControl");
const LinkFormControl_1 = require("../Controls/Web/LinkFormControl");
const SwitchFormControl_1 = require("../Controls/Web/SwitchFormControl");
const CheckboxListFormControl_1 = require("../Controls/Web/CheckboxListFormControl");
const RatingFormControl_1 = require("../Controls/Web/RatingFormControl");
const InlineTextEditFormControl_1 = require("../Controls/Web/InlineTextEditFormControl");
const MultiInlineTextEditFormControl_1 = require("../Controls/Web/MultiInlineTextEditFormControl");
const Containers_1 = require("../Containers");
const RadioGroupFormControl_1 = require("../Controls/Web/RadioGroupFormControl");
const FormConfiguration_1 = require("../FormConfiguration");
const DatePickerFormControl_1 = require("../Controls/Web/DatePickerFormControl");
const TimePickerFormControl_1 = require("../Controls/Web/TimePickerFormControl");
const NumberFormControl_1 = require("../Controls/Web/NumberFormControl");
const SliderFormControl_1 = require("../Controls/Web/SliderFormControl");
const ButtonGroupFormControl_1 = require("../Controls/Web/ButtonGroupFormControl");
const TagGroupFormControl_1 = require("../Controls/Web/TagGroupFormControl");
const FormDesignConstants_1 = require("../Utilities/FormDesignConstants");
const DefaultOnOff_1 = require("../Utilities/DefaultOnOff");
const ListEntryFormControl_1 = require("../Controls/Web/ListEntryFormControl");
const ValueSliderFormControl_1 = require("../Controls/Web/ValueSliderFormControl");
const ImageFormControl_1 = require("../Controls/Web/ImageFormControl");
const DataDefinition_1 = require("@appglue/common/dist/Common/Data/DataDefinition");
const BooleanDataDefinition_1 = require("@appglue/common/dist/Common/Data/Definitions/BooleanDataDefinition");
const NumberDataDefinition_1 = require("@appglue/common/dist/Common/Data/Definitions/NumberDataDefinition");
const ObjectDataDefinition_1 = require("@appglue/common/dist/Common/Data/Definitions/ObjectDataDefinition");
const StringDataDefinition_1 = require("@appglue/common/dist/Common/Data/Definitions/StringDataDefinition");
const TimelineFormControl_1 = require("../Controls/Web/TimelineFormControl");
const DataGridFormControl_1 = require("../Controls/Web/DataGridFormControl");
const ExpressionConfiguration_1 = require("@appglue/common/dist/Expressions/ExpressionConfiguration");
const FormRule_1 = require("../Structure/FormRule");
const StringData_1 = require("../../Expressions/Testing/StringData");
// this is temporary code to create form definition.
// eventually, this form will be read in from JSON and written to JSON... even though I think that
// this might be useful pattern to create test scripts.
function getFormData() {
    let formData = new ExecutionData_1.ExecutionData({
        firstName: "Carl",
        lastName: "Hewitt",
        testdata: "",
        age: 28,
    });
    return formData;
}
exports.getFormData = getFormData;
function getFormConfig() {
    let heading = new HeadingFormControl_1.HeadingFormControl();
    heading.text = "Person Information";
    heading.type = "h3";
    let label = new LabelFormControl_1.LabelFormControl();
    label.text = " Enter Information Below";
    let composite2 = new TextFormControl_1.TextFormControl();
    composite2.label = "first name";
    composite2.valueName = "firstName";
    let composite3 = new TextFormControl_1.TextFormControl();
    composite3.label = "last name";
    composite3.valueName = "lastName";
    let composite4 = new TextFormControl_1.TextFormControl();
    composite4.label = "full name";
    composite4.valueName = "fullName";
    let compositeCheckbox = new CheckboxFormControl_1.CheckboxFormControl();
    compositeCheckbox.label = "Is Male";
    compositeCheckbox.valueName = "isMale";
    let numberBox = new NumberFormControl_1.NumberFormControl();
    numberBox.label = "Age";
    numberBox.valueName = "age";
    let compositeCheckList = new CheckboxListFormControl_1.CheckboxListFormControl();
    compositeCheckList.label = "Software Used";
    compositeCheckList.valueName = "softwareUsed";
    compositeCheckList.list = ["Upwork", "Hubstaff", "Google Sites"];
    let selectBox = new SelectFormControl_1.SelectFormControl();
    selectBox.valueName = "selectLabel";
    selectBox.list = ["Pizza", "Cake", "Beer", "Candy"];
    let textbox = new MultiLineTextEditFormControl_1.MultiLineTextEditFormControl();
    textbox.valueName = "personDescription";
    textbox.rowMax = 20;
    textbox.rowMin = 7;
    textbox.placeholderText = "enter description of person";
    let radioButtonGroup = new RadioGroupFormControl_1.RadioGroupFormControl();
    radioButtonGroup.valueName = "tester";
    radioButtonGroup.label = "Happy to be tester";
    radioButtonGroup.list = ["Yes", "No", "Indifferent"];
    let tagGroup = new TagGroupFormControl_1.TagGroupFormControl();
    tagGroup.label = "Categories";
    tagGroup.valueName = "Categories";
    tagGroup.list = ["Upwork", "Hubstaff", "Appglue"];
    let button = new ButtonFormControl_1.ButtonFormControl();
    button.label = "Submit";
    let button2 = new ButtonFormControl_1.ButtonFormControl();
    button.label = "Cancel";
    let link = new LinkFormControl_1.LinkFormControl();
    link.label = "Test Link";
    link.size = FormDesignConstants_1.ButtonControlSize.STANDARD;
    let switchMe = new SwitchFormControl_1.SwitchFormControl();
    switchMe.label = "isAlive";
    switchMe.valueName = "isAlive";
    let datePicker = new DatePickerFormControl_1.DatePickerFormControl();
    datePicker.label = "Birthday";
    datePicker.valueName = "birthday";
    let timePicker = new TimePickerFormControl_1.TimePickerFormControl();
    timePicker.label = "Favorite Time Of Day";
    timePicker.valueName = "favoriteTime";
    let slider = new SliderFormControl_1.SliderFormControl();
    slider.step = 10;
    slider.min = 0;
    slider.max = 100;
    slider.label = "Skill Level";
    slider.valueName = "skillLevel";
    let rating = new RatingFormControl_1.RatingFormControl();
    rating.label = "Please rate";
    rating.valueName = "rating";
    let buttonGroup = new ButtonGroupFormControl_1.ButtonGroupFormControl();
    buttonGroup.label = "Skills";
    buttonGroup.valueName = "skills";
    buttonGroup.list = ["React", "Typescript", "NodeJS"];
    let listEntry = new ListEntryFormControl_1.ListEntryFormControl();
    listEntry.label = "List";
    listEntry.valueName = "list";
    let inlineTextEdit = new InlineTextEditFormControl_1.InlineTextEditFormControl();
    inlineTextEdit.label = "Label";
    inlineTextEdit.valueName = "label";
    let multiInlineTextEdit = new MultiInlineTextEditFormControl_1.MultiInlineTextEditFormControl();
    let valueSlider = new ValueSliderFormControl_1.ValueSliderFormControl();
    let timeline = new TimelineFormControl_1.TimelineFormControl();
    let imageControl = new ImageFormControl_1.ImageFormControl();
    let dataGrid = new DataGridFormControl_1.DataGridFormControl();
    let colContainer = new Containers_1.XColumnContainer();
    colContainer.lineBetweenColumns = false;
    let container1 = new Containers_1.XColumnContainerColumn();
    container1.targetWidth = 20;
    container1.widthUnit = FormDesignConstants_1.WidthUnitInterface.PERCENTAGE;
    colContainer.add(container1);
    [1, 2, 3].map((value) => {
        let composite = new TextFormControl_1.TextFormControl();
        composite.label = "Facts " + value;
        composite.valueName = "otherdata_" + value;
        container1.add(composite);
        return value;
    });
    let container2 = new Containers_1.XColumnContainerColumn();
    container2.targetWidth = 70;
    container2.widthUnit = FormDesignConstants_1.WidthUnitInterface.PERCENTAGE;
    colContainer.add(container2);
    [1, 2, 3].map((value) => {
        let composite = new TextFormControl_1.TextFormControl();
        composite.label = "Other Facts " + value;
        composite.valueName = "otherdata2_" + value;
        container2.add(composite);
        return value;
    });
    let container3 = new Containers_1.XColumnContainerColumn();
    container3.targetWidth = 20;
    container3.overrideFormBorderSettings = DefaultOnOff_1.DefaultOnOff.On;
    container3.showColumnBorder = true;
    container3.widthUnit = FormDesignConstants_1.WidthUnitInterface.PERCENTAGE;
    colContainer.add(container3);
    [1, 2, 3].map((value) => {
        let composite = new TextFormControl_1.TextFormControl();
        composite.label = "More Facts " + value;
        composite.valueName = "otherdata3_" + value;
        container3.add(composite);
        return value;
    });
    let container = new Containers_1.XStackContainer();
    container.add(label);
    container.add(composite2);
    container.add(composite3);
    container.add(composite4);
    container.add(switchMe);
    container.add(numberBox);
    container.add(compositeCheckbox);
    container.add(selectBox);
    container.add(textbox);
    container.add(radioButtonGroup);
    container.add(compositeCheckList);
    container.add(datePicker);
    container.add(timePicker);
    container.add(slider);
    container.add(rating);
    container.add(buttonGroup);
    container.add(listEntry);
    container.add(tagGroup);
    container.add(inlineTextEdit);
    container.add(multiInlineTextEdit);
    container.add(valueSlider);
    container.add(timeline);
    container.add(imageControl);
    container.add(dataGrid);
    let headingContainer = new Containers_1.XStackContainer();
    headingContainer.add(heading);
    let hstack1 = new Containers_1.XHStackContainer();
    hstack1.add(button);
    hstack1.add(button2);
    let hstack2 = new Containers_1.XHStackContainer();
    hstack2.add(link);
    let ui = new FormConfiguration_1.FormConfiguration([headingContainer, container, colContainer, hstack1, hstack2]);
    // todo: come back here
    //ui.setFormData(formData);
    // test code to start the process of writing out a json representation of the form
    let s = JSON.stringify(ui.getStorageData(), null, 2);
    let sasobj = JSON.parse(s);
    let newUI = new FormConfiguration_1.FormConfiguration();
    newUI.setStorageData(sasobj);
    return ui;
}
exports.getFormConfig = getFormConfig;
const getDataDefinitionForRulePage = () => {
    let data = new DataDefinition_1.DataDefinition();
    data.fields.push(new BooleanDataDefinition_1.BooleanDataDefinition("isEmployee"));
    data.fields.push(new NumberDataDefinition_1.NumberDataDefinition("income"));
    data.fields.push(new NumberDataDefinition_1.NumberDataDefinition("divideValue"));
    data.fields.push(new NumberDataDefinition_1.NumberDataDefinition("divideBy"));
    let person = new ObjectDataDefinition_1.ObjectDataDefinition("person");
    person.fields.push(new StringDataDefinition_1.StringDataDefinition("name"));
    data.fields.push(person);
    return data;
};
exports.getDataDefinitionForRulePage = getDataDefinitionForRulePage;
const getFormRules = () => {
    const validationRule = new FormRule_1.FormRule(new ExpressionConfiguration_1.ExpressionConfiguration());
    validationRule.expression = (0, StringData_1.getEqualSimpleRule)();
    validationRule.data = new FormRule_1.FormRuleValidationData("Test Validation Message", "lastName");
    const changeFocusRule = new FormRule_1.FormRule(new ExpressionConfiguration_1.ExpressionConfiguration());
    changeFocusRule.expression = (0, StringData_1.getEqualSimpleRule)();
    changeFocusRule.ruleType = FormRule_1.FormRuleType.CHANGE_FOCUS;
    changeFocusRule.data = new FormRule_1.FormRuleChangeFocusData("age");
    const changeValueRule = new FormRule_1.FormRule(new ExpressionConfiguration_1.ExpressionConfiguration());
    changeValueRule.expression = (0, StringData_1.getEqualSimpleRule)();
    changeValueRule.ruleType = FormRule_1.FormRuleType.CHANGE_VALUE;
    changeValueRule.data = new FormRule_1.FormRuleChangeValueData("personDescription", (0, StringData_1.getCombineSimpleRule)());
    const controlEnabledRule = new FormRule_1.FormRule(new ExpressionConfiguration_1.ExpressionConfiguration());
    controlEnabledRule.expression = (0, StringData_1.getEqualSimpleRule)();
    controlEnabledRule.ruleType = FormRule_1.FormRuleType.CONTROL_ENABLED;
    controlEnabledRule.data = new FormRule_1.FormRuleControlEnabledData("isMale");
    const controlVisibilityRule = new FormRule_1.FormRule(new ExpressionConfiguration_1.ExpressionConfiguration());
    controlVisibilityRule.expression = (0, StringData_1.getEqualSimpleRule)();
    controlVisibilityRule.ruleType = FormRule_1.FormRuleType.CONTROL_VISIBILITY;
    controlVisibilityRule.data = new FormRule_1.FormRuleControlVisibilityData("isMale");
    const exitFormRule = new FormRule_1.FormRule(new ExpressionConfiguration_1.ExpressionConfiguration());
    exitFormRule.expression = (0, StringData_1.getEqualSimpleRule)();
    exitFormRule.ruleType = FormRule_1.FormRuleType.EXIT_FORM;
    exitFormRule.data = new FormRule_1.FormRuleExitFormData("person");
    return [validationRule, changeFocusRule, changeValueRule, controlEnabledRule, controlVisibilityRule, exitFormRule];
};
exports.getFormRules = getFormRules;
//# sourceMappingURL=FormTestData.js.map