Corrected function of N/A field on injury edit and created portal templates.
This commit is contained in:
parent
e779b4da94
commit
78589bbcf3
3 changed files with 102 additions and 8 deletions
|
|
@ -63,13 +63,34 @@
|
|||
<label for="injury_date">Date of Injury</label>
|
||||
<div class="d-flex align-items-center">
|
||||
<input type="date" name="injury_date" id="injury_date" class="form-control"
|
||||
t-att-value="injury.injury_date" t-att-disabled="injury.injury_date_na"/>
|
||||
t-att-value="injury.injury_date" t-att-disabled="injury.injury_date_na"
|
||||
t-att-required="not injury.injury_date_na"/>
|
||||
<div class="form-check ml-3">
|
||||
<input type="checkbox" name="injury_date_na" id="injury_date_na" class="form-check-input"
|
||||
t-att-checked="injury.injury_date_na"/>
|
||||
t-att-checked="injury.injury_date_na"
|
||||
onchange="(function(){var el=document.getElementById('injury_date'); if(!el){return;} el.required=!this.checked; if(this.checked){ el.value=''; el.disabled=true; el.setAttribute('disabled','disabled'); } else { el.disabled=false; el.removeAttribute('disabled'); } }).call(this)"/>
|
||||
<label for="injury_date_na" class="form-check-label">N/A</label>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
<![CDATA[
|
||||
// Initialize required state based on N/A checkbox
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const naCheckbox = document.getElementById('injury_date_na');
|
||||
const dateInput = document.getElementById('injury_date');
|
||||
if (naCheckbox && dateInput) {
|
||||
dateInput.required = !naCheckbox.checked;
|
||||
if (naCheckbox.checked) {
|
||||
dateInput.disabled = true;
|
||||
dateInput.setAttribute('disabled','disabled');
|
||||
} else {
|
||||
dateInput.disabled = false;
|
||||
dateInput.removeAttribute('disabled');
|
||||
}
|
||||
}
|
||||
});
|
||||
]]>
|
||||
</script>
|
||||
<small class="text-muted">Check N/A if exact date is unknown</small>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -7,29 +7,33 @@
|
|||
<t t-call="portal.portal_docs_entry">
|
||||
<t t-set="title">Teams</t>
|
||||
<t t-set="url">/my/teams</t>
|
||||
<t t-set="placeholder_count">teams_count</t>
|
||||
<t t-set="show_count" t-value="True"/>
|
||||
</t>
|
||||
<t t-call="portal.portal_docs_entry">
|
||||
<t t-set="title">Players</t>
|
||||
<t t-set="url">/my/players</t>
|
||||
<t t-set="placeholder_count">players_count</t>
|
||||
<t t-set="show_count" t-value="True"/>
|
||||
</t>
|
||||
<t t-call="portal.portal_docs_entry">
|
||||
<t t-set="title">Activities</t>
|
||||
<t t-set="url">/my/activities</t>
|
||||
<t t-set="placeholder_count">activities_count</t>
|
||||
<t t-set="show_count" t-value="True"/>
|
||||
<t t-set="config_card" t-value="request.env.user.has_group('bemade_sports_clinic.group_portal_treatment_professional')"/>
|
||||
</t>
|
||||
<t t-call="portal.portal_docs_entry">
|
||||
<t t-set="title">Events</t>
|
||||
<t t-set="url">/my/events</t>
|
||||
<t t-set="placeholder_count">events_count</t>
|
||||
<t t-set="show_count" t-value="True"/>
|
||||
<t t-set="config_card" t-value="request.env.user.has_group('bemade_sports_clinic.group_portal_treatment_professional')"/>
|
||||
</t>
|
||||
</div>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Hide Invoice cards for coaches and treatment professionals -->
|
||||
<template id="portal_my_home_invoice_coach_override" inherit_id="account.portal_my_home_invoice" priority="50">
|
||||
<xpath expr="//div[@id='portal_client_category']" position="attributes">
|
||||
|
|
@ -83,6 +87,54 @@
|
|||
display: none !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- JavaScript fix for spinner issue -->
|
||||
<script type="text/javascript">
|
||||
<![CDATA[
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Remove problematic placeholder_count attributes for coaches and treatment professionals
|
||||
if (document.body.classList.contains('o_portal_user_coach') ||
|
||||
document.body.classList.contains('o_portal_user_therapist')) {
|
||||
|
||||
console.log('Portal spinner fix: Detected coach/therapist user');
|
||||
|
||||
// Remove ALL placeholder_count attributes that cause spinner issues
|
||||
const allCounterElements = document.querySelectorAll('[data-placeholder_count]');
|
||||
console.log('Portal spinner fix: Found ' + allCounterElements.length + ' placeholder_count elements');
|
||||
|
||||
allCounterElements.forEach(function(el) {
|
||||
const counterType = el.getAttribute('data-placeholder_count');
|
||||
console.log('Portal spinner fix: Removing ' + counterType + ' counter');
|
||||
el.removeAttribute('data-placeholder_count');
|
||||
|
||||
// Hide the parent card
|
||||
const card = el.closest('.o_portal_index_card');
|
||||
if (card && !card.classList.contains('d-none')) {
|
||||
card.classList.add('d-none');
|
||||
console.log('Portal spinner fix: Hiding card for ' + counterType);
|
||||
}
|
||||
});
|
||||
|
||||
// Force remove spinner immediately
|
||||
const spinner = document.querySelector('.o_portal_doc_spinner');
|
||||
if (spinner) {
|
||||
spinner.remove();
|
||||
console.log('Portal spinner fix: Spinner removed');
|
||||
}
|
||||
|
||||
// Also remove any knowledge cards for therapists (they should only see activities)
|
||||
const knowledgeCards = document.querySelectorAll('a[href*="/knowledge"]');
|
||||
knowledgeCards.forEach(function(card) {
|
||||
const parentCard = card.closest('.o_portal_index_card');
|
||||
if (parentCard) {
|
||||
parentCard.classList.add('d-none');
|
||||
console.log('Portal spinner fix: Hiding knowledge card');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
]]>
|
||||
</script>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
|
|
|
|||
|
|
@ -59,13 +59,34 @@
|
|||
<label for="injury_date">Date of Injury</label>
|
||||
<div class="d-flex align-items-center">
|
||||
<input type="date" name="injury_date" id="injury_date" class="form-control"
|
||||
required="required"/>
|
||||
t-att-required="'injury_date_na' not in request.params"/>
|
||||
<div class="form-check ml-3">
|
||||
<input type="checkbox" name="injury_date_na" id="injury_date_na" class="form-check-input"/>
|
||||
<input type="checkbox" name="injury_date_na" id="injury_date_na" class="form-check-input"
|
||||
t-att-checked="'injury_date_na' in request.params"
|
||||
onchange="(function(){var el=document.getElementById('injury_date'); if(!el){return;} el.required=!this.checked; if(this.checked){ el.value=''; el.disabled=true; el.setAttribute('disabled','disabled'); } else { el.disabled=false; el.removeAttribute('disabled'); } }).call(this)"/>
|
||||
<label for="injury_date_na" class="form-check-label">N/A</label>
|
||||
</div>
|
||||
</div>
|
||||
<small class="text-muted">Check N/A if exact date is unknown</small>
|
||||
<script>
|
||||
<![CDATA[
|
||||
// Initialize required/disabled state based on N/A checkbox
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const naCheckbox = document.getElementById('injury_date_na');
|
||||
const dateInput = document.getElementById('injury_date');
|
||||
if (naCheckbox && dateInput) {
|
||||
dateInput.required = !naCheckbox.checked;
|
||||
if (naCheckbox.checked) {
|
||||
dateInput.disabled = true;
|
||||
dateInput.setAttribute('disabled','disabled');
|
||||
} else {
|
||||
dateInput.disabled = false;
|
||||
dateInput.removeAttribute('disabled');
|
||||
}
|
||||
}
|
||||
});
|
||||
]]>
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
<div t-if="is_treatment_prof" class="col-lg-6">
|
||||
|
|
|
|||
Loading…
Reference in a new issue