tramway-admin 1.0
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 +28 -0
- data/Rakefile +36 -0
- data/app/assets/config/tramway_admin_manifest.js +2 -0
- data/app/assets/javascripts/tramway/admin/application.js.coffee +3 -0
- data/app/assets/javascripts/tramway/admin/records.js +2 -0
- data/app/assets/javascripts/tramway/admin/tramway/admin/records.js +2 -0
- data/app/assets/javascripts/tramway/admin/welcome.js +2 -0
- data/app/assets/stylesheets/tramway/admin/application.css.sass +7 -0
- data/app/assets/stylesheets/tramway/admin/records.css +4 -0
- data/app/assets/stylesheets/tramway/admin/tramway/admin/records.css +4 -0
- data/app/controllers/tramway/admin/application_controller.rb +58 -0
- data/app/controllers/tramway/admin/records_controller.rb +62 -0
- data/app/controllers/tramway/admin/singletons_controller.rb +31 -0
- data/app/controllers/tramway/admin/welcome_controller.rb +10 -0
- data/app/helpers/tramway/admin/application_helper.rb +21 -0
- data/app/helpers/tramway/admin/records_helper.rb +67 -0
- data/app/helpers/tramway/admin/russian_cases_helper.rb +23 -0
- data/app/helpers/tramway/admin/singleton_helper.rb +10 -0
- data/app/helpers/tramway/admin/welcome_helper.rb +4 -0
- data/app/jobs/tramway/admin/application_job.rb +6 -0
- data/app/mailers/tramway/admin/application_mailer.rb +8 -0
- data/app/models/tramway/user/user.rb +9 -0
- data/app/views/layouts/tramway/admin/application.html.haml +14 -0
- data/app/views/layouts/tramway/admin/shared/_navbar.html.haml +20 -0
- data/app/views/tramway/admin/records/_form.html.haml +18 -0
- data/app/views/tramway/admin/records/_list.html.haml +27 -0
- data/app/views/tramway/admin/records/_search.html.haml +9 -0
- data/app/views/tramway/admin/records/edit.html.haml +1 -0
- data/app/views/tramway/admin/records/index.html.haml +24 -0
- data/app/views/tramway/admin/records/new.html.haml +1 -0
- data/app/views/tramway/admin/records/show.html.haml +18 -0
- data/app/views/tramway/admin/singletons/_form.html.haml +18 -0
- data/app/views/tramway/admin/singletons/edit.html.haml +1 -0
- data/app/views/tramway/admin/singletons/show.html.haml +18 -0
- data/app/views/tramway/admin/welcome/index.html.haml +0 -0
- data/config/locales/ru.collections.yml +4 -0
- data/config/routes.rb +6 -0
- data/lib/tasks/tramway/admin_tasks.rake +4 -0
- data/lib/tramway/admin.rb +30 -0
- data/lib/tramway/admin/engine.rb +7 -0
- data/lib/tramway/admin/record_routes_helper.rb +19 -0
- data/lib/tramway/admin/version.rb +5 -0
- metadata +87 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 42d582e53ffb141a3dccb80c9ec4cf3878bc57bb8ee3acfce73ab61bab69f6e7
|
4
|
+
data.tar.gz: babce019849cb45c892cb220ff8f8d52fda7b746919e8b6b8d99d0e382a8364f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 51f0ea137169467a884d029cbbb38a91c547a421986c73a703a70a41ee03db82fa80faa9827e943cbe3db0f91dd7e5324bce00b6c1e0b4bbd73048e06044ad27
|
7
|
+
data.tar.gz: 7e5c8931ee73d927e167fe8f908d13125bd621ae5556cbc65893b1393024d82a7a422fa4c4637392967fc6af1780a5cb543d6fbf53020872f68c80a6e8957fcf
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2017 Pavel Kalashnikov
|
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,28 @@
|
|
1
|
+
# Tramway::Admin
|
2
|
+
Short description and motivation.
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
How to use my plugin.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'tramway-admin'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
```bash
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
```bash
|
21
|
+
$ gem install tramway-admin
|
22
|
+
```
|
23
|
+
|
24
|
+
## Contributing
|
25
|
+
Contribution directions go here.
|
26
|
+
|
27
|
+
## License
|
28
|
+
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,36 @@
|
|
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 = 'Tramway::Admin'
|
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("../test/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
load 'rails/tasks/statistics.rake'
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
require 'bundler/gem_tasks'
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
|
29
|
+
Rake::TestTask.new(:test) do |t|
|
30
|
+
t.libs << 'test'
|
31
|
+
t.pattern = 'test/**/*_test.rb'
|
32
|
+
t.verbose = false
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
task default: :test
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Tramway
|
2
|
+
module Admin
|
3
|
+
class ApplicationController < ActionController::Base
|
4
|
+
include AuthManagment
|
5
|
+
include RecordRoutesHelper
|
6
|
+
before_action :authenticate_admin!
|
7
|
+
before_action :check_available!
|
8
|
+
before_action :collections_counts, if: :model_given?
|
9
|
+
before_action :check_available_scope!, if: :model_given?, only: :index
|
10
|
+
before_action :application
|
11
|
+
|
12
|
+
protect_from_forgery with: :exception
|
13
|
+
|
14
|
+
def check_available!
|
15
|
+
render '/404' unless model_given?
|
16
|
+
end
|
17
|
+
|
18
|
+
def check_available_scope!
|
19
|
+
if params[:scope].present?
|
20
|
+
render '/404' unless available_scope_given?
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def collections_counts
|
25
|
+
@counts = "#{params[:model]}Decorator".constantize.collections.reduce({}) do |hash, collection|
|
26
|
+
hash.merge! collection => params[:model].constantize.active.send(collection).count
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def model_class
|
31
|
+
params[:model].constantize
|
32
|
+
end
|
33
|
+
|
34
|
+
def decorator_class
|
35
|
+
"#{model_class}Decorator".constantize
|
36
|
+
end
|
37
|
+
|
38
|
+
def form_class
|
39
|
+
"#{model_class}Form".constantize
|
40
|
+
end
|
41
|
+
|
42
|
+
def application
|
43
|
+
@application = ::Tramway::Core.application.model_class.first
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def model_given?
|
49
|
+
params[:model].in?(::Tramway::Admin.available_models.map(&:to_s)) ||
|
50
|
+
params[:model].in?(::Tramway::Admin.singleton_models.map(&:to_s))
|
51
|
+
end
|
52
|
+
|
53
|
+
def available_scope_given?
|
54
|
+
params[:scope].present? && params[:scope].in?(decorator_class.collections.map(&:to_s))
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Tramway::Admin
|
2
|
+
class RecordsController < ApplicationController
|
3
|
+
def index
|
4
|
+
@records = decorator_class.decorate model_class.active.send(params[:scope] || :all).page params[:page]
|
5
|
+
end
|
6
|
+
|
7
|
+
def show
|
8
|
+
@record = decorator_class.decorate model_class.active.find params[:id]
|
9
|
+
end
|
10
|
+
|
11
|
+
def edit
|
12
|
+
@record_form = form_class.new model_class.active.find params[:id]
|
13
|
+
end
|
14
|
+
|
15
|
+
def update
|
16
|
+
@record_form = form_class.new model_class.active.find params[:id]
|
17
|
+
if @record_form.submit params[:record]
|
18
|
+
redirect_to params[:redirect] || record_path(@record_form.model)
|
19
|
+
else
|
20
|
+
render :edit
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def new
|
25
|
+
@record_form = form_class.new model_class.new
|
26
|
+
end
|
27
|
+
|
28
|
+
def create
|
29
|
+
@record_form = form_class.new model_class.new
|
30
|
+
if @record_form.submit params[:record]
|
31
|
+
redirect_to params[:redirect] || record_path(@record_form.model)
|
32
|
+
else
|
33
|
+
render :new
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def destroy
|
38
|
+
record = model_class.active.find params[:id]
|
39
|
+
record.remove
|
40
|
+
redirect_to records_path
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
# FIXME replace to module
|
47
|
+
def record_path(*args, **options)
|
48
|
+
super args, options.merge(model: params[:model])
|
49
|
+
end
|
50
|
+
|
51
|
+
def edit_record_path(*args, **options)
|
52
|
+
super args, options.merge(model: params[:model])
|
53
|
+
end
|
54
|
+
|
55
|
+
def new_record_path(*args, **options)
|
56
|
+
super args, options.merge(model: params[:model])
|
57
|
+
end
|
58
|
+
|
59
|
+
def records_path(*args, **options)
|
60
|
+
super args, options.merge(model: params[:model])
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Tramway::Admin
|
2
|
+
class SingletonsController < ApplicationController
|
3
|
+
def show
|
4
|
+
@singleton = decorator_class.decorate model_class.active.first
|
5
|
+
end
|
6
|
+
|
7
|
+
def edit
|
8
|
+
@singleton_form = form_class.new model_class.active.first
|
9
|
+
end
|
10
|
+
|
11
|
+
def update
|
12
|
+
@singleton_form = form_class.new model_class.active.first
|
13
|
+
if @singleton_form.submit params[:singleton]
|
14
|
+
redirect_to params[:redirect] || singleton_path(model: params[:model])
|
15
|
+
else
|
16
|
+
render :edit
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
# FIXME replace to module
|
24
|
+
def singleton_path(*args, **options)
|
25
|
+
super args, options.merge(model: params[:model])
|
26
|
+
end
|
27
|
+
|
28
|
+
def edit_singleton_path(*args, **options)
|
29
|
+
super args, options.merge(model: params[:model])
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Tramway
|
2
|
+
module Admin
|
3
|
+
module ApplicationHelper
|
4
|
+
include ::FontAwesome::Rails::IconHelper
|
5
|
+
include AuthManagment
|
6
|
+
|
7
|
+
def title(page_title = default_title)
|
8
|
+
title_text = "#{page_title} | #{t('application.name')}"
|
9
|
+
content_for(:title) { title_text }
|
10
|
+
end
|
11
|
+
|
12
|
+
def default_title
|
13
|
+
t('.title')
|
14
|
+
end
|
15
|
+
|
16
|
+
def page_title(action, model_name)
|
17
|
+
t("helpers.actions.#{action}") + ' ' + genitive(model_name)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Tramway::Admin
|
2
|
+
module RecordsHelper
|
3
|
+
# FIXME replace to module
|
4
|
+
def record_path(*args, **options)
|
5
|
+
super args, options.merge(model: params[:model])
|
6
|
+
end
|
7
|
+
|
8
|
+
def edit_record_path(*args, **options)
|
9
|
+
super args, options.merge(model: params[:model])
|
10
|
+
end
|
11
|
+
|
12
|
+
def new_record_path(*args, **options)
|
13
|
+
super args, options.merge(model: params[:model])
|
14
|
+
end
|
15
|
+
|
16
|
+
def records_path(*args, **options)
|
17
|
+
super args, options.merge(model: params[:model])
|
18
|
+
end
|
19
|
+
|
20
|
+
def model_class
|
21
|
+
params[:model].constantize
|
22
|
+
end
|
23
|
+
|
24
|
+
def decorator_class
|
25
|
+
"#{model_class}Decorator".constantize
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_collection(model_class)
|
29
|
+
decorator_class.collections
|
30
|
+
end
|
31
|
+
|
32
|
+
def to_path(constant)
|
33
|
+
constant.name.underscore.gsub '/', '_'
|
34
|
+
end
|
35
|
+
|
36
|
+
def search_tab_title(count)
|
37
|
+
"#{t("helpers.found")} / #{count}"
|
38
|
+
end
|
39
|
+
|
40
|
+
def searchable_model?(model_class)
|
41
|
+
model_class.methods.include?(:search) || model_class.methods.include?(:search_everywhere)
|
42
|
+
end
|
43
|
+
|
44
|
+
def admin_index_path_of_model(model_class, tab = nil)
|
45
|
+
if tab
|
46
|
+
records_path model: model_class, scope: tab
|
47
|
+
else
|
48
|
+
records_path model: model_class
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def tab_title(model_class, tab, count, state_method = :state)
|
53
|
+
model = model_class.name.underscore
|
54
|
+
name = if t("default.collections.#{tab}").include?('<span')
|
55
|
+
t("collections.#{model}.#{tab}").pluralize(:ru)
|
56
|
+
else
|
57
|
+
t("default.collections.#{tab}")
|
58
|
+
end
|
59
|
+
"#{name} / #{count}"
|
60
|
+
end
|
61
|
+
|
62
|
+
def active_tab(tab, index)
|
63
|
+
return :active if params[:scope].nil? && index == 0
|
64
|
+
return :active if params[:search].nil? && params[:scope].to_s == tab.to_s
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Tramway::Admin::RussianCasesHelper
|
2
|
+
def case_word(model_name, case_name)
|
3
|
+
word_case = I18n.t("cases.#{model_name.name.underscore}.#{case_name}")
|
4
|
+
return word_case if word_case.present?
|
5
|
+
raise "There is not #{case_name} implementation for \"#{model_name}\""
|
6
|
+
end
|
7
|
+
|
8
|
+
def genitive(word)
|
9
|
+
case_word word, :genitive
|
10
|
+
end
|
11
|
+
|
12
|
+
def instrumental(word)
|
13
|
+
case_word word, :instrumental
|
14
|
+
end
|
15
|
+
|
16
|
+
def dative(word)
|
17
|
+
case_word word, :dative
|
18
|
+
end
|
19
|
+
|
20
|
+
def plural(word)
|
21
|
+
case_word word, :plural
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Tramway::Admin::SingletonHelper
|
2
|
+
# FIXME replace to module
|
3
|
+
def singleton_path(*args, **options)
|
4
|
+
super args, options.merge(model: params[:model])
|
5
|
+
end
|
6
|
+
|
7
|
+
def edit_singleton_path(*args, **options)
|
8
|
+
super args, options.merge(model: params[:model])
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
%html
|
2
|
+
%head
|
3
|
+
%meta{content: "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
|
4
|
+
%title Tramway admin
|
5
|
+
= stylesheet_link_tag "tramway/admin/application", media: "all"
|
6
|
+
= javascript_include_tag "tramway/admin/application"
|
7
|
+
= csrf_meta_tags
|
8
|
+
%body
|
9
|
+
= render 'layouts/tramway/admin/shared/navbar'
|
10
|
+
%main.container{ role: :main }
|
11
|
+
= yield
|
12
|
+
%footer
|
13
|
+
.container
|
14
|
+
= copyright '2017', 'Tramway'
|
@@ -0,0 +1,20 @@
|
|
1
|
+
%nav.navbar.navbar-expand-md.navbar-dark.bg-dark
|
2
|
+
= link_to @application.title, try(:root_path) || '/', class: 'navbar-brand'
|
3
|
+
.navbar-collapse.collapse
|
4
|
+
- if signed_in?
|
5
|
+
%ul.navbar-nav
|
6
|
+
- ::Tramway::Admin.singleton_models.each do |model|
|
7
|
+
= model_menu_item model: model, route: ::Tramway::Admin::Engine.routes.url_helpers.singleton_path(model: model)
|
8
|
+
- ::Tramway::Admin.available_models.each do |model|
|
9
|
+
= model_menu_item model: model, route: ::Tramway::Admin::Engine.routes.url_helpers.records_path(model: model)
|
10
|
+
%ul.nav.navbar-nav.ml-auto
|
11
|
+
- if signed_in?
|
12
|
+
%li.nav-item
|
13
|
+
= link_to '/session', method: :delete, class: 'nav-link' do
|
14
|
+
= fa_icon 'sign-out'
|
15
|
+
= t('helpers.links.sign_out')
|
16
|
+
- else
|
17
|
+
%li.nav-item
|
18
|
+
= link_to new_session_path, class: 'nav-link' do
|
19
|
+
= fa_icon 'sign-in'
|
20
|
+
= t('helpers.links.enter')
|
@@ -0,0 +1,18 @@
|
|
1
|
+
- current_title = page_title(action, model_class)
|
2
|
+
- title current_title
|
3
|
+
.page-header
|
4
|
+
%h1= current_title
|
5
|
+
%hr
|
6
|
+
.row
|
7
|
+
.col-lg-12
|
8
|
+
= render 'tramway/core/shared/messages', object: @record_form
|
9
|
+
.row
|
10
|
+
.col-lg-12
|
11
|
+
= simple_form_for @record_form.model, url: { controller: :records, action: action, model: @record_form.model.class }, input_html: { class: 'form-horizontal' } do |f|
|
12
|
+
- @record_form.properties.each do |property, type|
|
13
|
+
- if type == :default
|
14
|
+
= f.input property, input_html: { name: "record[#{property}]", id: "record_#{property}" }
|
15
|
+
- else
|
16
|
+
= f.input property, as: type, input_html: { name: "record[#{property}]", id: "record_#{property}" }
|
17
|
+
= f.button :submit, t('helpers.links.save'), class: 'btn-success'
|
18
|
+
= link_to t('helpers.links.back'), records_path, class: 'btn btn-secondary'
|
@@ -0,0 +1,27 @@
|
|
1
|
+
= paginate @records, theme: 'twitter-bootstrap-4'
|
2
|
+
%table.table.table-condensed.table-hover
|
3
|
+
%thead
|
4
|
+
%tr
|
5
|
+
%th= model_class.human_attribute_name(:id)
|
6
|
+
%th= model_class.human_attribute_name(:name)
|
7
|
+
- decorator_class.list_attributes.each do |attribute|
|
8
|
+
%th= model_class.human_attribute_name attribute
|
9
|
+
%th= t 'helpers.links.actions'
|
10
|
+
%tbody
|
11
|
+
- @records.each do |record|
|
12
|
+
%tr
|
13
|
+
%td
|
14
|
+
= link_to record.id, record_path(record.id)
|
15
|
+
%td
|
16
|
+
= link_to record.name, record_path(record.id)
|
17
|
+
- decorator_class.list_attributes.each do |attribute|
|
18
|
+
%td
|
19
|
+
= record.send attribute
|
20
|
+
%td.actions
|
21
|
+
.btn-group{ data: { toggle: :buttons } }
|
22
|
+
- record.model.class.state_machines.keys.each do |state_method|
|
23
|
+
- unless state_method == :state
|
24
|
+
= state_events_buttons record, state_method: state_method, model_param_name: :record, route_method: :record_path, parameters: { redirect: records_path }
|
25
|
+
= link_to fa_icon(:pencil), edit_record_path(record.id), class: 'btn btn-warning btn-xs'
|
26
|
+
= link_to fa_icon(:remove), record_path(record.id), method: :delete, class: 'btn btn-xs btn-danger'
|
27
|
+
= paginate @records, theme: 'twitter-bootstrap-4'
|
@@ -0,0 +1,9 @@
|
|
1
|
+
- if searchable_model?(model_class)
|
2
|
+
.col-md-6
|
3
|
+
.search
|
4
|
+
= form_tag request.fullpath, method: :get do |f|
|
5
|
+
.form-group.text
|
6
|
+
.input-group
|
7
|
+
= text_field_tag :search, params[:search], class: 'text form-control'
|
8
|
+
%span.input-group-btn
|
9
|
+
= submit_tag t('helpers.search')
|
@@ -0,0 +1 @@
|
|
1
|
+
= render partial: 'form', locals: { action: :update }
|
@@ -0,0 +1,24 @@
|
|
1
|
+
- default_page_title ||= nil; on_site_link ||= nil
|
2
|
+
- current_title = default_page_title || plural(model_class).capitalize
|
3
|
+
- title current_title
|
4
|
+
- state_method ||= :state
|
5
|
+
- tabs = get_collection model_class
|
6
|
+
- new_path = "new_admin_#{to_path(model_class)}_path"
|
7
|
+
.page-header
|
8
|
+
.row
|
9
|
+
.col-md-6
|
10
|
+
%h1
|
11
|
+
= current_title
|
12
|
+
= link_to fa_icon(:plus), new_record_path, class: 'btn btn-primary'
|
13
|
+
= render 'search', model_class: model_class
|
14
|
+
%hr
|
15
|
+
%ul.nav.nav-tabs
|
16
|
+
- if params[:search]
|
17
|
+
%li.active.nav-item
|
18
|
+
= link_to search_tab_title(items.total_count), '#', class: 'nav-link'
|
19
|
+
- tabs.each_with_index do |tab, index|
|
20
|
+
%li.nav-item
|
21
|
+
= link_to admin_index_path_of_model(model_class, tab), class: "#{active_tab(tab, index)} nav-link" do
|
22
|
+
= tab_title(model_class, tab, @counts[tab], state_method)
|
23
|
+
%div{ id: (params[:search] ? :search : params[:scope]) }
|
24
|
+
= render 'list'
|
@@ -0,0 +1 @@
|
|
1
|
+
= render partial: 'form', locals: { action: :create }
|
@@ -0,0 +1,18 @@
|
|
1
|
+
- default_page_title ||= nil; on_site_link ||= nil
|
2
|
+
- current_title = default_page_title || model_class.model_name.human.pluralize(:ru)
|
3
|
+
- title current_title
|
4
|
+
.page-header
|
5
|
+
.row
|
6
|
+
.col-md-6
|
7
|
+
%h1
|
8
|
+
= current_title
|
9
|
+
= link_to fa_icon(:pencil), edit_record_path(@record.id), class: 'btn btn-warning btn-xs'
|
10
|
+
%hr
|
11
|
+
.row
|
12
|
+
%table.table.table-striped.table-bordered
|
13
|
+
- @record.attributes.each do |attribute_name, value|
|
14
|
+
%tr
|
15
|
+
%td
|
16
|
+
= model_class.human_attribute_name attribute_name
|
17
|
+
%td
|
18
|
+
= value
|
@@ -0,0 +1,18 @@
|
|
1
|
+
- current_title = page_title(action, model_class)
|
2
|
+
- title current_title
|
3
|
+
.page-header
|
4
|
+
%h1= current_title
|
5
|
+
%hr
|
6
|
+
.row
|
7
|
+
.col-lg-12
|
8
|
+
= render 'tramway/core/shared/messages', object: @singleton_form
|
9
|
+
.row
|
10
|
+
.col-lg-12
|
11
|
+
= simple_form_for @singleton_form.model, url: { controller: :singletons, action: action, model: @singleton_form.model.class }, input_html: { class: 'form-horizontal' } do |f|
|
12
|
+
- @singleton_form.properties.each do |property, type|
|
13
|
+
- if type == :default
|
14
|
+
= f.input property, input_html: { name: "singleton[#{property}]", id: "singleton_#{property}" }
|
15
|
+
- else
|
16
|
+
= f.input property, as: type, input_html: { name: "singleton[#{property}]", id: "singleton_#{property}" }
|
17
|
+
= f.button :submit, t('helpers.links.save'), class: 'btn-success'
|
18
|
+
= link_to t('helpers.links.back'), singleton_path, class: 'btn btn-secondary'
|
@@ -0,0 +1 @@
|
|
1
|
+
= render partial: 'form', locals: { action: :update }
|
@@ -0,0 +1,18 @@
|
|
1
|
+
- default_page_title ||= nil; on_site_link ||= nil
|
2
|
+
- current_title = default_page_title || model_class.model_name.human.pluralize(:ru)
|
3
|
+
- title current_title
|
4
|
+
.page-header
|
5
|
+
.row
|
6
|
+
.col-md-6
|
7
|
+
%h1
|
8
|
+
= current_title
|
9
|
+
= link_to fa_icon(:pencil), edit_singleton_path, class: 'btn btn-warning btn-xs'
|
10
|
+
%hr
|
11
|
+
.row
|
12
|
+
%table.table.table-striped.table-bordered
|
13
|
+
- @singleton.attributes.each do |attribute_name, value|
|
14
|
+
%tr
|
15
|
+
%td
|
16
|
+
= model_class.human_attribute_name attribute_name
|
17
|
+
%td
|
18
|
+
= value
|
File without changes
|
data/config/routes.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'tramway/admin/record_routes_helper'
|
2
|
+
require "tramway/admin/engine"
|
3
|
+
require "tramway/user"
|
4
|
+
require 'font-awesome-rails'
|
5
|
+
|
6
|
+
module Tramway
|
7
|
+
module Admin
|
8
|
+
::Tramway::User.layout_path = 'tramway/admin/application'
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def set_available_models(*models)
|
12
|
+
@available_models ||= []
|
13
|
+
@available_models += models
|
14
|
+
end
|
15
|
+
|
16
|
+
def available_models
|
17
|
+
@available_models
|
18
|
+
end
|
19
|
+
|
20
|
+
def set_singleton_models(*models)
|
21
|
+
@singleton_models ||= []
|
22
|
+
@singleton_models += models
|
23
|
+
end
|
24
|
+
|
25
|
+
def singleton_models
|
26
|
+
@singleton_models
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Tramway::Admin
|
2
|
+
module RecordRoutesHelper
|
3
|
+
def record_path(*args, **options)
|
4
|
+
super args, options.merge(model: params[:model])
|
5
|
+
end
|
6
|
+
|
7
|
+
def edit_record_path(*args, **options)
|
8
|
+
super args, options.merge(model: params[:model])
|
9
|
+
end
|
10
|
+
|
11
|
+
def new_record_path(*args, **options)
|
12
|
+
super args, options.merge(model: params[:model])
|
13
|
+
end
|
14
|
+
|
15
|
+
def records_path(*args, **options)
|
16
|
+
super args, options.merge(model: params[:model])
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tramway-admin
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '1.0'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Pavel Kalashnikov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-02-21 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Engine for admin
|
14
|
+
email:
|
15
|
+
- kalashnikovisme@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- MIT-LICENSE
|
21
|
+
- README.md
|
22
|
+
- Rakefile
|
23
|
+
- app/assets/config/tramway_admin_manifest.js
|
24
|
+
- app/assets/javascripts/tramway/admin/application.js.coffee
|
25
|
+
- app/assets/javascripts/tramway/admin/records.js
|
26
|
+
- app/assets/javascripts/tramway/admin/tramway/admin/records.js
|
27
|
+
- app/assets/javascripts/tramway/admin/welcome.js
|
28
|
+
- app/assets/stylesheets/tramway/admin/application.css.sass
|
29
|
+
- app/assets/stylesheets/tramway/admin/records.css
|
30
|
+
- app/assets/stylesheets/tramway/admin/tramway/admin/records.css
|
31
|
+
- app/controllers/tramway/admin/application_controller.rb
|
32
|
+
- app/controllers/tramway/admin/records_controller.rb
|
33
|
+
- app/controllers/tramway/admin/singletons_controller.rb
|
34
|
+
- app/controllers/tramway/admin/welcome_controller.rb
|
35
|
+
- app/helpers/tramway/admin/application_helper.rb
|
36
|
+
- app/helpers/tramway/admin/records_helper.rb
|
37
|
+
- app/helpers/tramway/admin/russian_cases_helper.rb
|
38
|
+
- app/helpers/tramway/admin/singleton_helper.rb
|
39
|
+
- app/helpers/tramway/admin/welcome_helper.rb
|
40
|
+
- app/jobs/tramway/admin/application_job.rb
|
41
|
+
- app/mailers/tramway/admin/application_mailer.rb
|
42
|
+
- app/models/tramway/user/user.rb
|
43
|
+
- app/views/layouts/tramway/admin/application.html.haml
|
44
|
+
- app/views/layouts/tramway/admin/shared/_navbar.html.haml
|
45
|
+
- app/views/tramway/admin/records/_form.html.haml
|
46
|
+
- app/views/tramway/admin/records/_list.html.haml
|
47
|
+
- app/views/tramway/admin/records/_search.html.haml
|
48
|
+
- app/views/tramway/admin/records/edit.html.haml
|
49
|
+
- app/views/tramway/admin/records/index.html.haml
|
50
|
+
- app/views/tramway/admin/records/new.html.haml
|
51
|
+
- app/views/tramway/admin/records/show.html.haml
|
52
|
+
- app/views/tramway/admin/singletons/_form.html.haml
|
53
|
+
- app/views/tramway/admin/singletons/edit.html.haml
|
54
|
+
- app/views/tramway/admin/singletons/show.html.haml
|
55
|
+
- app/views/tramway/admin/welcome/index.html.haml
|
56
|
+
- config/locales/ru.collections.yml
|
57
|
+
- config/routes.rb
|
58
|
+
- lib/tasks/tramway/admin_tasks.rake
|
59
|
+
- lib/tramway/admin.rb
|
60
|
+
- lib/tramway/admin/engine.rb
|
61
|
+
- lib/tramway/admin/record_routes_helper.rb
|
62
|
+
- lib/tramway/admin/version.rb
|
63
|
+
homepage: https://github.com/kalashnikovisme/tramway-admin
|
64
|
+
licenses:
|
65
|
+
- MIT
|
66
|
+
metadata: {}
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
requirements: []
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 2.7.3
|
84
|
+
signing_key:
|
85
|
+
specification_version: 4
|
86
|
+
summary: Engine for admin
|
87
|
+
test_files: []
|