#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] }
|
:reorder_steps, :update, :update_step, :delete_step, :edit] }
|
||||||
pmap.permission :display_system_folders,
|
pmap.permission :display_system_folders,
|
||||||
read: true
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -22,6 +22,7 @@
|
|||||||
class DmsfContextMenusController < ApplicationController
|
class DmsfContextMenusController < ApplicationController
|
||||||
|
|
||||||
helper :context_menus
|
helper :context_menus
|
||||||
|
helper :watchers
|
||||||
|
|
||||||
before_action :find_folder
|
before_action :find_folder
|
||||||
before_action :find_dmsf_file
|
before_action :find_dmsf_file
|
||||||
|
|||||||
@ -45,6 +45,7 @@ class DmsfController < ApplicationController
|
|||||||
helper :dmsf_queries
|
helper :dmsf_queries
|
||||||
include DmsfQueriesHelper
|
include DmsfQueriesHelper
|
||||||
helper :context_menus
|
helper :context_menus
|
||||||
|
helper :watchers
|
||||||
|
|
||||||
def permissions
|
def permissions
|
||||||
if !DmsfFolder.permissions?(@folder, false)
|
if !DmsfFolder.permissions?(@folder, false)
|
||||||
|
|||||||
@ -73,7 +73,7 @@ class DmsfFile < ActiveRecord::Base
|
|||||||
url: Proc.new { |o| { controller: 'dmsf_files', action: 'view', id: o } },
|
url: Proc.new { |o| { controller: 'dmsf_files', action: 'view', id: o } },
|
||||||
datetime: Proc.new { |o| o.updated_at },
|
datetime: Proc.new { |o| o.updated_at },
|
||||||
author: Proc.new { |o| o.last_revision.user }
|
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"],
|
acts_as_searchable columns: ["#{table_name}.name", "#{DmsfFileRevision.table_name}.title", "#{DmsfFileRevision.table_name}.description", "#{DmsfFileRevision.table_name}.comment"],
|
||||||
project_key: 'project_id',
|
project_key: 'project_id',
|
||||||
date_column: "#{table_name}.updated_at"
|
date_column: "#{table_name}.updated_at"
|
||||||
@ -88,6 +88,9 @@ class DmsfFile < ActiveRecord::Base
|
|||||||
|
|
||||||
def initialize(*args)
|
def initialize(*args)
|
||||||
@project = nil
|
@project = nil
|
||||||
|
if new_record?
|
||||||
|
self.watcher_user_ids = []
|
||||||
|
end
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -78,13 +78,12 @@ class DmsfFolder < ActiveRecord::Base
|
|||||||
scope :notsystem, -> { where(system: false) }
|
scope :notsystem, -> { where(system: false) }
|
||||||
|
|
||||||
acts_as_customizable
|
acts_as_customizable
|
||||||
|
|
||||||
acts_as_searchable columns: ["#{table_name}.title", "#{table_name}.description"],
|
acts_as_searchable columns: ["#{table_name}.title", "#{table_name}.description"],
|
||||||
project_key: 'project_id',
|
project_key: 'project_id',
|
||||||
date_column: 'updated_at',
|
date_column: 'updated_at',
|
||||||
permission: :view_dmsf_files,
|
permission: :view_dmsf_files,
|
||||||
scope: Proc.new { DmsfFolder.visible }
|
scope: Proc.new { DmsfFolder.visible }
|
||||||
|
acts_as_watchable
|
||||||
acts_as_event title: Proc.new { |o| o.title },
|
acts_as_event title: Proc.new { |o| o.title },
|
||||||
description: Proc.new { |o| o.description },
|
description: Proc.new { |o| o.description },
|
||||||
url: Proc.new { |o| { controller: 'dmsf', action: 'show', id: o.project, folder_id: o } },
|
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)
|
DmsfFolder.permissions?(folder.dmsf_folder, allow_system)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def initialize(*args)
|
||||||
|
if new_record?
|
||||||
|
self.watcher_user_ids = []
|
||||||
|
end
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
def default_values
|
def default_values
|
||||||
if Setting.plugin_redmine_dmsf['dmsf_default_notifications'].present? && !system
|
if Setting.plugin_redmine_dmsf['dmsf_default_notifications'].present? && !system
|
||||||
self.notification = true
|
self.notification = true
|
||||||
|
|||||||
@ -91,6 +91,24 @@
|
|||||||
|
|
||||||
<% content_for :sidebar do %>
|
<% content_for :sidebar do %>
|
||||||
<%= render partial: 'dmsf/sidebar' %>
|
<%= 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 %>
|
<% end %>
|
||||||
|
|
||||||
<% if Redmine::Plugin.installed?(:easy_extensions) %>
|
<% if Redmine::Plugin.installed?(:easy_extensions) %>
|
||||||
|
|||||||
@ -72,6 +72,14 @@
|
|||||||
disabled: !email_allowed %>
|
disabled: !email_allowed %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% 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>
|
<li>
|
||||||
<%= context_menu_link l(:button_delete),
|
<%= context_menu_link l(:button_delete),
|
||||||
dmsf_link ? dmsf_link_path(id: dmsf_link, folder_id: folder, back_url: back_url) :
|
dmsf_link ? dmsf_link_path(id: dmsf_link, folder_id: folder, back_url: back_url) :
|
||||||
|
|||||||
@ -60,10 +60,19 @@
|
|||||||
class: 'icon dmsf-icon-link' %>
|
class: 'icon dmsf-icon-link' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% 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 %>
|
<% if trash_enabled %>
|
||||||
<%= link_to l(:link_trash_bin), trash_dmsf_path(project), title: l(:link_trash_bin), class: 'icon icon-del' %>
|
<%= link_to l(:link_trash_bin), trash_dmsf_path(project), title: l(:link_trash_bin), class: 'icon icon-del' %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<span class="icon icon-del">
|
<span class="icon icon-del">
|
||||||
<%= l(:link_trash_bin) %>
|
<%= l(:link_trash_bin) %>
|
||||||
</span>
|
</span>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@ -425,6 +425,15 @@ en:
|
|||||||
title_start_minor: Start not allowed, minor must be zero
|
title_start_minor: Start not allowed, minor must be zero
|
||||||
title_approval_minor: Approval 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:
|
easy_pages:
|
||||||
modules:
|
modules:
|
||||||
dmsf_locked_documents: My locked documents
|
dmsf_locked_documents: My locked documents
|
||||||
|
|||||||
@ -29,6 +29,11 @@ module RedmineDmsf
|
|||||||
##################################################################################################################
|
##################################################################################################################
|
||||||
# Overridden methods
|
# Overridden methods
|
||||||
|
|
||||||
|
def initialize(attributes=nil, *args)
|
||||||
|
self.watcher_user_ids = []
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
def copy(project, options={})
|
def copy(project, options={})
|
||||||
super(project, options)
|
super(project, options)
|
||||||
project = project.is_a?(Project) ? project : Project.find(project)
|
project = project.is_a?(Project) ? project : Project.find(project)
|
||||||
@ -62,6 +67,8 @@ module RedmineDmsf
|
|||||||
has_many :dmsf_links, -> { where dmsf_folder_id: nil },
|
has_many :dmsf_links, -> { where dmsf_folder_id: nil },
|
||||||
class_name: 'DmsfLink', foreign_key: 'project_id', dependent: :destroy
|
class_name: 'DmsfLink', foreign_key: 'project_id', dependent: :destroy
|
||||||
|
|
||||||
|
acts_as_watchable
|
||||||
|
|
||||||
before_save :set_default_dmsf_notification
|
before_save :set_default_dmsf_notification
|
||||||
|
|
||||||
validates_length_of :dmsf_description, maximum: 65535
|
validates_length_of :dmsf_description, maximum: 65535
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user