make move_files have EntryAmendments, do not remove from the UI instantly, and handle just like delete_files, remove restriction on forcing the page to go back to / on search, with new logic its not an issue, also force MoveDBox to start with Storage path rather than another, MOST moves should be to Storage, but should tweak this to be the opposite of current path type

This commit is contained in:
2025-10-26 13:32:31 +11:00
parent 6eba21e028
commit 4421da0d1d
5 changed files with 22 additions and 31 deletions

3
BUGs
View File

@@ -1,4 +1,5 @@
### Next: 144
### Next: 146
BUG-145: when I selected a few files with ctrl-click, moved them, the end result was "no files in path"
BUG-143: if I skip next fast enough in files_ip, it can get the warning about changes to entry list... (would have though I disabled next page until loaded)
BUG-142: after transforming, the face data is still in the old spots, really should delete it / make it recalc
BUG-141: can currently try to flip a video (in a highlighted group)

View File

@@ -674,8 +674,7 @@ def move_files():
for el in request.form:
jex.append( JobExtra( name=f"{el}", value=str(request.form[el]) ) )
job=NewJob( name="move_files", num_files=0, wait_for=None, jex=jex, desc="to move selected file(s)" )
# data is not used, but send response to trigger CheckForJobs()
return jsonify( job_id=job.id )
return jsonify( job=job_schema.dump(job) )
@login_required
@app.route("/view/", methods=["POST"])

View File

