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',
'selectEdition',
'clearAllEditionSelections',
'closeAllEditionLists',
'toggleEditionList'
);
}

View File

@ -59,8 +59,13 @@ let AccordionListItemTableEditions = React.createClass({
},
toggleTable() {
// This is triggered everytime show all editions is clicked, which is wrong
EditionListActions.fetchEditionList(this.props.parentId);
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');

View File

@ -23,12 +23,13 @@ let DeleteButton = React.createClass({
mixins: [Router.Navigation],
showNotification(response){
showNotification(response) {
this.props.editions
.forEach((edition) => {
EditionListActions.fetchEditionList(edition.parent);
});
EditionListActions.clearAllEditionSelections();
EditionListActions.closeAllEditionLists();
this.transitionTo('pieces');
let notification = new GlobalNotificationModel(response.notification, 'success');
GlobalNotificationActions.appendGlobalNotification(notification);

View File

@ -52,7 +52,7 @@ let LoanForm = React.createClass({
loaneeHasContract: true
});
}
else{
else {
this.resetLoanContract();
}
})
@ -63,10 +63,11 @@ let LoanForm = React.createClass({
},
resetLoanContract(){
this.setState({contract_key: null,
contract_url: null,
loaneeHasContract: false
});
this.setState({
contract_key: null,
contract_url: null,
loaneeHasContract: false
});
},
renderForm() {

View File

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

View File

@ -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>

View File

@ -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);