Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Production < Staging #722

Merged
merged 70 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
7d23831
JS: Re-do form for uploading support letters
Lubosky Jul 15, 2024
555e442
Make JS form work when re-submitting
Lubosky Jul 16, 2024
84eb8ad
Support letter upload via non-JS form
Lubosky Jul 16, 2024
061b89c
Make the non-JS form more seamless without additional buttons
Lubosky Jul 16, 2024
8cbf172
Update copy for non-JS version
Lubosky Jul 17, 2024
52a41bd
Add support letter checkboxes into the form
Lubosky Jul 17, 2024
a4ffb9c
Update `FormAnswer` factory
Lubosky Jul 17, 2024
1683445
No need for a function
Lubosky Jul 18, 2024
d8e36ee
Merge pull request #697 from bitzesty/letter-of-support-upload-form
Lubosky Jul 18, 2024
035925a
Build support letters if none are present in non-JS version
Lubosky Jul 18, 2024
7f2ead1
Merge pull request #698 from bitzesty/letter-of-support-upload-form
Lubosky Jul 18, 2024
1860e02
Disables ckeditor version warning
TheDancingClown Jul 19, 2024
f8abbc3
Merge pull request #699 from bitzesty/ckeditor-warning
TheDancingClown Jul 19, 2024
60bc94a
Formatting for support letters pdf section
TheDancingClown Jul 24, 2024
8c90e8b
Merge pull request #700 from bitzesty/pdf-support
TheDancingClown Jul 25, 2024
1a96c2c
Merge pull request #701 from bitzesty/main
TheDancingClown Jul 25, 2024
a92c240
Copy changes to the process guide page
TheDancingClown Aug 6, 2024
bbe60e5
Copy updates to eligibity
TheDancingClown Aug 6, 2024
9817331
Add bold to useful information
TheDancingClown Aug 6, 2024
8d2c741
Copy changes to step A of application
TheDancingClown Aug 6, 2024
5b1d483
Copy changes to D section
TheDancingClown Aug 6, 2024
c42f083
Copy changes to useful information page
TheDancingClown Aug 6, 2024
c3e7ea3
Update dates on what happens next
TheDancingClown Aug 6, 2024
02686c4
Merge pull request #702 from bitzesty/form-changes
TheDancingClown Aug 6, 2024
93db06a
chore: Update form hint for nominee name field
TheDancingClown Aug 7, 2024
cba033d
chore: Update form hint for nominee name field
TheDancingClown Aug 7, 2024
989f326
Merge pull request #703 from bitzesty/form-qa
TheDancingClown Aug 7, 2024
bdd14f9
fix: Add new line above list for formatting on PDF form
TheDancingClown Aug 7, 2024
a75411d
fix: Update PDF renderer to include form_hint
TheDancingClown Aug 7, 2024
5c6d3ee
Merge pull request #704 from bitzesty/form-qa-2
TheDancingClown Aug 7, 2024
d5b3fd2
Merge pull request #705 from bitzesty/main
TheDancingClown Aug 7, 2024
2d7e690
chore: Add new fields to Reports::Nomination model and Reports::Nomin…
TheDancingClown Aug 7, 2024
1d19517
chore: Refactor Reports::QavsBase#sanitize_string to use string.strip…
TheDancingClown Aug 8, 2024
3f9d314
Merge pull request #706 from bitzesty/nomination-csv
dreamfall Aug 9, 2024
b0fb9cd
chore: Remove unnecessary punctuation in QAE form instructions
TheDancingClown Aug 15, 2024
03a32cd
chore: Update Reports::QavsBase#sanitize_string to replace non-breaki…
TheDancingClown Aug 15, 2024
123745a
Merge pull request #707 from bitzesty/form-client-feedback
TheDancingClown Aug 15, 2024
484b968
Merge pull request #708 from bitzesty/non-breaking-space
TheDancingClown Aug 15, 2024
c6439b3
Merge pull request #710 from bitzesty/main
TheDancingClown Aug 19, 2024
23a5aaa
Enable `pgcrypto` PSQL extension
Lubosky Aug 21, 2024
29f2896
Add `ProtectedFile` model w/ migrations
Lubosky Aug 21, 2024
3c753c2
Add `NominationStatsSearch` service to get grouped data for report
Lubosky Aug 21, 2024
d7b5a60
Views & policies for nomination statistics
Lubosky Aug 21, 2024
316aa5c
Add mailer to send requested CSV file
Lubosky Aug 21, 2024
21328d0
Merge pull request #711 from bitzesty/nomination-statistics-report
TheDancingClown Aug 22, 2024
410a097
Modify support letter fields so each upload section is a new question
DaniBitZesty Aug 22, 2024
e4377e2
Extract question ref code into partial so it only has to be mofified …
DaniBitZesty Aug 22, 2024
829f49c
Adjust centering & styling on statistics page
Lubosky Aug 22, 2024
ae51742
Switch to text layout for email sent to user
Lubosky Aug 22, 2024
6ff3e11
Update non-js views with new format for Letters of Support
DaniBitZesty Aug 22, 2024
1c4c572
Update how index is written
DaniBitZesty Aug 22, 2024
00e75c8
Use `LEFT JOIN` to get also not assigned lieutenancies
Lubosky Aug 22, 2024
dff782e
Merge pull request #712 from bitzesty/nomination-statistics-report-qa
TheDancingClown Aug 23, 2024
13651e3
chore: Update email layout and styling for nomination statistics report
TheDancingClown Aug 27, 2024
10810b4
chore: Use existing code for lieutenancy filter
TheDancingClown Aug 28, 2024
b153dcf
Non-js destroy action for support letter attachments
DaniBitZesty Aug 23, 2024
3c77bbe
JS remove support letter attachment feature
DaniBitZesty Aug 27, 2024
fab91b2
Merge pull request #713 from bitzesty/letters-of-support
DaniBitZesty Aug 28, 2024
90270c9
Fix validation on Letters of Support subquestions
DaniBitZesty Aug 28, 2024
ea2df1c
Merge pull request #715 from bitzesty/letters-of-support
DaniBitZesty Aug 28, 2024
bb762e9
Merge pull request #714 from bitzesty/statistics-table
TheDancingClown Aug 28, 2024
e30117c
- Remove validation for old letters of support question. This checks …
DaniBitZesty Aug 28, 2024
a263acf
Merge pull request #716 from bitzesty/letters-of-support
macool Aug 28, 2024
9bb0e70
- Show status of attachment when first uploaded.
DaniBitZesty Aug 29, 2024
f06a4a6
Remove random square bracket in icon link - causing deployment errors
DaniBitZesty Aug 29, 2024
9859107
Merge pull request #717 from bitzesty/letters-of-support
DaniBitZesty Aug 29, 2024
857d461
Merge pull request #718 from bitzesty/main
DaniBitZesty Aug 29, 2024
bfe6577
Update copy
DaniBitZesty Aug 29, 2024
ef573aa
Merge pull request #720 from bitzesty/update-copy
DaniBitZesty Aug 29, 2024
7fa4bcd
Merge pull request #721 from bitzesty/main
TheDancingClown Aug 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,7 @@ PLATFORMS
arm64-darwin-21
arm64-darwin-23
x86_64-darwin-22
x86_64-darwin-23
x86_64-linux