@@ -87,18 +87,6 @@ function GetExistingDirsAsDiv( dt, divname, ptype )
} )
}
// wrapper to do some clean up before POST to /move_files or /delete_files
// used to remove the highlighted item(s) && reset the numbering so highlighting continues to work
function MoveOrDelCleanUpUI()
{
// remove the images being moved (so UI immediately 'sees' the move)
$("[name^=eid-]").each( function() { $('#'+$(this).attr('value')).remove() } )
// reorder the images via ecnt again, so future highlighting can work
// document.mf_id=0; $('.figure').each( function() { $(this).attr('ecnt', document.mf_id ); document.mf_id++ } )
$('#dbox').modal('hide')
}
// show the DBox for a move file, includes all thumbnails of selected files to move
// and a pre-populated folder to move them into, with text field to add a suffix
function MoveDBox(path_details)
@@ -116,7 +104,7 @@ function MoveDBox(path_details)
yr=$('.highlight').first().attr('yr')
dt=$('.highlight').first().attr('date')
div+='<div class="row">Use Existing Directory (in the chosen path):</div><div id="existing"></div>'
GetExistingDirsAsDiv( dt, "existing", path_details[0].type.name )
GetExistingDirsAsDiv( dt, "existing", 'Storage' )
div+=`
<div class="input-group my-3">
<alert class="alert alert-primary my-auto py-1">
@@ -125,7 +113,7 @@ function MoveDBox(path_details)
div+= '<svg id="move_path_icon" width="20" height="20" fill="currentColor"><use xlink:href="' + path_details[0].icon_url + '"></svg>'
div+= '<select id="rp_sel" name="rel_path" class="text-primary alert-primary py-1 border border-primary rounded" onChange="change_rp_sel()">'
for(p of path_details) {
div+= '<option path_type="'+p.type.name+'" icon_url="'+p.icon_url+'">'+p.root_dir+'</option>'
div+= `<option path_type="${p.type.name}" icon_url="${p.icon_url}" ${(p.type.name=='Storage') ? "selected" : ""}>${p.root_dir}</option>`
}
div+= '</select>'
div+=`
@@ -139,8 +127,16 @@ function MoveDBox(path_details)
</div>
<div class="form-row col-12 mt-2">
<button onClick="$('#dbox').modal('hide'); return false;" class="btn btn-outline-secondary offset-1 col-2">Cancel</button>
<button id="move_submit" onClick="MoveOrDelCleanUpUI(); $.ajax({ type: 'POST', data: $('#mv_fm').serialize(), url: '/move_files', success: function(data) {
if( $(location).attr('pathname').match('search') !== null ) { window.location='/' }; CheckForJobs() } }); return false" class="btn btn-outline-primary col-2">Ok</button>
<button onClick="
$.ajax({ type: 'POST', data: $('#mv_fm').serialize(), url: '/move_files',
success: function(data) {
processAmendments( data.job.amendments )
checkForAmendmentJobToComplete(data.job.id)
}
});
$('#dbox').modal('hide')
return false"
class="btn btn-outline-secondary col-2">Ok</button>
</div>
</form>
`
@@ -183,7 +179,7 @@ function processAmendments( ams )
// function to add data for document.amendment based on id and amt
// used when we transform several images in files_*, or single image in viewer
// show the DBox for a delete/restore file, includes all thumbnails of selected files
// with appropriate coloured button to Delete or Restore files`
// with appropriate coloured button to Delete or Restore files
function DelDBox(del_or_undel)
{
to_del = GetSelnAsData()
@@ -208,10 +204,6 @@ function DelDBox(del_or_undel)
<button onClick="
$.ajax({ type: 'POST', data: to_del, url: '/${which}_files',
success: function(data) {
// FIXME: what is the ! search stuff for???
// FIXME: really, also why not show 'delete' throbber, and on success of actual delete go back to /
if( $(location).attr('pathname').match('search') !== null || document.viewing ) { window.location='/' }
processAmendments( data.job.amendments )
checkForAmendmentJobToComplete(data.job.id)
}
@@ -854,10 +846,10 @@ function changeSize()
// when a delete or restore files job has completed successfullly, then get ids
// find the page we are on, remove amendments & ids from entryList and re-get page
// which will reset pageList and the UI of images for that page
function handleDeleteOrRestoreFileJobCompleted(job)
function handleMoveOrDeleteOrRestoreFileJobCompleted(job)
{
// this grabs the values from the object attributes of eid-0, eid-1, etc.
const ids = job.extra.map(item => item.value)
const ids = job.extra.filter(item => item.name.startsWith("eid-")).map(item => item.value);
// find page number of first element to delete (this is the page we will return too)
pnum=getPageNumberForId( ids[0] )
@@ -903,8 +895,8 @@ function handleCheckAmendmentJobStatus(data)
// transforms contain the single transformed entry data for convenience
if( data.job.name == 'transform_image' )
handleTransformImageJobCompleted(data.job, data.entry)
else if ( data.job.name == 'delete_files' || data.job.name == 'restore_files' )
handleDeleteOrRestoreFileJobCompleted(data.job)
else if ( data.job.name == 'delete_files' || data.job.name == 'restore_files' || data.job.name == 'move_files' )
handleMoveOrDeleteOrRestoreFileJobCompleted(data.job)
}
else { setTimeout( function() { checkForAmendmentJobToComplete(data.job.id) }, 1000 ); }
}

4
job.py
View File

@@ -127,13 +127,11 @@ def NewJob(name, num_files="0", wait_for=None, jex=None, desc="No description pr
ea=EntryAmendment( eid=id, job_id=job.id, amend_type=at_id )
db.session.add(ea)
job.amendments.append(ea)
# FIXME: add ea to job.amend
elif job.name == 'delete_files' or job.name == 'restore_files':
elif job.name == 'delete_files' or job.name == 'restore_files' or job.name == 'move_files':
for j in jex:
if 'eid-' in j.name:
ea=EntryAmendment( eid=j.value, job_id=job.id, amend_type=at_id )
db.session.add(ea)
# FIXME: add ea to job.amend
job.amendments.append(ea)
SetFELog( message=f'Created <a class="link-light" href="/job/{job.id}">Job #{job.id}</a> to {desc}', level="success" )

View File

@@ -2199,6 +2199,7 @@ def JobMoveFiles(job):
if 'eid-' in jex.name:
move_me=session.query(Entry).get(jex.value)
MoveEntriesToOtherFolder( job, move_me, dst_storage_path, f"{prefix}{suffix}" )
removeEntryAmendment( job, move_me.id )
NewJob( name="check_dups", num_files=0, wait_for=None, jex=None, parent_job=None, desc="check for duplicate files" )
FinishJob(job, f"Finished move selected file(s)")
return