<commit_before>import QtQuick 2.0
import Sailfish.Silica 1.0

Dialog
{
    id: dialog

    property var fields
    property var content

    SilicaFlickable
    {
        id: flick

        anchors.fill: parent
        contentHeight: col.height + dialogHeader.height
        width: parent.width

        VerticalScrollDecorator { flickable: flick }

        DialogHeader
        {
            id: dialogHeader
            acceptText: "Create"
            cancelText: "Back"
        }

        Column
        {
            id: col
            spacing: Theme.paddingSmall
            anchors.top: dialogHeader.bottom
            width: parent.width

            Component.onCompleted:
            {
                for (var i=0 ; i<fields.length ; i++)
                {
                    /* User selector */
                    if (fields[i].schema.type === "user")
                    {
                        var component = Qt.createComponent(Qt.resolvedUrl("../fields/UserField.qml"))
                        if (component.status == Component.Ready)
                            component.createObject(col, { fieldnumber: i } )
                        log("userfield \"" + fields[i].name + "\"", i)
                    }

                    /* Free text field */
                    else if (fields[i].schema.type === "string" && fields[i].allowedValues == undefined)
                    {
                        var component = Qt.createComponent(Qt.resolvedUrl("../fields/TextEditField.qml"))
                        if (component.status == Component.Ready)
                            component.createObject(col, { fieldnumber: i } )
                        log("texteditfield \"" + fields[i].name + "\"", i)
                    }

                    /* Item selector with predefined values */
                    else if (fields[i].allowedValues != undefined && !(fields[i].schema.custom != undefined && fields[i].schema.custom.split(":")[1] == "cascadingselect"))
                    {
                        var obj = "name"
                        if (fields[i].allowedValues[0].value != undefined)
                            obj = "value"

                        var component = Qt.createComponent(Qt.resolvedUrl(fields[i].schema.type == "array" ? "../fields/MultiSelectField.qml"
                                                                                                           : "../fields/SingleSelectField.qml"))
                        if (component.status == Component.Ready)
                            component.createObject(col, { fieldnumber: i, obj: obj } )
                        log(((fields[i].schema.type == "array") ? "multiselectfield" : "singelselectfield") +  " \"" + fields[i].name + "\"", i)
                    }

                    /* cascading field selector */
                    else if (fields[i].allowedValues != undefined && fields[i].schema.custom != undefined && fields[i].schema.custom.split(":")[1] == "cascadingselect")
                    {
                        var obj = "name"
                        if (fields[i].allowedValues[0].value != undefined)
                            obj = "value"

                        var component = Qt.createComponent(Qt.resolvedUrl("../fields/CascadeSelectField.qml"))
                        if (component.status == Component.Ready)
                            component.createObject(col, { fieldnumber: i, obj: obj } )
                        log("cascadeselectfield \"" + fields[i].name + "\"", i)
                    }

                    /* date picker */
                    else if (fields[i].schema.type == "date")
                    {
                        var component = Qt.createComponent(Qt.resolvedUrl("../fields/DateSelectField.qml"))
                        if (component.status == Component.Ready)
                            component.createObject(col, { fieldnumber: i} )
                        log("dateselectfield \"" + fields[i].name + "\"", i)
                    }

                    else
                    {
                        log("field not implemented \"" + fields[i].name + "\"", i)
                    }
                }
            }
        }
    }
}<commit_msg>delete unsupported fields from content<commit_after>import QtQuick 2.0
import Sailfish.Silica 1.0

Dialog
{
    id: dialog

    property var fields
    property var content

    SilicaFlickable
    {
        id: flick

        anchors.fill: parent
        contentHeight: col.height + dialogHeader.height
        width: parent.width

        VerticalScrollDecorator { flickable: flick }

        DialogHeader
        {
            id: dialogHeader
            acceptText: "Create"
            cancelText: "Back"
        }

        Column
        {
            id: col
            spacing: Theme.paddingSmall
            anchors.top: dialogHeader.bottom
            width: parent.width

            Component.onCompleted:
            {
                for (var i=0 ; i<fields.length ; i++)
                {
                    /* User selector */
                    if (fields[i].schema.type === "user")
                    {
                        var component = Qt.createComponent(Qt.resolvedUrl("../fields/UserField.qml"))
                        if (component.status == Component.Ready)
                            component.createObject(col, { fieldnumber: i } )
                        log("userfield \"" + fields[i].name + "\"", i)
                    }

                    /* Free text field */
                    else if (fields[i].schema.type === "string" && fields[i].allowedValues == undefined)
                    {
                        var component = Qt.createComponent(Qt.resolvedUrl("../fields/TextEditField.qml"))
                        if (component.status == Component.Ready)
                            component.createObject(col, { fieldnumber: i } )
                        log("texteditfield \"" + fields[i].name + "\"", i)
                    }

                    /* Item selector with predefined values */
                    else if (fields[i].allowedValues != undefined && !(fields[i].schema.custom != undefined && fields[i].schema.custom.split(":")[1] == "cascadingselect"))
                    {
                        var obj = "name"
                        if (fields[i].allowedValues[0].value != undefined)
                            obj = "value"

                        var component = Qt.createComponent(Qt.resolvedUrl(fields[i].schema.type == "array" ? "../fields/MultiSelectField.qml"
                                                                                                           : "../fields/SingleSelectField.qml"))
                        if (component.status == Component.Ready)
                            component.createObject(col, { fieldnumber: i, obj: obj } )
                        log(((fields[i].schema.type == "array") ? "multiselectfield" : "singelselectfield") +  " \"" + fields[i].name + "\"", i)
                    }

                    /* cascading field selector */
                    else if (fields[i].allowedValues != undefined && fields[i].schema.custom != undefined && fields[i].schema.custom.split(":")[1] == "cascadingselect")
                    {
                        var obj = "name"
                        if (fields[i].allowedValues[0].value != undefined)
                            obj = "value"

                        var component = Qt.createComponent(Qt.resolvedUrl("../fields/CascadeSelectField.qml"))
                        if (component.status == Component.Ready)
                            component.createObject(col, { fieldnumber: i, obj: obj } )
                        log("cascadeselectfield \"" + fields[i].name + "\"", i)
                    }

                    /* date picker */
                    else if (fields[i].schema.type == "date")
                    {
                        var component = Qt.createComponent(Qt.resolvedUrl("../fields/DateSelectField.qml"))
                        if (component.status == Component.Ready)
                            component.createObject(col, { fieldnumber: i} )
                        log("dateselectfield \"" + fields[i].name + "\"", i)
                    }

                    else
                    {
                        log("field not implemented \"" + fields[i].name + "\"", i)
                        if (content.fields[fields[i].schema.system] != undefined)
                            delete content.fields[fields[i].schema.system]
                    }
                }
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.11817970745298352, 'fraction_numerical': 0.0020896215463199444, 'mean_word_length': 1.1564455569461827, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4512998', 'n_tokens_mistral': 2094, 'n_tokens_neox': 1962, 'n_words': 381}