Skip to content

Commit

Permalink
Merge pull request #219 from Badgerati/Issue-209
Browse files Browse the repository at this point in the history
Fix for login submit missing spinner
  • Loading branch information
Badgerati authored Nov 21, 2021
2 parents 6c65927 + 488f3f7 commit 945b3cf
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
20 changes: 17 additions & 3 deletions src/Templates/Public/scripts/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,7 @@ function loadTable(tableId, opts) {
}

data += form.serialize();
url = form.attr('method');
url = form.attr('action');
}

// invoke and load table content
Expand Down Expand Up @@ -1286,7 +1286,7 @@ function loadChart(chartId) {
}

data += form.serialize();
url = form.attr('method');
url = form.attr('action');
}

sendAjaxReq(url, data, chart, true);
Expand Down Expand Up @@ -1461,6 +1461,7 @@ function buildElements(elements) {
}

function bindFormSubmits() {
// general forms
$("form.pode-form").off('submit').on('submit', function(e) {
e.preventDefault();
e.stopPropagation();
Expand All @@ -1470,7 +1471,20 @@ function bindFormSubmits() {

// submit the form
var inputs = serializeInputs(form);
sendAjaxReq(form.attr('method'), inputs.data, form, true, null, inputs.opts);
sendAjaxReq(form.attr('action'), inputs.data, form, true, null, inputs.opts);
});

// login form
$("form.form-signin").off('submit').on('submit', function(e) {
// get the form
var form = $(e.target);

// show the spinner
showSpinner(form);
$('.alert').remove();

// remove validation errors
removeValidationErrors(form);
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/Templates/Views/elements/form.pode
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ $(if (![string]::IsNullOrWhiteSpace($data.Message)) {
"<p class='card-text'>$($data.Message)</p>"
})

<form id="$($data.ID)" name="$($data.Name)" class="pode-form $($data.CssClasses)" style="$($data.CssStyles)" action="POST" method="/components/form/$($data.ID)" pode-object="$($data.ObjectType)">
<form id="$($data.ID)" name="$($data.Name)" class="pode-form $($data.CssClasses)" style="$($data.CssStyles)" method="POST" action="/components/form/$($data.ID)" pode-object="$($data.ObjectType)">
$(Use-PodeWebPartialView -Path 'shared/_load' -Data @{ Content = $data.Content })
<button class="btn btn-inbuilt-theme" type="submit">
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true" style="display: none"></span>
Expand Down
13 changes: 10 additions & 3 deletions src/Templates/Views/login.pode
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,21 @@

if ($data.Flash['auth-error']) {
"<div class='alert alert-danger' role='alert'>
$($data.Flash['auth-error'])
<span class='mdi mdi-alert-circle'></span>
<strong>$($data.Flash['auth-error'])</strong>
</div>"
}

"<button class='btn btn-lg btn-inbuilt-theme btn-block' type='submit'>Sign in</button>"
"<button class='btn btn-lg btn-inbuilt-theme btn-block' type='submit'>
<span class='spinner-border spinner-border-sm' role='status' aria-hidden='true' style='display: none'></span>
Sign in
</button>"
}
else {
"<button class='btn btn-lg btn-inbuilt-theme btn-block' type='submit'>Sign in using OAuth2 ($($data.Auth.Name))</button>"
"<button class='btn btn-lg btn-inbuilt-theme btn-block' type='submit'>
<span class='spinner-border spinner-border-sm' role='status' aria-hidden='true' style='display: none'></span>
Sign in using OAuth2 ($($data.Auth.Name))
</button>"
})

$(if (![string]::IsNullOrWhiteSpace($data.Copyright)) {
Expand Down

0 comments on commit 945b3cf

Please sign in to comment.