add feature do not show again job for parent portal
This commit is contained in:
@@ -71,14 +71,18 @@
|
||||
<ul class="mb-0 ps-3">
|
||||
<?php foreach ($notifications as $n): ?>
|
||||
<li class="mb-2">
|
||||
<strong><?= esc($n['title']) ?></strong><br>
|
||||
<strong><?= esc($n['title'] ?? 'Notification') ?></strong><br>
|
||||
<small class="text-muted">
|
||||
<?= isset($n['created_at']) && strtotime($n['created_at'])
|
||||
? esc(local_datetime($n['created_at'], 'm-d-Y H:i'))
|
||||
: 'No date' ?>
|
||||
</small>
|
||||
<?php if (!empty($n['message'] ?? '')): ?>
|
||||
<br>
|
||||
<span><?= esc($n['message']) ?></span>
|
||||
<?php endif; ?>
|
||||
<br>
|
||||
<span class="badge bg-light text-dark"><?= ucfirst($n['notification_type'] ?? 'broadcast') ?></span>
|
||||
<span class="badge bg-light text-dark"><?= esc(ucfirst((string) ($n['notification_type'] ?? 'notice'))) ?></span>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
@@ -256,6 +260,20 @@
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="form-check me-auto text-start">
|
||||
<input
|
||||
class="form-check-input"
|
||||
type="checkbox"
|
||||
value="1"
|
||||
id="hideJobOpeningsPopup"
|
||||
data-save-url="<?= esc(site_url('parent_dashboard/job-openings-popup')) ?>"
|
||||
data-csrf-name="<?= esc(csrf_token()) ?>"
|
||||
data-csrf-value="<?= esc(csrf_hash()) ?>">
|
||||
<label class="form-check-label" for="hideJobOpeningsPopup">
|
||||
Do not show again
|
||||
</label>
|
||||
<div class="small text-muted d-none" id="hideJobOpeningsPopupStatus"></div>
|
||||
</div>
|
||||
<a class="btn btn-outline-secondary" href="<?= site_url('careers') ?>">View all openings</a>
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
</div>
|
||||
@@ -276,6 +294,68 @@
|
||||
}
|
||||
|
||||
bootstrap.Modal.getOrCreateInstance(modalEl).show();
|
||||
|
||||
const checkbox = document.getElementById('hideJobOpeningsPopup');
|
||||
const statusEl = document.getElementById('hideJobOpeningsPopupStatus');
|
||||
if (!checkbox) {
|
||||
return;
|
||||
}
|
||||
|
||||
checkbox.addEventListener('change', async function () {
|
||||
if (!checkbox.checked) {
|
||||
return;
|
||||
}
|
||||
|
||||
checkbox.disabled = true;
|
||||
if (statusEl) {
|
||||
statusEl.classList.remove('d-none', 'text-danger');
|
||||
statusEl.classList.add('text-muted');
|
||||
statusEl.textContent = 'Saving preference...';
|
||||
}
|
||||
|
||||
const body = new FormData();
|
||||
let csrfName = checkbox.dataset.csrfName || '';
|
||||
let csrfValue = checkbox.dataset.csrfValue || '';
|
||||
body.append('hide_job_openings_popup', '1');
|
||||
if (csrfName && csrfValue) {
|
||||
body.append(csrfName, csrfValue);
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(checkbox.dataset.saveUrl || '', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
...(csrfValue ? { 'X-CSRF-TOKEN': csrfValue } : {})
|
||||
},
|
||||
body
|
||||
});
|
||||
const data = await response.json().catch(function () {
|
||||
return {};
|
||||
});
|
||||
|
||||
if (data.csrf_token && data.csrf_hash) {
|
||||
checkbox.dataset.csrfName = data.csrf_token;
|
||||
checkbox.dataset.csrfValue = data.csrf_hash;
|
||||
}
|
||||
|
||||
if (!response.ok || !data.ok) {
|
||||
throw new Error(data.error || 'Unable to save preference.');
|
||||
}
|
||||
|
||||
if (statusEl) {
|
||||
statusEl.textContent = 'Saved.';
|
||||
}
|
||||
} catch (error) {
|
||||
checkbox.checked = false;
|
||||
checkbox.disabled = false;
|
||||
if (statusEl) {
|
||||
statusEl.classList.remove('d-none', 'text-muted');
|
||||
statusEl.classList.add('text-danger');
|
||||
statusEl.textContent = error.message || 'Unable to save preference.';
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
Reference in New Issue
Block a user