97 lines
2.8 KiB
JavaScript
97 lines
2.8 KiB
JavaScript
var MoneyFastForm;
|
|
export default window.MoneyFastForm = MoneyFastForm = class MoneyFastForm extends React.Component {
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = {
|
|
expand: false,
|
|
values: {}
|
|
};
|
|
this.cat = null;
|
|
this.value = null;
|
|
this.comment = null;
|
|
this.checkExpand = this.checkExpand.bind(this);
|
|
this.setValue = this.setValue.bind(this);
|
|
this.cancel = this.cancel.bind(this);
|
|
}
|
|
|
|
setValue(e) {
|
|
var t, v;
|
|
t = e.target;
|
|
v = this.state.values;
|
|
v[t.getAttribute('name')] = t.value;
|
|
this.setState({
|
|
values: v
|
|
});
|
|
return this.checkExpand();
|
|
}
|
|
|
|
checkExpand() {
|
|
var c, expand, isCat, isComment, isValue; //isCat = (this.cat == document.activeElement || (c = this.state.values.cat)? && c!='')
|
|
|
|
isCat = false;
|
|
isValue = this.value === document.activeElement || (c = this.state.values.value) != null && c !== '';
|
|
isComment = this.comment === document.activeElement || (c = this.state.values.comment) != null && c !== '';
|
|
expand = isCat || isValue || isComment;
|
|
console.log(isCat, isValue, isComment);
|
|
return this.setState({
|
|
expand
|
|
});
|
|
}
|
|
|
|
cancel() {
|
|
this.cat.cancel();
|
|
this.value.value = '';
|
|
this.comment.value = '';
|
|
return this.setState({
|
|
expand: false,
|
|
values: {}
|
|
}, this.checkExpand);
|
|
}
|
|
|
|
render() {
|
|
var _this = this;
|
|
|
|
return /*#__PURE__*/React.createElement("form", {
|
|
onSubmit: this.submit
|
|
}, /*#__PURE__*/React.createElement("div", {
|
|
className: "inputs"
|
|
}, /*#__PURE__*/React.createElement(SelectSearch, {
|
|
ref: function (i) {
|
|
return _this.cat = i;
|
|
},
|
|
data: H.getData.bind(null, 'money_categories'),
|
|
placeholder: "Категория",
|
|
canCreateNew: true
|
|
}), /*#__PURE__*/React.createElement("input", {
|
|
ref: function (i) {
|
|
return _this.value = i;
|
|
},
|
|
name: "value",
|
|
className: "input_value",
|
|
placeholder: "1000.00",
|
|
onKeyUp: this.setValue,
|
|
onFocus: this.checkExpand,
|
|
onBlur: this.checkExpand
|
|
}), /*#__PURE__*/React.createElement("input", {
|
|
ref: function (i) {
|
|
return _this.comment = i;
|
|
},
|
|
name: "comment",
|
|
className: "input_comment",
|
|
placeholder: "\u041A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0439",
|
|
onKeyUp: this.setValue,
|
|
onFocus: this.checkExpand,
|
|
onBlur: this.checkExpand
|
|
})), this.state.expand ? /*#__PURE__*/React.createElement("div", {
|
|
className: "buttons"
|
|
}, /*#__PURE__*/React.createElement("button", {
|
|
type: "submit",
|
|
className: ""
|
|
}, "\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C"), /*#__PURE__*/React.createElement("button", {
|
|
type: "button",
|
|
className: "",
|
|
onClick: this.cancel
|
|
}, "\u041E\u0442\u043C\u0435\u043D\u0430")) : null);
|
|
}
|
|
|
|
}; |