New UI: List view improvements #1123

This commit is contained in:
karel.picman@lbcfree.net 2020-11-10 12:10:35 +01:00
parent 087c9c26a0
commit 524aca0e0b
4 changed files with 41 additions and 1 deletions

View File

@ -29,6 +29,24 @@ module DmsfQueriesHelper
return super column, item, value
end
case column.name
when :modified
val = super(column, item, value)
case item.type
when 'file'
file = DmsfFile.find_by(id: item.id)
if file&.locked?
return content_tag(:span, val) +
content_tag(:span, '', title: l(:title_locked_by_user, user: file.locked_by), class: 'icon icon-unlock')
end
when 'folder'
folder = DmsfFolder.find_by(id: item.id)
if folder&.locked?
return content_tag(:span, val) +
content_tag(:span, '', title: l(:title_locked_by_user, user: folder.locked_by), class: 'icon icon-unlock')
end
end
content_tag(:span, val) +
content_tag(:span, '', class: 'icon icon-none')
when :id
case item.type
when 'file', 'file-link'

View File

@ -128,6 +128,16 @@ class DmsfFolder < ActiveRecord::Base
end
end
def locked_by
if lock && lock.reverse[0]
user = lock.reverse[0].user
if user
return (user == User.current) ? l(:label_me) : user.name
end
end
''
end
def delete(commit = false)
if locked?
errors[:base] << l(:error_folder_is_locked)

View File

@ -29,7 +29,7 @@ class DmsfQuery < Query
# Standard columns
self.available_columns = [
QueryColumn.new(:id, sortable: 'id', caption: +'#'),
QueryColumn.new(:id, sortable: 'id', caption: +'#', frozen: false),
DmsfTitleQueryColumn.new(:title, sortable: 'title', frozen: true),
QueryColumn.new(:size, sortable: 'size'),
DmsfModifiedQueryColumn.new(:modified, sortable: 'updated'),
@ -140,6 +140,17 @@ class DmsfQuery < Query
filters['title'] = filter if filter
end
def columns
cols = super
# Just move the optional column Id to the beginning as it isn't frozen
id_index = cols.index { |col| col.name == :id }
if id_index == 1
id_col = cols.delete_at(id_index)
cols.insert 0, id_col
end
cols
end
######################################################################################################################
# New

View File

@ -38,6 +38,7 @@
<li>
<% if locked %>
<%= context_menu_link l(:button_unlock), unlock_dmsf_path(id: project, folder_id: dmsf_folder),
title: l(:title_locked_by_user, user: dmsf_folder.locked_by),
class: 'icon icon-unlock', disabled: !allowed || !unlockable %>
<% else %>
<%= context_menu_link l(:button_lock), lock_dmsf_path(id: project, folder_id: dmsf_folder),