Skip to content

Commit

Permalink
(#448) иерархия в динсписках
Browse files Browse the repository at this point in the history
индикатор папки, удаления, проведения
  • Loading branch information
unpete committed Feb 7, 2020
1 parent d8f7dcc commit dc7212f
Show file tree
Hide file tree
Showing 16 changed files with 70 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class FieldInfinit extends AbstractField {
handleSelect = (value) => {
if(value) {
const {_obj, _fld, handleValueChange} = this.props;
_obj[_fld] = value;
_obj[_fld] = value && value.ref ? value.ref : value;
value = _obj[_fld];
this.handleCloseDialog();
const loader = value && value.is_new() ? value.load() : Promise.resolve();
Expand Down
33 changes: 17 additions & 16 deletions packages/metadata-react/src/DynList/DynList.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,15 @@ class DynList extends MDNRComponent {
docs.unshift(prnt.toJSON());
count++;
prnt = prnt.parent;
} while (!prnt.parent.empty());
} while (!prnt.empty());
}
for(let j = startIndex; j <= stopIndex; j++) {
fakeRows.delete(j);
}
this.updateList(docs, startIndex, count);
if(!startIndex && docs.length) {
this.setState({selectedRow: this.rows.get(0)}, () => this.grid.selectCell({rowIdx: 0, idx: 0}));
}
});
}
else {
Expand Down Expand Up @@ -246,7 +249,7 @@ class DynList extends MDNRComponent {
}
this.setState(newState, () => {
//selectRow
this.grid.openCellEditor(scroll, 0);
this.grid.selectCell({rowIdx: scroll, idx: 0});
});
}
}
Expand Down Expand Up @@ -432,23 +435,21 @@ class DynList extends MDNRComponent {

// обработчик выбора значения в списке
handleSelect = () => {
setTimeout(() => {
const {selectedRow: row, props: {handlers, _mgr}, state: {flat, parent}, _mounted} = this;
if(!_mounted) {
return;
}
if(row) {
if(!flat && parent && row.is_folder) {
this.setState({parent: row.ref == parent ? parent.parent : _mgr.get(row.ref)}, () => this.handleFilterChange());
}
else {
handlers.handleSelect && handlers.handleSelect(row, _mgr);
}
const {selectedRow: row, props: {handlers, _mgr}, state: {flat, parent}, _mounted} = this;
if(!_mounted) {
return;
}
if(row) {
if(!flat && parent && row.is_folder) {
this.setState({parent: row.ref == parent ? parent.parent : _mgr.get(row.ref)}, () => this.handleFilterChange());
}
else {
this.handleInfoText('Не выбрана строка');
handlers.handleSelect && handlers.handleSelect(row, _mgr);
}
}, 200);
}
else {
this.handleInfoText('Не выбрана строка');
}
};

// обработчик добавления элемента списка
Expand Down
54 changes: 44 additions & 10 deletions packages/metadata-react/src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,47 @@ function rx_columns({utils: {moment}, enm, md}) {

const typed_formatters = {};

const date_formatter = {
date: ({value}) => {
const presentation = !value || value.length < 5 ? value || '' : moment(value).format(moment._masks.date);
return <div title={presentation}>{presentation}</div>;
},
date_time: ({value}) => {
const presentation = !value || value.length < 5 ? value || '' : moment(value).format(moment._masks.date_time);
return <div title={presentation}>{presentation}</div>;
// const date_formatter = {
// date: ({value}) => {
// const presentation = !value || value.length < 5 ? value || '' : moment(value).format(moment._masks.date);
// return <div title={presentation}>{presentation}</div>;
// },
// date_time: ({value}) => {
// const presentation = !value || value.length < 5 ? value || '' : moment(value).format(moment._masks.date_time);
// return <div title={presentation}>{presentation}</div>;
// }
// };

const indicator_formatter = (is_doc) => ({value, row}) => {
if(value && value.toString) {
value = value.toString();
}
let indicator = 'cell_ref_elm';
if(row.deleted) {
indicator = is_doc ? 'cell_doc_deleted' : 'cell_ref_elm_deleted';
}
else if(row.is_folder) {
indicator = 'cell_ref_folder';
}
else if(is_doc) {
indicator = row.posted ? 'cell_doc_posted' : 'cell_doc';
}
return <div className={indicator} title={value}>{value}</div>;
};

const date_formatter = (format, indicator, is_doc) => {
const formatter = indicator && indicator_formatter(is_doc);
return ({value, row}) => {
if(!value || value.length < 5) {
value = value || '';
}
else {
value = moment(value).format(moment._masks[format]);
}
return formatter ? formatter({value, row}) : <div title={value}>{value}</div>;
}
}

const presentation_formatter = ({value}) => {
let text = typeof value === 'string' ? value : (value && value.presentation) || '';
if(text === '_') {
Expand Down Expand Up @@ -122,9 +152,10 @@ function rx_columns({utils: {moment}, enm, md}) {
_mgr = _obj._manager;
}
const editable = (_obj && !read_only) ? _mgr.class_name.indexOf('rep.') !== 0 || this.obj.indexOf(`.${_mgr._tabular || 'data'}`) === -1 : false;
const is_doc = _mgr.class_name.startsWith('doc.');

if(fields) {
res.forEach((column) => {
res.forEach((column, index) => {

const keys = column.key.split('.');
let _fld = column._meta = fields[keys[0]];
Expand All @@ -144,7 +175,7 @@ function rx_columns({utils: {moment}, enm, md}) {
column.formatter = !_obj && _fld.type.types[0].includes('.') ? typed_formatter(_fld.type.types[0]) : presentation_formatter;
}
else if(_fld.type.date_part) {
column.formatter = date_formatter[_fld.type.date_part];
column.formatter = date_formatter(_fld.type.date_part, !index && !editable, is_doc);
}
else if(_fld.type.digits && _fld.type.types.length === 1){
column.formatter = number_formatter(_fld.type.fraction);
Expand Down Expand Up @@ -211,6 +242,9 @@ function rx_columns({utils: {moment}, enm, md}) {
if(editable){
column.editor = DataCell;
}
else if(!column.formatter && !index) {
column.formatter = indicator_formatter(is_doc);
}
}

});
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions packages/metadata-react/src/styles/indicator/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* зачки состояния объекта: папка, элемент, пометка удаления, проведён */
.cell_ref_folder {padding-left: 26px !important; background: url(./folderClosed.gif) no-repeat left center;}
.cell_ref_folder_deleted {padding-left: 26px !important; background: url(./folderDeleted.gif) no-repeat left center;}
.cell_ref_elm {padding-left: 26px !important; background: url(./catelm.gif) no-repeat left center;}
.cell_ref_elm_deleted {padding-left: 26px !important; background: url(./catelmDeleted.gif) no-repeat left center;}
.cell_doc_posted {padding-left: 26px !important; background: url(./doc_posted.png) no-repeat left center;}
.cell_doc_deleted {padding-left: 26px !important; background: url(./doc_deleted.png) no-repeat left center;}
.cell_doc {padding-left: 26px !important; background: url(./doc_saved.png) no-repeat left center;}

0 comments on commit dc7212f

Please sign in to comment.