This repository has been archived by the owner on Jul 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
157 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
$(document).on 'rails_admin.dom_ready', -> | ||
console.log 'loaded' | ||
|
||
$('.history_approve_contribution').on 'click', (e) -> | ||
version_id = $(this).attr('data-id') | ||
console.log 'clicked' | ||
$.ajax | ||
type: "POST" | ||
url: "/versions/" | ||
data: | ||
version_id: version_id | ||
dataType: "json" | ||
success: (msg) -> | ||
alert "Data Saved: " + msg | ||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#history > tbody > tr > td:nth-child(3){ | ||
white-space: pre; | ||
max-width: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class VersionsController < ApplicationController | ||
|
||
def change | ||
@version = PaperTrail::Version.find(params[:version_id]).next | ||
if @version.reify | ||
@version.reify.save! | ||
else | ||
@version.item.destroy | ||
end | ||
render :inline => "Success" | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,3 +38,4 @@ def avatar_url(user) | |
"http://gravatar.com/avatar/#{gravatar_id}.png?s=100" | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
- params = request.params.except(:action, :controller, :model_name) | ||
- query = params[:query] | ||
- filter = params[:filter] | ||
- sort = params[:sort] | ||
- sort_reverse = params[:sort_reverse] | ||
- path_method = params[:id] ? "history_show_path" : "history_index_path" | ||
|
||
= form_tag("", method: "get", class: "search pjax-form form-inline") do | ||
.well | ||
%input{name: "query", type: "search", value: query, placeholder: "#{t("admin.misc.filter")}", class: 'input-small'} | ||
%button.btn.btn-primary{type: "submit", :'data-disable-with' => "<i class='icon-white icon-refresh'></i> ".html_safe + t("admin.misc.refresh")} | ||
%i.icon-white.icon-refresh | ||
= t("admin.misc.refresh") | ||
|
||
%table#history.table.table-striped.table-condensed | ||
%thead | ||
%tr | ||
- columns = [] | ||
- columns << { property_name: "created_at", css_class: "created_at",link_text: t('admin.table_headers.created_at') } | ||
- columns << { property_name: "username", css_class: "username", link_text: t('admin.table_headers.username') } | ||
- columns << { property_name: "item", css_class: "item", link_text: t('admin.table_headers.item') } if @general | ||
- columns << { property_name: "changes", css_class: "changes", link_text: t('admin.table_headers.changes') } | ||
- columns << { property_name: "approve", css_class: "approve", link_text: t('admin.table_headers.approve_change') } | ||
|
||
- columns.each do |column| | ||
- property_name = column[:property_name] | ||
- selected = (sort == property_name) | ||
- sort_direction = (sort_reverse ? "headerSortUp" : "headerSortDown" if selected) | ||
- sort_location = send(path_method, params.except("sort_reverse").merge(model_name: @abstract_model.to_param, sort: property_name).merge(selected && sort_reverse != "true" ? {sort_reverse: "true"} : {})) | ||
%th{class: "header pjax #{column[:css_class]} #{sort_direction if selected}", :'data-href' => sort_location}= column[:link_text] | ||
%tbody | ||
- @history.each_with_index do |object, index| | ||
%tr | ||
- unless object.created_at.nil? | ||
%td= l(object.created_at, format: :long, default: l(object.created_at, format: :long, locale: :en)) | ||
%td= object.username | ||
- if @general | ||
- if o = @abstract_model.get(object.item) | ||
- label = o.send(@abstract_model.config.object_label_method) | ||
- if show_action = action(:show, @abstract_model, o) | ||
%td= link_to(label, url_for(action: show_action.action_name, model_name: @abstract_model.to_param, id: o.id), class: 'pjax') | ||
- else | ||
%td= label | ||
- else | ||
%td= "#{@abstract_model.config.label} ##{object.item}" | ||
%td= object.changes | ||
- if index == 0 | ||
%td | ||
- else | ||
%td= link_to("##{object.id}", "#", :class => 'history_approve_contribution', :'data-id' => "#{object.id}") | ||
|
||
- unless params[:all] || [email protected]_to?(:current_page) | ||
= paginate(@history, theme: 'twitter-bootstrap', remote: true) | ||
= link_to(t("admin.misc.show_all"), send(path_method, params.merge(all: true)), class: "show-all btn pjax") unless (tc = @history.total_count) <= @history.size || tc > 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class CreateVersions < ActiveRecord::Migration | ||
def change | ||
create_table :versions do |t| | ||
t.string :item_type, :null => false | ||
t.integer :item_id, :null => false | ||
t.string :event, :null => false | ||
t.string :whodunnit | ||
t.text :object | ||
t.datetime :created_at | ||
end | ||
add_index :versions, [:item_type, :item_id] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddObjectChangesToVersions < ActiveRecord::Migration | ||
def change | ||
add_column :versions, :object_changes, :text | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module RailsAdmin | ||
module Extensions | ||
module PaperTrail | ||
class VersionProxy | ||
def id | ||
@version.id | ||
end | ||
|
||
def changes | ||
@changes = @version.changeset.to_a.collect {|c| c[0] + " = " + c[1][1].to_s}.join(", \n") | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,4 +71,4 @@ | |
} | ||
], | ||
"resourcePath": "cameras" | ||
} | ||
} |