Skip to content

Commit

Permalink
add file ledger apis (#5507)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
AlexCXC and YangGuoXuan-0503 authored Jul 27, 2023
1 parent e97b0c2 commit 0a7aeec
Show file tree
Hide file tree
Showing 32 changed files with 2,330 additions and 36 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,5 @@ frontend/package-lock.json
frontend/.eslintcache

/.idea

.vscode
68 changes: 38 additions & 30 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"i18next": "22.4.6",
"i18next-browser-languagedetector": "7.0.1",
"i18next-xhr-backend": "3.2.2",
"is-hotkey": "0.2.0",
"MD5": "^1.3.0",
"moment": "^2.22.2",
"object-assign": "4.1.1",
Expand All @@ -38,7 +39,7 @@
"react-select": "5.7.0",
"react-transition-group": "4.4.5",
"reactstrap": "8.9.0",
"seafile-js": "0.2.205",
"seafile-js": "0.2.206",
"socket.io-client": "^2.2.0",
"svg-sprite-loader": "^6.0.11",
"svgo-loader": "^3.0.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Col } from 'reactstrap';

function ColumnName(props) {
const { column } = props;
const { name } = column;

return (
<Col md={3} className="d-flex column-name">
<div className="w-100 text-truncate">
{name || ''}
</div>
</Col>
);
}

ColumnName.propTypes = {
column: PropTypes.object.isRequired,
};

export default ColumnName;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.extra-attributes-dialog .column-name {
padding-top: 9px;
}

.extra-attributes-dialog .column-item {
min-height: 56px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Col } from 'reactstrap';
import ColumnName from './column-name';
import CONFIG from '../editor';

import './index.css';

class Column extends Component {
render() {
const { column, row, columns } = this.props;
const Editor = CONFIG[column.type] || CONFIG['text'];

return (
<div className="pb-4 row column-item">
<ColumnName column={column} />
<Col md={9} className='d-flex align-items-center extra-attribute-item-info'>
<Editor
column={column}
row={row}
columns={columns}
onCommit={this.props.onCommit}
/>
</Col>
</div>
);
}
}

Column.propTypes = {
column: PropTypes.object,
row: PropTypes.object,
columns: PropTypes.array,
onCommit: PropTypes.func,
};

export default Column;
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { getDateDisplayString } from '../../../../utils/extra-attributes';

class CtimeFormatter extends Component {
render() {
const { column, row } = this.props;
const { key } = column;
const value = getDateDisplayString(row[key], 'YYYY-MM-DD HH:mm:ss') || '';

return (
<div className="form-control" style={{ width: 320 }}>{value}</div>
);
}
}

CtimeFormatter.propTypes = {
column: PropTypes.object,
row: PropTypes.object,
};

export default CtimeFormatter;
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { getDateDisplayString } from '../../../../utils/extra-attributes';


class DateEditor extends Component {
render() {
const { column, row } = this.props;
const { data, key } = column;
const value = getDateDisplayString(row[key], data ? data.format : '');

return (
<input
type="text"
className="form-control"
value={value}
disabled={true}
/>
);
}
}

DateEditor.propTypes = {
column: PropTypes.object,
row: PropTypes.object,
};

export default DateEditor;
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from 'react';
import PropTypes from 'prop-types';
import { FORMULA_RESULT_TYPE } from '../../../../constants';
import { getDateDisplayString } from '../../../../utils/extra-attributes';

function FormulaFormatter(props) {
const { column, row } = props;
const value = row[column.key];

const { data } = column;
const { result_type, format } = data || {};
if (result_type === FORMULA_RESULT_TYPE.DATE) {
return (
<div className="form-control disabled">{getDateDisplayString(value, format)}</div>
);
}
if (result_type === FORMULA_RESULT_TYPE.STRING) {
return value;
}
if (typeof value === 'object') {
return null;
}
return <></>;
}

FormulaFormatter.propTypes = {
column: PropTypes.object,
row: PropTypes.object,
};

export default FormulaFormatter;
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import SimpleText from './simple-text';
import FormulaFormatter from './formula-formatter';
import SingleSelect from './single-select';
import NumberEditor from './number-editor';
import DateEditor from './date-editor';
import CtimeFormatter from './ctime-formatter';
import { EXTRA_ATTRIBUTES_COLUMN_TYPE } from '../../../../constants';


const CONFIG = {
[EXTRA_ATTRIBUTES_COLUMN_TYPE.TEXT]: SimpleText,
[EXTRA_ATTRIBUTES_COLUMN_TYPE.FORMULA]: FormulaFormatter,
[EXTRA_ATTRIBUTES_COLUMN_TYPE.SINGLE_SELECT]: SingleSelect,
[EXTRA_ATTRIBUTES_COLUMN_TYPE.NUMBER]: NumberEditor,
[EXTRA_ATTRIBUTES_COLUMN_TYPE.DATE]: DateEditor,
[EXTRA_ATTRIBUTES_COLUMN_TYPE.CTIME]: CtimeFormatter,
[EXTRA_ATTRIBUTES_COLUMN_TYPE.MTIME]: CtimeFormatter,
};

export default CONFIG;
Loading

0 comments on commit 0a7aeec

Please sign in to comment.