Merge pull request #1128 from nishanthvijayan/event-changelog
Improve event history page
This commit is contained in:
commit
99992750bb
8 changed files with 69 additions and 47 deletions
|
|
@ -86,6 +86,9 @@ module Admin
|
||||||
@comment_count = @event.comment_threads.count
|
@comment_count = @event.comment_threads.count
|
||||||
@ratings = @event.votes.includes(:user)
|
@ratings = @event.votes.includes(:user)
|
||||||
@difficulty_levels = @program.difficulty_levels
|
@difficulty_levels = @program.difficulty_levels
|
||||||
|
@versions = @event.versions |
|
||||||
|
PaperTrail::Version.where(item_type: 'Commercial').where_object(commercialable_id: @event.id, commercialable_type: 'Event') |
|
||||||
|
PaperTrail::Version.where(item_type: 'Commercial').where_object_changes(commercialable_id: @event.id, commercialable_type: 'Event')
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ module Admin
|
||||||
flash[:error] = 'Revert failed. Attribute missing or invalid'
|
flash[:error] = 'Revert failed. Attribute missing or invalid'
|
||||||
end
|
end
|
||||||
|
|
||||||
redirect_to admin_revision_history_path
|
redirect_back_or_to admin_revision_history_path
|
||||||
end
|
end
|
||||||
|
|
||||||
def revert_object
|
def revert_object
|
||||||
|
|
@ -52,7 +52,7 @@ module Admin
|
||||||
flash[:error] = 'The item is already in the state that you are trying to revert it back to'
|
flash[:error] = 'The item is already in the state that you are trying to revert it back to'
|
||||||
end
|
end
|
||||||
|
|
||||||
redirect_to admin_revision_history_path
|
redirect_back_or_to admin_revision_history_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -493,4 +493,14 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def general_change_description(version)
|
||||||
|
if version.event == 'create'
|
||||||
|
'created new'
|
||||||
|
elsif version.event == 'update'
|
||||||
|
"updated #{updated_attributes(version)} of"
|
||||||
|
else
|
||||||
|
'deleted'
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -210,6 +210,12 @@ class Ability
|
||||||
role.resource_type == 'Conference' && role.name == 'cfp' &&
|
role.resource_type == 'Conference' && role.name == 'cfp' &&
|
||||||
(Conference.with_role(:cfp, user).pluck(:id).include? role.resource_id)
|
(Conference.with_role(:cfp, user).pluck(:id).include? role.resource_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
can [:index, :revert_object, :revert_attribute], PaperTrail::Version, item_type: 'Event', conference_id: conf_ids_for_cfp
|
||||||
|
can [:index, :revert_object, :revert_attribute], PaperTrail::Version do |version|
|
||||||
|
version.item_type == 'Commercial' && conf_ids_for_cfp.include?(version.conference_id) &&
|
||||||
|
(version.object.to_s.include?('Event') || version.object_changes.to_s.include?('Event'))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def signed_in_with_info_desk_role(user)
|
def signed_in_with_info_desk_role(user)
|
||||||
|
|
|
||||||
|
|
@ -9,29 +9,36 @@
|
||||||
= render 'proposal'
|
= render 'proposal'
|
||||||
#history-content.tab-pane
|
#history-content.tab-pane
|
||||||
.col-md-12
|
.col-md-12
|
||||||
%table.table
|
%table.table.table-striped.table-bordered.table-hover.datatable
|
||||||
%thead
|
%thead
|
||||||
%th
|
%th ID
|
||||||
%b Who
|
%th Description
|
||||||
%th
|
%th Actions
|
||||||
%b Timestamp
|
|
||||||
%th
|
|
||||||
%b Modification Type
|
|
||||||
%th
|
|
||||||
%b Changes
|
|
||||||
%tbody
|
%tbody
|
||||||
- @event.versions.each do |version|
|
- @versions.each do |version|
|
||||||
%tr
|
%tr
|
||||||
%td
|
%td
|
||||||
- unless version.whodunnit.nil?
|
= version.id
|
||||||
= User.find(version.whodunnit).name
|
%td
|
||||||
|
%p
|
||||||
|
= change_creator_link(version.whodunnit)
|
||||||
|
|
||||||
|
- if version.item_type == 'Event'
|
||||||
|
= event_change_description(version)
|
||||||
|
= "event #{@event.title}"
|
||||||
|
|
||||||
- else
|
- else
|
||||||
No user (probably via the console)
|
= general_change_description(version)
|
||||||
%td
|
= link_to 'commercial',
|
||||||
= version.created_at
|
edit_admin_conference_program_event_path(conference_id: @conference.short_title,
|
||||||
%td
|
id: @event.id, anchor: 'commercials-content')
|
||||||
= version.event
|
|
||||||
%td
|
%small.text-muted
|
||||||
- version.changeset.each_key do |key|
|
= distance_of_time_in_words(Time.now,version.created_at) + ' ago'
|
||||||
= "#{key}: #{version.changeset[key][0]} -> #{version.changeset[key][1]}"
|
|
||||||
%br
|
%br
|
||||||
|
= "(#{version.created_at.strftime('%B %-d, %Y %H:%M')})"
|
||||||
|
|
||||||
|
%br
|
||||||
|
= render partial: 'shared/object_changes', locals: { version: version }
|
||||||
|
%td
|
||||||
|
= render partial: 'shared/changelog_actions', locals: { version: version }
|
||||||
|
|
|
||||||
|
|
@ -42,12 +42,7 @@
|
||||||
= user_change_description(version)
|
= user_change_description(version)
|
||||||
|
|
||||||
- else
|
- else
|
||||||
- if version.event == 'create'
|
= general_change_description(version)
|
||||||
= 'created new'
|
|
||||||
- elsif version.event == 'update'
|
|
||||||
= "updated #{updated_attributes(version)} of"
|
|
||||||
- else
|
|
||||||
= 'deleted'
|
|
||||||
|
|
||||||
= render partial: 'object_desc_and_link', locals: { version: version }
|
= render partial: 'object_desc_and_link', locals: { version: version }
|
||||||
|
|
||||||
|
|
@ -57,21 +52,7 @@
|
||||||
= "(#{version.created_at.strftime('%B %-d, %Y %H:%M')})"
|
= "(#{version.created_at.strftime('%B %-d, %Y %H:%M')})"
|
||||||
|
|
||||||
%br
|
%br
|
||||||
= render partial: 'object_changes', locals: { version: version }
|
= render partial: 'shared/object_changes', locals: { version: version }
|
||||||
|
|
||||||
%td.col-md-2
|
%td.col-md-2
|
||||||
.btn-group{role: 'group'}
|
= render partial: 'shared/changelog_actions', locals: { version: version }
|
||||||
%a.btn.btn-success.btn-sm.show-changeset{id: version.id} View Changes
|
|
||||||
- if can? :revert_object, version
|
|
||||||
%button.btn.btn-default.dropdown-toggle.btn-sm.btn-primary{'data-toggle' => 'dropdown', type: 'button'}
|
|
||||||
Revert
|
|
||||||
%span.caret
|
|
||||||
%ul.dropdown-menu
|
|
||||||
%li= link_to 'All Changes', admin_revision_history_revert_object_path(id: version.id), data: { confirm: 'Are you sure you want to revert this change?' }
|
|
||||||
|
|
||||||
- if can? :revert_attribute, version
|
|
||||||
%li.divider{role: 'separator'}
|
|
||||||
- version.changeset.reject{ |_, values| values[0].blank? && values[1].blank? }.each do |attribute, values|
|
|
||||||
%li= link_to attribute, admin_revision_history_revert_attribute_path(id: version.id, attribute: attribute), data: { confirm: "Are you sure you want to revert #{attribute}?" }
|
|
||||||
- else
|
|
||||||
%button.btn.btn-sm.btn-primary.disabled Revert
|
|
||||||
|
|
|
||||||
15
app/views/shared/_changelog_actions.haml
Normal file
15
app/views/shared/_changelog_actions.haml
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
.btn-group{role: 'group'}
|
||||||
|
%a.btn.btn-success.btn-sm.show-changeset{id: version.id} View Changes
|
||||||
|
- if can? :revert_object, version
|
||||||
|
%button.btn.btn-default.dropdown-toggle.btn-sm.btn-primary{'data-toggle' => 'dropdown', type: 'button'}
|
||||||
|
Revert
|
||||||
|
%span.caret
|
||||||
|
%ul.dropdown-menu
|
||||||
|
%li= link_to 'All Changes', admin_revision_history_revert_object_path(id: version.id), data: { confirm: 'Are you sure you want to revert this change?' }
|
||||||
|
|
||||||
|
- if can? :revert_attribute, version
|
||||||
|
%li.divider{role: 'separator'}
|
||||||
|
- version.changeset.reject{ |_, values| values[0].blank? && values[1].blank? }.each do |attribute, values|
|
||||||
|
%li= link_to attribute, admin_revision_history_revert_attribute_path(id: version.id, attribute: attribute), data: { confirm: "Are you sure you want to revert #{attribute}?" }
|
||||||
|
- else
|
||||||
|
%button.btn.btn-sm.btn-primary.disabled Revert
|
||||||
Loading…
Add table
Add a link
Reference in a new issue