Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"start": "hadron-build develop",
"pretest": "mongodb-runner install",
"test": "xvfb-maybe hadron-build test",
"check": "mongodb-js-precommit ./src/app/*.js ./src/app/**/**/*.js ./src/{app/**/*.js,main/**/*.js} ./test/*.js",
"check": "mongodb-js-precommit ./src/app/*.js ./src/app/**/**/*.js ./src/{app/**/*.js,main/**/*.js} ./test/*.js ./src/internal-packages/**/*.js ./src/internal-packages/**/**/*{.js,.jsx} ./src/internal-packages/**/**/**/*{.js,.jsx} ./src/internal-packages/**/**/**/**/*{.js,.jsx}",
"ci": "npm run check && npm run test-unit",
"clean": "hadron-build clean",
"compile-ui": "hadron-build ui",
Expand Down
2 changes: 0 additions & 2 deletions src/internal-packages/crud/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

const app = require('ampersand-app');
const Document = require('./lib/component/document');
const DocumentList = require('./lib/component/document-list');
Expand Down
2 changes: 0 additions & 2 deletions src/internal-packages/crud/lib/actions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

const Reflux = require('reflux');

const Actions = Reflux.createActions([
Expand Down
36 changes: 19 additions & 17 deletions src/internal-packages/crud/lib/component/binary-value.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

const React = require('react');
const truncate = require('hadron-app-registry').truncate;

Expand Down Expand Up @@ -35,7 +33,21 @@ class BinaryValue extends React.Component {
*/
constructor(props) {
super(props);
this.value = props.element.currentValue;
this.element = props.element;
}

/**
* Render the value.
*
* @returns {Component} The component.
*/
renderValue() {
const type = this.element.currentValue.sub_type;
const buffer = this.element.currentValue.buffer;
if (type === UUID || type === UUID_OLD) {
return `Binary('${truncate(buffer.toString())}')`;
}
return `Binary('${truncate(buffer.toString(BASE_64))}')`;
}

/**
Expand All @@ -50,22 +62,12 @@ class BinaryValue extends React.Component {
</div>
);
}

/**
* Render the value.
*
* @returns {Component} The component.
*/
renderValue() {
var type = this.value.sub_type;
var buffer = this.value.buffer;
if (type === UUID || type === UUID_OLD) {
return `Binary('${truncate(buffer.toString())}')`;
}
return `Binary('${truncate(buffer.toString(BASE_64))}')`;
}
}

BinaryValue.displayName = 'BinaryValue';

BinaryValue.propTypes = {
element: React.PropTypes.object.isRequired
};

module.exports = BinaryValue;
10 changes: 6 additions & 4 deletions src/internal-packages/crud/lib/component/code-value.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

const React = require('react');
const truncate = require('hadron-app-registry').truncate;

Expand All @@ -20,7 +18,7 @@ class CodeValue extends React.Component {
*/
constructor(props) {
super(props);
this.value = props.element.currentValue;
this.element = props.element;
}

/**
Expand All @@ -31,12 +29,16 @@ class CodeValue extends React.Component {
render() {
return (
<div className={VALUE_CLASS}>
{truncate(this.value.code)}
{truncate(this.element.currentValue.code)}
</div>
);
}
}

CodeValue.displayName = 'CodeValue';

CodeValue.propTypes = {
element: React.PropTypes.object.isRequired
};

module.exports = CodeValue;
31 changes: 13 additions & 18 deletions src/internal-packages/crud/lib/component/document-actions.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

const React = require('react');
const IconButton = require('hadron-app-registry').IconButton;

Expand All @@ -8,34 +6,25 @@ const IconButton = require('hadron-app-registry').IconButton;
*/
class DocumentActions extends React.Component {

/**
* The component constructor.
*
* @param {Object} props - The properties.
*/
constructor(props) {
super(props);
}

/**
* Render the actions.
*
* @returns {Component} The actions component.
*/
render() {
return (
<div className='document-actions'>
<div className="document-actions">
<IconButton
title='Edit Document'
iconClassName='fa fa-pencil'
title="Edit Document"
iconClassName="fa fa-pencil"
clickHandler={this.props.edit} />
<IconButton
title='Delete Document'
iconClassName='fa fa-trash-o'
title="Delete Document"
iconClassName="fa fa-trash-o"
clickHandler={this.props.remove} />
<IconButton
title='Clone Document'
iconClassName='fa fa-clone'
title="Clone Document"
iconClassName="fa fa-clone"
clickHandler={this.props.clone} />
</div>
);
Expand All @@ -44,4 +33,10 @@ class DocumentActions extends React.Component {

DocumentActions.displayName = 'DocumentActions';

DocumentActions.propTypes = {
edit: React.PropTypes.func.isRequired,
remove: React.PropTypes.func.isRequired,
clone: React.PropTypes.func.isRequired
};

module.exports = DocumentActions;
45 changes: 24 additions & 21 deletions src/internal-packages/crud/lib/component/document-footer.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
'use strict';

const _ = require('lodash');
const React = require('react');
const Element = require('hadron-document').Element;
const TextButton = require('hadron-app-registry').TextButton;
Expand Down Expand Up @@ -39,7 +36,7 @@ const MODES = {
'Error': 'error',
'Editing': 'modified',
'Viewing': 'viewing'
}
};

/**
* The empty message.
Expand Down Expand Up @@ -130,7 +127,7 @@ class DocumentFooter extends React.Component {
* Handle the user clicking the update button.
*/
handleUpdate() {
var object = this.props.doc.generateObject();
const object = this.props.doc.generateObject();
this.setState({ mode: PROGRESS, message: UPDATING });
this.actions.update(object);
}
Expand All @@ -146,7 +143,7 @@ class DocumentFooter extends React.Component {
* Handles a trigger from the store.
*
* @param {Boolean} success - If the update succeeded.
* @param {Error, Document} object - The error or document.
* @param {Object} object - The error or document.
*/
handleStoreUpdate(success, object) {
if (success) {
Expand All @@ -156,6 +153,15 @@ class DocumentFooter extends React.Component {
}
}

/**
* Get the style of the footer based on the current mode.
*
* @returns {String} The style.
*/
style() {
return `document-footer ${MODES[this.state.mode]}`;
}

/**
* Render the footer.
*
Expand All @@ -164,33 +170,30 @@ class DocumentFooter extends React.Component {
render() {
return (
<div className={this.style()}>
<div className='edit-message' title={this.state.message}>
<div className="edit-message" title={this.state.message}>
{this.state.message}
</div>
<div className='document-footer-actions'>
<div className="document-footer-actions">
<TextButton
className='btn btn-link btn-xs cancel'
text='Cancel'
className="btn btn-link btn-xs cancel"
text="Cancel"
clickHandler={this.handleCancel.bind(this)} />
<TextButton
className='btn btn-default btn-xs update'
text='Update'
className="btn btn-default btn-xs update"
text="Update"
clickHandler={this.handleUpdate.bind(this)} />
</div>
</div>
);
}

/**
* Get the style of the footer based on the current mode.
*
* @returns {String} The style.
*/
style() {
return `document-footer ${MODES[this.state.mode]}`;
}
}

DocumentFooter.displayName = 'DocumentFooter';

DocumentFooter.propTypes = {
doc: React.PropTypes.object.isRequired,
actions: React.PropTypes.object.isRequired,
updateStore: React.PropTypes.object.isRequired
};

module.exports = DocumentFooter;
Loading