DEPENDENCIES
Expand Down
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,7 @@ jQuery ->
height: 200
wordcount:
maxWordCount: $(this).data('word-max')
versionCheck: false

CKEDITOR.on 'instanceCreated', (event) ->
editor = event.editor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,48 @@ window.SupportLetters =
init: ->
$('.js-support-letter-attachment').each (idx, el) ->
SupportLetters.fileupload_init(el)
SupportLetters.save_collection_init()

$(document).on 'change', '.js-trigger-autosave', debounce(SupportLetters.submit, 1000)

$(document).on 'click', '.js-remove-support-letter-attachment', (e) ->
e.preventDefault()
SupportLetters.removeFile($(this).closest('.govuk-form-group').find('input:first'), e)

new_item_init: (el) ->
SupportLetters.clean_up_system_tags(el)
SupportLetters.enable_item_fields_and_controls(el)
SupportLetters.fileupload_init(el.find(".js-support-letter-attachment"))
SupportLetters.fileupload_init(el.find('.js-support-letter-attachment'))
el.find('input,textarea,select').first().focus()

fileupload_init: (el) ->
$el = $(el)
parent = $el.closest(".govuk-form-group")
parent = $el.closest('.govuk-form-group')

upload_done = (e, data) ->
SupportLetters.clean_up_system_tags(parent)

