#557 UI for watching folders
This commit is contained in:
parent
7938532c0e
commit
4faef673b0
@ -91,6 +91,13 @@ def dmsf_init
|
||||
:reorder_steps, :update, :update_step, :delete_step, :edit] }
|
||||
pmap.permission :display_system_folders,
|
||||
read: true
|
||||
# Watchers
|
||||
pmap.permission :view_dmsf_folder_watchers, {}, read: true
|
||||
pmap.permission :add_dmsf_folder_watchers, { watchers: [:new, :create, :append, :autocomplete_for_user]}
|
||||
pmap.permission :delete_dmsf_folder_watchers, { watchers: :destroy}
|
||||
pmap.permission :view_project_watchers, {}, read: true
|
||||
pmap.permission :add_project_watchers, { watchers: [:new, :create, :append, :autocomplete_for_user]}
|
||||
pmap.permission :delete_project_watchers, { watchers: :destroy}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
class DmsfContextMenusController < ApplicationController
|
||||
|
||||
helper :context_menus
|
||||
helper :watchers
|
||||
|
||||
before_action :find_folder
|
||||
before_action :find_dmsf_file
|
||||
|
||||
@ -45,6 +45,7 @@ class DmsfController < ApplicationController
|
||||
helper :dmsf_queries
|
||||
include DmsfQueriesHelper
|
||||
helper :context_menus
|
||||
helper :watchers
|
||||
|
||||
def permissions
|
||||
if !DmsfFolder.permissions?(@folder, false)
|
||||
|
||||
@ -73,7 +73,7 @@ class DmsfFile < ActiveRecord::Base
|
||||
url: Proc.new { |o| { controller: 'dmsf_files', action: 'view', id: o } },
|
||||
datetime: Proc.new { |o| o.updated_at },
|
||||
author: Proc.new { |o| o.last_revision.user }
|
||||
|
||||
acts_as_watchable
|
||||
acts_as_searchable columns: ["#{table_name}.name", "#{DmsfFileRevision.table_name}.title", "#{DmsfFileRevision.table_name}.description", "#{DmsfFileRevision.table_name}.comment"],
|
||||
project_key: 'project_id',
|
||||
date_column: "#{table_name}.updated_at"
|
||||
@ -88,6 +88,9 @@ class DmsfFile < ActiveRecord::Base
|
||||
|
||||
def initialize(*args)
|
||||
@project = nil
|
||||
if new_record?
|
||||
self.watcher_user_ids = []
|
||||
end
|
||||
super
|
||||
end
|
||||
|
||||
|
||||
@ -78,13 +78,12 @@ class DmsfFolder < ActiveRecord::Base
|
||||
scope :notsystem, -> { where(system: false) }
|
||||
|
||||
acts_as_customizable
|
||||
|
||||
acts_as_searchable columns: ["#{table_name}.title", "#{table_name}.description"],
|
||||
project_key: 'project_id',
|
||||
date_column: 'updated_at',
|
||||
permission: :view_dmsf_files,
|
||||
scope: Proc.new { DmsfFolder.visible }
|
||||
|
||||
acts_as_watchable
|
||||
acts_as_event title: Proc.new { |o| o.title },
|
||||
description: Proc.new { |o| o.description },
|
||||
url: Proc.new { |o| { controller: 'dmsf', action: 'show', id: o.project, folder_id: o } },
|
||||
@ -122,6 +121,13 @@ class DmsfFolder < ActiveRecord::Base
|
||||
DmsfFolder.permissions?(folder.dmsf_folder, allow_system)
|
||||
end
|
||||
|
||||
def initialize(*args)
|
||||
if new_record?
|
||||
self.watcher_user_ids = []
|
||||
end
|
||||
super
|
||||
end
|
||||
|
||||
def default_values
|
||||
if Setting.plugin_redmine_dmsf['dmsf_default_notifications'].present? && !system
|
||||
self.notification = true
|
||||
|
||||
@ -91,6 +91,24 @@
|
||||
|
||||
<% content_for :sidebar do %>
|
||||
<%= render partial: 'dmsf/sidebar' %>
|
||||
|
||||
<% project_or_folder = @folder? @folder : @project %>
|
||||
<% if project_or_folder.watchers.present? %>
|
||||
<div id="watchers">
|
||||
<% if @folder %>
|
||||
<%= render partial: 'watchers/watchers', locals: { watched: @folder } %>
|
||||
<% else %>
|
||||
<% if User.current.allowed_to?(:add_project_watchers, @project) %>
|
||||
<div class="contextual">
|
||||
<%= link_to l(:button_add), new_watchers_path(object_type: :project, object_id: @project.id), remote: true,
|
||||
method: 'get' %>
|
||||
</div>
|
||||
<% end %>
|
||||
<h3><%= l(:label_project_watchers) %> (<%= @project.watcher_users.size %>)</h3>
|
||||
<%= watchers_list @project %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if Redmine::Plugin.installed?(:easy_extensions) %>
|
||||
|
||||
@ -72,6 +72,14 @@
|
||||
disabled: !email_allowed %>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
<% watched = Watcher.any_watched?([dmsf_folder], User.current) %>
|
||||
<% css = [watcher_css([dmsf_folder]), watched ? 'icon icon-fav' : 'icon icon-fav-off'].join(' ') %>
|
||||
<% text = watched ? l(:button_unwatch) : l(:button_watch) %>
|
||||
<% url = watch_path(object_type: dmsf_folder.class.to_s.underscore, object_id: dmsf_folder, back_url: back_url) %>
|
||||
<% method = watched ? 'delete' : 'post' %>
|
||||
<%= context_menu_link text, url, method: method, class: css, disabled: !User.current.logged? %>
|
||||
|
||||
<li>
|
||||
<%= context_menu_link l(:button_delete),
|
||||
dmsf_link ? dmsf_link_path(id: dmsf_link, folder_id: folder, back_url: back_url) :
|
||||
|
||||
@ -60,10 +60,19 @@
|
||||
class: 'icon dmsf-icon-link' %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% object = folder ? folder : project %>
|
||||
<% watched = Watcher.any_watched?([object], User.current) %>
|
||||
<% css = [watcher_css([object]), watched ? 'icon icon-fav' : 'icon icon-fav-off'].join(' ') %>
|
||||
<% text = watched ? l(:button_unwatch) : l(:button_watch) %>
|
||||
<% url = watch_path(object_type: object.class.to_s.underscore, object_id: object.id) %>
|
||||
<% method = watched ? 'delete' : 'post' %>
|
||||
<%= context_menu_link text, url, method: method, class: css, disabled: !User.current.logged? %>
|
||||
|
||||
<% if trash_enabled %>
|
||||
<%= link_to l(:link_trash_bin), trash_dmsf_path(project), title: l(:link_trash_bin), class: 'icon icon-del' %>
|
||||
<% else %>
|
||||
<span class="icon icon-del">
|
||||
<%= l(:link_trash_bin) %>
|
||||
</span>
|
||||
<%= l(:link_trash_bin) %>
|
||||
</span>
|
||||
<% end %>
|
||||
|
||||
@ -425,6 +425,15 @@ en:
|
||||
title_start_minor: Start not allowed, minor must be zero
|
||||
title_approval_minor: Approval not allowed, minor must be zero
|
||||
|
||||
label_project_watchers: Watchers
|
||||
label_dmsf_folder_watchers: Watchers
|
||||
permission_view_dmsf_folder_watchers: View watchers
|
||||
permission_add_dmsf_folder_watchers: Add watchers
|
||||
permission_delete_dmsf_folder_watchers: Delete watchers
|
||||
permission_view_project_watchers: View project's watchers
|
||||
permission_add_project_watchers: Add project's watchers
|
||||
permission_delete_project_watchers: Delete project's watchers
|
||||
|
||||
easy_pages:
|
||||
modules:
|
||||
dmsf_locked_documents: My locked documents
|
||||
|
||||
@ -29,6 +29,11 @@ module RedmineDmsf
|
||||
##################################################################################################################
|
||||
# Overridden methods
|
||||
|
||||
def initialize(attributes=nil, *args)
|
||||
self.watcher_user_ids = []
|
||||
super
|
||||
end
|
||||
|
||||
def copy(project, options={})
|
||||
super(project, options)
|
||||
project = project.is_a?(Project) ? project : Project.find(project)
|
||||
@ -62,6 +67,8 @@ module RedmineDmsf
|
||||
has_many :dmsf_links, -> { where dmsf_folder_id: nil },
|
||||
class_name: 'DmsfLink', foreign_key: 'project_id', dependent: :destroy
|
||||
|
||||
acts_as_watchable
|
||||
|
||||
before_save :set_default_dmsf_notification
|
||||
|
||||
validates_length_of :dmsf_description, maximum: 65535
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user