Link to packages and screenshots (highlighted) from logs view

This commit is contained in:
Christoph Haas 2021-03-06 20:47:33 +01:00
parent 9a16bad007
commit 330536cb7e
4 changed files with 17 additions and 4 deletions

View file

@ -598,3 +598,7 @@ a.black
#f0f0f0 10px
);
}
.pkgcard.highlight {
border: 5px solid red;
}

View file

@ -18,6 +18,12 @@ class PackagesController < ApplicationController
def details
@package = Package.find_by(name: params[:name])
# Highlight a certain screenshot (by ID). This is used by the logs.slim
# view to link to a certain screenshot of a package.
if params[:highlight]
@highlight_id = params[:highlight].to_i
end
if @package.nil?
@packagename = params[:name]
render 'notfound', status: 404
@ -177,7 +183,7 @@ class PackagesController < ApplicationController
# Check if the user is allowed to change this screenshot
# - Is this the user's own screenshot? (anonymous)
if (@screenshot.user == current_user) || (can? :destroy, @screenshot)
auditlog "Screenshot #{@screenshot} deleted",
auditlog "Screenshot #{@screenshot.id} deleted",
package: @screenshot.package
@screenshot.destroy
flash['notice'] = "Screenshot deleted."

View file

@ -29,12 +29,12 @@
td #{log.section}
td
- if log.package
= log.package.name
= link_to log.package.name, log.package
- else
' -
td
- if log.screenshot
= log.screenshot.id
= link_to log.screenshot.id, package_path(log.package, highlight: log.screenshot.id)
- else
' -
td

View file

@ -15,7 +15,10 @@
= render(partial: 'packages/paginator', locals: {items: @screenshots})
.grid-x.grid-margin-x.medium-up-1.large-up-2 data-equalizer=true data-equalize-on="medium"
- @screenshots.each do |screenshot|
div class=("cell pkgcard" + (screenshot.approved ? " approved" : " unapproved")) data-equalizer-watch=true
- @divclasses = %W(cell pkgcard)
- @divclasses << (screenshot.approved ? "approved" : "unapproved")
- @divclasses << 'highlight' if screenshot.id == @highlight_id
div class=(@divclasses.join(' ')) data-equalizer-watch=true
a.black href =url_for(screenshot.simage_url(:large)) rel='fancybox-thumb' title=screenshot.caption data-fancybox='gallery' data-caption=screenshot_caption(screenshot)
.image.image-with-zoom-icon
= small_img(screenshot, cls: '')