-
-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33410 from dimagi/bmb/b5-hqwebapp-views-static
[B5] Migrate license pages to Bootstrap 5 (first real views!)
- Loading branch information
Showing
28 changed files
with
537 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
135 changes: 74 additions & 61 deletions
135
corehq/apps/hqwebapp/static/hqwebapp/js/bootstrap5/hq-bug-report.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,107 +1,120 @@ | ||
hqDefine('hqwebapp/js/bootstrap5/hq-bug-report', [ | ||
"jquery", "jquery-form/dist/jquery.form.min", "hqwebapp/js/bootstrap5/hq.helpers", | ||
], function ($) { | ||
"jquery", | ||
"hqwebapp/js/bootstrap5_loader", | ||
"jquery-form/dist/jquery.form.min", | ||
"hqwebapp/js/bootstrap5/hq.helpers", | ||
], function ($, bootstrap) { | ||
'use strict'; | ||
$(function () { | ||
var $hqwebappBugReportModal = $('#modalReportIssue'), | ||
$hqwebappBugReportForm = $('#hqwebapp-bugReportForm'), | ||
$hqwebappBugReportSubmit = $('#bug-report-submit'), | ||
$hqwebappBugReportCancel = $('#bug-report-cancel'), | ||
$ccFormGroup = $("#bug-report-cc-form-group"), | ||
$emailFormGroup = $("#bug-report-email-form-group"), | ||
$issueSubjectFormGroup = $("#bug-report-subject-form-group"), | ||
isBugReportSubmitting = false; | ||
let self = {}; | ||
|
||
var resetForm = function () { | ||
$hqwebappBugReportForm.find("button[type='submit']").button('reset'); | ||
$hqwebappBugReportForm.resetForm(); | ||
$hqwebappBugReportCancel.enableButton(); | ||
$hqwebappBugReportSubmit.button('reset'); | ||
$ccFormGroup.removeClass('has-error has-feedback'); | ||
$ccFormGroup.find(".label-danger").addClass('hide'); | ||
$emailFormGroup.removeClass('has-error has-feedback'); | ||
$emailFormGroup.find(".label-danger").addClass('hide'); | ||
self.$bugReportModalElement = $('#modalReportIssue'); | ||
self.bugReportModal = new bootstrap.Modal(self.$bugReportModalElement); | ||
self.$hqwebappBugReportForm = $('#hqwebapp-bugReportForm'); | ||
self.$hqwebappBugReportSubmit = $('#bug-report-submit'); | ||
self.$hqwebappBugReportCancel = $('#bug-report-cancel'); | ||
self.$ccFormGroup = $("#bug-report-cc-form-group"); | ||
self.$emailFormGroup = $("#bug-report-email-form-group"); | ||
self.$issueSubjectFormGroup = $("#bug-report-subject-form-group"); | ||
self.isBugReportSubmitting = false; | ||
|
||
self.resetForm = function () { | ||
self.$hqwebappBugReportForm.find("button[type='submit']").changeButtonState('reset'); | ||
self.$hqwebappBugReportForm.resetForm(); | ||
self.$hqwebappBugReportCancel.enableButton(); | ||
self.$hqwebappBugReportSubmit.changeButtonState('reset'); | ||
self.$ccFormGroup.removeClass('has-error has-feedback'); | ||
self.$ccFormGroup.find(".label-danger").addClass('hide'); | ||
self.$emailFormGroup.removeClass('has-error has-feedback'); | ||
self.$emailFormGroup.find(".label-danger").addClass('hide'); | ||
}; | ||
|
||
$hqwebappBugReportModal.on('shown.bs.modal', function () { | ||
self.$bugReportModalElement.on('shown.bs.modal', function () { | ||
$("input#bug-report-subject").focus(); | ||
}); | ||
|
||
$hqwebappBugReportForm.submit(function () { | ||
var isDescriptionEmpty = !$("#bug-report-subject").val() && !$("#bug-report-message").val(); | ||
self.$hqwebappBugReportForm.submit(function (e) { | ||
e.preventDefault(); | ||
|
||
let isDescriptionEmpty = !$("#bug-report-subject").val() && !$("#bug-report-message").val(); | ||
if (isDescriptionEmpty) { | ||
highlightInvalidField($issueSubjectFormGroup); | ||
self.highlightInvalidField(self.$issueSubjectFormGroup); | ||
} | ||
|
||
var emailAddress = $(this).find("input[name='email']").val(); | ||
if (emailAddress && !IsValidEmail(emailAddress)) { | ||
highlightInvalidField($emailFormGroup); | ||
let emailAddress = $(this).find("input[name='email']").val(); | ||
if (emailAddress && !self.isValidEmail(emailAddress)) { | ||
self.highlightInvalidField(self.$emailFormGroup); | ||
return false; | ||
} | ||
|
||
var emailAddresses = $(this).find("input[name='cc']").val(); | ||
let emailAddresses = $(this).find("input[name='cc']").val(); | ||
emailAddresses = emailAddresses.replace(/ /g, "").split(","); | ||
for (var index in emailAddresses) { | ||
var email = emailAddresses[index]; | ||
if (email && !IsValidEmail(email)) { | ||
highlightInvalidField($ccFormGroup); | ||
for (let index in emailAddresses) { | ||
let email = emailAddresses[index]; | ||
if (email && !self.isValidEmail(email)) { | ||
self.highlightInvalidField(self.$ccFormGroup); | ||
return false; | ||
} | ||
} | ||
if (isDescriptionEmpty) { | ||
return false; | ||
} | ||
|
||
if (!isBugReportSubmitting && $hqwebappBugReportSubmit.text() === $hqwebappBugReportSubmit.data("success-text")) { | ||
$hqwebappBugReportModal.modal("hide"); | ||
} else if (!isBugReportSubmitting) { | ||
$hqwebappBugReportCancel.disableButtonNoSpinner(); | ||
$hqwebappBugReportSubmit.button('loading'); | ||
if (!self.isBugReportSubmitting && self.$hqwebappBugReportSubmit.text() === | ||
self.$hqwebappBugReportSubmit.data("success-text")) { | ||
self.bugReportModal.hide(); | ||
} else if (!self.isBugReportSubmitting) { | ||
self.$hqwebappBugReportCancel.disableButtonNoSpinner(); | ||
self.$hqwebappBugReportSubmit.changeButtonState('loading'); | ||
$(this).ajaxSubmit({ | ||
type: "POST", | ||
url: $(this).attr('action'), | ||
beforeSerialize: hqwebappBugReportBeforeSerialize, | ||
beforeSubmit: hqwebappBugReportBeforeSubmit, | ||
success: hqwebappBugReportSucccess, | ||
error: hqwebappBugReportError, | ||
beforeSerialize: self.hqwebappBugReportBeforeSerialize, | ||
beforeSubmit: self.hqwebappBugReportBeforeSubmit, | ||
success: self.hqwebappBugReportSuccess, | ||
error: self.hqwebappBugReportError, | ||
}); | ||
} | ||
return false; | ||
}); | ||
|
||
function IsValidEmail(email) { | ||
var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; | ||
self.isValidEmail = function (email) { | ||
let regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; | ||
return regex.test(email); | ||
} | ||
}; | ||
|
||
function hqwebappBugReportBeforeSerialize($form) { | ||
self.hqwebappBugReportBeforeSerialize = function ($form) { | ||
$form.find("#bug-report-url").val(location.href); | ||
} | ||
}; | ||
|
||
function hqwebappBugReportBeforeSubmit() { | ||
isBugReportSubmitting = true; | ||
} | ||
self.hqwebappBugReportBeforeSubmit = function () { | ||
self.isBugReportSubmitting = true; | ||
}; | ||
|
||
function hqwebappBugReportSucccess() { | ||
isBugReportSubmitting = false; | ||
$hqwebappBugReportForm.find("button[type='submit']").button('success').removeClass('btn-danger').addClass('btn-primary'); | ||
$hqwebappBugReportModal.one('hidden.bs.modal', function () { | ||
resetForm(); | ||
self.hqwebappBugReportSuccess = function () { | ||
self.isBugReportSubmitting = false; | ||
self.$bugReportModalElement.one('hidden.bs.modal', function () { | ||
self.resetForm(); | ||
}); | ||
} | ||
self.$hqwebappBugReportForm.find("button[type='submit']") | ||
.changeButtonState('success') | ||
.removeClass('btn-danger').addClass('btn-primary'); | ||
}; | ||
|
||
function hqwebappBugReportError() { | ||
isBugReportSubmitting = false; | ||
$hqwebappBugReportForm.find("button[type='submit']").button('error').removeClass('btn-primary').addClass('btn-danger'); | ||
$hqwebappBugReportCancel.enableButton(); | ||
} | ||
self.hqwebappBugReportError = function () { | ||
self.isBugReportSubmitting = false; | ||
self.$hqwebappBugReportForm.find("button[type='submit']").changeButtonState('error') | ||
.removeClass('btn-primary').addClass('btn-danger'); | ||
self.$hqwebappBugReportCancel.enableButton(); | ||
}; | ||
|
||
function highlightInvalidField($element) { | ||
self.highlightInvalidField = function ($element) { | ||
$element.addClass('has-error has-feedback'); | ||
$element.find(".label-danger").removeClass('hide'); | ||
$element.find("input").focus(function () { | ||
$element.removeClass("has-error has-feedback"); | ||
$element.find(".label-danger").addClass('hide'); | ||
}); | ||
} | ||
}; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
corehq/apps/hqwebapp/static/hqwebapp/scss/commcarehq/_containers.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
html, body { | ||
height: 100%; | ||
} | ||
|
||
.hq-container { | ||
min-height: 100%; | ||
height: auto !important; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,7 @@ | |
.nav-main-icon { | ||
font-size: 1.7em; | ||
line-height: 0.7em; | ||
color: $gray-light; | ||
} | ||
|
||
.text-hq-nav-header { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
corehq/apps/hqwebapp/static/hqwebapp/scss/commcarehq/_variables.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.