adminable 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +91 -0
- data/Rakefile +22 -0
- data/app/assets/javascripts/adminable/application.js +18 -0
- data/app/assets/javascripts/adminable/scripts.js +20 -0
- data/app/assets/stylesheets/adminable/application.scss +3 -0
- data/app/controllers/adminable/application_controller.rb +7 -0
- data/app/controllers/adminable/resources_controller.rb +93 -0
- data/app/helpers/adminable/application_helper.rb +4 -0
- data/app/views/adminable/kaminari/_first_page.html.haml +2 -0
- data/app/views/adminable/kaminari/_last_page.html.haml +2 -0
- data/app/views/adminable/kaminari/_next_page.html.haml +2 -0
- data/app/views/adminable/kaminari/_page.html.haml +6 -0
- data/app/views/adminable/kaminari/_paginator.html.haml +10 -0
- data/app/views/adminable/kaminari/_prev_page.html.haml +2 -0
- data/app/views/adminable/resources/_form.html.haml +14 -0
- data/app/views/adminable/resources/_search.html.haml +9 -0
- data/app/views/adminable/resources/edit.html.haml +5 -0
- data/app/views/adminable/resources/form/_belongs_to.html.haml +3 -0
- data/app/views/adminable/resources/form/_boolean.html.haml +3 -0
- data/app/views/adminable/resources/form/_datetime.html.haml +2 -0
- data/app/views/adminable/resources/form/_decimal.html.haml +2 -0
- data/app/views/adminable/resources/form/_float.html.haml +2 -0
- data/app/views/adminable/resources/form/_has_many.html.haml +9 -0
- data/app/views/adminable/resources/form/_integer.html.haml +2 -0
- data/app/views/adminable/resources/form/_string.html.haml +2 -0
- data/app/views/adminable/resources/form/_text.html.haml +2 -0
- data/app/views/adminable/resources/index.html.haml +35 -0
- data/app/views/adminable/resources/index/_belongs_to.html.haml +5 -0
- data/app/views/adminable/resources/index/_boolean.html.haml +2 -0
- data/app/views/adminable/resources/index/_datetime.html.haml +2 -0
- data/app/views/adminable/resources/index/_decimal.html.haml +1 -0
- data/app/views/adminable/resources/index/_float.html.haml +1 -0
- data/app/views/adminable/resources/index/_has_many.html.haml +3 -0
- data/app/views/adminable/resources/index/_integer.html.haml +1 -0
- data/app/views/adminable/resources/index/_string.html.haml +1 -0
- data/app/views/adminable/resources/index/_text.html.haml +1 -0
- data/app/views/adminable/resources/new.html.haml +5 -0
- data/app/views/adminable/shared/_alert.html.haml +4 -0
- data/app/views/adminable/shared/_label.html.haml +5 -0
- data/app/views/layouts/adminable/application.html.haml +40 -0
- data/config/initializers/haml.rb +3 -0
- data/config/locales/adminable.en.yml +18 -0
- data/config/routes.rb +7 -0
- data/lib/adminable.rb +33 -0
- data/lib/adminable/attributes/association.rb +21 -0
- data/lib/adminable/attributes/base.rb +42 -0
- data/lib/adminable/attributes/collection.rb +77 -0
- data/lib/adminable/attributes/types/belongs_to.rb +13 -0
- data/lib/adminable/attributes/types/boolean.rb +8 -0
- data/lib/adminable/attributes/types/datetime.rb +8 -0
- data/lib/adminable/attributes/types/decimal.rb +8 -0
- data/lib/adminable/attributes/types/float.rb +8 -0
- data/lib/adminable/attributes/types/has_many.rb +21 -0
- data/lib/adminable/attributes/types/integer.rb +8 -0
- data/lib/adminable/attributes/types/string.rb +8 -0
- data/lib/adminable/attributes/types/text.rb +8 -0
- data/lib/adminable/configuration.rb +19 -0
- data/lib/adminable/engine.rb +9 -0
- data/lib/adminable/extensions/devise.rb +24 -0
- data/lib/adminable/resource.rb +37 -0
- data/lib/adminable/version.rb +3 -0
- data/lib/generators/cms/resource/templates/resource_controller.rb.erb +2 -0
- data/lib/generators/cms/resource_generator.rb +28 -0
- metadata +381 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8c8c3f78e6cda87d730a35355df1313ab3fd7674
|
4
|
+
data.tar.gz: 95a90979dce955f6408263afeb5b163a8e0104e5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7fd364eb2250b70f05ff858899bbb8fe836d338d2c568808211d3f1c4390ace87d04b7f7a3eaea610f96d1d9a8b0b8ba5ebdd1112fcef180cb205f0f181ac2f9
|
7
|
+
data.tar.gz: e6b5dd483ccd126c981c3e0656fb8a02fff620937d1279f395400a6bd17267f7ea0c84d2f89a4e64d59c64561a16c33844bc331a1fa39a9795695f329ea9f5d8
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2016 Sergey Novikov
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
# Adminable
|
2
|
+
|
3
|
+
Simple admin interface for Ruby on Rails applications.
|
4
|
+
|
5
|
+
## Features
|
6
|
+
|
7
|
+
* Built with common Rails controllers without DSL.
|
8
|
+
* Supports namespaced models.
|
9
|
+
* Has simple search with Ransack.
|
10
|
+
* Uses Bootstrap 4.0.
|
11
|
+
* Mobile friendly.
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'adminable'
|
19
|
+
```
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
```bash
|
23
|
+
$ bundle
|
24
|
+
```
|
25
|
+
|
26
|
+
Or install it yourself as:
|
27
|
+
```bash
|
28
|
+
$ gem install adminable
|
29
|
+
```
|
30
|
+
|
31
|
+
## Built-in Attributes
|
32
|
+
|
33
|
+
List of attributes with default modifiable parameters.
|
34
|
+
|
35
|
+
##### String
|
36
|
+
|
37
|
+
* show: `true`
|
38
|
+
* center: `false`
|
39
|
+
|
40
|
+
##### Text
|
41
|
+
|
42
|
+
* show: `true`
|
43
|
+
* center: `false`
|
44
|
+
* wysiwyg: `true`
|
45
|
+
|
46
|
+
##### Integer
|
47
|
+
|
48
|
+
* show: `true`
|
49
|
+
* center: `true`
|
50
|
+
|
51
|
+
##### Float
|
52
|
+
|
53
|
+
* show: `true`
|
54
|
+
* center: `true`
|
55
|
+
|
56
|
+
##### Decimal
|
57
|
+
|
58
|
+
* show: `true`
|
59
|
+
* center: `true`
|
60
|
+
|
61
|
+
##### DateTime
|
62
|
+
|
63
|
+
* show: `true`
|
64
|
+
* center: `false`
|
65
|
+
|
66
|
+
##### Boolean
|
67
|
+
|
68
|
+
* show: `true`
|
69
|
+
* center: `true`
|
70
|
+
|
71
|
+
##### Belongs To
|
72
|
+
|
73
|
+
* show: `true`
|
74
|
+
* center: `false`
|
75
|
+
|
76
|
+
##### Has Many
|
77
|
+
|
78
|
+
* show: `true`
|
79
|
+
* center: `false`
|
80
|
+
|
81
|
+
## Contributing
|
82
|
+
|
83
|
+
1. Fork it (https://github.com/droptheplot/adminable/fork)
|
84
|
+
2. Create your feature branch (git checkout -b my-new-feature)
|
85
|
+
3. Commit your changes (git commit -am 'Add some feature')
|
86
|
+
4. Push to the branch (git push origin my-new-feature)
|
87
|
+
5. Create new Pull Request
|
88
|
+
|
89
|
+
## License
|
90
|
+
|
91
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'Adminable'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path('../spec/dummy/Rakefile', __FILE__)
|
18
|
+
|
19
|
+
load 'rails/tasks/engine.rake'
|
20
|
+
load 'rails/tasks/statistics.rake'
|
21
|
+
|
22
|
+
Bundler::GemHelper.install_tasks
|
@@ -0,0 +1,18 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require tether
|
16
|
+
//= require bootstrap
|
17
|
+
//= require bootstrap-sprockets
|
18
|
+
//= require_tree .
|
@@ -0,0 +1,20 @@
|
|
1
|
+
$(document).ready(function() {
|
2
|
+
if($('#clusterizeScrollArea').length && $('#clusterizeContentArea').length) {
|
3
|
+
var clusterize = new Clusterize({
|
4
|
+
scrollId: 'clusterizeScrollArea',
|
5
|
+
contentId: 'clusterizeContentArea'
|
6
|
+
});
|
7
|
+
};
|
8
|
+
|
9
|
+
$('.toggleCheckbox').click(function() {
|
10
|
+
var checkbox = $(this).children('input[type=checkbox]');
|
11
|
+
checkbox.prop('checked', !checkbox.prop('checked'));
|
12
|
+
$(this).toggleClass('active');
|
13
|
+
});
|
14
|
+
|
15
|
+
tinymce.init({
|
16
|
+
selector: '.wysiwyg',
|
17
|
+
menubar: false,
|
18
|
+
statusbar: false
|
19
|
+
});
|
20
|
+
});
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module Adminable
|
2
|
+
class ResourcesController < ApplicationController
|
3
|
+
before_action :set_resource
|
4
|
+
before_action :set_entry, only: [:edit, :update, :destroy]
|
5
|
+
|
6
|
+
before_action do
|
7
|
+
append_view_path Adminable::Engine.root.join('app/views/adminable', controller_name)
|
8
|
+
append_view_path Adminable::Engine.root.join('app/views/adminable/resources')
|
9
|
+
end
|
10
|
+
|
11
|
+
def index
|
12
|
+
@q = @resource.model.ransack(params[:q])
|
13
|
+
@entries = @q.result.includes(*@resource.includes).all
|
14
|
+
.page(params[:page]).per(25)
|
15
|
+
end
|
16
|
+
|
17
|
+
def new
|
18
|
+
@entry = @resource.model.new
|
19
|
+
end
|
20
|
+
|
21
|
+
def edit
|
22
|
+
end
|
23
|
+
|
24
|
+
def create
|
25
|
+
@entry = @resource.model.new(resource_params)
|
26
|
+
|
27
|
+
if @entry.save
|
28
|
+
redirect_to polymorphic_path(@resource.model),
|
29
|
+
notice: t(
|
30
|
+
'adminable.resources.created',
|
31
|
+
resource: @resource.model.model_name.human
|
32
|
+
)
|
33
|
+
else
|
34
|
+
flash.now[:alert] = @entry.errors.full_messages
|
35
|
+
render :new
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def update
|
40
|
+
if @entry.update(resource_params)
|
41
|
+
redirect_to polymorphic_path(@resource.model),
|
42
|
+
notice: t(
|
43
|
+
'adminable.resources.updated',
|
44
|
+
resource: @resource.model.model_name.human
|
45
|
+
)
|
46
|
+
else
|
47
|
+
flash.now[:alert] = @entry.errors.full_messages
|
48
|
+
render :edit
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def destroy
|
53
|
+
@entry.destroy
|
54
|
+
|
55
|
+
redirect_to polymorphic_path(@resource.model),
|
56
|
+
notice: t(
|
57
|
+
'adminable.resources.deleted',
|
58
|
+
resource: @resource.model.model_name.human
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def set_resource
|
65
|
+
@resource = Adminable::Configuration.find_resource(resource_model).clone
|
66
|
+
|
67
|
+
@resource.attributes.index = index_attributes
|
68
|
+
@resource.attributes.form = form_attributes
|
69
|
+
end
|
70
|
+
|
71
|
+
def set_entry
|
72
|
+
@entry = @resource.model.find(params[:id])
|
73
|
+
end
|
74
|
+
|
75
|
+
def index_attributes
|
76
|
+
@resource.attributes.index
|
77
|
+
end
|
78
|
+
|
79
|
+
def form_attributes
|
80
|
+
@resource.attributes.form
|
81
|
+
end
|
82
|
+
|
83
|
+
def resource_model
|
84
|
+
controller_path.sub(%r{^adminable/}, '')
|
85
|
+
end
|
86
|
+
|
87
|
+
def resource_params
|
88
|
+
params.require(@resource.model.model_name.param_key).permit(
|
89
|
+
*@resource.attributes.form.values.map(&:strong_parameter)
|
90
|
+
)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
- if page.current?
|
2
|
+
%li.page-item.active
|
3
|
+
= content_tag :a, page, remote: remote, rel: (page.next? ? 'next' : (page.prev? ? 'prev' : nil)), class: 'page-link'
|
4
|
+
- else
|
5
|
+
%li.page-item
|
6
|
+
= link_to page, url, remote: remote, rel: (page.next? ? 'next' : (page.prev? ? 'prev' : nil)), class: 'page-link'
|
@@ -0,0 +1,10 @@
|
|
1
|
+
= paginator.render do
|
2
|
+
%nav
|
3
|
+
%ul.pagination
|
4
|
+
= first_page_tag unless current_page.first?
|
5
|
+
= prev_page_tag unless current_page.first?
|
6
|
+
- each_page do |page|
|
7
|
+
- if page.left_outer? || page.right_outer? || page.inside_window?
|
8
|
+
= page_tag page
|
9
|
+
= next_page_tag unless current_page.last?
|
10
|
+
= last_page_tag unless current_page.last?
|
@@ -0,0 +1,14 @@
|
|
1
|
+
= form_for @entry do |f|
|
2
|
+
- @resource.attributes.form.each_value do |attribute|
|
3
|
+
- if attribute.show?
|
4
|
+
%fieldset.form-group
|
5
|
+
= render attribute.form_partial_path, f: f, entry: @entry,
|
6
|
+
attribute: attribute
|
7
|
+
%fieldset.form-group
|
8
|
+
= f.submit t('adminable.buttons.submit'), class: 'btn btn-primary'
|
9
|
+
= link_to t('adminable.buttons.back'), polymorphic_path(@resource.model),
|
10
|
+
class: 'btn btn-secondary-outline'
|
11
|
+
- if @entry.persisted?
|
12
|
+
= link_to t('adminable.buttons.delete'), polymorphic_path(@entry),
|
13
|
+
class: 'btn btn-danger-outline pull-xs-right', method: :delete,
|
14
|
+
data: { confirm: t('adminable.ui.confirm') }
|
@@ -0,0 +1,9 @@
|
|
1
|
+
.card.bg-faded
|
2
|
+
.card-block
|
3
|
+
= search_form_for @q do |f|
|
4
|
+
- @resource.attributes.ransack.each_value do |attribute|
|
5
|
+
%fieldset.form-group
|
6
|
+
= f.label attribute.ransack_name, @resource.model.human_attribute_name(attribute.name),
|
7
|
+
class: 'text-muted'
|
8
|
+
= f.search_field attribute.ransack_name, class: 'form-control'
|
9
|
+
= f.submit class: 'btn btn-primary-outline'
|
@@ -0,0 +1,9 @@
|
|
1
|
+
= render 'adminable/shared/label', f: f, attribute: attribute
|
2
|
+
= hidden_field_tag "#{@resource.model.model_name.param_key}[#{attribute.key}][]", nil
|
3
|
+
#clusterizeScrollArea.clusterize-scroll
|
4
|
+
#clusterizeContentArea.clusterize-content.list-group
|
5
|
+
- attribute.options_for_select(entry).each do |value, key|
|
6
|
+
.list-group-item.bg-faded.toggleCheckbox{ :class => ('active' if f.object.send(attribute.key).include?(key)) }
|
7
|
+
= check_box_tag "#{@resource.model.model_name.param_key}[#{attribute.key}][]",
|
8
|
+
key, f.object.send(attribute.key).include?(key), hidden: true
|
9
|
+
= value
|
@@ -0,0 +1,35 @@
|
|
1
|
+
.m-b-1.clearfix
|
2
|
+
%h1.pull-md-left.m-b-2
|
3
|
+
= @resource.model.model_name.human.pluralize
|
4
|
+
= link_to t('adminable.buttons.new', resource: @resource.model.model_name.human),
|
5
|
+
new_polymorphic_path(@resource.model), class: 'btn btn-primary pull-md-right m-b-2'
|
6
|
+
.row
|
7
|
+
.col-md-9
|
8
|
+
.table-responsive.m-b-3
|
9
|
+
%table.table.table-striped
|
10
|
+
%thead
|
11
|
+
%tr
|
12
|
+
- @resource.attributes.index.each_value do |attribute|
|
13
|
+
%th.text-nowrap{ :class => ('text-md-center' if attribute.center?) }
|
14
|
+
= @resource.model.human_attribute_name(attribute.name)
|
15
|
+
%th
|
16
|
+
%tbody
|
17
|
+
- @entries.each do |entry|
|
18
|
+
%tr
|
19
|
+
- @resource.attributes.index.each_value do |attribute|
|
20
|
+
%td{ :class => ('text-md-center' if attribute.center?) }
|
21
|
+
= render attribute.index_partial_path, entry: entry,
|
22
|
+
attribute: attribute, value: entry[attribute.key]
|
23
|
+
%td.text-nowrap.text-md-right
|
24
|
+
= link_to t('adminable.buttons.edit'), edit_polymorphic_path(entry),
|
25
|
+
class: 'label label-primary'
|
26
|
+
= link_to t('adminable.buttons.delete'), polymorphic_path(entry),
|
27
|
+
class: 'label label-danger', method: :delete,
|
28
|
+
data: { confirm: t('adminable.ui.confirm') }
|
29
|
+
- if @entries.empty?
|
30
|
+
%tr
|
31
|
+
%td.text-md-center.text-muted{ :colspan => @resource.attributes.index.size + 1 }
|
32
|
+
No data available
|
33
|
+
.col-md-3.hidden-sm-down
|
34
|
+
= render 'search'
|
35
|
+
= paginate @entries, views_prefix: 'adminable'
|