From ecadb07367d31c0929212618e120130f54af78da Mon Sep 17 00:00:00 2001 From: Justin Choquette Date: Tue, 8 Aug 2023 11:33:57 -0400 Subject: MVP Change-Id: Ib590302f49e7e66f8d04841fb6cb97baf623f51a Signed-off-by: Justin Choquette --- src/static/js/workflows/workflow.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/static/js/workflows/workflow.js') diff --git a/src/static/js/workflows/workflow.js b/src/static/js/workflows/workflow.js index f3f39e9..97bf8f4 100644 --- a/src/static/js/workflows/workflow.js +++ b/src/static/js/workflows/workflow.js @@ -29,7 +29,6 @@ class LibLaaSAPI { /** POSTs to dashboard, which then auths and logs the requests, makes the request to LibLaaS, and passes the result back to here. Treat this as a private function. Only use the async functions when outside of this class */ static makeRequest(method, endpoint, workflow_data) { - console.log("Making request: %s, %s, %s", method, endpoint, workflow_data.toString()) const token = document.getElementsByName('csrfmiddlewaretoken')[0].value return new Promise((resolve, reject) => {// -> HttpResponse $.ajax( @@ -130,7 +129,6 @@ class LibLaaSAPI { static async makeTemplate(templateBlob) { // -> UUID or null templateBlob.owner = user; - console.log(JSON.stringify(templateBlob)) return await this.handleResponse(this.makeRequest(HTTP.POST, endpoint.MAKE_TEMPLATE, templateBlob)); } @@ -230,12 +228,13 @@ class Workflow { } goTo(step_number) { - while (step_number > this.step) { - this.goNext(); - } - - while (step_number < this.step) { - this.goPrev(); + if (step_number < 0) return; + this.step = step_number + document.getElementById(this.sections[this.step]).scrollIntoView({behavior: 'smooth'}); + if (this.step == this.sections.length - 1) { + document.getElementById('next').setAttribute('disabled', ''); + } else if (this.step == 1) { + document.getElementById('prev').removeAttribute('disabled'); } } @@ -245,9 +244,11 @@ function apiError(info) { showError("Unable to fetch " + info +". Please try again later or contact support.") } -function showError(message) { +// global variable needed for a scrollintoview bug affecting chrome +let alert_destination = -1; +function showError(message, destination) { + alert_destination = destination; const text = document.getElementById('alert_modal_message'); - text.innerText = message; $("#alert_modal").modal('show'); } -- cgit 1.2.3-korg