if data.result['original_filename']
filename = data.result['original_filename']
else
filename = "File uploaded"
file_title = $("<p class='govuk-body support-letter-attachment-filename'>" + filename + "</p>")
hidden_input = $("<input class='js-support-letter-attachment-id' type='hidden' name='#{$el.attr("name")}' value='#{data.result['id']}' />")

parent.find(".govuk-error-message").html("")
parent.find(".govuk-error-message").closest(".govuk-form-group").removeClass("govuk-form-group--error")
parent.append(file_title)
parent.append(hidden_input)
filename = 'File uploaded'

parent.find('.govuk-error-message').html('')
parent.find('.govuk-error-message').closest('.govuk-form-group').removeClass('govuk-form-group--error')

textContainer = parent.find('.support-letter-attachment-container')
textContainer.removeClass('govuk-!-display-none')
scanningText = '<p class="govuk-hint">(File uploaded and is being scanned for viruses. Preview available once the scan is complete. You may need to refresh this page.)</p>'
textContainer.prepend('<div class="support-letter-attachment-filename"><p class="govuk-body">' + filename + '</p>' + scanningText + '</div>')
hiddenInput = $("<input class='js-support-letter-attachment-id' type='hidden' name='#{$el.attr("name")}' value='#{data.result['id']}' />")
parent.append(hiddenInput)
parent.find('.js-support-letter-attachment').addClass('govuk-!-display-none')
SupportLetters.autosave()
SupportLetters.submit(e)

failed = (error_message) ->
SupportLetters.clean_up_system_tags(parent)
parent.find(".govuk-error-message").html(error_message)
parent.closest(".govuk-form-group").addClass("govuk-form-group--error")
parent.find('.govuk-error-message').html(error_message)
parent.closest('.govuk-form-group').addClass('govuk-form-group--error')

success_or_error = (e, data) ->
errors = data.result.errors
Expand All @@ -44,108 +54,39 @@ window.SupportLetters =
upload_done(e, data)

$el.fileupload(
url: $el.closest(".list-add").data('attachments-url') + ".json"
url: $el.closest('.list-add').data('attachments-url') + '.json'
forceIframeTransport: true
dataType: 'json'
formData: [
{ name: "authenticity_token", value: $("meta[name='csrf-token']").attr("content") }
{ name: 'authenticity_token', value: $('meta[name="csrf-token"]').attr('content') }
]
always: success_or_error
)

clean_up_system_tags: (parent) ->
parent.find("input[type='hidden']").remove()
parent.find(".support-letter-attachment-filename").remove()
parent.find('input[type="hidden"]').remove()
parent.find('.support-letter-attachment-filename').remove()

removeFile: (el, e) ->
$el = $(el)
$el.val('')
$el.siblings('.js-support-letter-attachment-id').first().val('')
$el.siblings('.support-letter-attachment-container').addClass('govuk-!-display-none')
$el.removeClass('govuk-!-display-none')
SupportLetters.autosave()
SupportLetters.submit(e)

enable_item_fields_and_controls: (parent) ->
parent.find(".js-save-collection").removeClass("govuk-!-display-none")
parent.find(".visible-read-only").hide()
fields = parent.find("input")
fields.removeClass("read-only")
parent.find(".govuk-error-message").html("")
form_name_prefix = parent.find(".js-system-tag").data("new-hidden-input-name")
letter_id_hidden_input = $("<input class='js-support-entry-id'>").prop('type', 'hidden').
prop('name', form_name_prefix)
parent.append(letter_id_hidden_input)

disable_item_fields_and_controls: (parent) ->
parent.find(".js-save-collection").addClass("govuk-!-display-none")
parent.find(".visible-read-only").show()
fields = parent.find("input")
fields.addClass("read-only")

save_collection_init: () ->
$(document).on 'click', '.js-save-collection', (e) ->
e.preventDefault()
e.stopPropagation()

button = $(this)
parent = $(this).closest("li")

if !button.hasClass("govuk-!-display-none")
save_url = button.data 'save-collection-url'

