Skip to content

Commit a081eca

Browse files
authored
Merge pull request #18 from opencobra/constructor_dev
Constructor dev
2 parents 5760f85 + b89fb7a commit a081eca

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

curationTool/reactions/static/reactions/js_VMH_workspace/handleAdd2VMH.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,12 +448,24 @@ confirmAddToVMHBtn && confirmAddToVMHBtn.addEventListener('click', addToVMH);
448448
// Close the alert modal when the user clicks on <span> (x)
449449
document.querySelector('.close-alert-btn').addEventListener('click', function () {
450450
document.getElementById('alertModal').style.display = 'none';
451+
452+
if (window.pkPendingRemoval !== null) {
453+
const li = document.querySelector(`#wsAvailableReactionList li[data-pk="${window.pkPendingRemoval}"]`);
454+
if (li) li.remove();
455+
window.pkPendingRemoval = null;
456+
}
451457
});
452458

453459
// Also close the modal if the user clicks anywhere outside of the modal
454460
window.onclick = function (event) {
455461
if (event.target == document.getElementById('alertModal')) {
456462
document.getElementById('alertModal').style.display = 'none';
463+
464+
if (window.pkPendingRemoval !== null) {
465+
const li = document.querySelector(`#wsAvailableReactionList li[data-pk="${window.pkPendingRemoval}"]`);
466+
if (li) li.remove();
467+
window.pkPendingRemoval = null;
468+
}
457469
}
458470
};
459471

curationTool/reactions/static/reactions/js_VMH_workspace/workspace.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ document.querySelectorAll('.subtabs').forEach((bar) => {
3636
// 1 – draw the list of abbreviations
3737
const availableListEl = document.getElementById('wsAvailableReactionList');
3838
const availableDetailEl = document.getElementById('wsAvailableReactionDetails');
39+
window.pkPendingRemoval = null;
3940

4041
// Load available reactions
4142
reactions_active.forEach((r) => {
@@ -80,13 +81,15 @@ document.querySelectorAll('.subtabs').forEach((bar) => {
8081
'An error occurred while fetching data from VMH. Check console for error. Please try again later.';
8182
document.getElementById('alertModal').style.display = 'block';
8283
document.getElementById('loadingIndicator').style.display = 'none';
84+
window.pkPendingRemoval = reaction.pk;
8385
return '';
8486
}
8587

8688
if (vmhResponse.status === 'error') {
8789
document.getElementById('alertMessage').textContent = vmhResponse.message;
8890
document.getElementById('alertModal').style.display = 'block';
8991
document.getElementById('loadingIndicator').style.display = 'none';
92+
window.pkPendingRemoval = reaction.pk;
9093
return '';
9194
}
9295

curationTool/reactions/utils/add_to_vmh_utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -386,10 +386,10 @@ def update_vmh_info(items_info, names_vmh, abbr_vmh, found_info):
386386

387387
def validate_reaction_fields(reactions):
388388
"""
389-
Validate that each reaction has non-empty short_name, abbreviation, and confidence_score.
389+
Validate that each reaction has non-empty description, abbreviation, and confidence_score.
390390
Also check for duplicates in the list.
391391
"""
392-
missing_names = [reaction['short_name'] == '' for reaction in reactions]
392+
missing_names = [reaction['description'] == '' for reaction in reactions]
393393
if True in missing_names:
394394
return JsonResponse({'status': 'error',
395395
'message': 'Please enter a description for reaction'})
@@ -404,7 +404,7 @@ def validate_reaction_fields(reactions):
404404
return JsonResponse({'status': 'error',
405405
'message': 'Please enter a confidence score for reaction'})
406406

407-
names_list = [reaction['short_name'] for reaction in reactions]
407+
names_list = [reaction['description'] for reaction in reactions]
408408
for name in names_list:
409409
if names_list.count(name) > 1:
410410
return JsonResponse({'status': 'error',
@@ -423,13 +423,13 @@ def validate_reaction_existence(reactions):
423423
Validate that the reaction names and abbreviations do not already exist in VMH.
424424
"""
425425
name_in_vmh, abbr_in_vmh = check_names_abbrs_vmh(
426-
[(reaction['short_name'], reaction['abbreviation']) for reaction in reactions]
426+
[(reaction['description'], reaction['abbreviation']) for reaction in reactions]
427427
)
428428
if True in list(name_in_vmh.values()):
429429
name_in_vmh_reactions = [
430430
reaction for reaction, in_vmh in zip(reactions, name_in_vmh.values()) if in_vmh
431431
]
432-
reaction_names = ", ".join([reaction["short_name"] for reaction in name_in_vmh_reactions])
432+
reaction_names = ", ".join([reaction["description"] for reaction in name_in_vmh_reactions])
433433
return JsonResponse({'status': 'error',
434434
'message': f'The following reaction descriptions are already in VMH: {reaction_names}'})
435435

curationTool/reactions/views/vmh_views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ def add_to_vmh(request):
534534

535535
reaction_identifiers, reaction_names = [
536536
reaction['abbreviation'] for reaction in reactions], [
537-
reaction['description'] for reaction in reaction_objs]
537+
reaction.description for reaction in reaction_objs]
538538
matlab_session = None if all_vmh else MatlabSessionManager()
539539
if not all_vmh:
540540
unique_abbrs, unique_mols, unique_types, unique_names = get_nonfound_metabolites(

0 commit comments

Comments
 (0)