Skip to content

Commit

Permalink
Merge pull request #1964 from tomudding/fix/company-update-language-t…
Browse files Browse the repository at this point in the history
…oggle-not-working

fix: language toggle not working for company update form
  • Loading branch information
tomudding authored Jan 6, 2025
2 parents 3614742 + 4d4a397 commit 1efd96a
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 54 deletions.
4 changes: 2 additions & 2 deletions module/Company/view/company/admin/add-company.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ $this->headTitle($this->translate('Create Company'));

$this->headScript()
->appendFile(
$this->basepath('js/company-create.js'),
$this->basepath('js/company-admin.js'),
'text/javascript',
['nonce' => NONCE_REPLACEMENT_STRING],
)
Expand Down Expand Up @@ -68,7 +68,7 @@ $form->setAttribute('class', 'form-company');
</div>
<?= $this->form()->closeTag() ?>
<script nonce="<?= NONCE_REPLACEMENT_STRING ?>">
Company.updateForm();
Company.Admin.updateForm();

GEDITOR.MarkdownCompanyEditor
.create(document.querySelector('#description-nl'), {
Expand Down
4 changes: 2 additions & 2 deletions module/Company/view/company/admin/add-job.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $this->headTitle($this->translate('Add Job'));

$this->headScript()
->appendFile(
$this->basepath('js/company-create.js'),
$this->basepath('js/company-admin.js'),
'text/javascript',
['nonce' => NONCE_REPLACEMENT_STRING],
)
Expand Down Expand Up @@ -83,7 +83,7 @@ $form->setAttribute('class', 'form-company');
</div>
<?= $this->form()->closeTag() ?>
<script nonce="<?= NONCE_REPLACEMENT_STRING ?>">
Company.updateForm();
Company.Admin.updateForm();
Job.updateAllLabels();
$('label[for^="labels-"]').on('click', function () {
Job.toggleLabel($(this).data('label-id'));
Expand Down
4 changes: 2 additions & 2 deletions module/Company/view/company/admin/add-label.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ $this->headTitle($this->translate('Create Job Label'));

$this->headScript()
->appendFile(
$this->basepath('js/company-create.js'),
$this->basepath('js/company-admin.js'),
'text/javascript',
['nonce' => NONCE_REPLACEMENT_STRING],
);
Expand Down Expand Up @@ -50,6 +50,6 @@ $form->setAttribute('class', 'form-company');
</div>
<?= $this->form()->closeTag() ?>
<script nonce="<?= NONCE_REPLACEMENT_STRING ?>">
Company.updateForm();
Company.Admin.updateForm();
</script>

4 changes: 2 additions & 2 deletions module/Company/view/company/admin/add-package.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ $this->headTitle($this->translate('Add Package'));

$this->headScript()
->appendFile(
$this->basepath('js/company-create.js'),
$this->basepath('js/company-admin.js'),
'text/javascript',
['nonce' => NONCE_REPLACEMENT_STRING],
);
Expand Down Expand Up @@ -52,6 +52,6 @@ $form->setAttribute('class', 'form-company');
</div>
<?= $this->form()->closeTag() ?>
<script nonce="<?= NONCE_REPLACEMENT_STRING ?>">
Company.updateForm();
Company.Admin.updateForm();
</script>

11 changes: 2 additions & 9 deletions module/Company/view/company/admin/edit-company.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ $this->breadcrumbs()

$this->headScript()
->appendFile(
$this->basepath('js/company-create.js'),
$this->basepath('js/company-admin.js'),
'text/javascript',
['nonce' => NONCE_REPLACEMENT_STRING],
)
Expand Down Expand Up @@ -58,13 +58,6 @@ if ($isCompany) {
$uploadPath = '/admin/career/company/edit/' . $company->getSlugName() . '/upload';
}

$this->inlineScript()
->appendFile(
$this->basepath('js/company-admin.js'),
'text/javascript',
['nonce' => NONCE_REPLACEMENT_STRING],
);

$this->scriptUrl()->requireUrls(
[
'company_admin/company/edit/package/delete'
Expand Down Expand Up @@ -246,7 +239,7 @@ $form->setAttribute('class', 'form-company');
</div>
</div>
<script nonce="<?= NONCE_REPLACEMENT_STRING ?>">
Company.updateForm();
Company.Admin.updateForm();

document.querySelectorAll('.delete-package').forEach(companyPackage => {
companyPackage.addEventListener('click', e => {
Expand Down
4 changes: 2 additions & 2 deletions module/Company/view/company/admin/edit-job.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ $this->headTitle($this->translate('Edit Job'));

$this->headScript()
->appendFile(
$this->basepath('js/company-create.js'),
$this->basepath('js/company-admin.js'),
'text/javascript',
['nonce' => NONCE_REPLACEMENT_STRING],
)
Expand Down Expand Up @@ -120,7 +120,7 @@ $form->setAttribute('class', 'form-company');
</div>
<?= $this->form()->closeTag() ?>
<script nonce="<?= NONCE_REPLACEMENT_STRING ?>">
Company.updateForm();
Company.Admin.updateForm();
Job.updateAllLabels();
$('label[for^="labels-"]').on('click', function () {
Job.toggleLabel($(this).data('label-id'));
Expand Down
4 changes: 2 additions & 2 deletions module/Company/view/company/admin/edit-label.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ $this->headTitle($this->translate('Edit Job Label'));

$this->headScript()
->appendFile(
$this->basepath('js/company-create.js'),
$this->basepath('js/company-admin.js'),
'text/javascript',
['nonce' => NONCE_REPLACEMENT_STRING],
);
Expand Down Expand Up @@ -50,6 +50,6 @@ $form->setAttribute('class', 'form-company');
</div>
<?= $this->form()->closeTag() ?>
<script nonce="<?= NONCE_REPLACEMENT_STRING ?>">
Company.updateForm();
Company.Admin.updateForm();
</script>

4 changes: 2 additions & 2 deletions module/Company/view/company/admin/edit-package.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $this->headTitle($this->translate('Edit Package'));

$this->headScript()
->appendFile(
$this->basepath('js/company-create.js'),
$this->basepath('js/company-admin.js'),
'text/javascript',
['nonce' => NONCE_REPLACEMENT_STRING],
);
Expand Down Expand Up @@ -164,7 +164,7 @@ $form->setAttribute('class', 'form-company');
</div>
</div>
<script nonce="<?= NONCE_REPLACEMENT_STRING ?>">
Company.updateForm();
Company.Admin.updateForm();

document.querySelectorAll('.delete-job').forEach(job => {
job.addEventListener('click', e => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ use Laminas\View\Renderer\PhpRenderer;
<script nonce="<?= NONCE_REPLACEMENT_STRING ?>">
document.querySelectorAll('.language-control').forEach(checkbox => {
checkbox.addEventListener('click', () => {
Company.updateForm();
Company.Admin.updateForm();
});
});
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ use Laminas\View\Renderer\PhpRenderer;
<script nonce="<?= NONCE_REPLACEMENT_STRING ?>">
document.querySelectorAll('.language-control').forEach(checkbox => {
checkbox.addEventListener('click', () => {
Company.updateForm();
Company.Admin.updateForm();
});
});
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ use Laminas\View\Renderer\PhpRenderer;
<script nonce="<?= NONCE_REPLACEMENT_STRING ?>">
document.querySelectorAll('.language-control').forEach(checkbox => {
checkbox.addEventListener('click', () => {
Company.updateForm();
Company.Admin.updateForm();
});
});
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ use Laminas\View\Renderer\PhpRenderer;
<script nonce="<?= NONCE_REPLACEMENT_STRING ?>">
document.querySelectorAll('.language-control').forEach(checkbox => {
checkbox.addEventListener('click', () => {
Company.updateForm();
Company.Admin.updateForm();
});
});
</script>
23 changes: 22 additions & 1 deletion public/js/company-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,26 @@ Company.Admin = {
'companySlugName': companySlugName,
'packageId': packageId
}));
}
},

/**
* Updates the form to accommodate changes in the language checkboxes.
*/
updateForm: function () {
if ($('[name="language_dutch"]').is(':checked')) {
$('.form-control-dutch').removeAttr('disabled');
$('label[for$="-nl"]').addClass('label-required');
} else {
$('.form-control-dutch').attr('disabled', 'disabled');
$('label[for$="-nl"]').removeClass('label-required');
}

if ($('[name="language_english"]').is(':checked')) {
$('.form-control-english').removeAttr('disabled');
$('label[for$="-en"]').addClass('label-required');
} else {
$('.form-control-english').attr('disabled', 'disabled');
$('label[for$="-en"]').removeClass('label-required');
}
},
};
26 changes: 0 additions & 26 deletions public/js/company-create.js

This file was deleted.

0 comments on commit 1efd96a

Please sign in to comment.