Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
88470e3
Make rademade_admin get along with md files
x-yuri Nov 28, 2016
7a25e73
Update Bowerfile
Praffesor Mar 7, 2017
66bd0f2
fixed jquery form
Mar 7, 2017
0efbfae
Merge pull request #49 from Rademade/no-changes-md
Praffesor Mar 29, 2017
a231af1
add explicit definition for table columns
isaiev Apr 3, 2017
e79192b
Merge pull request #58 from isaiev/feature/rails-5
Praffesor Apr 3, 2017
bd4b1a7
Fixed search value case.
Apr 7, 2017
1910f02
Merge pull request #59 from sergeyslavin/feature/rails-5
Praffesor Apr 7, 2017
f7d8f7f
uploader fix
Apr 8, 2017
9b59c51
Merge pull request #52 from Rademade/bug/fixed-logout
Praffesor Apr 11, 2017
07f9d8e
Merge branch 'feature/rails-5' into feature/fixed-thead
Apr 11, 2017
2c0e775
Merge pull request #54 from Rademade/feature/fixed-thead
Apr 11, 2017
39d295a
merge with master
Apr 11, 2017
e84082b
Merge pull request #60 from Rademade/feature/rails-5
Apr 11, 2017
c97ed3b
Update README.md
Melanitski Apr 21, 2017
739aed3
fix asstets path
isaiev Apr 27, 2017
64e9f3a
Merge pull request #62 from isaiev/bugfix/assets
Praffesor Apr 27, 2017
465ea3b
jquery-form: add version constraint
x-yuri Apr 28, 2017
897f10c
Merge pull request #63 from Rademade/jquery-form-version
Melanitski Apr 29, 2017
6fa425a
Update README.md
Melanitski May 3, 2017
87e2ba2
Update README.md
Melanitski May 3, 2017
a22058d
Revert "jquery-form: add version constraint"
Praffesor May 4, 2017
2b16da6
Merge pull request #64 from Rademade/revert-63-jquery-form-version
Praffesor May 4, 2017
a4ce760
temp: fixes
isaiev May 19, 2017
445fa78
Merge pull request #66 from isaiev/bugfix/imports
Praffesor May 24, 2017
502620b
fix related items destroy
andrey-abramow May 26, 2017
abebabd
remove logs
andrey-abramow May 26, 2017
a791f7d
set deletable to true
andrey-abramow May 26, 2017
fd58ed5
added _relation_destroyable? to sequel/mongoid
andrey-abramow May 26, 2017
614e720
Merge pull request #67 from Rademade/issue/destroy_related_items
Praffesor May 27, 2017
38ee63b
fix
Nefor Jun 30, 2017
9d6e38a
Merge pull request #68 from Rademade/bugfix/img-as-file-upload
Jun 30, 2017
44ae27e
Merge pull request #69 from Rademade/feature/rails-5
Jun 30, 2017
1e7aac0
No bower tasks on asset precompile
x-yuri Jul 6, 2017
c3dd93b
Merge pull request #70 from Rademade/bower-precompile
Praffesor Jul 6, 2017
7d8bfe6
Update _destroy.html.erb
Praffesor Jan 5, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Bowerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ asset 'leaflet'
asset 'data-tables', :github => 'DataTables/DataTables'
asset 'flot', :github => 'flot/flot'
asset 'knob', :github => 'aterrien/jQuery-Knob'
asset 'uniform', :github => 'AudithSoftworks/Uniform', :ref => 'v2.2.0'
asset 'uniform', :github => 'AudithSoftworks/Uniform'
asset 'jquery-ui', :github => 'jquery/jquery-ui#1.11.4'
asset 'jquery-filthypillow', :github => 'Rademade/jquery.filthypillow#master'
asset 'magnific-popup', :github => 'dimsemenov/Magnific-Popup'
Expand All @@ -31,3 +31,6 @@ asset 'jquery-form', :github => 'malsup/form'
asset 'jquery-serialize', :github => 'macek/jquery-serialize-object'
asset 'jquery-formrestrict', :github => 'treyhunner/jquery-formrestrict'
asset 'jquery-validation', :github => 'jzaefferer/jquery-validation#v1.13.1'

#Thead
asset 'floatThead', :github => 'mkoryak/floatThead'
84 changes: 10 additions & 74 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,89 +16,25 @@ rademade_admin

**Best rails admin panel!**


How to use it
Live demo
--------------
1. [http://admin.rademade.com/login](http://admin.rademade.com/login)
2. Login: mrtom@rademade.com
3. Password: 123456

1) Add `gem 'rademade_admin'` to Gemfile

2) Update `config/initializers/assets.rb` with line:
```ruby
config.assets.precompile += %w(rademade_admin.css rademade_admin.js)
```

3) Mount rails engine at routing.rb `mount RademadeAdmin::Engine => '/admin'`

