Skip to content
This repository has been archived by the owner on Aug 24, 2024. It is now read-only.

Commit

Permalink
BUGFIX: Fix disappearing documents
Browse files Browse the repository at this point in the history
When a user cut and moved a folder, an unknown javascript bug would
occasionally cause the path value not to be registered. The server-side script
would then erroneously update all document paths for the current case,
making it appear to the user that all case documents had disappeared. This
fix throws an error if the path value is not registered client side
and prompts the user to reload page and try again.
  • Loading branch information
judsonmitchell committed Aug 28, 2016
1 parent 6cc73d7 commit 3d3e642
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 12 deletions.
2 changes: 1 addition & 1 deletion html/js/Cases.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions html/js/cases.min.js

Large diffs are not rendered by default.

14 changes: 11 additions & 3 deletions html/js/casesDocuments.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ function createDragDrop() {
'case_id': caseId
}, function(data) {
var serverResponse = $.parseJSON(data);
notify(serverResponse.message);
ui.draggable.fadeOut();
if (serverResponse.wait){
notify(serverResponse.message,true,'error');
} else {
notify(serverResponse.message);
ui.draggable.fadeOut();
}
});
}}).draggable({revert: 'invalid',containment: 'div.case_detail_panel_casenotes'});
}
Expand Down Expand Up @@ -447,7 +451,11 @@ $('.case_detail_nav #item3').live('click', function() {
},
function(data) {
var serverResponse = $.parseJSON(data);
notify(serverResponse.message);
if (serverResponse.error){
notify(serverResponse.message,true,'error');
} else {
notify(serverResponse.message);
}
el.closest('.case_detail_panel_casenotes')
.load('lib/php/data/cases_documents_load.php',
{'id': caseId,'update': 'yes','path': targetPath,'container': targetPath}, function() {
Expand Down
13 changes: 10 additions & 3 deletions lib/php/data/cases_documents_process.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
session_start();
require('../auth/session_check.php');
require('../../../db.php');

include('../../../debug.php');
function update_paths($dbh,$path,$new_path,$case_id) {

//Change paths of documents which reside in the recently changed folder
Expand Down Expand Up @@ -465,6 +465,12 @@ function check_folder_unique($dbh,$container,$new_folder,$case_id) {
{
if ($doc_type == 'folder') {

if ($selection_path == ''){
$return = array('message'=>'There was an error moving your folder. Please reload the page and try again','wait'=>true,'error'=>true);
echo json_encode($return);
die;

}
//change the path of the selected folder

if (stristr($selection_path, '/'))
Expand Down Expand Up @@ -495,8 +501,9 @@ function check_folder_unique($dbh,$container,$new_folder,$case_id) {

$update_paths = $dbh->prepare("SELECT * FROM cm_documents WHERE folder LIKE :old_path AND case_id = :case_id");

$old_path = $selection_path . "%";

$old_path = $selection_path . "%";
// Bug Code:
//$old_path = '' . "%";
$data = array('old_path' => $old_path,'case_id' => $case_id);

$update_paths->execute($data);
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php

$version = "7.2.5";
$version = "7.2.6";

0 comments on commit 3d3e642

Please sign in to comment.