From 39ec4c5b917787ac039a5bd08cd05d826aa3752e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Daubensch=C3=BCtz?= Date: Thu, 16 Jul 2015 11:50:52 +0200 Subject: [PATCH] fix wrong feedback for deleting an edition --- js/components/ascribe_detail/edition.js | 2 +- js/stores/edition_list_store.js | 12 ++++++++++++ js/utils/lang_utils.js | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/js/components/ascribe_detail/edition.js b/js/components/ascribe_detail/edition.js index 5b246e8f..0de6d153 100644 --- a/js/components/ascribe_detail/edition.js +++ b/js/components/ascribe_detail/edition.js @@ -29,7 +29,6 @@ import InputTextAreaToggable from './../ascribe_forms/input_textarea_toggable'; import EditionFurtherDetails from './further_details'; import RequestActionForm from './../ascribe_forms/form_request_action'; -import EditionActions from '../../actions/edition_actions'; import AclButtonList from './../ascribe_buttons/acl_button_list'; import UnConsignRequestButton from './../ascribe_buttons/unconsign_request_button'; import DeleteButton from '../ascribe_buttons/delete_button'; @@ -80,6 +79,7 @@ let Edition = React.createClass({ handleDeleteSuccess(response) { PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search, this.state.orderBy, this.state.orderAsc); + console.log(this.props.edition.parent); EditionListActions.refreshEditionList(this.props.edition.parent); EditionListActions.closeAllEditionLists(); EditionListActions.clearAllEditionSelections(); diff --git a/js/stores/edition_list_store.js b/js/stores/edition_list_store.js index 2857f7df..76c54a1c 100644 --- a/js/stores/edition_list_store.js +++ b/js/stores/edition_list_store.js @@ -61,6 +61,16 @@ class EditionListStore { * this method provides exactly that functionality without any side effects */ onRefreshEditionList(pieceId) { + + // It may happen that the user enters the site logged in already + // through /editions + // If he then tries to delete a piece/edition and this method is called, + // we'll not be able to refresh his edition list since its not yet there. + // Therefore we can just return, since there is no data to be refreshed + if(!this.editionList[pieceId]) { + return; + } + const prevEditionListLength = this.editionList[pieceId].length; const prevEditionListPage = this.editionList[pieceId].page; const prevEditionListPageSize = this.editionList[pieceId].pageSize; @@ -69,6 +79,8 @@ class EditionListStore { // http://davidwalsh.name/empty-array this.editionList[pieceId].length = 0; + + // refetch editions with adjusted page size EditionsListActions.fetchEditionList(pieceId, 1, prevEditionListLength, this.editionList[pieceId].orderBy, this.editionList[pieceId].orderAsc) .then(() => { diff --git a/js/utils/lang_utils.js b/js/utils/lang_utils.js index 39454806..6f0336c2 100644 --- a/js/utils/lang_utils.js +++ b/js/utils/lang_utils.js @@ -29,7 +29,7 @@ export function getLangText(s, ...args) { } } catch(err) { //if(!(s in languages[lang])) { - console.warn('Language-string is not in constants file. Add: "' + s + '" to the "' + lang + '" language file. Defaulting to keyname'); + //console.warn('Language-string is not in constants file. Add: "' + s + '" to the "' + lang + '" language file. Defaulting to keyname'); return s; //} else { // console.error(err);