mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-08 22:24:23 +08:00
Merge pull request #812 from mlorb/ml-sci-1634
Fix a few style error on All teams page [SCI-1634]
This commit is contained in:
commit
25e6eb4511
4 changed files with 67 additions and 27 deletions
|
@ -1,6 +1,6 @@
|
||||||
import React, { Component } from "react";
|
import React, { Component } from "react";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import { BootstrapTable, TableHeaderColumn } from 'react-bootstrap-table';
|
import { BootstrapTable, TableHeaderColumn } from "react-bootstrap-table";
|
||||||
import styled from "styled-components";
|
import styled from "styled-components";
|
||||||
import {
|
import {
|
||||||
WHITE_COLOR,
|
WHITE_COLOR,
|
||||||
|
@ -14,7 +14,7 @@ const StyledBootstrapTable = styled(BootstrapTable)`
|
||||||
background-color: ${COLOR_GRAY};
|
background-color: ${COLOR_GRAY};
|
||||||
|
|
||||||
> tr > th,
|
> tr > th,
|
||||||
>tr > td {
|
> tr > td {
|
||||||
padding: 6px;
|
padding: 6px;
|
||||||
padding-right: 30px;
|
padding-right: 30px;
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,8 @@ const StyledBootstrapTable = styled(BootstrapTable)`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
td, th {
|
td,
|
||||||
|
th {
|
||||||
box-sizing: content-box;
|
box-sizing: content-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,14 +43,32 @@ const StyledBootstrapTable = styled(BootstrapTable)`
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.react-bs-table-pagination {
|
||||||
|
.btn {
|
||||||
|
border-radius: 4px;
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
.dropdown.show {
|
||||||
|
display: inline-block !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
class DataTable extends Component {
|
class DataTable extends Component {
|
||||||
static cleanColumnAttributes(col) {
|
static cleanColumnAttributes(col) {
|
||||||
// Remove additional attributes from the columns
|
// Remove additional attributes from the columns
|
||||||
const {
|
const {
|
||||||
id, isKey, textId, name, position, visible,
|
id,
|
||||||
sortable, locked, ...cleanCol
|
isKey,
|
||||||
|
textId,
|
||||||
|
name,
|
||||||
|
position,
|
||||||
|
visible,
|
||||||
|
sortable,
|
||||||
|
locked,
|
||||||
|
width,
|
||||||
|
...cleanCol
|
||||||
} = col;
|
} = col;
|
||||||
return cleanCol;
|
return cleanCol;
|
||||||
}
|
}
|
||||||
|
@ -62,25 +81,27 @@ class DataTable extends Component {
|
||||||
|
|
||||||
cleanProps() {
|
cleanProps() {
|
||||||
// Remove additional props from the props value
|
// Remove additional props from the props value
|
||||||
const {columns, ...cleanProps} = this.props;
|
const { columns, ...cleanProps } = this.props;
|
||||||
return cleanProps;
|
return cleanProps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
displayHeader() {
|
displayHeader() {
|
||||||
const orderedCols = this.props.columns.sort((a, b) => a.position - b.position);
|
const orderedCols = this.props.columns.sort(
|
||||||
return orderedCols.map((col) =>
|
(a, b) => a.position - b.position
|
||||||
|
);
|
||||||
|
return orderedCols.map(col => (
|
||||||
<TableHeaderColumn
|
<TableHeaderColumn
|
||||||
key={col.id}
|
key={col.id}
|
||||||
dataField={col.textId}
|
dataField={col.textId}
|
||||||
isKey={col.isKey}
|
isKey={col.isKey}
|
||||||
hidden={('visible' in col) && !col.visible}
|
hidden={"visible" in col && !col.visible}
|
||||||
dataSort={col.sortable}
|
dataSort={col.sortable}
|
||||||
|
width={col.width}
|
||||||
{...DataTable.cleanColumnAttributes(col)}
|
{...DataTable.cleanColumnAttributes(col)}
|
||||||
>
|
>
|
||||||
{col.name}
|
{col.name}
|
||||||
</TableHeaderColumn>
|
</TableHeaderColumn>
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -102,7 +123,8 @@ DataTable.propTypes = {
|
||||||
position: PropTypes.number.isRequired,
|
position: PropTypes.number.isRequired,
|
||||||
visible: PropTypes.bool,
|
visible: PropTypes.bool,
|
||||||
sortable: PropTypes.bool,
|
sortable: PropTypes.bool,
|
||||||
locked: PropTypes.bool
|
locked: PropTypes.bool,
|
||||||
|
width: PropTypes.string
|
||||||
})
|
})
|
||||||
).isRequired,
|
).isRequired,
|
||||||
data: PropTypes.arrayOf(PropTypes.object).isRequired
|
data: PropTypes.arrayOf(PropTypes.object).isRequired
|
||||||
|
|
|
@ -63,8 +63,9 @@ export default {
|
||||||
},
|
},
|
||||||
settings_page: {
|
settings_page: {
|
||||||
all_teams: "All teams",
|
all_teams: "All teams",
|
||||||
in_team: "You are member of {num} team",
|
in_team: "You are member of {num} team.",
|
||||||
in_teams: "You are member of {num} team",
|
in_teams: "You are member of {num} teams.",
|
||||||
|
shows_total_entries: "Showing {start} to {to} of {total} entries.",
|
||||||
leave_team: "Leave team",
|
leave_team: "Leave team",
|
||||||
account: "Account",
|
account: "Account",
|
||||||
team: "Team",
|
team: "Team",
|
||||||
|
|
|
@ -9,6 +9,21 @@ import DataTable from "../../../../../components/data_table";
|
||||||
import { SETTINGS_TEAMS_ROUTE } from "../../../../../config/routes";
|
import { SETTINGS_TEAMS_ROUTE } from "../../../../../config/routes";
|
||||||
|
|
||||||
class TeamsDataTable extends Component {
|
class TeamsDataTable extends Component {
|
||||||
|
static renderShowsTotal(start, to, total) {
|
||||||
|
return (
|
||||||
|
<span>
|
||||||
|
<FormattedMessage
|
||||||
|
id="settings_page.shows_total_entries"
|
||||||
|
values={{
|
||||||
|
start,
|
||||||
|
to,
|
||||||
|
total
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
|
@ -37,11 +52,7 @@ class TeamsDataTable extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
linkToTeam(name, row) {
|
linkToTeam(name, row) {
|
||||||
return (
|
return <Link to={`${SETTINGS_TEAMS_ROUTE}/${row.id}`}>{name}</Link>;
|
||||||
<Link to={`${SETTINGS_TEAMS_ROUTE}/${row.id}`}>
|
|
||||||
{name}
|
|
||||||
</Link>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -49,18 +60,21 @@ class TeamsDataTable extends Component {
|
||||||
defaultSortName: "name",
|
defaultSortName: "name",
|
||||||
defaultSortOrder: "desc",
|
defaultSortOrder: "desc",
|
||||||
sizePerPageList: [10, 25, 50, 100],
|
sizePerPageList: [10, 25, 50, 100],
|
||||||
paginationPosition: "top",
|
prePage: "Prev", // Previous page button text
|
||||||
alwaysShowAllBtns: false
|
nextPage: "Next", // Next page button textu
|
||||||
|
paginationShowsTotal: TeamsDataTable.renderShowsTotal,
|
||||||
|
alwaysShowAllBtns: true
|
||||||
};
|
};
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
name: "Name",
|
name: "Team",
|
||||||
isKey: false,
|
isKey: false,
|
||||||
textId: "name",
|
textId: "name",
|
||||||
dataFormat: this.linkToTeam,
|
dataFormat: this.linkToTeam,
|
||||||
position: 0,
|
position: 0,
|
||||||
dataSort: true
|
dataSort: true,
|
||||||
|
width: "50%"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
|
@ -68,7 +82,8 @@ class TeamsDataTable extends Component {
|
||||||
isKey: false,
|
isKey: false,
|
||||||
textId: "role",
|
textId: "role",
|
||||||
position: 1,
|
position: 1,
|
||||||
dataSort: true
|
dataSort: true,
|
||||||
|
width: "35%"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 3,
|
id: 3,
|
||||||
|
@ -76,7 +91,8 @@ class TeamsDataTable extends Component {
|
||||||
isKey: false,
|
isKey: false,
|
||||||
textId: "members",
|
textId: "members",
|
||||||
position: 2,
|
position: 2,
|
||||||
dataSort: true
|
dataSort: true,
|
||||||
|
width: "15%"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 4,
|
id: 4,
|
||||||
|
@ -84,7 +100,8 @@ class TeamsDataTable extends Component {
|
||||||
isKey: true,
|
isKey: true,
|
||||||
textId: "id",
|
textId: "id",
|
||||||
dataFormat: this.leaveTeamButton,
|
dataFormat: this.leaveTeamButton,
|
||||||
position: 3
|
position: 3,
|
||||||
|
width: "116px"
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -22,7 +22,7 @@ const Wrapper = styled.div`
|
||||||
const SettingsTeams = ({ teams }) =>
|
const SettingsTeams = ({ teams }) =>
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
<Breadcrumb>
|
<Breadcrumb>
|
||||||
<Breadcrumb.Item active={false}>
|
<Breadcrumb.Item active>
|
||||||
<FormattedMessage id="settings_page.all_teams" />
|
<FormattedMessage id="settings_page.all_teams" />
|
||||||
</Breadcrumb.Item>
|
</Breadcrumb.Item>
|
||||||
</Breadcrumb>
|
</Breadcrumb>
|
||||||
|
|
Loading…
Add table
Reference in a new issue