index.html 9.39 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
<!DOCTYPE html>

<head>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdn.form.io/formiojs/formio.full.min.css">
    <script src="./../node_modules/formiojs/dist/formio.form.js"></script>
    <script src="./../dist/main.js"></script>
</head>

<body>
    <button onclick="printVariables()">Print variables in console</button>
    <button
        onclick="Formio.Providers.providers.storage.gestionePraticheStorageProvider.prototype.deleteFile()">DELETE</button>
    <div id="formio">
        <script>
            let form = null;

            document.addEventListener("DOMContentLoaded", function (event) {
                // Extending FormIO
                const extender = new FormioExtender();

                extender.applyGlobalExtensions({
                    generalSettings: {
                        baseBackendUrl: 'https://api-gateway.comune.salerno.it/gestionepratiche/v1/api'
                    },
                    storageProvider: {
                        backendUrl: 'http://localhost:8080/gestionepratiche/api/public/proceduremanager/file/',
                        authenticationMethod: 'localStorageAuthentication'
                    }
                });

                const populatedForm = {
                        "components": [
                            {
                                "label": "Regione",
                                "isProcessVariable": false,
                                "variableName": "regione",
                                "widget": "choicesjs",
                                "tableView": true,
                                "selectLookup": 5,
                                "dataSrc": "url",
                                "defaultValue": {
                                    "label": "Puglia",
                                    "value": "Puglia",
                                    "tags": []
                                },
                                "data": {
                                    "values": [
                                        {
                                            "label": "",
                                            "value": ""
                                        }
                                    ],
                                    "url": "https://api-gateway.comune.salerno.it/gestionepratiche/v1/api/lookupexternal",
                                    "headers": [
                                        {
                                            "key": "",
                                            "value": ""
                                        }
                                    ]
                                },
                                "selectThreshold": 0.3,
                                "key": "select_region",
                                "type": "selectlookup",
                                "indexeddb": {
                                    "filter": {}
                                },
                                "input": true,
                                "disableLimit": false
                            },

                            {
                                "label": "Provincia",
                                "isProcessVariable": false,
                                "variableName": "provincia",
                                "widget": "choicesjs",
                                "tableView": true,
                                "selectLookup": 6,
                                "dependsOnLookupComponents": "select_region",
                                "dependsOnLookupTags": "Regione",
                                "dataSrc": "url",
                                "defaultValue": {
                                    "label": "Bari",
                                    "value": "Bari",
                                    "tags": []
                                },
                                "data": {
                                    "values": [
                                        {
                                            "label": "",
                                            "value": ""
                                        }
                                    ],
                                    "url": "https://api-gateway.comune.salerno.it/gestionepratiche/v1/api/lookupexternal",
                                    "headers": [
                                        {
                                            "key": "",
                                            "value": ""
                                        }
                                    ]
                                },
                                "selectThreshold": 0.3,
                                "key": "select_province",
                                "type": "selectlookup",
                                "indexeddb": {
                                    "filter": {}
                                },
                                "input": true,
                                "disableLimit": false
                            },

                            {
                                "label": "Comune",
                                "isProcessVariable": false,
                                "variableName": "comune",
                                "widget": "choicesjs",
                                "tableView": true,
                                "selectLookup": 3,
                                "dependsOnLookupComponents": "select_province",
                                "dependsOnLookupTags": "provincia",
                                "dataSrc": "url",
                                "defaultValue": {
                                    "label": "Monopoli",
                                    "value": "Monopoli",
                                    "tags": []
                                },
                                "data": {
                                    "values": [
                                        {
                                            "label": "",
                                            "value": ""
                                        }
                                    ],
                                    "url": "https://api-gateway.comune.salerno.it/gestionepratiche/v1/api/lookupexternal",
                                    "headers": [
                                        {
                                            "key": "",
                                            "value": ""
                                        }
                                    ]
                                },
                                "selectThreshold": 0.3,
                                "key": "select_city",
                                "type": "selectlookup",
                                "indexeddb": {
                                    "filter": {}
                                },
                                "input": true,
                                "disableLimit": false
                            },

                            {
                                "label": "Comune NON DIPENDENTE",
                                "isProcessVariable": false,
                                "variableName": "comune_non_dipendente",
                                "widget": "choicesjs",
                                "tableView": true,
                                "selectLookup": 3,
                                "dependsOnLookupComponents": null,
                                "dependsOnLookupTags": null,
                                "dataSrc": "url",
                                "defaultValue": null,
                                "data": {
                                    "values": [
                                        {
                                            "label": "",
                                            "value": ""
                                        }
                                    ],
                                    "url": "https://api-gateway.comune.salerno.it/gestionepratiche/v1/api/lookupexternal",
                                    "headers": [
                                        {
                                            "key": "",
                                            "value": ""
                                        }
                                    ]
                                },
                                "selectThreshold": 0.3,
                                "key": "select_non_dependent_city",
                                "type": "selectlookup",
                                "indexeddb": {
                                    "filter": {}
                                },
                                "input": true,
                                "disableLimit": false
                            }
                        ]
                    };

                extender.createExtendedForm(
                    document.getElementById('formio'),
                    populatedForm,
                    false
                ).then(function (f) {
                    form = f;
                });
            });

            function printVariables() {
                console.log(JSON.stringify(form.getVariables(), null, 2))
            }
        </script>
</body>