Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurkushman committed Jun 12, 2017
2 parents af3f121 + 98292eb commit 233a6d0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gigatables-react",
"version": "1.6.5",
"version": "1.6.6",
"description": "GigaTables is a ReactJS plug-in to help web-developers process table-data in applications and CMS, CRM, ERP or similar systems. It supports ajax data processing/editing (CRUD), pagination, cross-sorting, global search, shft/ctrl rows selection, 7 popular languages and more.",
"main": "./build/index.js",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/Reactables.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Reactables extends Main {
fieldsEdit: {},
columnsSearch: {},
discreteFocus: false,
scrolledDown: false
scrolledDown: false,
}
// cols opts
this.searchableCols = [];
Expand Down
31 changes: 25 additions & 6 deletions src/components/Editor.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component } from 'react';
import React, { Component, PropTypes } from 'react';
import { EditorException } from './Exceptions';
import editorStyles from '../css/editor.css';
import classNames from 'classnames/bind';
Expand Down Expand Up @@ -250,7 +250,7 @@ class Editor extends Component {
btnClicked(e)
{
e.persist(); // this is to avoid null values in this.props.editorUpdate(e, dataResp) call
const { action, editorUpdate } = this.props;
const { action, editorUpdate, selectedIds } = this.props;
let ajaxUrl = this.props.editor.ajax, that = this;
var dataResp = that.state.dataIndices;
if (action === EditorConstants.ACTION_CREATE) {
Expand All @@ -268,9 +268,13 @@ class Editor extends Component {
} else if (action === EditorConstants.ACTION_EDIT) {
this.triggerBefore(EditorConstants.EDITOR_EDIT);
this.fileUpload();
// fill-in id
let payload = Object.assign({}, this.state.dataIndices, {
['id']: selectedIds[0]
});
fetch(ajaxUrl, {
method: EditorConstants.HTTP_METHOD_PUT,
body: JSON.stringify(this.state.dataIndices)
body: JSON.stringify(payload)
}).then(response => response.json()).then((data) => {
editorUpdate(e, dataResp);
this.triggerAfter(EditorConstants.EDITOR_EDIT);
Expand All @@ -279,7 +283,7 @@ class Editor extends Component {
this.triggerBefore(EditorConstants.EDITOR_REMOVE);
fetch(ajaxUrl, {
method: EditorConstants.HTTP_METHOD_DELETE,
body: JSON.stringify(this.props.dataIndices)
body: JSON.stringify(this.props.dataIndices) // prop ids are passed from Reactables
}).then(response => response.json()).then((data) => {
// call editorUpdate method with passing all user-input values
editorUpdate(e, dataResp);
Expand All @@ -293,6 +297,13 @@ class Editor extends Component {
e.stopPropagation();
}

btnClickedEnter(e)
{
if(e.keyCode === CommonConstants.ENTER_KEY) {
document.getElementById('gte_sent_btn').click();
}
}

render()
{
const {
Expand All @@ -301,7 +312,7 @@ class Editor extends Component {
popupTitle,
action,
popupButton,
active
active,
} = this.props;
this.setFields(this.props);
let editorClasses = classNames({
Expand All @@ -319,7 +330,7 @@ class Editor extends Component {
<div onClick={hidePopup} className={editorClasses}>
<div className="gte_popup_container">
<div className="gte_popup_container_wrapper">
<div onClick={this.stopPropagation.bind(this)} className="gte_form_border_box">
<div onKeyUp={this.btnClickedEnter.bind(this)} onClick={this.stopPropagation.bind(this)} className="gte_form_border_box">
<div className="gte_form_fields">
<div className="gte_header">
<div className="gte_editor_title">{popupTitle}</div>
Expand Down Expand Up @@ -359,4 +370,12 @@ class Editor extends Component {
}
}

Editor.PropTYpes = {
active: PropTypes.bool.isRequired,
editor: PropTypes.object.isRequired,
action: PropTypes.string.isRequired,
popupTitle: PropTypes.string.isRequired,
popupButton: PropTypes.string.isRequired,
}

export default Editor

0 comments on commit 233a6d0

Please sign in to comment.