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',
|
'updateEditionList',
|
||||||
'selectEdition',
|
'selectEdition',
|
||||||
'clearAllEditionSelections',
|
'clearAllEditionSelections',
|
||||||
|
'closeAllEditionLists',
|
||||||
'toggleEditionList'
|
'toggleEditionList'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
EditionListActions.fetchEditionList(this.props.parentId);
|
if(isEditionListOpen) {
|
||||||
|
EditionListActions.toggleEditionList(this.props.parentId);
|
||||||
|
} else {
|
||||||
|
EditionListActions.toggleEditionList(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');
|
||||||
|
@ -23,12 +23,13 @@ let DeleteButton = React.createClass({
|
|||||||
|
|
||||||
mixins: [Router.Navigation],
|
mixins: [Router.Navigation],
|
||||||
|
|
||||||
showNotification(response){
|
showNotification(response) {
|
||||||
this.props.editions
|
this.props.editions
|
||||||
.forEach((edition) => {
|
.forEach((edition) => {
|
||||||
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);
|
||||||
|
@ -52,7 +52,7 @@ let LoanForm = React.createClass({
|
|||||||
loaneeHasContract: true
|
loaneeHasContract: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
this.resetLoanContract();
|
this.resetLoanContract();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -63,10 +63,11 @@ let LoanForm = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
resetLoanContract(){
|
resetLoanContract(){
|
||||||
this.setState({contract_key: null,
|
this.setState({
|
||||||
contract_url: null,
|
contract_key: null,
|
||||||
loaneeHasContract: false
|
contract_url: null,
|
||||||
});
|
loaneeHasContract: false
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
renderForm() {
|
renderForm() {
|
||||||
|
@ -65,6 +65,7 @@ let PieceListBulkModal = React.createClass({
|
|||||||
|
|
||||||
clearAllSelections() {
|
clearAllSelections() {
|
||||||
EditionListActions.clearAllEditionSelections();
|
EditionListActions.clearAllEditionSelections();
|
||||||
|
EditionListActions.closeAllEditionLists();
|
||||||
},
|
},
|
||||||
|
|
||||||
handleSuccess() {
|
handleSuccess() {
|
||||||
|
@ -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>
|
||||||
|
@ -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);
|
Loading…
Reference in New Issue
Block a user