poi-plugin-ship-info
Advanced tools
Comparing version 5.0.1 to 5.0.2
{ | ||
"name": "poi-plugin-ship-info", | ||
"version": "5.0.1", | ||
"version": "5.0.2", | ||
"description": "Show detailed information of all owned ship girls", | ||
@@ -5,0 +5,0 @@ "main": "index.es", |
@@ -124,2 +124,9 @@ 'use strict'; | ||
this.setRef = this.setRef.bind(this); | ||
this.onClickFactory = (0, _lodash.memoize)(this.onClickFactory); | ||
this.state = { | ||
windowWidth: window.innerWidth, | ||
windowHeight: window.innerHeight, | ||
activeColumn: -1, | ||
activeRow: -1 | ||
}; | ||
} | ||
@@ -176,9 +183,2 @@ | ||
}, _initialiseProps = function () { | ||
this.state = { | ||
windowWidth: window.innerWidth, | ||
windowHeight: window.innerHeight, | ||
activeColumn: -1, | ||
activeRow: -1 | ||
}; | ||
this.componentDidMount = () => { | ||
@@ -200,37 +200,61 @@ this.updateWindowSize(); | ||
this.updateWindowSize = () => { | ||
this.onContextMenu = () => this.setState({ | ||
activeColumn: -1, | ||
activeRow: -1 | ||
}); | ||
this.onClickFactory = ({ columnIndex, rowIndex }) => () => { | ||
const { activeColumn, activeRow } = this.state; | ||
const off = activeColumn === columnIndex && activeRow === rowIndex; | ||
this.setState({ | ||
windowWidth: window.innerWidth, | ||
windowHeight: window.innerHeight | ||
}, () => { | ||
if (this.grid) { | ||
this.grid.recomputeGridSize(); | ||
this.grid.forceUpdateGrids(); | ||
} | ||
activeColumn: off ? -1 : columnIndex, | ||
activeRow: off ? -1 : rowIndex | ||
}); | ||
}; | ||
this.saveSortRules = _ref3; | ||
this.setRef = ref => { | ||
this.grid = ref; | ||
}; | ||
this.titleRenderer = (_ref) => { | ||
let { | ||
columnIndex, style, sortName, sortOrder } = _ref, | ||
props = _objectWithoutProperties(_ref, ['columnIndex', 'style', 'sortName', 'sortOrder']); | ||
this.getColumnWidth = ({ index }) => { | ||
// 20: magic number, seems it need to be greater than 16 | ||
const width = (0, _lodash.floor)((WIDTHS[index] || 40) * (this.state.windowWidth - 20 > this.tableWidth ? (this.state.windowWidth - 20) / this.tableWidth : 1)); | ||
return width; | ||
}; | ||
if (columnIndex === 0) { | ||
return _react2.default.createElement('div', _extends({ style: style }, props)); | ||
this.handleContentRendered = e => { | ||
const { rowStopIndex, columnStopIndex } = e; | ||
if (this.activeColumn !== -1 && this.activeRow !== -1) { | ||
this.setState({ | ||
activeColumn: this.state.activeColumn + columnStopIndex - this.columnStopIndex, | ||
activeRow: this.state.activeRow + rowStopIndex - this.rowStopIndex | ||
}); | ||
} | ||
const index = columnIndex - 1; | ||
return _react2.default.createElement(TitleCell, _extends({}, props, { | ||
style: style, | ||
title: TITLES[index], | ||
sortable: SORTABLES[index], | ||
centerAlign: CENTER_ALIGNS[index], | ||
sorting: sortName === TYPES[index], | ||
up: sortName === TYPES[index] && Boolean(sortOrder), | ||
down: sortName === TYPES[index] && Boolean(!sortOrder), | ||
handleClickTitle: this.handleClickTitle(TYPES[index]) | ||
})); | ||
this.rowStopIndex = rowStopIndex; | ||
this.columnStopIndex = columnStopIndex; | ||
}; | ||
this.handleClickTitle = title => () => { | ||
if (this.props.sortName !== title) { | ||
const order = title === 'id' || title === 'type' || title === 'name' ? 1 : 0; | ||
this.saveSortRules(title, order); | ||
} else { | ||
this.saveSortRules(this.props.sortName, (this.props.sortOrder + 1) % 2); | ||
} | ||
}; | ||
this.handleScroll = ({ scrollTop }) => { | ||
const { rows } = this.props; | ||
const contentHeight = rows.length * ROW_HEIGHT; | ||
const safeZone = Math.round(window.screen.height / config.get('poi.zoomLevel', 1)); | ||
if (this.props.toTop !== !scrollTop && contentHeight > safeZone) { | ||
this.props.dispatch({ | ||
type: '@@poi-plugin-ship-info@scroll', | ||
toTop: !scrollTop | ||
}); | ||
} | ||
}; | ||
this.saveSortRules = _ref3; | ||
this.cellRenderer = ({ | ||
@@ -240,22 +264,8 @@ columnIndex, key, rowIndex, style | ||
const { rows, sortName, sortOrder } = this.props; | ||
const setState = this.setState.bind(this); | ||
const onClick = () => { | ||
const { activeColumn, activeRow } = this.state; | ||
const off = activeColumn === columnIndex && activeRow === rowIndex; | ||
setState({ | ||
activeColumn: off ? -1 : columnIndex, | ||
activeRow: off ? -1 : rowIndex | ||
}); | ||
}; | ||
const onContextMenu = () => { | ||
setState({ | ||
activeColumn: -1, | ||
activeRow: -1 | ||
}); | ||
}; | ||
const highlight = (columnIndex === this.state.activeColumn || rowIndex === this.state.activeRow) && !(columnIndex === 0 && rowIndex !== this.state.activeRow) && !(rowIndex === 0 && columnIndex !== this.state.activeColumn); | ||
const props = { | ||
key, | ||
onClick, | ||
onContextMenu, | ||
onClick: this.onClickFactory({ columnIndex, rowIndex }), | ||
onContextMenu: this.onContextMenu, | ||
className: (0, _classnames2.default)({ | ||
@@ -289,44 +299,34 @@ 'ship-info-cell': true, | ||
this.handleContentRendered = e => { | ||
const { rowStopIndex, columnStopIndex } = e; | ||
if (this.activeColumn !== -1 && this.activeRow !== -1) { | ||
this.setState({ | ||
activeColumn: this.state.activeColumn + columnStopIndex - this.columnStopIndex, | ||
activeRow: this.state.activeRow + rowStopIndex - this.rowStopIndex | ||
}); | ||
} | ||
this.rowStopIndex = rowStopIndex; | ||
this.columnStopIndex = columnStopIndex; | ||
}; | ||
this.titleRenderer = (_ref) => { | ||
let { | ||
columnIndex, style, sortName, sortOrder } = _ref, | ||
props = _objectWithoutProperties(_ref, ['columnIndex', 'style', 'sortName', 'sortOrder']); | ||
this.handleClickTitle = title => () => { | ||
if (this.props.sortName !== title) { | ||
const order = title === 'id' || title === 'type' || title === 'name' ? 1 : 0; | ||
this.saveSortRules(title, order); | ||
} else { | ||
this.saveSortRules(this.props.sortName, (this.props.sortOrder + 1) % 2); | ||
if (columnIndex === 0) { | ||
return _react2.default.createElement('div', _extends({ style: style }, props)); | ||
} | ||
const index = columnIndex - 1; | ||
return _react2.default.createElement(TitleCell, _extends({}, props, { | ||
style: style, | ||
title: TITLES[index], | ||
sortable: SORTABLES[index], | ||
centerAlign: CENTER_ALIGNS[index], | ||
sorting: sortName === TYPES[index], | ||
up: sortName === TYPES[index] && Boolean(sortOrder), | ||
down: sortName === TYPES[index] && Boolean(!sortOrder), | ||
handleClickTitle: this.handleClickTitle(TYPES[index]) | ||
})); | ||
}; | ||
this.getColumnWidth = ({ index }) => { | ||
// 20: magic number, seems it need to be greater than 16 | ||
const width = (0, _lodash.floor)((WIDTHS[index] || 40) * (this.state.windowWidth - 20 > this.tableWidth ? (this.state.windowWidth - 20) / this.tableWidth : 1)); | ||
return width; | ||
this.updateWindowSize = () => { | ||
this.setState({ | ||
windowWidth: window.innerWidth, | ||
windowHeight: window.innerHeight | ||
}, () => { | ||
if (this.grid) { | ||
this.grid.recomputeGridSize(); | ||
this.grid.forceUpdateGrids(); | ||
} | ||
}); | ||
}; | ||
this.handleScroll = ({ scrollTop }) => { | ||
const { rows } = this.props; | ||
const contentHeight = rows.length * ROW_HEIGHT; | ||
const safeZone = Math.round(window.screen.height / config.get('poi.zoomLevel', 1)); | ||
if (this.props.toTop !== !scrollTop && contentHeight > safeZone) { | ||
this.props.dispatch({ | ||
type: '@@poi-plugin-ship-info@scroll', | ||
toTop: !scrollTop | ||
}); | ||
} | ||
}; | ||
this.setRef = ref => { | ||
this.grid = ref; | ||
}; | ||
}, _temp)); | ||
@@ -333,0 +333,0 @@ |
@@ -31,2 +31,6 @@ 'use strict'; | ||
var _reactRedux = require('react-redux'); | ||
var _lodash = require('lodash'); | ||
var _tools = require('views/utils/tools'); | ||
@@ -54,2 +58,4 @@ | ||
const enableAvatarConfigSelector = state => (0, _lodash.get)(state, ['config', 'poi', 'enableAvatar'], false); | ||
const Id = (_ref) => { | ||
@@ -72,4 +78,4 @@ let { ship } = _ref, | ||
const Name = (_ref2) => { | ||
let { className, ship } = _ref2, | ||
props = _objectWithoutProperties(_ref2, ['className', 'ship']); | ||
let { className, ship, enableAvatar } = _ref2, | ||
props = _objectWithoutProperties(_ref2, ['className', 'ship', 'enableAvatar']); | ||
@@ -81,3 +87,3 @@ return _react2.default.createElement( | ||
}), | ||
_react2.default.createElement(_avatar.Avatar, { mstId: ship.shipId, height: 35 }), | ||
enableAvatar && _react2.default.createElement(_avatar.Avatar, { mstId: ship.shipId, height: 35 }), | ||
_react2.default.createElement( | ||
@@ -102,3 +108,4 @@ 'span', | ||
ship: _propTypes2.default.shape(_utils.shipInfoShape).isRequired, | ||
className: _propTypes2.default.string | ||
className: _propTypes2.default.string, | ||
enableAvatar: _propTypes2.default.bool.isRequired | ||
}; | ||
@@ -503,3 +510,3 @@ | ||
id: Id, | ||
name: Name, | ||
name: (0, _reactRedux.connect)(state => ({ enableAvatar: enableAvatarConfigSelector(state) }))(Name), | ||
type: Type, | ||
@@ -506,0 +513,0 @@ soku: Soku, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
580542
8826