Skip to content

Commit 5c7edd9

Browse files
EsariUpEsari Upendri
andauthored
Fix for "I am open for a new mentee" bug - #527 (#540)
* Updated Default cshtml file * Updated review comments * Moved mentor checkbox logic to JS and updated layout version. * Changed the version number * Updated review comments --------- Co-authored-by: Esari Upendri <esari.upendri@igt1sl.com>
1 parent 0cf2bb1 commit 5c7edd9

File tree

5 files changed

+52
-4
lines changed

5 files changed

+52
-4
lines changed

headapps/MvpSite/MvpSite.Rendering/Views/Shared/Components/MvpMentorData/Default.cshtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
<input asp-for="MentorId" type="hidden"/>
1414
<div class="form-group">
1515
<div class="form-check">
16-
@Html.CheckBoxFor(m => m.IsMentor, new { @class = "align-middle" })
16+
@Html.CheckBoxFor(m => m.IsMentor, new { @class = "align-middle", id = "IsMentor" })
1717
<label asp-for="IsMentor" class="w-75 align-middle">
1818
@(Model.IsEditing ? Html.Raw(Model.IsMentorLabel?.EditableMarkup) : Model.IsMentorLabel?.Value)
1919
</label>
2020
</div>
2121
<div class="form-check">
22-
@Html.CheckBoxFor(m => m.IsOpenToNewMentees, new { @class = "align-middle" })
22+
@Html.CheckBoxFor(m => m.IsOpenToNewMentees, new { @class = "align-middle", id = "IsOpenToNewMentees" })
2323
<label asp-for="IsOpenToNewMentees" class="w-75 align-middle">
2424
@(Model.IsEditing ? Html.Raw(Model.IsOpenToNewMenteesLabel?.EditableMarkup) : Model.IsOpenToNewMenteesLabel?.Value)
2525
</label>

headapps/MvpSite/MvpSite.Rendering/Views/Shared/_Layout.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,6 @@
6969
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
7070
<script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/2.0.2/anime.min.js"></script>
7171
<script src="https://www.w3.org/TR/wai-aria-practices-1.1/examples/accordion/js/accordion.js"></script>
72-
<script src="/js/mvp-site.es5.min.js?v=1.14"></script>
72+
<script src="/js/mvp-site.es5.min.js?v=1.15"></script>
7373
</body>
7474
</html>

headapps/MvpSite/MvpSite.Rendering/wwwroot/js/mvp-site.es5.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,24 @@ function directorySearchClearHandler() {
3939
window.addEventListener('pageshow', clearIfNeeded);
4040
}
4141

42+
function setupMentorCheckboxBehavior() {
43+
var mentorCheckbox = document.getElementById("IsMentor");
44+
var menteeCheckbox = document.getElementById("IsOpenToNewMentees");
45+
46+
if (!mentorCheckbox || !menteeCheckbox) {
47+
return;
48+
}
49+
50+
menteeCheckbox.disabled = !mentorCheckbox.checked;
51+
52+
mentorCheckbox.addEventListener("change", function () {
53+
menteeCheckbox.disabled = !this.checked;
54+
if (!this.checked) {
55+
menteeCheckbox.checked = false;
56+
}
57+
});
58+
}
59+
4260
$(document).ready(function () {
4361
var $window = $(window);
4462

@@ -128,5 +146,10 @@ $(document).ready(function () {
128146
});
129147
});
130148
}
149+
150+
var $mvpmentordata = $(".mvp-fs-mvpmentordata");
151+
if ($mvpmentordata.length > 0) {
152+
setupMentorCheckboxBehavior();
153+
}
131154
});
132155

headapps/MvpSite/MvpSite.Rendering/wwwroot/js/mvp-site.es5.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

headapps/MvpSite/MvpSite.Rendering/wwwroot/js/mvp-site.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,26 @@ function directorySearchClearHandler() {
4040

4141
}
4242

43+
44+
function setupMentorCheckboxBehavior() {
45+
const mentorCheckbox = document.getElementById("IsMentor");
46+
const menteeCheckbox = document.getElementById("IsOpenToNewMentees");
47+
48+
if (!mentorCheckbox || !menteeCheckbox) {
49+
return;
50+
}
51+
52+
menteeCheckbox.disabled = !mentorCheckbox.checked;
53+
54+
mentorCheckbox.addEventListener("change", function () {
55+
menteeCheckbox.disabled = !this.checked;
56+
if (!this.checked) {
57+
menteeCheckbox.checked = false;
58+
}
59+
});
60+
}
61+
62+
4363
$(document).ready(function () {
4464
const $window = $(window);
4565

@@ -128,4 +148,9 @@ $(document).ready(function () {
128148
});
129149
});
130150
}
151+
152+
const $mvpmentordata = $(".mvp-fs-mvpmentordata");
153+
if ($mvpmentordata.length > 0) {
154+
setupMentorCheckboxBehavior();
155+
}
131156
});

0 commit comments

Comments
 (0)