Skip to content

Commit

Permalink
refactor: cleanup viewconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
Birkbjo committed Mar 1, 2024
1 parent b506bae commit e0329f0
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 54 deletions.
76 changes: 41 additions & 35 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2024-01-28T22:30:49.498Z\n"
"PO-Revision-Date: 2024-01-28T22:30:49.498Z\n"
"POT-Creation-Date: 2024-03-01T17:52:14.520Z\n"
"PO-Revision-Date: 2024-03-01T17:52:14.520Z\n"

msgid "schemas"
msgstr "schemas"
Expand Down Expand Up @@ -66,6 +66,12 @@ msgstr "All"
msgid "Filter options"
msgstr "Filter options"

msgid "Something went wrong when submitting the form"
msgstr "Something went wrong when submitting the form"

msgid "Save and close"
msgstr "Save and close"

msgid "Failed to load {{label}}"
msgstr "Failed to load {{label}}"

Expand Down Expand Up @@ -99,8 +105,8 @@ msgstr "New"
msgid "Download"
msgstr "Download"

msgid "Manage Columns"
msgstr "Manage Columns"
msgid "Manage View"
msgstr "Manage View"

msgid "There aren't any items that match your filter."
msgstr "There aren't any items that match your filter."
Expand Down Expand Up @@ -168,26 +174,41 @@ msgstr "Data set"
msgid "Search by name, code or ID"
msgstr "Search by name, code or ID"

msgid "Public access"
msgstr "Public access"

msgid "At least one column must be selected"
msgstr "At least one column must be selected"

msgid "Available table columns"
msgstr "Available table columns"
msgid "At least one filter must be selected"
msgstr "At least one filter must be selected"

msgid "Selected table columns"
msgstr "Selected table columns"
msgid "An unknown error occurred"
msgstr "An unknown error occurred"

msgid "Reset to default columns"
msgstr "Reset to default columns"
msgid "Available columns"
msgstr "Available columns"

msgid "Selected columns"
msgstr "Selected columns"

msgid "Available filters"
msgstr "Available filters"

msgid "Selected filters"
msgstr "Selected filters"

msgid "Failed to save"
msgstr "Failed to save"

msgid "Manage {{section}} table columns"
msgstr "Manage {{section}} table columns"
msgid "Reset to default"
msgstr "Reset to default"

msgid "Update table columns"
msgstr "Update table columns"
msgid "Manage {{section}} view"
msgstr "Manage {{section}} view"

msgid "Update view"
msgstr "Update view"

msgid "Public can edit"
msgstr "Public can edit"
Expand All @@ -198,21 +219,6 @@ msgstr "Public can view"
msgid "Public cannot access"
msgstr "Public cannot access"

msgid "Public access"
msgstr "Public access"

msgid "Hello available public"
msgstr "Hello available public"

msgid "Domain"
msgstr "Domain"

msgid "Value type"
msgstr "Value type"

msgid "Hello public"
msgstr "Hello public"

msgid "Category"
msgstr "Category"

Expand Down Expand Up @@ -618,6 +624,9 @@ msgstr "Name"
msgid "Sharing"
msgstr "Sharing"

msgid "Value type"
msgstr "Value type"

msgid "Owner"
msgstr "Owner"

Expand All @@ -633,12 +642,6 @@ msgstr "Required"
msgid "Custom attributes"
msgstr "Custom attributes"

msgid "Something went wrong when submitting the form"
msgstr "Something went wrong when submitting the form"

msgid "Save and close"
msgstr "Save and close"

msgid "Exit without saving"
msgstr "Exit without saving"

Expand Down Expand Up @@ -682,6 +685,9 @@ msgstr "Description"
msgid "Explain the purpose of this data element and how it's measured."
msgstr "Explain the purpose of this data element and how it's measured."

msgid "Domain"
msgstr "Domain"

msgid "A data element can either be aggregated or tracked data."
msgstr "A data element can either be aggregated or tracked data."

Expand Down
1 change: 1 addition & 0 deletions src/lib/constants/translatedModelProperties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const TRANSLATED_PROPERTY: Record<string, string> = {
lastUpdatedBy: i18n.t('Last updated by'),
created: i18n.t('Created'),
domainType: i18n.t('Domain type'),
dataSet: i18n.t('Data set'),
lastUpdated: i18n.t('Last updated'),
name: i18n.t('Name'),
sharing: i18n.t('Sharing'),
Expand Down
29 changes: 10 additions & 19 deletions src/lib/sectionList/listViews/sectionListViewsConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ export interface FilterDescriptor {
filterKey: ConfigurableFilterKey
}

type Descriptor =
| (ModelPropertyDescriptor & Partial<FilterDescriptor>)
| (FilterDescriptor & Partial<ModelPropertyDescriptor>)

/* Configs can either define the label and filterKey, or a string
If config is a string, getTranslatedProperty will be used to get the label. */

Expand All @@ -36,20 +40,12 @@ export type SectionListViewConfig<Key extends string = string> = {
}

const DESCRIPTORS = {
publicAccess: { path: 'sharing.public', label: i18n.t('Public access') },
} satisfies Record<string, ModelPropertyDescriptor>

const FILTERS = {
categoryCombo: {
filterKey: 'categoryCombo',
label: i18n.t('Category combo'),
},
dataSet: { filterKey: 'dataSet', label: i18n.t('Data set') },
publicAccess: {
filterKey: 'publicAccess',
path: 'sharing.public',
label: i18n.t('Public access'),
filterKey: 'publicAccess',
},
} satisfies Record<string, FilterDescriptor>
} satisfies Record<string, Descriptor>

// This is the default views, and can be overriden per section in modelListViewsConfig below
export const defaultModelViewConfig = {
Expand Down Expand Up @@ -86,7 +82,7 @@ export const defaultModelViewConfig = {
export const modelListViewsConfig = {
dataElement: {
columns: {
available: ['zeroIsSignificant', DESCRIPTORS.publicAccess],
available: ['zeroIsSignificant'],
default: [
'name',
{ label: i18n.t('Domain type'), path: 'domainType' },
Expand All @@ -97,13 +93,8 @@ export const modelListViewsConfig = {
],
},
filters: {
default: [
'domainType',
'valueType',
FILTERS.dataSet,
'categoryCombo',
],
available: ['categoryCombo', FILTERS.publicAccess],
default: ['domainType', 'valueType', 'dataSet', 'categoryCombo'],
available: [DESCRIPTORS.publicAccess],
},
},
} satisfies SectionListViewConfig

0 comments on commit e0329f0

Please sign in to comment.