osem-fcy/app/views/admin/versions/index.html.haml
Nishanth Vijayan a45e537bac Setup basic Revision History page
Sets up paper_trail tracking in important models

and add conference_id to versions for storing conference_id
of conference related objects  as metadata.This will help in querying
for versions related to conferences.

Fix issues with factories & event types initialization.Import paper_trail testing helpers
Fix bug: Creating an event creates a useless version with event update

Add revert and view changes features to revision history
2016-08-12 13:35:56 +05:30

77 lines
2.8 KiB
Text

.row
.col-md-12
.page-header
%h1 Revision History
%p.text-muted
Log of changes made to conferences and associated resources
%table.table.table-striped.table-bordered.table-hover#versionstable
%thead
%td ID
%td Description
%td Actions
%tbody
- @versions.each do |version|
%tr
%td.col-md-1
= version.id
%td.col-md-9
%p
= change_creator_link(version.whodunnit) unless version.item_type == 'User'
- case version.item_type
- when 'Event'
= event_change_description(version)
-when 'UsersRole'
= users_role_change_description(version)
- when 'Subscription'
= subscription_change_description(version)
- when 'Registration', 'EventsRegistration'
= registration_change_description(version)
- when 'Comment'
= comment_change_description(version)
- when 'Vote'
= vote_change_description(version)
- when 'User'
= user_change_description(version)
- else
- if version.event == 'create'
= 'created new'
- elsif version.event == 'update'
= "updated #{updated_attributes(version)} of"
- else
= 'deleted'
= render partial: 'object_desc_and_link', locals: { version: version }
%small.text-muted
= distance_of_time_in_words(Time.now,version.created_at) + ' ago'
%br
= "(#{version.created_at.strftime('%B %-d, %Y %H:%M')})"
%br
= render partial: 'object_changes', locals: { version: version }
%td.col-md-2
.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