Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the appearance of boolean search filter flags #5859

Merged
merged 1 commit into from
Aug 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions client/src/js/components/bhFilters.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ angular.module('bhima.components')
},
});

bhFiltersController.$inject = ['$filter'];
function bhFiltersController($filter) {
bhFiltersController.$inject = ['$filter', '$translate'];

function bhFiltersController($filter, $translate) {
const $ctrl = this;

// formats the $viewValue according to any filters passed in
Expand All @@ -26,9 +27,12 @@ function bhFiltersController($filter) {

function mapDisplayValues(filter) {
filter.displayValue = filter._displayValue || filter._value;

if (filter._valueFilter) {
filter.displayValue = $filter(filter._valueFilter)(filter.displayValue);
if (filter._valueFilter === 'boolean') {
filter.displayValue = $translate.instant(filter._value ? 'FORM.LABELS.YES' : 'FORM.LABELS.NO');
} else {
filter.displayValue = $filter(filter._valueFilter)(filter.displayValue);
}
}
}
}
2 changes: 1 addition & 1 deletion client/src/js/constants/bhConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ function constantConfig() {
},
defaultFilters : [
{ key : 'period', label : 'TABLE.COLUMNS.PERIOD', valueFilter : 'translate' },
{ key : 'includeEmptyLot', label : 'STOCK.INCLUDE_EMPTY_LOTS' },
{ key : 'includeEmptyLot', label : 'STOCK.INCLUDE_EMPTY_LOTS', valueFilter : 'boolean' },
{
key : 'custom_period_start',
label : 'PERIODS.START',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function AccountReferenceService(Api, Filters, $uibModal, AppCache) {
{ key : 'number', label : 'FORM.LABELS.ACCOUNT' },
{ key : 'description', label : 'ACCOUNT.REFERENCE.DESCRIPTION' },
{ key : 'reference_type_id', label : 'FORM.LABELS.TYPE' },
{ key : 'is_exception', label : 'ACCOUNT.REFERENCE.EXCEPTION' },
{ key : 'is_exception', label : 'ACCOUNT.REFERENCE.EXCEPTION', valueFilter : 'boolean' },
]);

if (filterCache.filters) {
Expand Down
4 changes: 2 additions & 2 deletions client/src/modules/cash/cash.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function CashService(

cashFilters.registerCustomFilters([
{ key : 'uuid', label : 'FORM.LABELS.REFERENCE' },
{ key : 'is_caution', label : 'FORM.LABELS.CAUTION' },
{ key : 'is_caution', label : 'FORM.LABELS.CAUTION', valueFilter : 'boolean' },
{ key : 'cashbox_id', label : 'FORM.LABELS.CASHBOX' },
{ key : 'project_id', label : 'FORM.LABELS.PROJECT' },
{ key : 'debtor_uuid', label : 'FORM.LABELS.CLIENT' },
Expand All @@ -146,7 +146,7 @@ function CashService(
key : 'dateTo', label : 'FORM.LABELS.DATE_TO', comparitor : '<', valueFilter : 'date',
},
{ key : 'currency_id', label : 'FORM.LABELS.CURRENCY' },
{ key : 'reversed', label : 'CASH.REGISTRY.REVERSED_RECORDS' },
{ key : 'reversed', label : 'CASH.REGISTRY.REVERSED_RECORDS', valueFilter : 'boolean' },
{ key : 'description', label : 'FORM.LABELS.DESCRIPTION' },
{ key : 'patientReference', label : 'FORM.LABELS.REFERENCE_PATIENT' },
{ key : 'defaultPeriod', label : 'TABLE.COLUMNS.PERIOD', valueFilter : 'translate' },
Expand Down
2 changes: 1 addition & 1 deletion client/src/modules/employees/employee.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function EmployeeService(Filters, $uibModal, Api, AppCache, Languages, $httpPara
{ key : 'reference', label : 'FORM.LABELS.REFERENCE' },
{ key : 'fonction_id', label : 'FORM.LABELS.PROFESSION' },
{ key : 'service_uuid', label : 'FORM.LABELS.SERVICE' },
{ key : 'is_medical', label : 'FORM.LABELS.MEDICAL_STAFF' },
{ key : 'is_medical', label : 'FORM.LABELS.MEDICAL_STAFF', valueFilter : 'boolean' },
]);

if (filterCache.filters) {
Expand Down
1 change: 1 addition & 0 deletions client/src/modules/inventory/inventory.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ function InventoryService(
{
key : 'consumable',
label : 'FORM.LABELS.CONSUMABLE',
valueFilter : 'boolean',
},
{
key : 'locked',
Expand Down
2 changes: 1 addition & 1 deletion client/src/modules/invoices/patientInvoice.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function PatientInvoiceService(
{
key : 'billingDateTo', label : 'FORM.LABELS.DATE', comparitor : '<', valueFilter : 'date',
},
{ key : 'reversed', label : 'FORM.INFO.CREDIT_NOTE' },
{ key : 'reversed', label : 'FORM.INFO.CREDIT_NOTE', valueFilter : 'boolean' },
{ key : 'defaultPeriod', label : 'TABLE.COLUMNS.PERIOD', valueFilter : 'translate' },
{ key : 'debtor_group_uuid', label : 'FORM.LABELS.DEBTOR_GROUP' },
{ key : 'project_id', label : 'FORM.LABELS.PROJECT' },
Expand Down
12 changes: 6 additions & 6 deletions client/src/modules/stock/StockFilterer.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@ function StockFiltererService(Filters, AppCache, $httpParamSerializer, Languages
{ key : 'invoice_uuid', label : 'FORM.LABELS.INVOICE' },
{ key : 'group_uuid', label : 'STOCK.INVENTORY_GROUP' },
{ key : 'label', label : 'STOCK.LOT' },
{ key : 'is_exit', label : 'STOCK.OUTPUT' },
{ key : 'is_exit', label : 'STOCK.OUTPUT', valueFilter : 'boolean' },
{ key : 'reference', label : 'FORM.LABELS.REFERENCE' },
{ key : 'flux_id', label : 'STOCK.FLUX' },
{ key : 'user_id', label : 'FORM.LABELS.USER' },
{ key : 'status', label : 'STOCK.STATUS.LABEL', valueFilter : 'translate' },
{ key : 'require_po', label : 'STOCK.REQUIRES_PO' },
{ key : 'require_po', label : 'STOCK.REQUIRES_PO', valueFilter : 'boolean' },
{ key : 'entity_uuid', label : 'ENTITY.LABEL' },
{ key : 'description', label : 'FORM.LABELS.DESCRIPTION' },
{ key : 'text', label : 'STOCK.DEPOT' },
{ key : 'is_warehouse', label : 'DEPOT.WAREHOUSE' },
{ key : 'is_warehouse', label : 'DEPOT.WAREHOUSE', valueFilter : 'boolean' },
{ key : 'patientReference', label : 'FORM.LABELS.REFERENCE_PATIENT' },
{ key : 'requestor_uuid', label : 'REQUISITION.RECEIVER' },
{ key : 'service_uuid', label : 'STOCK.SERVICE' },
{ key : 'is_expired', label : 'STOCK.EXPIRED' },
{ key : 'is_expiry_risk', label : 'STOCK.STATUS.IS_IN_RISK_OF_EXPIRATION' },
{ key : 'is_expired', label : 'STOCK.EXPIRED', valueFilter : 'boolean' },
{ key : 'is_expiry_risk', label : 'STOCK.STATUS.IS_IN_RISK_OF_EXPIRATION', valueFilter : 'boolean' },
{ key : 'tag_uuid', label : 'TAG.LABEL' },
{ key : 'voucherReference', label : 'FORM.LABELS.REFERENCE_VOUCHER' },
{ key : 'tags', label : 'TAG.LABEL' },
{ key : 'show_only_risky', label : 'LOTS.SHOW_ONLY_RISKY_LOTS' },
{ key : 'show_only_risky', label : 'LOTS.SHOW_ONLY_RISKY_LOTS', valueFilter : 'boolean' },
{ key : 'stock_requisition_uuid', label : 'FORM.LABELS.REQUISITION_REFERENCE' },
{
key : 'dateFrom', label : 'FORM.LABELS.DATE', comparitor : '>', valueFilter : 'date',
Expand Down
2 changes: 1 addition & 1 deletion client/src/modules/vouchers/vouchers.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function VoucherService(
{ key : 'uuid', label : 'FORM.LABELS.REFERENCE' },
{ key : 'user_id', label : 'FORM.LABELS.USER' },
{ key : 'reference', label : 'FORM.LABELS.REFERENCE' },
{ key : 'reversed', label : 'VOUCHERS.GLOBAL.REVERSED_RECORDS' },
{ key : 'reversed', label : 'VOUCHERS.GLOBAL.REVERSED_RECORDS', valueFilter : 'boolean' },
{ key : 'description', label : 'FORM.LABELS.DESCRIPTION' },
{ key : 'entity_uuid', label : 'FORM.LABELS.ENTITY' },
{ key : 'account_id', label : 'FORM.LABELS.ACCOUNT' },
Expand Down
3 changes: 3 additions & 0 deletions server/controllers/finance/reports/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const filters = [{
}, {
field : 'is_caution',
displayName : 'FORM.LABELS.CAUTION',
valueFilter : 'boolean',
}, {
field : 'supplier_uuid',
displayName : 'FORM.LABELS.SUPPLIER',
Expand Down Expand Up @@ -125,6 +126,7 @@ const filters = [{
}, {
field : 'is_exit',
displayName : 'STOCK.OUTPUT',
valueFilter : 'boolean',
}, {
field : 'label',
displayName : 'STOCK.LOT',
Expand Down Expand Up @@ -181,6 +183,7 @@ const filters = [{
}, {
field : 'reversed',
displayName : 'CASH.REGISTRY.REVERSED_RECORDS',
valueFilter : 'boolean',
}, {
field : 'limit',
displayName : 'FORM.LABELS.LIMIT',
Expand Down