Skip to content

Commit 0a7aeec

Browse files
add file ledger apis (#5507)
* add file ledger apis * remove apis about export ledgers * opt code struct * feat: update api * feat: update code * rename init-ledger script -> init-extended-props * remove useless code * POST/PUT extended-props return row * return default some fields when extended-row not exists * feat: update seafile-js version --------- Co-authored-by: er-pai-r <[email protected]>
1 parent e97b0c2 commit 0a7aeec

32 files changed

+2330
-36
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,5 @@ frontend/package-lock.json
6464
frontend/.eslintcache
6565

6666
/.idea
67+
68+
.vscode

frontend/package-lock.json

Lines changed: 38 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"i18next": "22.4.6",
2121
"i18next-browser-languagedetector": "7.0.1",
2222
"i18next-xhr-backend": "3.2.2",
23+
"is-hotkey": "0.2.0",
2324
"MD5": "^1.3.0",
2425
"moment": "^2.22.2",
2526
"object-assign": "4.1.1",
@@ -38,7 +39,7 @@
3839
"react-select": "5.7.0",
3940
"react-transition-group": "4.4.5",
4041
"reactstrap": "8.9.0",
41-
"seafile-js": "0.2.205",
42+
"seafile-js": "0.2.206",
4243
"socket.io-client": "^2.2.0",
4344
"svg-sprite-loader": "^6.0.11",
4445
"svgo-loader": "^3.0.1",
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import { Col } from 'reactstrap';
4+
5+
function ColumnName(props) {
6+
const { column } = props;
7+
const { name } = column;
8+
9+
return (
10+
<Col md={3} className="d-flex column-name">
11+
<div className="w-100 text-truncate">
12+
{name || ''}
13+
</div>
14+
</Col>
15+
);
16+
}
17+
18+
ColumnName.propTypes = {
19+
column: PropTypes.object.isRequired,
20+
};
21+
22+
export default ColumnName;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.extra-attributes-dialog .column-name {
2+
padding-top: 9px;
3+
}
4+
5+
.extra-attributes-dialog .column-item {
6+
min-height: 56px;
7+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import React, { Component } from 'react';
2+
import PropTypes from 'prop-types';
3+
import { Col } from 'reactstrap';
4+
import ColumnName from './column-name';
5+
import CONFIG from '../editor';
6+
7+
import './index.css';
8+
9+
class Column extends Component {
10+
render() {
11+
const { column, row, columns } = this.props;
12+
const Editor = CONFIG[column.type] || CONFIG['text'];
13+
14+
return (
15+
<div className="pb-4 row column-item">
16+
<ColumnName column={column} />
17+
<Col md={9} className='d-flex align-items-center extra-attribute-item-info'>
18+
<Editor
19+
column={column}
20+
row={row}
21+
columns={columns}
22+
onCommit={this.props.onCommit}
23+
/>
24+
</Col>
25+
</div>
26+
);
27+
}
28+
}
29+
30+
Column.propTypes = {
31+
column: PropTypes.object,
32+
row: PropTypes.object,
33+
columns: PropTypes.array,
34+
onCommit: PropTypes.func,
35+
};
36+
37+
export default Column;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React, { Component } from 'react';
2+
import PropTypes from 'prop-types';
3+
import { getDateDisplayString } from '../../../../utils/extra-attributes';
4+
5+
class CtimeFormatter extends Component {
6+
render() {
7+
const { column, row } = this.props;
8+
const { key } = column;
9+
const value = getDateDisplayString(row[key], 'YYYY-MM-DD HH:mm:ss') || '';
10+
11+
return (
12+
<div className="form-control" style={{ width: 320 }}>{value}</div>
13+
);
14+
}
15+
}
16+
17+
CtimeFormatter.propTypes = {
18+
column: PropTypes.object,
19+
row: PropTypes.object,
20+
};
21+
22+
export default CtimeFormatter;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import React, { Component } from 'react';
2+
import PropTypes from 'prop-types';
3+
import { getDateDisplayString } from '../../../../utils/extra-attributes';
4+
5+
6+
class DateEditor extends Component {
7+
render() {
8+
const { column, row } = this.props;
9+
const { data, key } = column;
10+
const value = getDateDisplayString(row[key], data ? data.format : '');
11+
12+
return (
13+
<input
14+
type="text"
15+
className="form-control"
16+
value={value}
17+
disabled={true}
18+
/>
19+
);
20+
}
21+
}
22+
23+
DateEditor.propTypes = {
24+
column: PropTypes.object,
25+
row: PropTypes.object,
26+
};
27+
28+
export default DateEditor;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import { FORMULA_RESULT_TYPE } from '../../../../constants';
4+
import { getDateDisplayString } from '../../../../utils/extra-attributes';
5+
6+
function FormulaFormatter(props) {
7+
const { column, row } = props;
8+
const value = row[column.key];
9+
10+
const { data } = column;
11+
const { result_type, format } = data || {};
12+
if (result_type === FORMULA_RESULT_TYPE.DATE) {
13+
return (
14+
<div className="form-control disabled">{getDateDisplayString(value, format)}</div>
15+
);
16+
}
17+
if (result_type === FORMULA_RESULT_TYPE.STRING) {
18+
return value;
19+
}
20+
if (typeof value === 'object') {
21+
return null;
22+
}
23+
return <></>;
24+
}
25+
26+
FormulaFormatter.propTypes = {
27+
column: PropTypes.object,
28+
row: PropTypes.object,
29+
};
30+
31+
export default FormulaFormatter;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import SimpleText from './simple-text';
2+
import FormulaFormatter from './formula-formatter';
3+
import SingleSelect from './single-select';
4+
import NumberEditor from './number-editor';
5+
import DateEditor from './date-editor';
6+
import CtimeFormatter from './ctime-formatter';
7+
import { EXTRA_ATTRIBUTES_COLUMN_TYPE } from '../../../../constants';
8+
9+
10+
const CONFIG = {
11+
[EXTRA_ATTRIBUTES_COLUMN_TYPE.TEXT]: SimpleText,
12+
[EXTRA_ATTRIBUTES_COLUMN_TYPE.FORMULA]: FormulaFormatter,
13+
[EXTRA_ATTRIBUTES_COLUMN_TYPE.SINGLE_SELECT]: SingleSelect,
14+
[EXTRA_ATTRIBUTES_COLUMN_TYPE.NUMBER]: NumberEditor,
15+
[EXTRA_ATTRIBUTES_COLUMN_TYPE.DATE]: DateEditor,
16+
[EXTRA_ATTRIBUTES_COLUMN_TYPE.CTIME]: CtimeFormatter,
17+
[EXTRA_ATTRIBUTES_COLUMN_TYPE.MTIME]: CtimeFormatter,
18+
};
19+
20+
export default CONFIG;

0 commit comments

Comments
 (0)