diff --git a/js/defaults_dialog.js b/js/defaults_dialog.js index 27c465ef..64009317 100644 --- a/js/defaults_dialog.js +++ b/js/defaults_dialog.js @@ -37,20 +37,48 @@ helper.defaultsDialog = (function (data) { } }; + privateScope.saveWizardStep = function (selectedDefaultPreset, wizardStep) { + //TODO add saving logic + + privateScope.wizard(selectedDefaultPreset, wizardStep + 1); + }; + privateScope.wizard = function (selectedDefaultPreset, wizardStep) { const steps = selectedDefaultPreset.wizardPages; const stepsCount = selectedDefaultPreset.wizardPages.length; const stepName = steps[wizardStep]; - + console.log(steps[wizardStep], wizardStep, stepsCount); - if (wizardStep >= stepsCount) { + if (wizardStep >= stepsCount - 1) { //This is the last step, time to finalize + $container.hide(); privateScope.saveAndReboot(); } else { + const $content = $container.find('.defaults-dialog__wizard'); + $.get("./wizard/" + stepName + ".html", function(data) { + $content.html(data); + }); + $.get("./wizard/buttons.html", function(data) { + $(data).appendTo($content); + }); + + $container.on('click', '#wizard-next', function () { + privateScope.saveWizardStep(selectedDefaultPreset, wizardStep); + }); + + $container.on('click', '#wizard-skip', function () { + privateScope.wizard(selectedDefaultPreset, wizardStep + 1); + }); + + $container.find('.defaults-dialog__content').hide(); + $container.find('.defaults-dialog__wizard').show(); + + savingDefaultsModal.close(); + $container.show(); } @@ -150,6 +178,8 @@ helper.defaultsDialog = (function (data) { }; privateScope.render = function () { + $container.find('.defaults-dialog__content').show(); + $container.find('.defaults-dialog__wizard').hide(); let $place = $container.find('.defaults-dialog__options'); $place.html(""); for (let i in data) { diff --git a/js/defaults_dialog_entries.js b/js/defaults_dialog_entries.js index 9336e27f..78ae7ce4 100644 --- a/js/defaults_dialog_entries.js +++ b/js/defaults_dialog_entries.js @@ -6,7 +6,7 @@ helper.defaultsDialogData = [{ "notRecommended": false, "reboot": true, "mixerToApply": 3, - "wizardPages": ['receiver', 'motors', 'gps', 'filter', 'pid'], + "wizardPages": ['receiver', 'outputs', 'gps', 'filters', 'pids'], "settings": [ { key: "model_preview_type", diff --git a/main.html b/main.html index 71da7b46..8d7689ab 100755 --- a/main.html +++ b/main.html @@ -16,8 +16,12 @@