poi-plugin-item-improvement2-beta 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +42 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/inspectionProfiles/profiles_settings.xml +6 -0
- package/.idea/misc.xml +4 -0
- package/.idea/modules.xml +8 -0
- package/.idea/plugin-item-improvement.iml +8 -0
- package/.idea/vcs.xml +6 -0
- package/README.md +7 -0
- package/assets/arsenal.nedb +704 -0
- package/assets/items.nedb +756 -0
- package/assets/main.css +192 -0
- package/assets/useitem.svg +107 -0
- package/i18n/en-US.json +4 -0
- package/i18n/ja-JP.json +54 -0
- package/i18n/zh-CN.json +53 -0
- package/i18n/zh-TW.json +53 -0
- package/index.es +12 -0
- package/index.js +21 -0
- package/package.json +56 -0
- package/views/detail-row.js +186 -0
- package/views/divider.js +17 -0
- package/views/item-info-area.js +157 -0
- package/views/item-info-row.js +93 -0
- package/views/item-wrapper.js +126 -0
- package/views/mat-row.js +153 -0
- package/views/selectors.js +127 -0
- package/views/starcraft/add-new-equip-view.js +110 -0
- package/views/starcraft/control-panel.js +104 -0
- package/views/starcraft/equip-category-view.js +115 -0
- package/views/starcraft/equip-list-view.js +100 -0
- package/views/starcraft/equip-view.js +142 -0
- package/views/starcraft/equiptype.js +109 -0
- package/views/starcraft/plan-modify-control.js +201 -0
- package/views/starcraft/plan-view.js +108 -0
- package/views/starcraft/starcraft-area.js +222 -0
- package/views/starcraft/utils.js +51 -0
- package/views/useitem-icon.js +69 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.EquipListView = void 0;
|
|
5
|
+
|
|
6
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
7
|
+
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
|
|
10
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
11
|
+
|
|
12
|
+
var _reactBootstrap = require("react-bootstrap");
|
|
13
|
+
|
|
14
|
+
var _equipView = require("./equip-view");
|
|
15
|
+
|
|
16
|
+
var _addNewEquipView = require("./add-new-equip-view");
|
|
17
|
+
|
|
18
|
+
var _equiptype = require("./equiptype");
|
|
19
|
+
|
|
20
|
+
var _utils = require("./utils");
|
|
21
|
+
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
+
|
|
24
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
|
25
|
+
|
|
26
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
27
|
+
|
|
28
|
+
// props:
|
|
29
|
+
// - $equips
|
|
30
|
+
// - equipLevels
|
|
31
|
+
// - equipMstIds
|
|
32
|
+
// - plans
|
|
33
|
+
// - viewMode
|
|
34
|
+
class EquipListView extends _react.Component {
|
|
35
|
+
shouldComponentUpdate(nextProps) {
|
|
36
|
+
return this.props.viewMode !== nextProps.viewMode || !_lodash.default.isEqual(this.props.equipMstIds, nextProps.equipMstIds) || !_lodash.default.isEqual(this.props.plans, nextProps.plans) || !(0, _utils.isEquipMasterEqual)(this.props.$equips, nextProps.$equips);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
render() {
|
|
40
|
+
// equipment list for those that has plans.
|
|
41
|
+
const equipList = []; // equipment list for those that doesn't have plans
|
|
42
|
+
|
|
43
|
+
const equipListNoPlan = [];
|
|
44
|
+
const $equips = this.props.$equips;
|
|
45
|
+
this.props.equipMstIds.map(mstId => {
|
|
46
|
+
const plans = this.props.plans[mstId];
|
|
47
|
+
const $equip = $equips[mstId];
|
|
48
|
+
const name = $equip.api_name;
|
|
49
|
+
const iconId = (0, _equiptype.getIconId)($equip);
|
|
50
|
+
|
|
51
|
+
if (plans) {
|
|
52
|
+
equipList.push({
|
|
53
|
+
mstId,
|
|
54
|
+
name,
|
|
55
|
+
iconId,
|
|
56
|
+
plans
|
|
57
|
+
});
|
|
58
|
+
} else {
|
|
59
|
+
equipListNoPlan.push({
|
|
60
|
+
mstId,
|
|
61
|
+
name,
|
|
62
|
+
iconId
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
return _react.default.createElement(_reactBootstrap.ListGroup, {
|
|
67
|
+
style: {
|
|
68
|
+
marginBottom: '0'
|
|
69
|
+
}
|
|
70
|
+
}, equipList.map(args => _react.default.createElement(_reactBootstrap.ListGroupItem, {
|
|
71
|
+
style: {
|
|
72
|
+
padding: '0'
|
|
73
|
+
},
|
|
74
|
+
key: args.mstId
|
|
75
|
+
}, _react.default.createElement("div", null, _react.default.createElement(_equipView.EquipView, _extends({
|
|
76
|
+
viewMode: this.props.viewMode
|
|
77
|
+
}, args))))), !this.props.viewMode && equipListNoPlan.length > 0 && _react.default.createElement(_reactBootstrap.ListGroupItem, {
|
|
78
|
+
style: {
|
|
79
|
+
padding: '0'
|
|
80
|
+
},
|
|
81
|
+
key: "noplan"
|
|
82
|
+
}, _react.default.createElement("div", null, _react.default.createElement(_addNewEquipView.AddNewEquipView, {
|
|
83
|
+
equips: equipListNoPlan
|
|
84
|
+
}))));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
exports.EquipListView = EquipListView;
|
|
90
|
+
Object.defineProperty(EquipListView, "propTypes", {
|
|
91
|
+
configurable: true,
|
|
92
|
+
enumerable: true,
|
|
93
|
+
writable: true,
|
|
94
|
+
value: {
|
|
95
|
+
viewMode: _propTypes.default.bool.isRequired,
|
|
96
|
+
$equips: _propTypes.default.object.isRequired,
|
|
97
|
+
plans: _propTypes.default.object.isRequired,
|
|
98
|
+
equipMstIds: _propTypes.default.arrayOf(_propTypes.default.number).isRequired
|
|
99
|
+
}
|
|
100
|
+
});
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.EquipView = void 0;
|
|
5
|
+
|
|
6
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
7
|
+
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
|
|
10
|
+
var _reactRedux = require("react-redux");
|
|
11
|
+
|
|
12
|
+
var _reactBootstrap = require("react-bootstrap");
|
|
13
|
+
|
|
14
|
+
var _icon = require("views/components/etc/icon");
|
|
15
|
+
|
|
16
|
+
var _planView = require("./plan-view");
|
|
17
|
+
|
|
18
|
+
var _planModifyControl = require("./plan-modify-control");
|
|
19
|
+
|
|
20
|
+
var _utils = require("./utils");
|
|
21
|
+
|
|
22
|
+
var _selectors = require("../selectors");
|
|
23
|
+
|
|
24
|
+
var _class, _temp2;
|
|
25
|
+
|
|
26
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
+
|
|
28
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
|
29
|
+
|
|
30
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
31
|
+
|
|
32
|
+
const {
|
|
33
|
+
__
|
|
34
|
+
} = window.i18n['poi-plugin-item-improvement']; // props:
|
|
35
|
+
// - mstId, name, iconId, plans, viewMode
|
|
36
|
+
|
|
37
|
+
const EquipView = (0, _reactRedux.connect)((state, {
|
|
38
|
+
mstId
|
|
39
|
+
}) => ({
|
|
40
|
+
levels: (0, _selectors.itemLevelStatFactory)(mstId)(state)
|
|
41
|
+
}))((_temp2 = _class = class EquipView extends _react.Component {
|
|
42
|
+
constructor(...args) {
|
|
43
|
+
var _temp;
|
|
44
|
+
|
|
45
|
+
return _temp = super(...args), Object.defineProperty(this, "handleRemove", {
|
|
46
|
+
configurable: true,
|
|
47
|
+
enumerable: true,
|
|
48
|
+
writable: true,
|
|
49
|
+
value: mstId => () => {
|
|
50
|
+
(0, _utils.modifyPlans)(plans => {
|
|
51
|
+
const newPlans = _extends({}, plans);
|
|
52
|
+
|
|
53
|
+
delete newPlans[mstId];
|
|
54
|
+
return newPlans;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}), _temp;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
render() {
|
|
61
|
+
const {
|
|
62
|
+
mstId,
|
|
63
|
+
name,
|
|
64
|
+
iconId,
|
|
65
|
+
plans,
|
|
66
|
+
levels,
|
|
67
|
+
viewMode
|
|
68
|
+
} = this.props; // sort plans because its is not guaranteed to be ordered.
|
|
69
|
+
|
|
70
|
+
const planArr = Object.keys(plans).map(k => {
|
|
71
|
+
const star = parseInt(k, 10);
|
|
72
|
+
const planCount = plans[k];
|
|
73
|
+
const actualCount = levels.filter(lvl => lvl >= star).length;
|
|
74
|
+
return {
|
|
75
|
+
star,
|
|
76
|
+
planCount,
|
|
77
|
+
actualCount
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
|
+
planArr.sort((x, y) => x.star - y.star);
|
|
81
|
+
if (viewMode && planArr.length === 0) return null;
|
|
82
|
+
return _react.default.createElement("div", null, !this.props.hideTitle && _react.default.createElement("div", {
|
|
83
|
+
style: {
|
|
84
|
+
display: 'flex',
|
|
85
|
+
borderBottom: 'solid 1px #666',
|
|
86
|
+
alignItems: 'center'
|
|
87
|
+
}
|
|
88
|
+
}, _react.default.createElement(_icon.SlotitemIcon, {
|
|
89
|
+
slotitemId: iconId,
|
|
90
|
+
className: "equip-icon"
|
|
91
|
+
}), _react.default.createElement("div", {
|
|
92
|
+
style: {
|
|
93
|
+
flex: 1
|
|
94
|
+
}
|
|
95
|
+
}, name), // allow an equipment entity to be removed when it's empty
|
|
96
|
+
planArr.length === 0 && _react.default.createElement(_reactBootstrap.Button, {
|
|
97
|
+
onClick: this.handleRemove(mstId),
|
|
98
|
+
style: {
|
|
99
|
+
margin: '5px'
|
|
100
|
+
},
|
|
101
|
+
bsStyle: "warning"
|
|
102
|
+
}, __('Remove'))), _react.default.createElement("div", {
|
|
103
|
+
onClick: e => e.stopPropagation(),
|
|
104
|
+
style: {
|
|
105
|
+
width: '80%',
|
|
106
|
+
maxWidth: '500px',
|
|
107
|
+
margin: 'auto',
|
|
108
|
+
marginBottom: '2px',
|
|
109
|
+
marginTop: '2px'
|
|
110
|
+
}
|
|
111
|
+
}, planArr.map(args => _react.default.createElement(_planView.PlanView, _extends({
|
|
112
|
+
viewMode: this.props.viewMode,
|
|
113
|
+
mstId: mstId,
|
|
114
|
+
key: `plan-${mstId}-${args.star}`
|
|
115
|
+
}, args))), !this.props.viewMode && _react.default.createElement(_planModifyControl.PlanModifyControl, {
|
|
116
|
+
mstId: mstId,
|
|
117
|
+
plans: plans
|
|
118
|
+
})));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
}, Object.defineProperty(_class, "propTypes", {
|
|
122
|
+
configurable: true,
|
|
123
|
+
enumerable: true,
|
|
124
|
+
writable: true,
|
|
125
|
+
value: {
|
|
126
|
+
mstId: _propTypes.default.number.isRequired,
|
|
127
|
+
iconId: _propTypes.default.number.isRequired,
|
|
128
|
+
viewMode: _propTypes.default.bool.isRequired,
|
|
129
|
+
name: _propTypes.default.string.isRequired,
|
|
130
|
+
levels: _propTypes.default.arrayOf(_propTypes.default.number).isRequired,
|
|
131
|
+
plans: _propTypes.default.object.isRequired,
|
|
132
|
+
hideTitle: _propTypes.default.bool
|
|
133
|
+
}
|
|
134
|
+
}), Object.defineProperty(_class, "defaultProps", {
|
|
135
|
+
configurable: true,
|
|
136
|
+
enumerable: true,
|
|
137
|
+
writable: true,
|
|
138
|
+
value: {
|
|
139
|
+
hideTitle: false
|
|
140
|
+
}
|
|
141
|
+
}), _temp2));
|
|
142
|
+
exports.EquipView = EquipView;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.prepareEquipTypeInfo = exports.getIconId = exports.getCatId = void 0;
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
|
|
8
|
+
Equipment type related functions
|
|
9
|
+
|
|
10
|
+
- Overview
|
|
11
|
+
|
|
12
|
+
In "api_mst_slotitem" of "api_start2", equipment type is defined by "api_type",
|
|
13
|
+
which is an array of length 5 - so there are really 5 different equipment types
|
|
14
|
+
that one equipment can have.
|
|
15
|
+
|
|
16
|
+
- api_type[0]
|
|
17
|
+
|
|
18
|
+
Gives a general equipment type, without getting too much into finer details.
|
|
19
|
+
for example it doesn't distinguish main gun and secondary gun.
|
|
20
|
+
|
|
21
|
+
- api_type[1]
|
|
22
|
+
|
|
23
|
+
A little more precise than api_type[0]. it distinguishes main
|
|
24
|
+
and secondary gun, but does not distinguish between seaplanes.
|
|
25
|
+
(however seaplane fighter does has its own type in this one)
|
|
26
|
+
|
|
27
|
+
- api_type[2]: "category"
|
|
28
|
+
|
|
29
|
+
One of the most commonly used equipment type, we will be referring to this
|
|
30
|
+
using term "category". It's the category used in in-game picture book.
|
|
31
|
+
|
|
32
|
+
- api_type[3]: "icon"
|
|
33
|
+
|
|
34
|
+
Another most commonly used equipment type. Will be referring to this using "icon"
|
|
35
|
+
This is the equipment icon id used in game.
|
|
36
|
+
|
|
37
|
+
Despite that some equipment has the same icon, game mechanism treats them differently.
|
|
38
|
+
For example some high-angle gun mounts (abbr. HA) are actually
|
|
39
|
+
small-caliber main guns while other HAs are secondary guns.
|
|
40
|
+
This is where having notions of both "Category" and "Icon" could be useful.
|
|
41
|
+
|
|
42
|
+
- api_type[4]
|
|
43
|
+
|
|
44
|
+
Mainly used by aircrafts. Currently I see no need of getting into this.
|
|
45
|
+
|
|
46
|
+
- Terms
|
|
47
|
+
|
|
48
|
+
- category: api_type[2], see above.
|
|
49
|
+
- icon: api_type[3], see above.
|
|
50
|
+
|
|
51
|
+
- EquipTypeInfo: a structured data
|
|
52
|
+
|
|
53
|
+
- catInfo: an object indexed by api_type[2]. its element has the following structure:
|
|
54
|
+
|
|
55
|
+
- group: a collection of master ids of equipments of having that icon
|
|
56
|
+
- icons: all icon ids used by this group of equipments
|
|
57
|
+
|
|
58
|
+
- iconInfo: an object indexed by api_type[3], with each element
|
|
59
|
+
being a collection of master ids of equipments of having that icon
|
|
60
|
+
|
|
61
|
+
*/
|
|
62
|
+
const getCatId = $equip => $equip.api_type[2];
|
|
63
|
+
|
|
64
|
+
exports.getCatId = getCatId;
|
|
65
|
+
|
|
66
|
+
const getIconId = $equip => $equip.api_type[3]; // prepare equipment type related information for further processing
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
exports.getIconId = getIconId;
|
|
70
|
+
|
|
71
|
+
const prepareEquipTypeInfo = $equips => {
|
|
72
|
+
const catInfo = {};
|
|
73
|
+
const iconInfo = {}; // first pass, sets everything but "catInfo[?].icons"
|
|
74
|
+
|
|
75
|
+
Object.keys($equips).map(k => {
|
|
76
|
+
const equip = $equips[k]; // excluding abyssal equipments
|
|
77
|
+
|
|
78
|
+
if (equip.api_id > 500) return;
|
|
79
|
+
const catId = getCatId(equip);
|
|
80
|
+
const iconId = getIconId(equip);
|
|
81
|
+
let cat = catInfo[catId];
|
|
82
|
+
if (typeof cat === 'undefined') cat = {
|
|
83
|
+
group: []
|
|
84
|
+
};
|
|
85
|
+
let icon = iconInfo[iconId];
|
|
86
|
+
if (typeof icon === 'undefined') icon = [];
|
|
87
|
+
cat.group.push(equip.api_id);
|
|
88
|
+
icon.push(equip.api_id);
|
|
89
|
+
catInfo[catId] = cat;
|
|
90
|
+
iconInfo[iconId] = icon;
|
|
91
|
+
}); // second pass, finishing "catInfo[?].icons"
|
|
92
|
+
|
|
93
|
+
Object.keys(catInfo).map(k => {
|
|
94
|
+
const cat = catInfo[k];
|
|
95
|
+
const icons = [];
|
|
96
|
+
cat.group.map(mstId => {
|
|
97
|
+
const equip = $equips[mstId];
|
|
98
|
+
const iconId = getIconId(equip);
|
|
99
|
+
if (icons.indexOf(iconId) === -1) icons.push(iconId);
|
|
100
|
+
});
|
|
101
|
+
cat.icons = icons.sort();
|
|
102
|
+
});
|
|
103
|
+
return {
|
|
104
|
+
catInfo,
|
|
105
|
+
iconInfo
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
exports.prepareEquipTypeInfo = prepareEquipTypeInfo;
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.PlanModifyControl = void 0;
|
|
5
|
+
|
|
6
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
7
|
+
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
|
|
10
|
+
var _reactFontawesome = _interopRequireDefault(require("react-fontawesome"));
|
|
11
|
+
|
|
12
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
13
|
+
|
|
14
|
+
var _reactBootstrap = require("react-bootstrap");
|
|
15
|
+
|
|
16
|
+
var _reactNumericInput = _interopRequireDefault(require("react-numeric-input"));
|
|
17
|
+
|
|
18
|
+
var _utils = require("./utils");
|
|
19
|
+
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
+
|
|
22
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
|
23
|
+
|
|
24
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
25
|
+
|
|
26
|
+
const {
|
|
27
|
+
__
|
|
28
|
+
} = window.i18n['poi-plugin-item-improvement']; // props:
|
|
29
|
+
// - plans: star to plan count
|
|
30
|
+
|
|
31
|
+
class PlanModifyControl extends _react.Component {
|
|
32
|
+
constructor() {
|
|
33
|
+
super();
|
|
34
|
+
Object.defineProperty(this, "getCurrentAction", {
|
|
35
|
+
configurable: true,
|
|
36
|
+
enumerable: true,
|
|
37
|
+
writable: true,
|
|
38
|
+
value: () => {
|
|
39
|
+
if (typeof this.state.planCount !== 'number') return 'invalid';
|
|
40
|
+
const {
|
|
41
|
+
star,
|
|
42
|
+
planCount,
|
|
43
|
+
isInfinity
|
|
44
|
+
} = this.state;
|
|
45
|
+
const oldPlanCount = this.props.plans[star];
|
|
46
|
+
|
|
47
|
+
if (oldPlanCount) {
|
|
48
|
+
// we are editing an existing one
|
|
49
|
+
return planCount === 0 && !isInfinity ? 'remove' : 'modify';
|
|
50
|
+
} else {
|
|
51
|
+
// we are creating a new one
|
|
52
|
+
return planCount === 0 && !isInfinity ? 'invalid' : 'add';
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
Object.defineProperty(this, "handleChangeStar", {
|
|
57
|
+
configurable: true,
|
|
58
|
+
enumerable: true,
|
|
59
|
+
writable: true,
|
|
60
|
+
value: e => {
|
|
61
|
+
const star = parseInt(e.target.value, 10);
|
|
62
|
+
this.setState({
|
|
63
|
+
star
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
Object.defineProperty(this, "handleChangeCount", {
|
|
68
|
+
configurable: true,
|
|
69
|
+
enumerable: true,
|
|
70
|
+
writable: true,
|
|
71
|
+
value: valAsNum => {
|
|
72
|
+
// note that 'valAsNum' could be 'null'
|
|
73
|
+
this.setState({
|
|
74
|
+
planCount: valAsNum
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
Object.defineProperty(this, "handleAction", {
|
|
79
|
+
configurable: true,
|
|
80
|
+
enumerable: true,
|
|
81
|
+
writable: true,
|
|
82
|
+
value: (action, {
|
|
83
|
+
star,
|
|
84
|
+
planCount,
|
|
85
|
+
isInfinity
|
|
86
|
+
}) => () => {
|
|
87
|
+
if (action === 'invalid') return;
|
|
88
|
+
const mstId = this.props.mstId;
|
|
89
|
+
|
|
90
|
+
if (action === 'add' || action === 'modify') {
|
|
91
|
+
(0, _utils.modifyPlans)(plans => {
|
|
92
|
+
const newPlans = _extends({}, plans); // it's safe to assume that plans[mstId] must exist at this point
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
newPlans[mstId] = _extends({}, plans[mstId]);
|
|
96
|
+
newPlans[mstId][star] = isInfinity ? 10000 : planCount;
|
|
97
|
+
return newPlans;
|
|
98
|
+
});
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (action === 'remove') {
|
|
103
|
+
(0, _utils.modifyPlans)(plans => {
|
|
104
|
+
const newPlans = _extends({}, plans); // it's safe to assume that plans[mstId] must exist at this point
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
newPlans[mstId] = _extends({}, plans[mstId]);
|
|
108
|
+
delete newPlans[mstId][star];
|
|
109
|
+
return newPlans;
|
|
110
|
+
});
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
console.error(`undefined action: ${action}`);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
this.state = {
|
|
118
|
+
star: 0,
|
|
119
|
+
planCount: 1,
|
|
120
|
+
isInfinity: true
|
|
121
|
+
};
|
|
122
|
+
} // The button action depends on current state
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
render() {
|
|
126
|
+
const action = this.getCurrentAction();
|
|
127
|
+
const [faIcon, btnStyle, btnText] = action === 'add' ? ['plus', 'primary', 'Add'] : action === 'remove' ? ['minus', 'warning', 'Remove'] : action === 'modify' ? ['pencil', 'success', 'Modify'] : action === 'invalid' ? ['ban', 'danger', 'Invalid'] : console.error(`invalid action: ${action}`);
|
|
128
|
+
const checkboxText = 'Infinity';
|
|
129
|
+
return _react.default.createElement("div", {
|
|
130
|
+
style: {
|
|
131
|
+
display: 'flex',
|
|
132
|
+
alignItems: 'center',
|
|
133
|
+
justifyContent: 'space-between',
|
|
134
|
+
minHeight: '50px'
|
|
135
|
+
}
|
|
136
|
+
}, _react.default.createElement(_reactFontawesome.default, {
|
|
137
|
+
style: {
|
|
138
|
+
marginRight: '10px',
|
|
139
|
+
maxWidth: '100px'
|
|
140
|
+
},
|
|
141
|
+
name: faIcon
|
|
142
|
+
}), _react.default.createElement(_reactBootstrap.FormControl, {
|
|
143
|
+
value: this.state.star,
|
|
144
|
+
onChange: this.handleChangeStar,
|
|
145
|
+
style: {
|
|
146
|
+
flex: 1,
|
|
147
|
+
marginRight: '10px',
|
|
148
|
+
maxWidth: '100px'
|
|
149
|
+
},
|
|
150
|
+
componentClass: "select"
|
|
151
|
+
}, _lodash.default.range(0, 10 + 1).map(star => _react.default.createElement("option", {
|
|
152
|
+
key: star,
|
|
153
|
+
value: star
|
|
154
|
+
}, (0, _utils.starText)(star)))), _react.default.createElement("div", {
|
|
155
|
+
style: {
|
|
156
|
+
flex: 1,
|
|
157
|
+
marginRight: '10px',
|
|
158
|
+
maxWidth: '100px'
|
|
159
|
+
}
|
|
160
|
+
}, _react.default.createElement(_reactNumericInput.default, {
|
|
161
|
+
onChange: this.handleChangeCount,
|
|
162
|
+
min: 0,
|
|
163
|
+
disabled: this.state.isInfinity,
|
|
164
|
+
value: this.state.planCount,
|
|
165
|
+
className: "form-control"
|
|
166
|
+
})), _react.default.createElement("div", {
|
|
167
|
+
style: {
|
|
168
|
+
flex: 1,
|
|
169
|
+
marginRight: '10px',
|
|
170
|
+
maxWidth: '100px',
|
|
171
|
+
display: 'flex',
|
|
172
|
+
alignItems: 'center'
|
|
173
|
+
}
|
|
174
|
+
}, _react.default.createElement(_reactBootstrap.Checkbox, {
|
|
175
|
+
checked: this.state.isInfinity,
|
|
176
|
+
onChange: () => this.setState({
|
|
177
|
+
isInfinity: !this.state.isInfinity
|
|
178
|
+
})
|
|
179
|
+
}, __(checkboxText))), _react.default.createElement(_reactBootstrap.Button, {
|
|
180
|
+
style: {
|
|
181
|
+
width: '25%',
|
|
182
|
+
maxWidth: '100px'
|
|
183
|
+
},
|
|
184
|
+
disabled: action === 'invalid',
|
|
185
|
+
onClick: this.handleAction(action, this.state),
|
|
186
|
+
bsStyle: btnStyle
|
|
187
|
+
}, __(btnText)));
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
exports.PlanModifyControl = PlanModifyControl;
|
|
193
|
+
Object.defineProperty(PlanModifyControl, "propTypes", {
|
|
194
|
+
configurable: true,
|
|
195
|
+
enumerable: true,
|
|
196
|
+
writable: true,
|
|
197
|
+
value: {
|
|
198
|
+
mstId: _propTypes.default.number.isRequired,
|
|
199
|
+
plans: _propTypes.default.object.isRequired
|
|
200
|
+
}
|
|
201
|
+
});
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.PlanView = void 0;
|
|
5
|
+
|
|
6
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
7
|
+
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
|
|
10
|
+
var _reactBootstrap = require("react-bootstrap");
|
|
11
|
+
|
|
12
|
+
var _utils = require("./utils");
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
|
17
|
+
|
|
18
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
19
|
+
|
|
20
|
+
const {
|
|
21
|
+
__
|
|
22
|
+
} = window.i18n['poi-plugin-item-improvement'];
|
|
23
|
+
|
|
24
|
+
class PlanView extends _react.Component {
|
|
25
|
+
constructor(...args) {
|
|
26
|
+
var _temp;
|
|
27
|
+
|
|
28
|
+
return _temp = super(...args), Object.defineProperty(this, "handleRemove", {
|
|
29
|
+
configurable: true,
|
|
30
|
+
enumerable: true,
|
|
31
|
+
writable: true,
|
|
32
|
+
value: () => {
|
|
33
|
+
const {
|
|
34
|
+
mstId,
|
|
35
|
+
star
|
|
36
|
+
} = this.props;
|
|
37
|
+
(0, _utils.modifyPlans)(plans => {
|
|
38
|
+
const newPlans = _extends({}, plans);
|
|
39
|
+
|
|
40
|
+
newPlans[mstId] = _extends({}, plans[mstId]);
|
|
41
|
+
delete newPlans[mstId][star];
|
|
42
|
+
|
|
43
|
+
if (Object.keys(newPlans[mstId]).length === 0) {
|
|
44
|
+
delete newPlans[mstId];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return newPlans;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}), _temp;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
render() {
|
|
54
|
+
const {
|
|
55
|
+
star,
|
|
56
|
+
planCount,
|
|
57
|
+
actualCount,
|
|
58
|
+
viewMode
|
|
59
|
+
} = this.props;
|
|
60
|
+
const done = actualCount >= planCount;
|
|
61
|
+
return _react.default.createElement("div", {
|
|
62
|
+
style: {
|
|
63
|
+
display: 'flex',
|
|
64
|
+
alignItems: 'center',
|
|
65
|
+
fontSize: '16px'
|
|
66
|
+
}
|
|
67
|
+
}, _react.default.createElement("div", {
|
|
68
|
+
key: "1",
|
|
69
|
+
style: {
|
|
70
|
+
flex: 1
|
|
71
|
+
},
|
|
72
|
+
className: "star-text"
|
|
73
|
+
}, (0, _utils.starText)(star)), _react.default.createElement("div", {
|
|
74
|
+
key: "2",
|
|
75
|
+
style: {
|
|
76
|
+
flex: 1,
|
|
77
|
+
display: 'flex',
|
|
78
|
+
justifyContent: viewMode ? 'flex-end' : 'flex-start'
|
|
79
|
+
}
|
|
80
|
+
}, _react.default.createElement("div", {
|
|
81
|
+
className: done ? 'text-success' : 'text-danger'
|
|
82
|
+
}, actualCount), _react.default.createElement("div", {
|
|
83
|
+
style: {
|
|
84
|
+
marginLeft: '2px'
|
|
85
|
+
}
|
|
86
|
+
}, "/", planCount < 9999 ? planCount : '∞')), !viewMode && _react.default.createElement("div", {
|
|
87
|
+
key: "3"
|
|
88
|
+
}, _react.default.createElement(_reactBootstrap.Button, {
|
|
89
|
+
onClick: this.handleRemove,
|
|
90
|
+
bsStyle: "warning"
|
|
91
|
+
}, __('Remove'))));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
exports.PlanView = PlanView;
|
|
97
|
+
Object.defineProperty(PlanView, "propTypes", {
|
|
98
|
+
configurable: true,
|
|
99
|
+
enumerable: true,
|
|
100
|
+
writable: true,
|
|
101
|
+
value: {
|
|
102
|
+
mstId: _propTypes.default.number.isRequired,
|
|
103
|
+
star: _propTypes.default.number.isRequired,
|
|
104
|
+
planCount: _propTypes.default.number.isRequired,
|
|
105
|
+
actualCount: _propTypes.default.number.isRequired,
|
|
106
|
+
viewMode: _propTypes.default.bool.isRequired
|
|
107
|
+
}
|
|
108
|
+
});
|