4) Create `User` model and other needed models
```ruby
class User < ActiveRecord::Base
include RademadeAdmin::UserModule

has_secure_password

validates :password, length: { minimum: 8 }, allow_nil: true

def self.get_by_email(email)
where(email: email).first
end

alias valid_password? authenticate

def to_s
email
end

end
```


5) Add rademade_admin initializer `initializers/rademade_admin.rb`
```ruby
RademadeAdmin.configure do |config|
config.admin_class = User
end

```

6) Create admin controller. Example `app/controllers/rademade_admin/users_controller.rb`
```ruby
class RademadeAdmin::UsersController < RademadeAdmin::ModelController

# You can leave controller absolutely empty!

options do
list do
email
end
form do
first_name
email
password :hint => 'Or leave it empty'
end
end

end
```

7) Add `admin_resources` to `routers.rb`
```ruby
namespace :rademade_admin, :path => 'admin' do
admin_resources :users
end
```

8) Install assets with bower `rake rademade_admin:bower:install`

9) Start rails `rails s`

**Good luck :)**
How to install
--------------
[https://github.com/Rademade/rademade_admin/wiki/install](https://github.com/Rademade/rademade_admin/wiki/install)


Supported options
--------------
```ruby
options do
model 'ModelName'

# Fixed table head if need
fixed_thead true

# Navigation menu settings
parent_menu 'ModelName'
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/app/common/uploader.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class @Uploader extends Backbone.View
updateUploader : (result) =>
@$el.find('[data-preview-item]').replaceWith(result.html)
@$el.find('.upload-holder.hide').removeClass('hide')
@$hidden.val(result.file[@$uploader.data('column')].url)
@$hidden.val(result.file.url)
ImagePreview.initPlugin()

showLoader : () ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class @Select2Input.RelatedCollectionView extends Backbone.View
views = []
collection = new Select2Input.RelatedCollection
collection.setSortable $list.data('sortable')
collection.setDeletable $list.data('deletable')

$list.find('li').each () ->
relatedView = Select2Input.RelatedView.init $(this)
views.push relatedView
Expand Down
6 changes: 6 additions & 0 deletions app/assets/javascripts/app/select2/related/collection.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@ class @Select2Input.RelatedCollection extends Backbone.Collection
setSortable : (sortable) ->
@sortable = sortable

setDeletable : (deletable) ->
@deletable = deletable

isSortable : () ->
@sortable

isDeletable : () ->
@deletable

resort : () ->
@sort()
@_triggerChange()
Expand Down
7 changes: 7 additions & 0 deletions app/assets/javascripts/app/select2/related/view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,16 @@ class @Select2Input.RelatedView extends Backbone.View
else
false

isDeletable: () ->
if @model.collection
@model.collection.isDeletable()
else
false

_getHtml : (data) ->
JST['app/templates/related-item'] _.extend
isSortable : @isSortable()
isDeletable : @isDeletable()
, data

@init : ($el) ->
Expand Down
6 changes: 5 additions & 1 deletion app/assets/javascripts/app/templates/related-item.jst.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ if (isSortable) {
%><i class="draggable-btn"></i><%
}
%><button class="select2-item-edit" data-edit="<%= editurl %>"><%= text %></button>
<button class="select2-item-remove" data-remove><%= I18n.t('rademade_admin.relation.destroy') %></button>
<%
if (isDeletable) {
%><button class="select2-item-remove" data-remove><%= I18n.t('rademade_admin.relation.destroy') %></button><%
}
%>
11 changes: 3 additions & 8 deletions app/assets/javascripts/rademade_admin.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@
#= require jquery-ujs
#= require jquery-ui/ui/core
#= require jquery-ui/ui/widget
#= require jquery-ui/ui/mouse
#= require jquery-ui/ui/draggable
#= require jquery-ui/ui/resizable
#= require jquery-ui/ui/sortable
#= require jquery-ui/ui/slider
#= require jquery-ui/ui/tabs
#= require jquery-ui/ui/datepicker
#= require touch-punch/jquery.ui.touch-punch
#= require jcrop/js/jquery.Jcrop
#= require jquery-filthypillow/jquery.filthypillow
Expand All @@ -32,12 +25,14 @@
#= require flot/jquery.flot.resize
#= require flot/jquery.flot.stack
#= require knob/js/jquery.knob
#= require uniform/dist/jquery.uniform.min
#= require uniform/src/js/jquery.uniform
#= require data-tables/media/js/jquery.dataTables
#= require floatThead/dist/jquery.floatThead
#= require wysihtml5/dist/wysihtml5-0.3.0
#= require underscore/underscore
#= require backbone/backbone
#= require backbone-notifier/js/backbone.notifier
#= require jquery-ujs
#= require_tree ./ckeditor
#= require_tree ./settings
#= require_tree ./form
Expand Down
6 changes: 5 additions & 1 deletion app/assets/javascripts/settings/ajax-csrf.coffee
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
$ ->
$.ajaxSetup(headers : {
'X-CSRF-Token' : $('meta[name="csrf-token"]').attr('content')
})
})

$(document).on 'page:load ready init-plugins', () ->
$('table.fixed-thead').floatThead
position: 'fixed'
2 changes: 1 addition & 1 deletion app/assets/stylesheets/rademade_admin.sass
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*= require jquery-ui/themes/base/core
*= require jquery-ui/themes/base/slider
*= require jquery-ui/themes/base/datepicker
*= require uniform/themes/default/css/uniform.default
*= require uniform/dist/css/default.css
*= require jcrop/css/jquery.Jcrop
*= require leaflet/dist/leaflet
*= require backbone-notifier/css/notifier-base
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/rademade_admin/file_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def upload
uploader.store!(params[param_key])
render :json => {
:html => RademadeAdmin::Upload::Preview::File.new(uploader).preview_html,
:file => uploader
:file => JSON.parse(uploader.to_json).merge(url: uploader.url)
}
rescue CarrierWave::UploadError => e
show_error(e)
Expand Down
5 changes: 5 additions & 0 deletions app/services/model_controller/model_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module ModelOptions
# - model
# - name
# - parent_menu (todo extract to menu method)
# - fixed_thead
# - menu_count
# - list
# - form
Expand All @@ -28,6 +29,10 @@ def parent_menu_item
configuration.parent_menu_item
end

def fixed_thead_value
configuration.fixed_thead_value
end

def model_class
configuration.model_class
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/rademade_admin/_blocks/_list.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ end %>
concat render @template_service.search_block
%></div>
<div class="content-table-holder">
<table class="content-table" cellspacing="0" cellpadding="0"><%
<table class="content-table<%= @model_info.fixed_thead ? ' fixed-thead' : '' %>" cellspacing="0" cellpadding="0"><%
concat render @template_service.table_head_block
concat render @template_service.table_head_list
%></table>
Expand Down
3 changes: 1 addition & 2 deletions app/views/rademade_admin/_blocks/_navigation.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<i class="user-img"></i>
<span class="user-name"><%= @current_user %></span><%
concat link_to '', rademade_admin_route(:logout_sessions_url), {
:method => :delete,
:class => 'user-settings'
}
%></div>
Expand All @@ -19,4 +18,4 @@
<a href="https://rademade.com"> Rademade</a> Admin
</div>
</div>
</div>
</div>
4 changes: 2 additions & 2 deletions app/views/rademade_admin/_blocks/button/_destroy.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%
if can? :destroy, @model
if can? :destroy, item
delete_uri = admin_delete_uri(item)
unless delete_uri.nil?
%><%= form_tag(delete_uri, :method => :delete, :class => 'inline-el', :data => { :'delete-item-form' => '' }) do
Expand All @@ -10,4 +10,4 @@ if can? :destroy, @model
</button><%
end
end
end %>
end %>
6 changes: 0 additions & 6 deletions config/initializers/bower_rails.rb

This file was deleted.

19 changes: 17 additions & 2 deletions lib/rademade_admin/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,22 @@ class Engine < ::Rails::Engine
config.assets.paths << "#{config.root}/vendor/assets/javascript/bower_components"

initializer 'ckeditor.assets_precompile', :group => :all do |app|
app.config.assets.precompile += %w(rademade_admin.css rademade_admin.js ckeditor/* rademade_admin/fav1.ico)
filter_ckeditor_assets = Proc.new do |logical_path|
File.fnmatch('ckeditor/*', logical_path) \
&& ! [
'ckeditor/CHANGES',
'ckeditor/LICENSE',
'ckeditor/README',
'ckeditor/plugins/scayt/CHANGELOG',
'ckeditor/plugins/scayt/LICENSE',
'ckeditor/plugins/scayt/README',
'ckeditor/plugins/wsc/LICENSE',
'ckeditor/plugins/wsc/README',
'ckeditor/skins/moono/readme',
].include?(logical_path)
end
app.config.assets.precompile << filter_ckeditor_assets
app.config.assets.precompile += %w(rademade_admin.css rademade_admin.js rademade_admin/fav1.ico)
end

$LOAD_PATH << "#{config.root}/app/services/"
Expand All @@ -29,4 +44,4 @@ class Engine < ::Rails::Engine
end

end
end
end
9 changes: 7 additions & 2 deletions lib/rademade_admin/input/related_select_input/related_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ def related_list_html
template.content_tag(:ul, related_list_items_html, {
:class => 'select2-items-list',
:data => {
:sortable => sortable_relation?
:sortable => sortable_relation?,
:deletable => destroyable_relation?
}
})
end
Expand Down Expand Up @@ -51,7 +52,7 @@ def related_list_item_remove_html
template.content_tag(:button, I18n.t('rademade_admin.relation.destroy'), {
:'data-remove' => '',
:class => 'select2-item-remove'
})
}) if destroyable_relation?
end

def related_item_class
Expand All @@ -64,6 +65,10 @@ def sortable_relation?
related_data_item.relation.sortable?
end

def destroyable_relation?
related_data_item.relation.destroyable?
end

end
end
end
Expand Down
Loading
Loading