1
0
mirror of https://github.com/ascribe/onion.git synced 2024-11-15 01:25:17 +01:00

Finish implementing refactor for open and close for edition lists

This commit is contained in:
Tim Daubenschütz 2015-06-15 09:29:34 +02:00
parent 9cc70dc4c9
commit 6e7037e5f2
7 changed files with 32 additions and 18 deletions

View File

@ -10,6 +10,7 @@ class EditionListActions {
'updateEditionList', 'updateEditionList',
'selectEdition', 'selectEdition',
'clearAllEditionSelections', 'clearAllEditionSelections',
'closeAllEditionLists',
'toggleEditionList' 'toggleEditionList'
); );
} }

View File

@ -59,8 +59,13 @@ let AccordionListItemTableEditions = React.createClass({
}, },
toggleTable() { toggleTable() {
// This is triggered everytime show all editions is clicked, which is wrong let isEditionListOpen = this.state.isEditionListOpenForPieceId[this.props.parentId] ? this.state.isEditionListOpenForPieceId[this.props.parentId].show : false;
if(isEditionListOpen) {
EditionListActions.toggleEditionList(this.props.parentId);
} else {
EditionListActions.toggleEditionList(this.props.parentId);
EditionListActions.fetchEditionList(this.props.parentId); EditionListActions.fetchEditionList(this.props.parentId);
}
}, },
changeEditionListOrder(orderBy, orderAsc) { changeEditionListOrder(orderBy, orderAsc) {
@ -84,8 +89,8 @@ let AccordionListItemTableEditions = React.createClass({
orderAsc = this.state.editionList[this.props.parentId].orderAsc; orderAsc = this.state.editionList[this.props.parentId].orderAsc;
} }
if(this.props.parentId in this.state.editionOpenList) { if(this.props.parentId in this.state.isEditionListOpenForPieceId) {
show = this.state.editionOpenList[this.props.parentId].show; show = this.state.isEditionListOpenForPieceId[this.props.parentId].show;
} }
let transition = new TransitionModel('edition', 'editionId', 'bitcoin_id'); let transition = new TransitionModel('edition', 'editionId', 'bitcoin_id');

View File

@ -29,6 +29,7 @@ let DeleteButton = React.createClass({
EditionListActions.fetchEditionList(edition.parent); EditionListActions.fetchEditionList(edition.parent);
}); });
EditionListActions.clearAllEditionSelections(); EditionListActions.clearAllEditionSelections();
EditionListActions.closeAllEditionLists();
this.transitionTo('pieces'); this.transitionTo('pieces');
let notification = new GlobalNotificationModel(response.notification, 'success'); let notification = new GlobalNotificationModel(response.notification, 'success');
GlobalNotificationActions.appendGlobalNotification(notification); GlobalNotificationActions.appendGlobalNotification(notification);

View File

@ -63,7 +63,8 @@ let LoanForm = React.createClass({
}, },
resetLoanContract(){ resetLoanContract(){
this.setState({contract_key: null, this.setState({
contract_key: null,
contract_url: null, contract_url: null,
loaneeHasContract: false loaneeHasContract: false
}); });

View File

@ -65,6 +65,7 @@ let PieceListBulkModal = React.createClass({
clearAllSelections() { clearAllSelections() {
EditionListActions.clearAllEditionSelections(); EditionListActions.clearAllEditionSelections();
EditionListActions.closeAllEditionLists();
}, },
handleSuccess() { handleSuccess() {

View File

@ -38,7 +38,7 @@ let Header = React.createClass({
return ( return (
<Navbar> <Navbar>
<Nav> <Nav>
<Link className="navbar-brand" to="pieces" path="/"> <Link className="navbar-brand" to="pieces" path="/?page=1">
<span>ascribe </span> <span>ascribe </span>
<span className="glyph-ascribe-spool-chunked ascribe-color"></span> <span className="glyph-ascribe-spool-chunked ascribe-color"></span>
</Link> </Link>

View File

@ -8,7 +8,7 @@ import EditionsListActions from '../actions/edition_list_actions';
class EditionListStore { class EditionListStore {
constructor() { constructor() {
this.editionList = {}; this.editionList = {};
this.editionOpenList = {}; this.isEditionListOpenForPieceId = {};
this.bindActions(EditionsListActions); this.bindActions(EditionsListActions);
} }
@ -25,13 +25,8 @@ class EditionListStore {
this.editionList[pieceId] = editionListOfPiece; this.editionList[pieceId] = editionListOfPiece;
// ToDo: Do merging later
this.editionOpenList[pieceId] = {
show: this.editionOpenList[pieceId] ? !this.editionOpenList[pieceId].show : true
};
/** /**
* orderBy and orderAsc are specific to a single list of editons * orderBy and orderAsc are specific to a single list of editions
* therefore they need to be saved in relation to their parent-piece. * therefore they need to be saved in relation to their parent-piece.
* *
* Default values for both are set in the editon_list-actions. * Default values for both are set in the editon_list-actions.
@ -68,6 +63,16 @@ class EditionListStore {
}); });
}); });
} }
onToggleEditionList(pieceId) {
this.isEditionListOpenForPieceId[pieceId] = {
show: this.isEditionListOpenForPieceId[pieceId] ? !this.isEditionListOpenForPieceId[pieceId].show : true
};
}
onCloseAllEditionLists() {
this.isEditionListOpenForPieceId = {};
}
} }
export default alt.createStore(EditionListStore); export default alt.createStore(EditionListStore);