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

feat(detailsPanel): add detailsPanel in list-view #358

Merged
merged 54 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
fe4bdfa
feat(datastore): add hook for accessing datastore
Birkbjo Aug 17, 2023
f53db76
fix(types): fix types for section handle
Birkbjo Aug 17, 2023
6231edb
feat(constants): add constants for columns and translated properties
Birkbjo Aug 18, 2023
29dad8a
fix: update types for sectionlistcolumns
Birkbjo Aug 18, 2023
5702039
fix: add selector to usedatastore
Birkbjo Aug 18, 2023
3156dd1
feat(managecolumns): manage columns implementation
Birkbjo Aug 18, 2023
8a08d34
fix: integrate selectedcoluns with list
Birkbjo Aug 18, 2023
fd3b02c
fix: mergecolumns
Birkbjo Aug 18, 2023
a7c1c6c
fix: managecolumns style
Birkbjo Aug 19, 2023
8ee8c0a
refactor: managecolumns
Birkbjo Aug 21, 2023
38f22e6
chore: add remeda util lib
Birkbjo Aug 22, 2023
befd522
refactor: refactor to config for listviews
Birkbjo Aug 22, 2023
e799d2b
refactor: manage list view
Birkbjo Sep 5, 2023
fbb1a20
fix: respect order of selected columns
Birkbjo Sep 6, 2023
d3c4625
fix(datastore): always use put for datastore
Birkbjo Sep 6, 2023
c39fd99
Merge branch 'master' into DHIS2-15562/manage-columns
Birkbjo Sep 12, 2023
14c7c05
refactor: allow arbitrary path as column
Birkbjo Sep 14, 2023
4858135
refactor: remove remeda, implement uniqueBy
Birkbjo Sep 14, 2023
5df49bd
fix: add uniqueBy
Birkbjo Sep 14, 2023
dbc4f82
fix: add test for path
Birkbjo Sep 14, 2023
0f6efc0
fix: add maxDepth to getFieldFilterFromPath
Birkbjo Sep 14, 2023
a88586e
fix: fix some tests
Birkbjo Sep 14, 2023
85dff70
fix: remove typepath file
Birkbjo Sep 14, 2023
2d07750
refactor: cleanup
Birkbjo Sep 26, 2023
63ae5b9
fix(constants): prevent circular dependency (#354)
Mohammer5 Sep 27, 2023
f767ac2
fix(managelistview): enforce at least one column
Birkbjo Sep 28, 2023
02e96ea
refactor: rename DataStoreModelListView schema
Birkbjo Sep 29, 2023
ebe3c28
refactor: rename useDataStoreValuesQuery
Birkbjo Sep 29, 2023
c34f3ba
Merge branch 'master' into DHIS2-15562/manage-columns
Birkbjo Sep 29, 2023
5f3aae3
refactor(modelvale): simplify modelvalue
Birkbjo Oct 10, 2023
25568ed
fix: fix imports
Birkbjo Oct 10, 2023
ebec718
refactor: remove component from list config
Birkbjo Oct 11, 2023
cc8de37
fix: fix tests
Birkbjo Oct 11, 2023
b1551c0
refactor: minor cleanup
Birkbjo Oct 11, 2023
8d18a7a
Merge branch 'master' into DHIS2-15562/manage-columns
Birkbjo Oct 12, 2023
438c64c
feat(detailpanel): initial detailsPanel implementation
Birkbjo Oct 13, 2023
cf1f18e
refactor(detailspanel): cleanup details panel implementation, add err…
Birkbjo Oct 13, 2023
7ac06cd
fix: responsive layout with detailspanel
Birkbjo Oct 13, 2023
f3da8ed
refactor: fix wrong name of sectionlistheader
Birkbjo Oct 13, 2023
6771447
refactor: minor cleanup
Birkbjo Oct 13, 2023
c4ccbb5
fix: fix id missing in details response
Birkbjo Oct 13, 2023
66f56e9
fix: add ui to resolution for alpha version
Birkbjo Oct 16, 2023
01c3401
fix: fix type errors
Birkbjo Oct 19, 2023
5b7b519
Merge branch 'master' into DHIS2-14652/feat/details-panel
Birkbjo Oct 20, 2023
5e4e8f9
refactor(details): make detailspanelcontent more composable
Birkbjo Oct 20, 2023
2e01ab4
fix(details): use correct property for lastUpdated
Birkbjo Oct 21, 2023
dead6f4
fix(details): add lastupdatedby
Birkbjo Oct 25, 2023
7fd98e3
fix(details): add createdBy, fallback to created if no lastUpdatedBy
Birkbjo Nov 6, 2023
8cb0c0c
fix(list): list header as grid-member
Birkbjo Nov 20, 2023
ea703c9
fix(test): fix failing test
Birkbjo Nov 21, 2023
b3d0899
chore(deps): update ui alpha version
Birkbjo Nov 21, 2023
983c653
fix(types): fix wrong types
Birkbjo Nov 21, 2023
503cc90
Merge branch 'master' into DHIS2-14652/feat/details-panel
Birkbjo Nov 21, 2023
148b322
Merge branch 'master' into DHIS2-14652/feat/details-panel
Birkbjo Nov 22, 2023
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
3 changes: 0 additions & 3 deletions global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ declare module '@dhis2/d2-i18n' {
export function exists(key: string): boolean
}

declare module '@dhis2/ui'
declare module '@dhis2/ui-icons'

declare module '*.bmp' {
const src: string
export default src
Expand Down
73 changes: 41 additions & 32 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: 2023-10-11T10:29:42.492Z\n"
"PO-Revision-Date: 2023-10-11T10:29:42.492Z\n"
"POT-Creation-Date: 2023-10-20T09:42:02.072Z\n"
"PO-Revision-Date: 2023-10-20T09:42:02.072Z\n"

msgid "schemas"
msgstr "schemas"
Expand Down Expand Up @@ -81,6 +81,15 @@ msgstr "Option set"
msgid "Actions"
msgstr "Actions"

msgid "New"
msgstr "New"

msgid "Download"
msgstr "Download"

msgid "Manage Columns"
msgstr "Manage Columns"

msgid "There aren't any items that match your filter."
msgstr "There aren't any items that match your filter."

Expand All @@ -93,14 +102,38 @@ msgstr "An error occurred while loading the items."
msgid "{{modelName}} management"
msgstr "{{modelName}} management"

msgid "New"
msgstr "New"
msgid "Short name"
msgstr "Short name"

msgid "Download"
msgstr "Download"
msgid "Code"
msgstr "Code"

msgid "Manage Columns"
msgstr "Manage Columns"
msgid "Created"
msgstr "Created"

msgid "Last updated"
msgstr "Last updated"

msgid "Id"
msgstr "Id"

msgid "API URL"
msgstr "API URL"

msgid "API URL link"
msgstr "API URL link"

msgid "Copy"
msgstr "Copy"

msgid "Edit"
msgstr "Edit"

msgid "Details"
msgstr "Details"

msgid "Failed to load details"
msgstr "Failed to load details"

msgid "Type to filter options"
msgstr "Type to filter options"
Expand Down Expand Up @@ -552,42 +585,24 @@ msgstr "Image"
msgid "GeoJSON"
msgstr "GeoJSON"

msgid "Code"
msgstr "Code"

msgid "Created by"
msgstr "Created by"

msgid "Favorite"
msgstr "Favorite"

msgid "Href"
msgstr "Href"

msgid "Id"
msgstr "Id"

msgid "Last updated by"
msgstr "Last updated by"

msgid "Created"
msgstr "Created"

msgid "Domain type"
msgstr "Domain type"

msgid "Last updated"
msgstr "Last updated"

msgid "Name"
msgstr "Name"

msgid "Sharing"
msgstr "Sharing"

msgid "Short name"
msgstr "Short name"

msgid "Value type"
msgstr "Value type"

Expand Down Expand Up @@ -621,9 +636,6 @@ msgstr "{{fieldLabel}} (required)"
msgid "A data element name should be concise and easy to recognize."
msgstr "A data element name should be concise and easy to recognize."

msgid "Short name"
msgstr "Short name"

msgid "Often used in reports where space is limited"
msgstr "Often used in reports where space is limited"

Expand Down Expand Up @@ -704,9 +716,6 @@ msgstr "Refresh list"
msgid "Add new"
msgstr "Add new"

msgid "Value type"
msgstr "Value type"

msgid "The type of data that will be recorded."
msgstr "The type of data that will be recorded."

Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
"dependencies": {
"@dhis2/app-runtime": "^3.9.3",
"@dhis2/ui": "^8.14.7",
"@dhis2/ui": "8.14.2-alpha.1",
"@types/lodash": "^4.14.198",
"lodash": "^4.17.21",
"react-color": "^2.19.3",
Expand All @@ -48,5 +48,8 @@
"use-query-params": "^2.2.1",
"zod": "^3.22.2",
"zustand": "^4.4.0"
},
"resolutions": {
"@dhis2/ui": "8.14.2-alpha.1"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is alpha up2date with ui@master? I suppose that in that case this is fine, otherwise it might cause issues.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to wait until including this? Maybe in a separate PR?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah maybe you could extract the upgrade to ui@alpha and we handle adding the details panel separate from that (but we can keep the fixes for wrong prop usage here, would be a shame to have those)

}
}
6 changes: 3 additions & 3 deletions src/app/sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import i18n from '@dhis2/d2-i18n'
import { InputEventPayload } from '@dhis2/ui'
import React, { useEffect, useState, PropsWithChildren } from 'react'
import { NavLink, useLocation, matchPath } from 'react-router-dom'
import { HidePreventUnmount } from '../../components'
Expand All @@ -10,7 +11,6 @@ import {
SidenavParent,
SidenavLink,
SidenavFilter,
OnChangeInput,
} from './sidenav'

interface SidebarNavLinkProps {
Expand Down Expand Up @@ -86,8 +86,8 @@ export const Sidebar = ({ className }: { className?: string }) => {
const sidebarLinks = useSidebarLinks()
const [filterValue, setFilterValue] = useState('')

const handleFilterChange = (input: OnChangeInput) => {
setFilterValue(input.value)
const handleFilterChange = (input: InputEventPayload) => {
setFilterValue(input.value ?? '')
}

const isFiltered = filterValue !== ''
Expand Down
20 changes: 12 additions & 8 deletions src/app/sidebar/sidenav/Sidenav.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,9 @@ html {
margin-left: auto;
width: 16px;
height: 16px;
transition: transform .1s linear;
transition: transform 0.1s linear;
}
.parent-is-open .sidenav-parent-chevron {

transform: rotate(180deg);
}

Expand All @@ -82,22 +81,27 @@ html {
display: flex;
align-items: center;
}
.sidenav-link:hover,.sidenav-link a:hover {
.sidenav-link:hover,
.sidenav-link a:hover {
background: var(--sidenav-dark-bg-hover);
}
.sidenav-link:focus,.sidenav-link a:focus {
.sidenav-link:focus,
.sidenav-link a:focus {
outline: 2px solid white;
background: var(--sidenav-dark-bg-hover);
outline-offset: -2px;
}
.sidenav-link-disabled, .sidenav-link-disabled a {
.sidenav-link-disabled,
.sidenav-link-disabled a {
cursor: not-allowed;
color: var(--colors-grey500);
}
.sidenav-link-disabled:hover,.sidenav-link-disabled:hover > a {
.sidenav-link-disabled:hover,
.sidenav-link-disabled:hover > a {
background: var(--colors-grey900);
}
.sidenav-link a.active, .sidenav-link :global(.active) {
.sidenav-link a.active,
.sidenav-link :global(.active) {
font-weight: 600;
background: var(--sidenav-dark-bg-selected);
box-shadow: inset 6px 0px 0px 0px var(--colors-teal500);
Expand Down Expand Up @@ -155,4 +159,4 @@ html {
background: #131a22;
border-color: var(--colors-grey700);
box-shadow: var(--colors-grey400) 0px 0px 0px 2px inset;
}
}
17 changes: 4 additions & 13 deletions src/app/sidebar/sidenav/SidenavFilter.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,20 @@
import i18n from '@dhis2/d2-i18n'
import { Input } from '@dhis2/ui'
import { Input, InputEventPayload, InputChangeHandler } from '@dhis2/ui'
import React, { useState } from 'react'
import styles from './Sidenav.module.css'

export type OnChangeInput = {
name?: string
value: string
}
export type OnChangeCallback = (
input: OnChangeInput,
e: React.ChangeEvent<HTMLInputElement>
) => void

interface SidenavParentProps {
onChange?: OnChangeCallback
onChange?: InputChangeHandler
}

export const SidenavFilter = ({ onChange }: SidenavParentProps) => {
const [value, setValue] = useState('')

const handleChange = (
input: OnChangeInput,
input: InputEventPayload,
e: React.ChangeEvent<HTMLInputElement>
) => {
setValue(input.value)
setValue(input.value ?? '')
if (onChange) {
onChange(input, e)
}
Expand Down
1 change: 0 additions & 1 deletion src/app/sidebar/sidenav/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from './Sidenav'
export { SidenavFilter } from './SidenavFilter'
export type { OnChangeInput, OnChangeCallback } from './SidenavFilter'
2 changes: 1 addition & 1 deletion src/components/ColorAndIconPicker/ColorPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export function ColorPicker({
</div>

{showPicker && (
<Layer onBackdropClick={() => setShowPicker(false)} transparent>
<Layer onBackdropClick={() => setShowPicker(false)} translucent>
<Popper placement="bottom-start" reference={ref}>
<div className={classes.colors}>
<SwatchesPicker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,7 @@ export const SearchableSingleSelect = ({
<Input
dense
value={filter}
onChange={({ value }: { value: string }) =>
setFilterValue(value)
}
onChange={({ value }) => setFilterValue(value ?? '')}
placeholder={i18n.t('Filter options')}
/>
</div>
Expand All @@ -151,7 +149,7 @@ export const SearchableSingleSelect = ({
<SingleSelectOption key={value} value={value} label={label} />
))}

{hasSelectedInOptionList && (
{hasSelectedInOptionList && selected && (
<SingleSelectOption
className={classes.invisibleOption}
value={selected}
Expand Down
38 changes: 38 additions & 0 deletions src/components/date/ClientDateTime.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { useTimeZoneConversion } from '@dhis2/app-runtime'
import React, { useState } from 'react'
import { selectedLocale } from '../../lib'

type DateTimeFormatOptions = Intl.DateTimeFormatOptions

const defaultDateTimeFormatter = new Intl.DateTimeFormat(selectedLocale, {
dateStyle: 'medium',
timeStyle: 'medium',
})

type ClientDateTimeProps = {
value?: string
options?: DateTimeFormatOptions
}

export const ClientDateTime = ({ value, options }: ClientDateTimeProps) => {
// NOTE: options cannot change after initial render
// this is to prevent having to memo the options object in the consuming component
const [dateTimeFormatter] = useState<Intl.DateTimeFormat>(() =>
options
? new Intl.DateTimeFormat(selectedLocale, options)
: defaultDateTimeFormatter
)
const { fromServerDate } = useTimeZoneConversion()

if (!value) {
return null
}

const clientDate = fromServerDate(value)

return (
<span title={clientDate.getClientZonedISOString()}>
{dateTimeFormatter.format(clientDate)}
</span>
)
}
1 change: 1 addition & 0 deletions src/components/date/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './ClientDateTime'
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import i18n from '@dhis2/d2-i18n'
import { MultiSelect, MultiSelectOption } from '@dhis2/ui'
import { MultiSelect, MultiSelectField, MultiSelectOption } from '@dhis2/ui'

Check warning on line 2 in src/components/metadataFormControls/AggregationLevelMultiSelect/AggregationLevelMultiSelect.tsx

View workflow job for this annotation

GitHub Actions / lint

'MultiSelectField' is defined but never used
import React, { forwardRef, useImperativeHandle } from 'react'
import classes from './AggregationLevelMultiSelect.module.css'
import { useOptionsQuery } from './useOptionsQuery'
Expand Down Expand Up @@ -42,7 +42,7 @@
function AggregationLevelMultiSelect(
{
onChange,
inputWidth,

Check warning on line 45 in src/components/metadataFormControls/AggregationLevelMultiSelect/AggregationLevelMultiSelect.tsx

View workflow job for this annotation

GitHub Actions / lint

'inputWidth' is defined but never used
selected,
showAllOption,
placeholder = i18n.t('Aggregation level(s)'),
Expand All @@ -62,7 +62,6 @@

return (
<MultiSelect
inputWidth={inputWidth}
placeholder={placeholder}
onChange={({ selected }: { selected: string[] }) => {
onChange({ selected })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
optionsQuery.fetching ||
optionsQuery.loading ||
initialOptionQuery.loading
const error =

Check warning on line 85 in src/components/metadataFormControls/LegendSetTransfer/LegendSetTransfer.tsx

View workflow job for this annotation

GitHub Actions / lint

'error' is assigned a value but never used
optionsQuery.error || initialOptionQuery.error
? // @TODO: Ask Joe what do do here!
'An error has occurred. Please try again'
Expand All @@ -100,7 +100,8 @@
)

const adjustQueryParamsWithChangedFilter = useCallback(
({ value }: { value: string }) => {
({ value }: { value: string | undefined }) => {
value = value ?? ''
setSearchTerm(value)
pageRef.current = 1
refetch({ page: pageRef.current, filter: value })
Expand Down Expand Up @@ -131,7 +132,6 @@
options={displayOptions}
selected={selected}
loading={loading}
error={error}
onChange={({ selected }: { selected: string[] }) => {
const nextSelectedOptions = displayOptions.filter(({ value }) =>
selected.includes(value)
Expand Down
Loading
Loading