Skip to content

Commit

Permalink
Fix user-friendly queries and dropdown values for various fields (#581)
Browse files Browse the repository at this point in the history
  • Loading branch information
bvsharp authored Jan 15, 2025
1 parent f03b2c1 commit af6b885
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
'inventory-storage.contributor-types.collection.get',
'inventory-storage.statistical-codes.collection.get',
'inventory-storage.statistical-code-types.collection.get',
'inventory-storage.instance-formats.collection.get'
],
columns: [
{
Expand Down Expand Up @@ -807,8 +808,8 @@
valueGetter: "( SELECT jsonb_agg(format.jsonb ->> 'name') FROM jsonb_array_elements_text(:inst.jsonb -> 'instanceFormatIds') record(value) JOIN src_inventory_instance_format format ON record.value::text = format.id::text )",
filterValueGetter: "( SELECT jsonb_agg(lower(format.jsonb ->> 'name')) FROM jsonb_array_elements_text(:inst.jsonb -> 'instanceFormatIds') record(value) JOIN src_inventory_instance_format format ON record.value::text = format.id::text )",
source: {
entityTypeId: '8fc4a9d2-7ccf-4233-afb8-796911839862',
columnName: 'format_names',
entityTypeId: '5e8f16c7-086e-4a3f-a8ec-a55237f061be',
columnName: 'name',
},
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
id: '5e8f16c7-086e-4a3f-a8ec-a55237f061be',
name: 'simple_instance_format',
private: true,
sources: [
{
type: 'db',
alias: 'format',
target: 'src_inventory_instance_format',
},
],
requiredPermissions: [
'inventory-storage.instance-formats.collection.get'
],
columns: [
{
name: 'id',
sourceAlias: 'format',
dataType: {
dataType: 'rangedUUIDType',
},
isIdColumn: true,
queryable: true,
visibleByDefault: false,
valueGetter: ":sourceAlias.id",
},
{
name: 'code',
sourceAlias: 'format',
dataType: {
dataType: 'stringType',
},
isIdColumn: false,
queryable: true,
visibleByDefault: true,
valueGetter: ":sourceAlias.jsonb->>'code'",
filterValueGetter: "lower(\
${tenant_id}_mod_inventory_storage.f_unaccent (:sourceAlias.jsonb->>'code'::text)\
)",
valueFunction: 'lower(${tenant_id}_mod_inventory_storage.f_unaccent (:value))',
source: {
entityTypeId: '5e8f16c7-086e-4a3f-a8ec-a55237f061be',
columnName: 'code',
},
valueSourceApi: {
path: 'instance-formats',
valueJsonPath: '$.instanceFormats.*.id',
labelJsonPath: '$.instanceFormats.*.code',
}
},
{
name: 'name',
sourceAlias: 'format',
dataType: {
dataType: 'stringType',
},
isIdColumn: false,
queryable: true,
visibleByDefault: true,
valueGetter: ":sourceAlias.jsonb->>'name'",
filterValueGetter: "lower(\
${tenant_id}_mod_inventory_storage.f_unaccent (:sourceAlias.jsonb->>'name'::text)\
)",
valueFunction: 'lower(${tenant_id}_mod_inventory_storage.f_unaccent (:value))',
source: {
entityTypeId: '5e8f16c7-086e-4a3f-a8ec-a55237f061be',
columnName: 'name',
},
valueSourceApi: {
path: 'instance-formats',
valueJsonPath: '$.instanceFormats.*.id',
labelJsonPath: '$.instanceFormats.*.name',
}
},
{
name: 'jsonb',
sourceAlias: 'format',
dataType: {
dataType: 'stringType',
},
isIdColumn: false,
queryable: false,
hidden: true,
essential: true,
visibleByDefault: false,
valueGetter: ":sourceAlias.jsonb::text",
}
],
defaultSort: [
{
columnName: 'id',
direction: 'ASC',
},
],
}
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,8 @@
filterValueGetter: "( SELECT jsonb_agg(lower(acq_unit.jsonb ->> 'name')) FILTER (WHERE (acq_unit.jsonb ->> 'name') IS NOT NULL) FROM jsonb_array_elements_text(:sourceAlias.jsonb -> 'acqUnitIds') record(value) JOIN src_acquisitions_unit acq_unit ON record.value::text = acq_unit.id::text )",
valueFunction: "lower(:value)",
source: {
entityTypeId: '48de4796-11a2-44e9-abb7-01e84af87234',
columnName: 'acquisition_unit'
entityTypeId: '661633d0-4cb5-4764-a108-2132b80320ec',
columnName: 'name'
},
valueSourceApi: {
path: 'acquisitions-units/units',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1575,8 +1575,8 @@
filterValueGetter: "( SELECT jsonb_agg(lower(acq_unit.jsonb ->> 'name')) FILTER (WHERE (acq_unit.jsonb ->> 'name') IS NOT NULL) FROM jsonb_array_elements_text(:sourceAlias.jsonb -> 'acqUnitIds') record(value) JOIN src_acquisitions_unit acq_unit ON record.value::text = acq_unit.id::text )",
valueFunction: 'lower(:value)',
source: {
entityTypeId: 'b5ffa2e9-8080-471a-8003-a8c5a1274503',
columnName: 'acq_unit_names',
entityTypeId: '661633d0-4cb5-4764-a108-2132b80320ec',
columnName: 'name',
},
valueSourceApi: {
path: 'acquisitions-units/units',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
id: '661633d0-4cb5-4764-a108-2132b80320ec',
name: 'drv_acquisitions_unit_details',
name: 'simple_acq_unit',
private: true,
requiredPermissions: [
'acquisitions-units.units.collection.get'
],
sources: [
{
type: 'db',
Expand Down Expand Up @@ -34,6 +37,11 @@
${tenant_id}_mod_orders_storage.f_unaccent (:sourceAlias.jsonb->>'name'::text)\
)",
valueFunction: 'lower(${tenant_id}_mod_orders_storage.f_unaccent (:value))',
valueSourceApi: {
path: 'acquisitions-units/units',
valueJsonPath: '$.acquisitionsUnits.*.id',
labelJsonPath: '$.acquisitionsUnits.*.name'
},
},
{
name: 'description',
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
${tenant_id}_mod_users.f_unaccent (:sourceAlias.jsonb->>'name'::text)\
)",
valueFunction: 'lower(${tenant_id}_mod_users.f_unaccent (:value))',
valueSourceApi: {
path: 'departments',
labelJsonPath: '$.departments.*.name',
valueJsonPath: '$.departments.*.id',
},
},
{
name: 'code',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,8 @@
{
name: 'departments',
source: {
columnName: 'departments',
entityTypeId: 'bb058933-cd06-4539-bd3a-6f248ff98ee2',
columnName: 'name',
entityTypeId: 'f067beda-cbeb-4423-9a0d-3b59fb329ce2',
},
dataType: {
dataType: 'jsonbArrayType',
Expand Down

0 comments on commit af6b885

Please sign in to comment.