fixed 3 BUGS: BUG-31: can post move/del/restore DBoxes without highlighted files/content; BUG-33: can call move/del/restore on mixed content - prob. stop it? (e.g right-click from search with highlighted files in both Bin and non Bin locations); BUG-34: shift-clicking (left or right) from a non-highlighted state does not add the shift-clicked item. ALSO removed ability to right-click change sel...

This commit is contained in:
2021-06-13 21:35:08 +10:00
parent 1234a3c804
commit ae5fb0f747
2 changed files with 53 additions and 29 deletions

4
BUGs
View File

@@ -1,3 +1 @@
### Next: 34 ### Next: 35
BUG-31: can post move/del/restore DBoxes without highlighted files/content
BUG-33: can call move/del/restore on mixed content - prob. stop it? (e.g right-click from search with highlighted files in both Bin and non Bin locations)

View File

@@ -46,12 +46,12 @@
<button id="next" name="next" class="sm-txt btn btn-info"><i class="fas fa-arrow-alt-circle-right"></i></button> <button id="next" name="next" class="sm-txt btn btn-info"><i class="fas fa-arrow-alt-circle-right"></i></button>
</div> </div>
<div class="col my-auto"> <div class="col my-auto">
<button id="move" name="move" class="sm-txt btn btn-primary ml-4" onClick="MoveDBox(); return false;"><i class="fas fa-folder-plus"></i></button> <button id="move" disabled name="move" class="sm-txt btn btn-primary ml-4" onClick="MoveDBox(); return false;"><i class="fas fa-folder-plus"></i></button>
{% if "files_rbp" in request.url %} {% if "files_rbp" in request.url %}
<button id="del" name="del" class="sm-txt btn btn-success mx-1" onClick="DelDBox('Restore'); return false;"> <button id="del" disabled name="del" class="sm-txt btn btn-success mx-1" onClick="DelDBox('Restore'); return false;">
<i class="fas fa-trash-restore-alt"></i> <i class="fas fa-trash-restore-alt"></i>
{% else %} {% else %}
<button id="del" name="del" class="sm-txt btn btn-danger mx-1" onClick="DelDBox('Delete'); return false;"> <button id="del" disabled name="del" class="sm-txt btn btn-danger mx-1" onClick="DelDBox('Delete'); return false;">
<i class="fas fa-trash-alt"></i> <i class="fas fa-trash-alt"></i>
{% endif %} {% endif %}
</button> </button>
@@ -234,7 +234,6 @@ function GetSelnAsData()
function DelDBox(del_or_undel) function DelDBox(del_or_undel)
{ {
console.log(del_or_undel)
to_del = GetSelnAsData() to_del = GetSelnAsData()
$('#dbox-title').html(del_or_undel+' Selected File(s)') $('#dbox-title').html(del_or_undel+' Selected File(s)')
div ='<div class="row col-lg-12"><p class="col">' + del_or_undel + ' the following files?</p></div>' div ='<div class="row col-lg-12"><p class="col">' + del_or_undel + ' the following files?</p></div>'
@@ -310,8 +309,6 @@ function ChangeSize(clicked_button,sz)
// whether you click after highlight or before // whether you click after highlight or before
function DoSel(e, el) function DoSel(e, el)
{ {
console.log(e)
console.log(el)
if( e.ctrlKey ) if( e.ctrlKey )
{ {
$(el).toggleClass('highlight') $(el).toggleClass('highlight')
@@ -322,6 +319,12 @@ function DoSel(e, el)
st=Number($('.highlight').first().attr('img')) st=Number($('.highlight').first().attr('img'))
end=Number($('.highlight').last().attr('img')) end=Number($('.highlight').last().attr('img'))
clicked=Number($(el).attr('img')) clicked=Number($(el).attr('img'))
// if we shift-click first element, then st/end are NaN, so just highlightthe one clicked
if( isNaN(st) )
{
$('.figure').slice( clicked, clicked+1 ).addClass('highlight')
return
}
if( clicked > end ) if( clicked > end )
$('.figure').slice( end, clicked+1 ).addClass('highlight') $('.figure').slice( end, clicked+1 ).addClass('highlight')
else else
@@ -332,35 +335,58 @@ function DoSel(e, el)
$(el).addClass('highlight') $(el).addClass('highlight')
} }
$('.figure').click( function(e) { DoSel(e, this ); return false; }); function SetButtonState() {
$(document).on('click', function(e) { $('.highlight').removeClass('highlight') }); var sel=false
$('.highlight').each(function( index ) { sel=true } )
if( sel ) {
$('#move').attr('disabled', false )
$('#del').attr('disabled', false )
} else {
$('#move').attr('disabled', true )
$('#del').attr('disabled', true )
}
}
function SelContainsBinAndNotBin() {
var bin=false
var not_bin=false
$('.highlight').each(function( index ) {
if( $(this).attr('path_type') == "Bin" ) {
bin=true
} else {
not_bin=true
}
} )
if( bin && not_bin )
return true
else
return false
}
$('.figure').click( function(e) { DoSel(e, this ); SetButtonState(); return false; });
$(document).on('click', function(e) { $('.highlight').removeClass('highlight') ; SetButtonState() });
$.contextMenu({ $.contextMenu({
selector: '.figure', selector: '.figure',
build: function($triggerElement, e){ build: function($triggerElement, e){
DoSel(e, e.currentTarget ) var tst;
if (e.currentTarget.getAttribute('path_type') == 'Bin' ) { item_list = {
item_list = { details: { name: "Details..." },
details: { name: "Details..." }, view: { name: "View File" },
view: { name: "View File" }, sep: "---",
sep: "---", move: { name: "Move selected file(s) to new storage folder" }
move: { name: "Move selected file(s) to new storage folder" }, }
undel: { name: "Restore selected file(s)" } if( SelContainsBinAndNotBin() ) {
} item_list['both']= { name: 'Cannot delete and restore at same time', disabled: true }
} else { } else {
item_list = { if (e.currentTarget.getAttribute('path_type') == 'Bin' )
details: { name: "Details..." }, item_list['undel']= { name: "Restore selected file(s)" }
view: { name: "View File" }, else
sep: "---", item_list['del']= { name: "Delete Selected file(s)" }
move: { name: "Move selected file(s) to new storage folder" },
del: { name: "Delete Selected file(s)" }
}
} }
return { return {
callback: function( key, options) { callback: function( key, options) {
console.log( $(this).attr('id') )
console.log( $(this).attr('path_type') )
if( key == "view" ) { document.location.href = $(this).find('a').attr('href'); } if( key == "view" ) { document.location.href = $(this).find('a').attr('href'); }
if( key == "move" ) { MoveDBox() } if( key == "move" ) { MoveDBox() }
if( key == "del" ) { DelDBox('Delete') } if( key == "del" ) { DelDBox('Delete') }