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
45 changes: 0 additions & 45 deletions src/internal-packages/crud/lib/component/cancel-edit-button.jsx

This file was deleted.

45 changes: 0 additions & 45 deletions src/internal-packages/crud/lib/component/cancel-insert-button.jsx

This file was deleted.

42 changes: 0 additions & 42 deletions src/internal-packages/crud/lib/component/clone-document-button.jsx

This file was deleted.

This file was deleted.

19 changes: 13 additions & 6 deletions src/internal-packages/crud/lib/component/document-actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

const React = require('react');
const app = require('ampersand-app');
const EditDocumentButton = require('./edit-document-button');
const DeleteDocumentButton = require('./delete-document-button');
const CloneDocumentButton = require('./clone-document-button');
const IconButton = require('./icon-button');

/**
* The feature flag.
Expand Down Expand Up @@ -34,9 +32,18 @@ class DocumentActions extends React.Component {
if (app.isFeatureEnabled(FEATURE)) {
return (
<div className='document-actions'>
<EditDocumentButton handler={this.props.edit} />
<DeleteDocumentButton handler={this.props.remove} />
<CloneDocumentButton handler={this.props.clone} />
<IconButton
title='Edit Document'
iconClassName='fa fa-pencil'
clickHandler={this.props.edit} />
<IconButton
title='Delete Document'
iconClassName='fa fa-trash-o'
clickHandler={this.props.remove} />
<IconButton
title='Clone Document'
iconClassName='fa fa-clone'
clickHandler={this.props.clone} />
</div>
);
}
Expand Down
13 changes: 9 additions & 4 deletions src/internal-packages/crud/lib/component/document-footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
const _ = require('lodash');
const React = require('react');
const Element = require('hadron-document').Element;
const CancelEditButton = require('./cancel-edit-button');
const UpdateButton = require('./update-button');
const TextButton = require('./text-button');

/**
* The progress mode.
Expand Down Expand Up @@ -169,8 +168,14 @@ class DocumentFooter extends React.Component {
{this.state.message}
</div>
<div className='document-footer-actions'>
<CancelEditButton handler={this.handleCancel.bind(this)} />
<UpdateButton handler={this.handleUpdate.bind(this)} />
<TextButton
className='btn btn-link btn-xs cancel'
text='Cancel'
clickHandler={this.handleCancel.bind(this)} />
<TextButton
className='btn btn-default btn-xs update'
text='Update'
clickHandler={this.handleUpdate.bind(this)} />
</div>
</div>
);
Expand Down
9 changes: 6 additions & 3 deletions src/internal-packages/crud/lib/component/document-list.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const app = require('ampersand-app');
const Action = require('hadron-action');
const ObjectID = require('bson').ObjectID;
const Document = require('./document');
const NamespaceStore = require('hadron-reflux-store').NamespaceStore;
const ResetDocumentListStore = require('../store/reset-document-list-store');
const LoadMoreDocumentsStore = require('../store/load-more-documents-store');
const RemoveDocumentStore = require('../store/remove-document-store');
Expand Down Expand Up @@ -68,7 +69,7 @@ class DocumentList extends React.Component {
*/
constructor(props) {
super(props);
this.state = { docs: [], nextSkip: 0 };
this.state = { docs: [], nextSkip: 0, namespace: NamespaceStore.ns };
}

/**
Expand Down Expand Up @@ -101,7 +102,8 @@ class DocumentList extends React.Component {
docs: this.renderDocuments(documents),
nextSkip: documents.length,
count: count,
loadedCount: documents.length
loadedCount: documents.length,
namespace: NamespaceStore.ns
});
}

Expand Down Expand Up @@ -212,7 +214,8 @@ class DocumentList extends React.Component {
shouldComponentUpdate(nextProps, nextState) {
return (nextState.docs.length !== this.state.docs.length) ||
(nextState.nextSkip !== this.state.nextSkip) ||
(nextState.loadedCount !== this.state.loadedCount);
(nextState.loadedCount !== this.state.loadedCount) ||
(nextState.namespace !== this.state.namespace);
}

/**
Expand Down
42 changes: 0 additions & 42 deletions src/internal-packages/crud/lib/component/edit-document-button.jsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class EditableValue extends React.Component {
<input
ref={(c) => this._node = c}
type='text'
size={this.element.currentValue.length}
size={this.element.currentValue ? this.element.currentValue.length : 5}
className={this.style()}
onBlur={this.handleBlur.bind(this)}
onFocus={this.handleFocus.bind(this)}
Expand Down
53 changes: 53 additions & 0 deletions src/internal-packages/crud/lib/component/icon-button.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
'use strict';

const React = require('react');

/**
* The button constant.
*/
const BUTTON = 'button';

/**
* Component for a button with an icon.
*/
class IconButton extends React.Component {

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

/**
* Render the button.
*
* @returns {Component} The button component.
*/
render() {
return (
<button
type={BUTTON}
title={this.props.title}
className='btn btn-default btn-xs'
onClick={this.props.clickHandler}>
<i className={this.props.iconClassName} aria-hidden='true'></i>
</button>
);
}

/**
* By default should not need to to re-render itself.
*
* @returns {Boolean} Always false.
*/
shouldComponentUpdate() {
return false;
}
}

IconButton.displayName = 'IconButton';

module.exports = IconButton;
Loading