-
Notifications
You must be signed in to change notification settings - Fork 2
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 #207 from Ches-ctrl/2024-07-01/bug_fixes
Application Bug Fixes & Code Cleanup
- Loading branch information
Showing
44 changed files
with
404 additions
and
637 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,5 +62,4 @@ doc/** | |
# Ignore DB backup | ||
latest.dump | ||
|
||
/app/assets/builds/* | ||
!/app/assets/builds/.keep | ||
/app/assets/builds/* |
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
class AttachmentsController < ApplicationController | ||
def destroy | ||
load_attachment | ||
destroy_attachment | ||
end | ||
|
||
private | ||
|
||
def destroy_attachment | ||
if @attachment.present? | ||
@attachment.purge | ||
success_redirect_to_referrer | ||
else | ||
error_redirect_to_referrer | ||
end | ||
end | ||
|
||
def load_attachment | ||
@attachment = ActiveStorage::Attachment.find(params.permit(:id)[:id]) | ||
end | ||
|
||
def success_redirect_to_referrer | ||
redirect_to request.referrer, notice: 'Attachment successfully removed!' | ||
end | ||
|
||
def error_redirect_to_referrer | ||
redirect_to request.referrer, alert: 'Something went wrong, please try again' | ||
end | ||
end |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module JobApplicationsHelper | ||
def attachment_required_but_absent?(application_criteria, attachment) | ||
application_criteria.required && !attachment.attached? | ||
end | ||
|
||
def mandatory_field(application_criteria) | ||
application_criteria.required ? "* " : "" | ||
end | ||
|
||
def mandatory_fields_only_label(job_application) | ||
total = job_application.job.application_criteria.count | ||
optionals = optional_fields(job_application.job.application_criteria).count | ||
"(#{optionals} out of #{total})" | ||
end | ||
|
||
def optional_fields(application_criteria) | ||
application_criteria.reject do |attribute, criteria_hash| | ||
application_criteria = ApplicationCriteria.new(criteria_hash.merge(attribute:)) | ||
application_criteria.required | ||
end | ||
end | ||
|
||
def mandatory_fields_only_disability(job_application) | ||
'disabled' if optional_fields(job_application.job.application_criteria).none? | ||
end | ||
|
||
def mandatory_fields_only_disability_cursor_class(job_application) | ||
'!cursor-not-allowed ' if optional_fields(job_application.job.application_criteria).none? | ||
end | ||
end |
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
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
33 changes: 33 additions & 0 deletions
33
app/javascript/controllers/mandatory_fields_only_controller.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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Controller } from "@hotwired/stimulus" | ||
import TomSelect from "tom-select" | ||
|
||
// Connects to data-controller="select-university" | ||
export default class extends Controller { | ||
static targets = [ "button", "form", "field", "innerRound" ] | ||
|
||
toggleHidden(event) { | ||
const hidden = this.buttonTarget.getAttribute("aria-checked") === "false"; | ||
this.fieldTargets.forEach((field) => { | ||
const isOptional = field.dataset.requiredValue === "false"; // Check for "false" | ||
|
||
if (isOptional) { | ||
field.hidden = hidden; | ||
} | ||
}); | ||
|
||
// Update button label based on hidden state (optional) | ||
if (hidden) { | ||
this.buttonTarget.classList.remove("bg-gray-200"); | ||
this.buttonTarget.classList.add("bg-indigo-600"); | ||
this.innerRoundTarget.classList.remove("translate-x-0"); | ||
this.innerRoundTarget.classList.add("translate-x-5"); | ||
this.buttonTarget.setAttribute("aria-checked", "true"); | ||
} else { | ||
this.buttonTarget.classList.remove("bg-indigo-600"); | ||
this.buttonTarget.classList.add("bg-gray-200"); | ||
this.innerRoundTarget.classList.remove("translate-x-5"); | ||
this.innerRoundTarget.classList.add("translate-x-0"); | ||
this.buttonTarget.setAttribute("aria-checked", "false"); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.