Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Nos Hs2023
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Språksamlingane
stadnamn
Nos Hs2023
Commits
53891dbd
Commit
53891dbd
authored
5 years ago
by
esikkala
Browse files
Options
Downloads
Patches
Plain Diff
Add expandable content to result table cells
parent
83f392b8
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/client/components/facet_results/ResultTable.js
+37
-31
37 additions, 31 deletions
src/client/components/facet_results/ResultTable.js
src/client/components/facet_results/ResultTableCell.js
+21
-10
21 additions, 10 deletions
src/client/components/facet_results/ResultTableCell.js
with
58 additions
and
41 deletions
src/client/components/facet_results/ResultTable.js
+
37
−
31
View file @
53891dbd
...
...
@@ -46,7 +46,8 @@ const styles = theme => ({
},
expandCell
:
{
paddingRight
:
0
,
//paddingLeft: 0
paddingTop
:
0
,
paddingBottom
:
0
},
expand
:
{
transform
:
'
rotate(0deg)
'
,
...
...
@@ -74,7 +75,6 @@ class ResultTable extends React.Component {
page
=
this
.
props
.
data
.
page
===
-
1
?
0
:
this
.
props
.
data
.
page
;
// console.log(`result table mounted WITHOUT page parameter, set page to ${page}`);
}
else
{
const
qs
=
this
.
props
.
routeProps
.
location
.
search
.
replace
(
'
?
'
,
''
);
page
=
parseInt
(
querystring
.
parse
(
qs
).
page
);
// console.log(`result table mounted with page parameter, set page to ${page}`);
...
...
@@ -140,7 +140,6 @@ class ResultTable extends React.Component {
}
handleExpandRow
=
rowId
=>
()
=>
{
console
.
log
(
rowId
);
let
expandedRows
=
this
.
state
.
expandedRows
;
if
(
expandedRows
.
has
(
rowId
))
{
expandedRows
.
delete
(
rowId
);
...
...
@@ -152,38 +151,45 @@ class ResultTable extends React.Component {
rowRenderer
=
row
=>
{
const
{
classes
}
=
this
.
props
;
//console.log(this.state.expandedRows)
const
expanded
=
this
.
state
.
expandedRows
.
has
(
row
.
id
);
let
hasExpandableContent
=
false
;
const
dataCells
=
this
.
props
.
data
.
tableColumns
.
map
(
column
=>
{
const
columnData
=
row
[
column
.
id
];
if
(
Array
.
isArray
(
columnData
))
{
hasExpandableContent
=
true
;
}
return
(
<
ResultTableCell
key
=
{
column
.
id
}
columnId
=
{
column
.
id
}
data
=
{
row
[
column
.
id
]
==
null
?
'
-
'
:
row
[
column
.
id
]}
valueType
=
{
column
.
valueType
}
makeLink
=
{
column
.
makeLink
}
sortValues
=
{
column
.
sortValues
}
numberedList
=
{
column
.
numberedList
}
minWidth
=
{
column
.
minWidth
}
container
=
'
cell
'
expanded
=
{
expanded
}
/
>
);
});
return
(
<
TableRow
key
=
{
row
.
id
}
>
<
TableCell
className
=
{
classes
.
expandCell
}
>
<
IconButton
className
=
{
clsx
(
classes
.
expand
,
{
[
classes
.
expandOpen
]:
expanded
,
})}
onClick
=
{
this
.
handleExpandRow
(
row
.
id
)}
aria
-
expanded
=
{
expanded
}
aria
-
label
=
"
Show more
"
>
<
ExpandMoreIcon
/>
<
/IconButton
>
{
hasExpandableContent
&&
<
IconButton
className
=
{
clsx
(
classes
.
expand
,
{
[
classes
.
expandOpen
]:
expanded
,
})}
onClick
=
{
this
.
handleExpandRow
(
row
.
id
)}
aria
-
expanded
=
{
expanded
}
aria
-
label
=
"
Show more
"
>
<
ExpandMoreIcon
/>
<
/IconButton
>
}
<
/TableCell
>
{
this
.
props
.
data
.
tableColumns
.
map
(
column
=>
{
return
(
<
ResultTableCell
key
=
{
column
.
id
}
columnId
=
{
column
.
id
}
data
=
{
row
[
column
.
id
]
==
null
?
'
-
'
:
row
[
column
.
id
]}
valueType
=
{
column
.
valueType
}
makeLink
=
{
column
.
makeLink
}
sortValues
=
{
column
.
sortValues
}
numberedList
=
{
column
.
numberedList
}
minWidth
=
{
column
.
minWidth
}
container
=
'
cell
'
expanded
=
{
expanded
}
/
>
);
})}
{
dataCells
}
<
/TableRow
>
);
}
...
...
@@ -201,7 +207,7 @@ class ResultTable extends React.Component {
count
=
{
resultCount
}
rowsPerPage
=
{
pagesize
}
rowsPerPageOptions
=
{[
5
]}
page
=
{
page
==
-
1
?
0
:
page
}
page
=
{
page
==
-
1
||
resultCount
==
0
?
0
:
page
}
onChangePage
=
{
this
.
handleChangePage
}
onChangeRowsPerPage
=
{
this
.
handleOnchangeRowsPerPage
}
ActionsComponent
=
{
ResultTablePaginationActions
}
...
...
This diff is collapsed.
Click to expand it.
src/client/components/facet_results/ResultTableCell.js
+
21
−
10
View file @
53891dbd
...
...
@@ -4,7 +4,7 @@ import { sortBy, orderBy, has } from 'lodash';
import
TableCell
from
'
@material-ui/core/TableCell
'
;
import
{
withStyles
}
from
'
@material-ui/core/styles
'
;
import
Collapse
from
'
@material-ui/core/Collapse
'
;
import
Typography
from
'
@material-ui/core/Typography
'
;
//
import Typography from '@material-ui/core/Typography';
const
styles
=
()
=>
({
valueList
:
{
...
...
@@ -42,12 +42,12 @@ const ResultTableCell = props => {
return
'
-
'
;
}
else
if
(
Array
.
isArray
(
cell
))
{
if
(
props
.
columnId
==
'
t
imespan
'
)
{
if
(
props
.
columnId
==
'
productionT
imespan
'
)
{
cell
=
sortValues
?
sortBy
(
cell
,
obj
=>
Number
(
obj
.
start
))
:
cell
;
}
else
{
cell
=
sortValues
?
orderBy
(
cell
,
'
prefLabel
'
)
:
cell
;
}
const
firstValue
=
cell
[
0
];
const
listItems
=
cell
.
map
((
item
,
i
)
=>
<
li
key
=
{
i
}
>
{
makeLink
&&
...
...
@@ -69,9 +69,23 @@ const ResultTableCell = props => {
);
}
else
{
return
(
<
ul
className
=
{
props
.
classes
.
valueList
}
>
{
listItems
}
<
/ul
>
<
React
.
Fragment
>
{
!
props
.
expanded
&&
!
makeLink
&&
<
span
>
{
firstValue
.
prefLabel
}
...
<
/span>
}
{
!
props
.
expanded
&&
makeLink
&&
<
a
target
=
'
_blank
'
rel
=
'
noopener noreferrer
'
href
=
{
firstValue
.
dataProviderUrl
}
>
{
firstValue
.
prefLabel
}
...
<
/a
>
}
<
Collapse
in
=
{
props
.
expanded
}
timeout
=
"
auto
"
unmountOnExit
>
<
ul
className
=
{
props
.
classes
.
valueList
}
>
{
listItems
}
<
/ul
>
<
/Collapse
>
<
/React.Fragment
>
);
}
}
else
if
(
makeLink
)
{
...
...
@@ -181,7 +195,7 @@ const ResultTableCell = props => {
};
const
{
data
,
valueType
,
makeLink
,
sortValues
,
numberedList
,
minWidth
,
container
,
expanded
}
=
props
;
container
}
=
props
;
let
renderer
=
null
;
let
cellStyle
=
minWidth
==
null
?
{}
:
{
minWidth
:
minWidth
};
switch
(
valueType
)
{
...
...
@@ -209,9 +223,6 @@ const ResultTableCell = props => {
return
(
<
TableCell
style
=
{
cellStyle
}
>
{
renderer
(
data
,
makeLink
,
sortValues
,
numberedList
)}
<
Collapse
in
=
{
expanded
}
timeout
=
"
auto
"
unmountOnExit
>
<
Typography
>
expanded
content
<
/Typography
>
<
/Collapse
>
<
/TableCell
>
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment