Skip to content

Commit

Permalink
Bug fix on canceling/deleting publication identifier
Browse files Browse the repository at this point in the history
Saving publication after deleting or cancelling an identifier leaves
database in inconsistent state. #29
  • Loading branch information
petkivim committed Sep 30, 2016
1 parent 2dfbd67 commit c642023
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ jQuery(document).ready(function ($) {
if (data.success == true) {
$('#system-message-container').html(showNotification('success', data.title, data.message));
$("#" + identifier).remove();
updateIdentifiersJson(identifier);
} else {
$('#system-message-container').html(showNotification('error', data.title, data.message));
}
Expand Down Expand Up @@ -116,6 +117,7 @@ jQuery(document).ready(function ($) {
if (data.success == true) {
$('#system-message-container').html(showNotification('success', data.title, data.message));
$("#" + identifier).remove();
updateIdentifiersJson(identifier);
} else {
$('#system-message-container').html(showNotification('error', data.title, data.message));
}
Expand All @@ -125,6 +127,29 @@ jQuery(document).ready(function ($) {
$('#system-message-container').html(showNotification('error', json.title, json.message));
});
}

function updateIdentifiersJson(identifier) {
updateIdentifierJson('print', identifier);
updateIdentifierJson('electronical', identifier);

}

function updateIdentifierJson(type, identifier) {
var str = $('#jform_publication_identifier_' + type).val();
if (str.length > 0) {
var json = jQuery.parseJSON(str);
if (json[identifier]) {
delete json[identifier];
if (jQuery.isEmptyObject(json)) {
str = '';
} else {
str = JSON.stringify(json);
}
$('#jform_publication_identifier_' + type).val(str);
}
}
}

});

function showNotification(type, title, message) {
Expand Down
2 changes: 1 addition & 1 deletion src/monograph-publishers/com_isbnregistry/isbnregistry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<name>COM_ISBNREGISTRY</name>
<!-- The following elements are optional and free of formatting constraints -->
<creationDate>24 September 2016</creationDate>
<creationDate>30 September 2016</creationDate>
<author>Petteri Kivimäki</author>
<copyright>(C)2015-2016 Petteri Kivimäki</copyright>
<license>http://www.gnu.org/copyright/gpl.html GNU/GPL</license>
Expand Down

0 comments on commit c642023

Please sign in to comment.