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:
parent
9cc70dc4c9
commit
6e7037e5f2
@ -10,6 +10,7 @@ class EditionListActions {
|
||||
'updateEditionList',
|
||||
'selectEdition',
|
||||
'clearAllEditionSelections',
|
||||
'closeAllEditionLists',
|
||||
'toggleEditionList'
|
||||
);
|
||||
}
|
||||
|
@ -59,8 +59,13 @@ let AccordionListItemTableEditions = React.createClass({
|
||||
},
|
||||
|
||||
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);
|
||||
}
|
||||
},
|
||||
|
||||
changeEditionListOrder(orderBy, orderAsc) {
|
||||
@ -84,8 +89,8 @@ let AccordionListItemTableEditions = React.createClass({
|
||||
orderAsc = this.state.editionList[this.props.parentId].orderAsc;
|
||||
}
|
||||
|
||||
if(this.props.parentId in this.state.editionOpenList) {
|
||||
show = this.state.editionOpenList[this.props.parentId].show;
|
||||
if(this.props.parentId in this.state.isEditionListOpenForPieceId) {
|
||||
show = this.state.isEditionListOpenForPieceId[this.props.parentId].show;
|
||||
}
|
||||
|
||||
let transition = new TransitionModel('edition', 'editionId', 'bitcoin_id');
|
||||
|
@ -29,6 +29,7 @@ let DeleteButton = React.createClass({
|
||||
EditionListActions.fetchEditionList(edition.parent);
|
||||
});
|
||||
EditionListActions.clearAllEditionSelections();
|
||||
EditionListActions.closeAllEditionLists();
|
||||
this.transitionTo('pieces');
|
||||
let notification = new GlobalNotificationModel(response.notification, 'success');
|
||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||
|
@ -63,7 +63,8 @@ let LoanForm = React.createClass({
|
||||
},
|
||||
|
||||
resetLoanContract(){
|
||||
this.setState({contract_key: null,
|
||||
this.setState({
|
||||
contract_key: null,
|
||||
contract_url: null,
|
||||
loaneeHasContract: false
|
||||
});
|
||||
|
@ -65,6 +65,7 @@ let PieceListBulkModal = React.createClass({
|
||||
|
||||
clearAllSelections() {
|
||||
EditionListActions.clearAllEditionSelections();
|
||||
EditionListActions.closeAllEditionLists();
|
||||
},
|
||||
|
||||
handleSuccess() {
|
||||
|
@ -38,7 +38,7 @@ let Header = React.createClass({
|
||||
return (
|
||||
<Navbar>
|
||||
<Nav>
|
||||
<Link className="navbar-brand" to="pieces" path="/">
|
||||
<Link className="navbar-brand" to="pieces" path="/?page=1">
|
||||
<span>ascribe </span>
|
||||
<span className="glyph-ascribe-spool-chunked ascribe-color"></span>
|
||||
</Link>
|
||||
|
@ -8,7 +8,7 @@ import EditionsListActions from '../actions/edition_list_actions';
|
||||
class EditionListStore {
|
||||
constructor() {
|
||||
this.editionList = {};
|
||||
this.editionOpenList = {};
|
||||
this.isEditionListOpenForPieceId = {};
|
||||
this.bindActions(EditionsListActions);
|
||||
}
|
||||
|
||||
@ -25,13 +25,8 @@ class EditionListStore {
|
||||
|
||||
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.
|
||||
*
|
||||
* 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);
|
Loading…
Reference in New Issue
Block a user