first_name = parent.find(".js-support-letter-first-name").val()
last_name = parent.find(".js-support-letter-last-name").val()
email = parent.find(".js-support-letter-email").val()
relationship_to_nominee = parent.find(".js-support-letter-relationship-to-nominee").val()
attachment_id = parent.find(".js-support-letter-attachment-id").val()

data = {
"support_letter": {
"first_name": first_name,
"last_name": last_name,
"relationship_to_nominee": relationship_to_nominee
}
}

if attachment_id
data["support_letter"]["attachment"] = attachment_id

if email
data["support_letter"]["email"] = email

if save_url
$.ajax
url: save_url
type: 'post'
data: data
dataType: 'json'
success: (response) ->
parent.find(".js-support-entry-id").prop('value', response)
parent.find(".govuk-error-message").html("")
parent.removeClass("govuk-form-group--error")
parent.addClass("read-only")
parent.addClass("js-support-letter-received")
parent.closest('li').find("input[type='text']").each ->
show_el = $(this).closest(".govuk-form-group").find(".visible-read-only")
show_el.text($(this).val())
SupportLetters.disable_item_fields_and_controls(parent)
window.FormValidation.validateStep()
SupportLetters.autosave()
SupportLetters.showRemoveLink(parent, data, response)

return
error: (response) ->
parent.find(".govuk-error-message").html("")
parent.removeClass("govuk-form-group--error")
error_message = response.responseText
$.each $.parseJSON(response.responseText), (question_key, error_message) ->
key_selector = ".js-support-letter-" + question_key.replace(/_/g, "-")
field_error_container = parent.find(key_selector).
closest(".govuk-form-group").
find(".govuk-error-message")
field_error_container.html(error_message[0])
field_error_container.closest(".govuk-form-group").addClass("govuk-form-group--error")
button.removeClass("govuk-visually-hidden")

return
parent.find('.govuk-error-message').html('')
prefixed = parent.find('.js-system-tag').data('new-hidden-input-name')
hiddenInput = $('<input class="js-support-entry-id">').prop('type', 'hidden').prop('name', prefixed)
parent.append(hiddenInput)

autosave: () ->
url = $('form.qae-form').data('autosave-url')
if url
# Setting current_step_id to form as we updating only current section form_data (not whole form)
$("#current_step_id").val($(".js-step-condition.step-current").attr("data-step"))
$('#current_step_id').val($('.js-step-condition.step-current').attr('data-step'))

form_data = $('form.qae-form').serialize()
$.ajax({
Expand All @@ -155,8 +96,71 @@ window.SupportLetters =
dataType: 'json'
})

showRemoveLink: (parent, data, response) ->
removeLink = $(".remove-supporter", parent)
removeLink.data("url", "/users/form_answers/#{response['form_answer_id']}/support_letters/#{response['id']}")
removeLink.attr("aria-label", "Delete support letter from #{data['support_letter']['first_name']} #{data['support_letter']['last_name']}")
removeLink.removeClass("govuk-!-display-none")
submit: (e) ->
e.preventDefault()
e.stopPropagation()

target = $(e.target)
parent = target.closest("li")

data = {'support_letter': {}}
data['support_letter']['first_name'] = parent.find('.js-support-letter-first-name').val()
data['support_letter']['last_name'] = parent.find('.js-support-letter-last-name').val()
data['support_letter']['relationship_to_nominee'] = parent.find('.js-support-letter-relationship-to-nominee').val()

attachmentId = parent.find('.js-support-letter-attachment-id').val()
if attachmentId
data['support_letter']['attachment'] = attachmentId

email = parent.find('.js-support-letter-email').val()
if email
data['support_letter']['email'] = email

createUrl = parent.data('create-url')
updateUrl = parent.data('update-url')
persistUrl = updateUrl || createUrl

type = if !!updateUrl
'put'
else
'post'

if persistUrl
$.ajax
url: persistUrl
type: type
data: data
dataType: 'json'
success: (response) ->
parent.find('.js-support-entry-id').prop('value', response['id'])
parent.find('.govuk-error-message').html('')
parent.removeClass('govuk-form-group--error')
parent.addClass('js-support-letter-received')
parent.attr('data-update-url', response['update_url'])
window.FormValidation.validateStep()
SupportLetters.autosave()

return
error: (response) ->
parent.find('.govuk-error-message').html('')
parent.removeClass('govuk-form-group--error')
msg = response.responseText
$.each $.parseJSON(response.responseText), (key, msg) ->
selector = '.js-support-letter-' + key.replace(/_/g, '-')

