Skip to content

Commit

Permalink
Fixed erroneous blur setting
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcameron committed Jul 30, 2024
1 parent b88ed68 commit 71c2007
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 22 deletions.
12 changes: 7 additions & 5 deletions client/src/modules/payroll/settings/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="flex-content">
<div class="container-fluid">
<form name="PayrollSettingsForm" bh-submit="PayrollSettingsCtrl.submit(PayrollSettingsForm)"
ng-model-options="{ updateOn: 'blur' }" novalidate>
ng-model-options="{ updateOn: 'default' }" novalidate>

<div class="panel panel-default">
<div class="panel-heading">
Expand Down Expand Up @@ -45,7 +45,7 @@
</div>
<span class="help-block" translate>
SETTINGS.BASE_INDEX_GROWTH_RATE_HELP_TEXT
</span>
</span>
<div class="help-block" ng-messages="PayrollSettingsForm.base_index_growth_rate.$error" ng-show="PayrollSettingsForm.$submitted">
<div ng-messages-include="modules/templates/messages.tmpl.html"></div>
</div>
Expand All @@ -65,7 +65,9 @@
on-change-callback="PayrollSettingsCtrl.enableActivatePensionFundSetting(value)">
</bh-yes-no-radios>

<div class="form-group" ng-class="{ 'has-error' : PayrollSettingsForm.$submitted && PayrollSettingsForm.pension_transaction_type_id.$invalid }">
<div class="form-group"
ng-if="PayrollSettingsCtrl.enterprise.settings.enable_activate_pension_fund"
ng-class="{ 'has-error' : PayrollSettingsForm.$submitted && PayrollSettingsForm.pension_transaction_type_id.$invalid }">
<label class="control-label" translate>
FORM.LABELS.TRANSACTION_TYPE_PENSION
</label>
Expand All @@ -82,8 +84,7 @@

<ui-select-choices
ui-select-focus-patch
repeat="item.id as item in PayrollSettingsCtrl.types | filter:{ 'plainText' : $select.search }"
group-by="PayrollSettingsCtrl.groupTransactionByType">
repeat="item.id as item in PayrollSettingsCtrl.types | filter:{ 'plainText' : $select.search }">
<div ng-bind-html="item.plainText | highlight: $select.search"></div>
</ui-select-choices>
</ui-select>
Expand All @@ -97,6 +98,7 @@
</div>

<hr>

<div class="form-group" ng-class="{ 'has-error' : PayrollSettingsForm.$submitted && PayrollSettingsForm.base_index_growth_rate.$invalid }">
<label class="control-label" translate>
SETTINGS.PERCENTAGE_ATTRIBUTED_FIXED_BONUS
Expand Down
35 changes: 18 additions & 17 deletions client/src/modules/payroll/settings/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,14 @@ function PayrollSettingsController(
return 0;
}

const changes = {};
if (vm.enterprise.settings.enable_activate_pension_fund
&& vm.enterprise.settings.pension_transaction_type_id === 0) {
form.pension_transaction_type_id.$invalid = true;
Notify.danger('FORM.ERRORS.MISSING');
return 0;
}

const changes = {};
changes.settings = angular.copy(vm.enterprise.settings);
const promise = Enterprises.update(vm.enterprise.id, changes);

Expand All @@ -66,23 +72,18 @@ function PayrollSettingsController(
.catch(Notify.handleError);
}

/**
* @function proxy
*
* @description
* Proxies requests for different payroll settings.
*
* @returns {function}
*/
function proxy(key) {
return (enabled) => {
vm.enterprise.settings[key] = enabled;
$touched = true;
};
}
vm.enableIndexPaymentSetting = (val) => {
vm.enterprise.settings.enable_index_payment_system = val;
$touched = true;
};

vm.enableIndexPaymentSetting = proxy('enable_index_payment_system');
vm.enableActivatePensionFundSetting = proxy('enable_activate_pension_fund');
vm.enableActivatePensionFundSetting = (val) => {
vm.enterprise.settings.enable_activate_pension_fund = val;
if (!vm.enterprise.settings.enable_activate_pension_fund) {
vm.enterprise.settings.pension_transaction_type_id = 0;
}
$touched = true;
};

startup();
}

0 comments on commit 71c2007

Please sign in to comment.