meraproject/lib/js/bws/react/table/TableTitle.js
keboss-m 5c21d25d45 Initial commit: Merakomis portal, Docker stack and user-reader API.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-24 11:04:05 +03:00

150 lines
4.0 KiB
JavaScript

var TableTitle;
import '../form/class/form.js';
import autoBind from 'react-autobind';
export default window.TableTitle = TableTitle = class TableTitle extends React.Component {
constructor(props) {
var ref, ref1, ref2;
super(props);
this.state = {
controller: (ref = props.controller) != null ? ref : '',
title: (ref1 = props.title) != null ? ref1 : '',
init_data: (ref2 = props.init_data) != null ? ref2 : [],
hide_title: props.hide_title === true,
selectedCount: 0
}; //this.createNew = this.createNew.bind(this)
//this.onSubmit = this.onSubmit.bind(this)
//this.onSubmitAndClose = this.onSubmitAndClose.bind(this)
//this.aOnSubmit = this.aOnSubmit.bind(this)
//this.deleteSelected = this.deleteSelected.bind(this)
this.modalIndex = null;
autoBind(this);
}
deleteSelected() {}
setSelectCount(x) {
return this.setState({
selectedCount: x
});
}
closeModal() {
var s;
s = Modals.rModals[this.modalIndex];
return s != null ? typeof s.close === "function" ? s.close() : void 0 : void 0;
} //console.log 'closeModal',this.modalIndex,Modals.rModals,s
aOnSubmit(x, cd) {
console.log('aOnSubmit', x, cd);
if (x.success) {
Notify.create({
text: 'Успешно сохранено'
});
this.closeModal();
if (cd.openCard) {
Modals.openCard(this.state.controller, x.id);
}
return Controllers.update(this.state.controller);
} else {
return Notify.create({
color: 'red',
text: 'Ошибка при сохранении: ' + x.error
});
}
}
deleteSelections() {
var base;
return typeof (base = this.props).onDelete === "function" ? base.onDelete() : void 0;
}
onSubmitAndClose(x) {
return this.onSubmit(x, false);
}
onSubmit(x, openCard = true) {
var controller, values;
values = x.values;
controller = values.controller;
return API(controller + '/uadd', {
values: values,
dataType: "JSON"
}, this.aOnSubmit, {
openCard
});
}
createNew() {
var init_data, title;
({
title,
init_data
} = this.state);
return this.modalIndex = Modals.create({
scrollable: true,
width: 800,
content: /*#__PURE__*/React.createElement("div", {
class: "f1_db"
}, /*#__PURE__*/React.createElement("div", {
class: "row"
}, /*#__PURE__*/React.createElement("div", {
class: "c"
}, /*#__PURE__*/React.createElement("div", {
class: "h"
}, title, ". \u0414\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u0438\u0435"))), /*#__PURE__*/React.createElement("div", {
class: "block"
}, /*#__PURE__*/React.createElement("div", {
class: "body"
}, /*#__PURE__*/React.createElement("div", {
class: "cont"
}, /*#__PURE__*/React.createElement(Form, {
ajaxFast: true,
ajaxInitData: init_data,
controller: this.state.controller,
onSubmit: this.onSubmit,
onSubmitAndClose: this.onSubmitAndClose,
values: init_data
})))))
});
}
render() {
var buttons, hide_title, selectedCount;
({
hide_title,
selectedCount
} = this.state);
if (hide_title) {
return null;
}
buttons = [];
if (selectedCount) {
buttons.push( /*#__PURE__*/React.createElement("button", {
type: "button",
className: "btn red small",
onClick: this.deleteSelections
}, "\u0423\u0434\u0430\u043B\u0438\u0442\u044C"));
}
return /*#__PURE__*/React.createElement("div", {
class: "table_title"
}, /*#__PURE__*/React.createElement("div", {
class: "btns"
}, /*#__PURE__*/React.createElement("button", {
type: "button",
className: "btn blue small",
onClick: this.createNew
}, "\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C"), buttons));
}
}; // <button type="button" className={"btn red small"} onClick={this.deleteSelected}>Удалить</button>
//# sourceMappingURL=TableTitle.js.map