errorContainer = parent.find(selector).closest('.govuk-form-group').find('.govuk-error-message')
errorContainer.html(msg[0])
errorContainer.closest('.govuk-form-group').addClass('govuk-form-group--error')

return

debounce = (fn, wait = 500) ->
last = (new Date) - wait
->
now = new Date

# Return if we haven't waited long enough
return if wait > (now - last)

fn.apply null, arguments
last = now
21 changes: 7 additions & 14 deletions app/assets/javascripts/frontend/form-validation.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ window.FormValidation =
clearErrors: (container) ->
if container.closest(".question-financial").length > 0
container.closest("label").find(".govuk-error-message").empty()
else if container.closest('.question-block').data('answer').indexOf('address') > -1
else if container.closest('.question-block').data('answer') && container.closest('.question-block').data('answer').indexOf('address') > -1
container.closest(".govuk-form-group").find(".govuk-error-message").empty()
else
container.closest(".question-block").find(".govuk-error-message").empty()
Expand Down Expand Up @@ -56,6 +56,9 @@ window.FormValidation =
isCheckboxQuestion: (question) ->
question.find("input[type='checkbox']").length

isSupportLetterAttachment: (question) ->
question.find(".js-support-letter-attachment").length

toDate: (str) ->
moment(str, "DD/MM/YYYY")

Expand All @@ -81,6 +84,9 @@ window.FormValidation =
if @isCheckboxQuestion(question)
return question.find("input[type='checkbox']").filter(":checked").length

if @isSupportLetterAttachment(question)
return (question.find(".js-support-letter-attachment-id").val() || '').toString().trim().length

validateRequiredQuestion: (question) ->
# if it's a conditional question, but condition was not satisfied
conditional = true
Expand Down Expand Up @@ -352,13 +358,6 @@ window.FormValidation =
@addErrorMessage(question, errorMessage)
return

validateSupportLetters: (question) ->
lettersReceived = $(".js-support-letter-received").length
if lettersReceived < 2
@logThis(question, "validateSupportLetters", "Upload two letters of support")
@appendMessage(question, "Upload two letters of support")
@addErrorClass(question)

validateSelectionLimit: (question) ->
selection_limit = question.data("selection-limit")
current_selection_count = question.find("input[type=checkbox]:checked").length
Expand Down Expand Up @@ -455,11 +454,6 @@ window.FormValidation =
# console.log "validateDropBlockCondition"
@validateDropBlockCondition(question)

if question.hasClass("question-support-requests") ||
question.hasClass("question-support-uploads")
# console.log "validateSupportLetters"
@validateSupportLetters(question)

if question.hasClass("question-limited-selections")
@validateSelectionLimit(question)

Expand Down Expand Up @@ -489,7 +483,6 @@ window.FormValidation =
stepContainer.find(".govuk-form-group--error").removeClass("govuk-form-group--error")
stepContainer.find(".govuk-error-message").empty()
$(".steps-progress-bar .js-step-link[data-step='" + currentStep + "']").removeClass("step-errors")

for question in stepContainer.find(".question-block")
question = $(question)
@validateIndividualQuestion(question)
41 changes: 41 additions & 0 deletions app/assets/stylesheets/admin/tables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,44 @@
[role="region"][aria-labelledby][tabindex]:focus {
outline: .1em solid rgba(0,0,0,.1);
}

.kavs-table {
border-top: 1px solid #b1b4b6;
border-bottom: 1px solid #b1b4b6;
width: max-content;

.text-center {
text-align: center;
}

thead {
background-color: #f2f2f2;

.govuk-table__header:last-child,
.govuk-table__cell:last-child,
.govuk-table__footer:last-child {
padding-right: 10px;
}
}

tfoot {
&.govuk-table__footer {
background-color: #f2f2f2;
font-weight: 700;
text-align: left;
}
}
}

.kavs-table__header--dense,
.kavs-table__cell--dense,
.kavs-table__footer--dense {
font-size: 1rem;
padding: 10px
}

.kavs-table__header--border-right,
.kavs-table__cell--border-right,
.kavs-table__footer--border-right {
border-right: 1px solid #b1b4b6;
}
Loading
Loading