-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(filters): implement filterbar.hbs
This commit implements a filterbar partial to enable rendering filters on the server. It implements a giant shared filter to render the correctly translated display value based on the filter passed in. A prototype implementation is available in cash's registry. Closes #1979.
- Loading branch information
Showing
7 changed files
with
125 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
const _ = require('lodash'); | ||
|
||
// translation key mappings for dynamic filters | ||
// Basically, to show a pretty filter bar, this will translate URL query string | ||
// into human-readable text to be placed in the report, showing the properties | ||
// filtered on. | ||
function formatFilters(qs) { | ||
const columns = [ | ||
{ field : 'billingDateFrom', displayName : 'FORM.LABELS.DATE', comparitor : '>', isDate : true }, | ||
{ field : 'billingDateTo', displayName : 'FORM.LABELS.DATE', comparitor : '<', isDate : true }, | ||
{ field : 'cashbox_id', displayName : 'FORM.LABELS.CASHBOX' }, | ||
{ field : 'cash_uuid', displayName : 'FORM.INFO.PAYMENT' }, | ||
{ field : 'currency_id', displayName : 'FORM.LABELS.CURRENCY' }, | ||
{ field : 'dateFrom', displayName : 'FORM.LABELS.DATE_FROM', comparitor : '>', isDate : true }, | ||
{ field : 'dateTo', displayName : 'FORM.LABELS.DATE_TO', comparitor : '<', isDate : true }, | ||
{ field : 'debtor_uuid', displayName : 'FORM.LABELS.CLIENT' }, | ||
{ field : 'debtor_group_uuid', displayName : 'FORM.LABELS.DEBTOR_GROUP' }, | ||
|
||
{ field : 'is_caution', displayName : 'FORM.LABELS.CAUTION' }, | ||
{ field : 'supplier_uuid', displayName : 'FORM.LABELS.SUPPLIER' }, | ||
{ field : 'status_id', displayName : 'PURCHASES.ORDER' }, | ||
{ field : 'patientReference', displayName : 'FORM.LABELS.REFERENCE_PATIENT' }, | ||
{ field : 'user_id', displayName : 'FORM.LABELS.USER' }, | ||
|
||
{ field : 'invoiceReference', displayName : 'FORM.LABELS.INVOICE' }, | ||
{ field : 'invoice_uuid', displayName : 'FORM.LABELS.INVOICE' }, | ||
{ field : 'service_id', displayName : 'FORM.LABELS.SERVICE' }, | ||
{ field : 'inventory_uuid', displayName : 'FORM.LABELS.INVENTORY' }, | ||
|
||
{ field : 'flux_id', displayName: 'STOCK.FLUX' }, | ||
{ field : 'status', displayName: 'STOCK.STATUS.LABEL' }, | ||
|
||
{ field : 'entry_date_from', displayName: 'STOCK.ENTRY_DATE', comparitor: '>', isDate : true }, | ||
{ field : 'entry_date_to', displayName: 'STOCK.ENTRY_DATE', comparitor: '<', isDate : true }, | ||
{ field : 'expiration_date_from', displayName: 'STOCK.EXPIRATION_DATE', comparitor: '>', isDate : true }, | ||
{ field : 'expiration_date_to', displayName: 'STOCK.EXPIRATION_DATE', comparitor: '<', isDate : true }, | ||
{ field : 'is_exit', displayName : 'STOCK.OUTPUT' }, | ||
{ field : 'label', displayName : 'STOCK.LOT' }, | ||
{ field : 'depot_uuid', displayName : 'STOCK.DEPOT' }, | ||
|
||
{ field : 'description', displayName : 'FORM.LABELS.DESCRIPTION' }, | ||
{ field : 'entity_uuid', displayName : 'FORM.LABELS.ENTITY' }, | ||
{ field : 'type_ids', displayName : 'FORM.LABELS.TRANSACTION_TYPE' }, | ||
|
||
{ field : 'reference', displayName : 'FORM.LABELS.REFERENCE' }, | ||
{ field : 'reversed', displayName : 'CASH.REGISTRY.REVERSED_RECORDS' }, | ||
{ field : 'limit', displayName : 'FORM.LABELS.LIMIT' }, | ||
{ field : 'period', displayName : 'TABLE.COLUMNS.PERIOD' }, | ||
{ field : 'custom_period_start', displayName : 'PERIODS.START', isDate : true, comparitor : '>' }, | ||
{ field : 'custom_period_end', displayName : 'PERIODS.END', isDate : true, comparitor : '<' }, | ||
]; | ||
|
||
return columns.filter(column => { | ||
const value = qs[column.field]; | ||
|
||
if (!_.isUndefined(value)) { | ||
column.value = value; | ||
return true; | ||
} | ||
return false; | ||
}); | ||
} | ||
|
||
exports.formatFilters = formatFilters; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{{#if filters}} | ||
<p class="pills"> | ||
{{#each filters}} | ||
<span class="label label-outlined text-capitalize" style="border-color: #000; color: #000;"> | ||
{{translate this.displayName}} | ||
|
||
{{#if this.comparitor}} {{this.comparitor}} | ||
{{else}}: {{/if}} | ||
|
||
{{#if this.isDate}} {{date this.value}} | ||
{{else}} {{translate this.value}} {{/if}} | ||
</span> | ||
{{/each}} | ||
</p> | ||
{{/if}} |