Skip to content

Commit

Permalink
fix(analyticstablehooks): Adds analytics table hooks to the Maintenan…
Browse files Browse the repository at this point in the history
…ce app (#2930)

* fix(analyticstablehooks): Adds analytics table hooks to the Maintenance app

* fix: add scroll to sidebar, move predictors back to other

* fix(analyticstablehooks): Slightly better dynamic form and slightly better label language

---------

Co-authored-by: Birk Johansson <[email protected]>
  • Loading branch information
benguaraldi and Birkbjo authored Sep 9, 2024
1 parent 6e9e1ed commit 1b70c09
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/SideBar/SideBarContainer.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ class SideBarContainer extends React.Component {
position: 'fixed',
bottom: '0',
top: '7rem',
overflow: 'auto',
};

return (
Expand Down
7 changes: 7 additions & 0 deletions src/config/field-config/field-order.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,13 @@ const fieldOrderByName = new Map([
'description',
'keywords',
]],
['analyticsTableHook', [
'name',
'phase',
'resourceTableType',
'analyticsTableType',
'sql',
]],
]);

export default {
Expand Down
10 changes: 10 additions & 0 deletions src/config/field-overrides/analyticsTableHook.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import SqlQuery from './sql-query';

export default new Map([
[
'sql',
{
component: SqlQuery,
},
],
]);
2 changes: 2 additions & 0 deletions src/config/field-overrides/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import sqlView from './sqlView';
import optionGroupSet from './optionGroupSet';
import eventProgramStage from './eventProgramStage';
import icon from './icon.js'
import analyticsTableHook from './analyticsTableHook'

const overridesByType = {
attribute,
Expand Down Expand Up @@ -69,6 +70,7 @@ const overridesByType = {
optionGroup,
optionGroupSet,
sqlView,
analyticsTableHook,
};

export default {
Expand Down
34 changes: 34 additions & 0 deletions src/config/field-rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,40 @@ export default new Map([
}],
},
]],
['analyticsTableHook', [
{
field: 'resourceTableType',
when: {
field: 'phase',
operator: 'PREDICATE',
value: (phase) => phase === 'ANALYTICS_TABLE_POPULATED'
},
operations: [{
type: 'HIDE_FIELD',
}, {
type: 'CHANGE_VALUE',
setValue: (model, fieldConfig) => {
fieldConfig.value = model[fieldConfig.name] = undefined;
},
}],
},
{
field: 'analyticsTableType',
when: {
field: 'phase',
operator: 'PREDICATE',
value: (phase) => phase === 'RESOURCE_TABLE_POPULATED'
},
operations: [{
type: 'HIDE_FIELD',
}, {
type: 'CHANGE_VALUE',
setValue: (model, fieldConfig) => {
fieldConfig.value = model[fieldConfig.name] = undefined;
},
}],
},
]],
['relationshipType', [
{
field: 'toFromName',
Expand Down
19 changes: 10 additions & 9 deletions src/config/maintenance-models.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,22 @@ export function getSideBarConfig() {

otherSection: {
items: [
'constant',
'analyticsTableHook',
'attribute',
'optionSet',
'constant',
'dataApprovalLevel',
'dataApprovalWorkflow',
'externalMapLayer',
'icon',
'legendSet',
'locale',
'optionGroup',
'optionGroupSet',
'legendSet',
'optionSet',
'predictor',
'predictorGroup',
'pushAnalysis',
'externalMapLayer',
'dataApprovalLevel',
'dataApprovalWorkflow',
'locale',
'sqlView',
'icon',
],
},
};
Expand Down Expand Up @@ -302,7 +303,7 @@ export function getDefaultFiltersForType(modelType) {
}

export function getAdditionalFieldsForType(modelType) {
if (typeDetails.hasOwnProperty(modelType) &&
if (typeDetails.hasOwnProperty(modelType) &&
typeDetails[modelType].hasOwnProperty('additionalFields')
) {
return typeDetails[modelType].additionalFields;
Expand Down
21 changes: 21 additions & 0 deletions src/i18n/i18n_module_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2368,3 +2368,24 @@ save_the_program_in_order_to_access_sharing_settings=Save the program in order t
confirm_delete_icon=Are you sure you want to delete this icon?
intro_icon=Upload, modify and view icons which can be used assigned to other metadata.
skip_in_analytics=Skip in analytics
analytics_table_hook=Analytics table hooks
intro_analytics_table_hook=Configure hooks in SQL that run during the analytics process
analytics_table_hook_management=Analytics table hooks management
phase=Phase that the SQL script should be invoked
resource_table_populated=After the temporary resource tables have been populated
analytics_table_populated=After the temporary analytics tables have been populated
resource_table_type=Resource table
org_unit_structure=Organisation unit structure
data_set_org_unit_category=Data set organisation unit category
category_option_combo_name=Category option combo name
org_unit_group_set_structure=Organisation unit group set structure
data_approval_remap_level=Data approval remap level
data_approval_min_level=Data approval minimum level
analytics_table_type=Analytics table
data_value=Data value
completeness=Completeness
completeness_target=Completeness target
org_unit_target=Organisation unit target
ownership=Ownership
validation_result=Validation result
sql=SQL

0 comments on commit 1b70c09

Please sign in to comment.