refined right-click seln. If you have one or more highlights, dont mess with them. If you have none, then select the one you are over. Also finished TODO for view details menu option

This commit is contained in:
2021-06-13 22:14:35 +10:00
parent ae5fb0f747
commit 7c3c8977d6
2 changed files with 40 additions and 3 deletions

1
TODO
View File

@@ -1,6 +1,5 @@
## GENERAL
* GUI and routes for View Details... in contextMenu
* AddJobForLog can absorb DEBUGs, etc. in fact fix up logging in general
* comment your code
* more OO goodness :)

View File

@@ -161,7 +161,7 @@
{% endif %}
{% if obj.type.name != "Directory" %}
{% if (not folders) or ((obj.in_dir.in_path.path_prefix+'/'+obj.in_dir.rel_path+'/'+obj.name) | TopLevelFolderOf(cwd)) %}
<figure id="{{obj.id}}" img="{{loop.index-1}}" class="figure mx-1" path_type="{{obj.in_dir.in_path.type.name}}" fname="{{obj.name}}" yr="{{obj.file_details.year}}" date="{{obj.file_details.year}}{{"%02d" % obj.file_details.month}}{{"%02d" % obj.file_details.day}}" details="{{obj.name}} (Date: {{obj.file_details.day}}/{{obj.file_details.month}}/{{obj.file_details.year}})">
<figure id="{{obj.id}}" img="{{loop.index-1}}" class="figure mx-1" path_type="{{obj.in_dir.in_path.type.name}}" size="{{obj.file_details.size_mb}}" hash="{{obj.file_details.hash}}" in_dir="{{obj.in_dir.in_path.path_prefix}}/{{obj.in_dir.rel_path}}" fname="{{obj.name}}" yr="{{obj.file_details.year}}" date="{{obj.file_details.year}}{{"%02d" % obj.file_details.month}}{{"%02d" % obj.file_details.day}}" pretty_date="{{obj.file_details.day}}/{{obj.file_details.month}}/{{obj.file_details.year}}">
{% if obj.type.name=="Image" %}
<div style="position:relative; width:100%">
<a href="{{obj.in_dir.in_path.path_prefix}}/{{obj.in_dir.rel_path}}/{{obj.name}}"><img class="thumb" height="{{size}}" src="data:image/jpeg;base64,{{obj.file_details.thumbnail}}"></img></a>
@@ -260,6 +260,32 @@ function DelDBox(del_or_undel)
$('#dbox').modal('show')
}
function DetailsDBox()
{
$('#dbox-title').html('Details of Selected File(s)')
var div ='<div class="row col-lg-12">'
$('.highlight').each(function( index ) {
div += "<div class='col-lg-3' style='background-color:lightgray'>Name:</div><div class='col-lg-9' style='background-color:lightgray'>" + $(this).attr('fname') + "</div>"
div += "<div class='col-lg-3'>Date:</div><div class='col-lg-9'>" + $(this).attr('pretty_date') + "</div>"
dir = $(this).attr('in_dir')
if( dir.slice(-1) != "/" )
dir=dir.concat('/')
div += "<div class='col-lg-3'>Dir:</div><div class='col-lg-9'>" + dir + "</div>"
div += "<div class='col-lg-3'>Size:</div><div class='col-lg-9'>" + $(this).attr('size') + " MB</div>"
div += "<div class='col-lg-3'>Hash:</div><div class='col-lg-9'>" + $(this).attr('hash') + "</div>"
div += "<div class='col-lg-3'>Path Type:</div><div class='col-lg-9'>" + $(this).attr('path_type') + "</div>"
} )
div += `
</div>
<br>
<div class="form-row col-lg-12">
<button onClick="$('#dbox').modal('hide'); return false;" class="btn btn-outline-secondary offset-lg-1 col-lg-2">Cancel</button>
</div>
`
$('#dbox-content').html(div)
$('#dbox').modal('show')
}
function MoveDBox()
{
$('#dbox-title').html('Move Selected File(s) to new directory in Storage Path')
@@ -363,13 +389,24 @@ function SelContainsBinAndNotBin() {
return false
}
function NoSel() {
var sel=false
$('.highlight').each(function( index ) { sel=true } )
// func looks for No Selection, so if sel is true and we have a sel, return false (i.e. NOT No Sel -> Sel )
if( sel )
return false
else
return true
}
$('.figure').click( function(e) { DoSel(e, this ); SetButtonState(); return false; });
$(document).on('click', function(e) { $('.highlight').removeClass('highlight') ; SetButtonState() });
$.contextMenu({
selector: '.figure',
build: function($triggerElement, e){
var tst;
if( NoSel() )
DoSel(e, e.currentTarget )
item_list = {
details: { name: "Details..." },
view: { name: "View File" },
@@ -387,6 +424,7 @@ $.contextMenu({
return {
callback: function( key, options) {
if( key == "details" ) { DetailsDBox() }
if( key == "view" ) { document.location.href = $(this).find('a').attr('href'); }
if( key == "move" ) { MoveDBox() }
if( key == "del" ) { DelDBox('Delete') }