trestle 0.9.0 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +15 -9
- data/Gemfile +3 -3
- data/README.md +4 -2
- data/app/assets/bundle/trestle/bundle.css +0 -0
- data/app/assets/bundle/trestle/bundle.js +0 -0
- data/app/assets/bundle/trestle/fa-brands-400.eot +0 -0
- data/app/assets/bundle/trestle/fa-brands-400.svg +0 -0
- data/app/assets/bundle/trestle/fa-brands-400.ttf +0 -0
- data/app/assets/bundle/trestle/fa-brands-400.woff +0 -0
- data/app/assets/bundle/trestle/fa-brands-400.woff2 +0 -0
- data/app/assets/bundle/trestle/fa-regular-400.eot +0 -0
- data/app/assets/bundle/trestle/fa-regular-400.svg +0 -0
- data/app/assets/bundle/trestle/fa-regular-400.ttf +0 -0
- data/app/assets/bundle/trestle/fa-regular-400.woff +0 -0
- data/app/assets/bundle/trestle/fa-regular-400.woff2 +0 -0
- data/app/assets/bundle/trestle/fa-solid-900.eot +0 -0
- data/app/assets/bundle/trestle/fa-solid-900.svg +0 -0
- data/app/assets/bundle/trestle/fa-solid-900.ttf +0 -0
- data/app/assets/bundle/trestle/fa-solid-900.woff +0 -0
- data/app/assets/bundle/trestle/fa-solid-900.woff2 +0 -0
- data/app/assets/bundle/trestle/flatpickr/ar.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/at.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/az.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/be.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/bg.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/bn.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/bs.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/cat.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/cs.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/cy.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/da.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/de.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/default.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/eo.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/es.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/et.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/fa.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/fi.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/fo.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/fr.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/ga.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/gr.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/he.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/hi.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/hr.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/hu.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/id.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/is.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/it.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/ja.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/ka.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/km.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/ko.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/kz.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/lt.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/lv.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/mk.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/mn.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/ms.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/my.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/nl.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/no.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/pa.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/pl.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/pt.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/ro.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/ru.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/si.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/sk.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/sl.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/sq.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/sr-cyr.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/sr.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/sv.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/th.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/tr.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/uk.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/uz.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/uz_latn.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/vn.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/zh-tw.js +0 -0
- data/app/assets/bundle/trestle/flatpickr/zh.js +0 -0
- data/app/assets/javascripts/trestle/admin.js +1 -0
- data/app/assets/javascripts/trestle/i18n.js.erb +8 -0
- data/{lib → app/controllers/concerns}/trestle/controller/breadcrumbs.rb +1 -1
- data/{lib → app/controllers/concerns}/trestle/controller/callbacks.rb +0 -0
- data/{lib → app/controllers/concerns}/trestle/controller/dialog.rb +0 -0
- data/{lib → app/controllers/concerns}/trestle/controller/helpers.rb +0 -0
- data/{lib → app/controllers/concerns}/trestle/controller/layout.rb +0 -0
- data/{lib → app/controllers/concerns}/trestle/controller/location.rb +0 -0
- data/app/controllers/concerns/trestle/controller/title.rb +20 -0
- data/app/controllers/concerns/trestle/controller/toolbars.rb +30 -0
- data/app/controllers/concerns/trestle/resource/controller/actions.rb +133 -0
- data/app/controllers/concerns/trestle/resource/controller/data_methods.rb +52 -0
- data/app/controllers/concerns/trestle/resource/controller/redirection.rb +23 -0
- data/app/controllers/concerns/trestle/resource/controller/toolbar.rb +11 -0
- data/app/controllers/trestle/admin_controller.rb +31 -0
- data/app/controllers/trestle/application_controller.rb +12 -0
- data/app/controllers/trestle/resource_controller.rb +6 -0
- data/app/helpers/trestle/grid_helper.rb +51 -7
- data/app/helpers/trestle/hook_helper.rb +1 -25
- data/app/helpers/trestle/i18n_helper.rb +8 -15
- data/app/helpers/trestle/layout_helper.rb +20 -0
- data/app/helpers/trestle/navigation_helper.rb +23 -0
- data/app/helpers/trestle/table_helper.rb +22 -3
- data/app/helpers/trestle/title_helper.rb +11 -0
- data/app/helpers/trestle/toolbars_helper.rb +0 -11
- data/app/views/layouts/trestle/admin.html.erb +6 -6
- data/app/views/trestle/application/_dialog.html.erb +1 -1
- data/app/views/trestle/application/_header.html.erb +1 -3
- data/app/views/trestle/resource/_scopes.html.erb +17 -8
- data/app/views/trestle/resource/edit.html.erb +2 -2
- data/app/views/trestle/resource/index.html.erb +3 -3
- data/app/views/trestle/resource/new.html.erb +1 -1
- data/app/views/trestle/resource/show.html.erb +2 -2
- data/app/views/trestle/shared/_sidebar.html.erb +5 -6
- data/app/views/trestle/table/_pagination.html.erb +1 -1
- data/config/locales/de.rb +18 -0
- data/config/locales/de.yml +101 -0
- data/config/locales/vi.rb +18 -0
- data/config/locales/vi.yml +101 -0
- data/frontend/css/components/_fields.scss +5 -0
- data/frontend/css/components/_scopes.scss +66 -21
- data/frontend/css/components/_table.scss +20 -0
- data/frontend/css/layout/_content.scss +5 -2
- data/frontend/css/layout/_sidebar.scss +6 -1
- data/frontend/css/variables/_trestle.scss +5 -5
- data/frontend/js/components/confirmation.js +4 -2
- data/frontend/js/components/dialog.js +7 -1
- data/frontend/js/components/form.js +9 -0
- data/frontend/js/components/navigation.js +63 -0
- data/frontend/js/components/pagination.js +51 -0
- data/frontend/js/components/sidebar.js +8 -11
- data/frontend/js/components/table.js +33 -2
- data/frontend/js/components/tabs.js +2 -2
- data/frontend/js/core/events.js +7 -3
- data/frontend/js/index.js +1 -0
- data/frontend/theme/trestle/theme/bootstrap/_buttons.scss +3 -0
- data/lib/generators/trestle/resource/resource_generator.rb +15 -1
- data/lib/generators/trestle/resource/templates/admin.rb.erb +15 -8
- data/lib/trestle.rb +33 -36
- data/lib/trestle/adapters.rb +1 -1
- data/lib/trestle/adapters/active_record_adapter.rb +1 -1
- data/lib/trestle/admin.rb +18 -8
- data/lib/trestle/admin/builder.rb +7 -3
- data/lib/trestle/configurable.rb +10 -0
- data/lib/trestle/configuration.rb +3 -3
- data/lib/trestle/engine.rb +3 -10
- data/lib/trestle/evaluation_context.rb +11 -3
- data/lib/trestle/form.rb +5 -7
- data/lib/trestle/form/automatic.rb +2 -2
- data/lib/trestle/form/builder.rb +2 -3
- data/lib/trestle/form/field.rb +44 -17
- data/lib/trestle/form/fields.rb +6 -38
- data/lib/trestle/form/fields/check_box_helpers.rb +1 -1
- data/lib/trestle/form/fields/collection_select.rb +1 -1
- data/lib/trestle/form/fields/date_picker.rb +9 -3
- data/lib/trestle/form/fields/date_select.rb +1 -1
- data/lib/trestle/form/fields/datetime_select.rb +1 -1
- data/lib/trestle/form/fields/file_field.rb +1 -1
- data/lib/trestle/form/fields/form_group.rb +18 -5
- data/lib/trestle/form/fields/grouped_collection_select.rb +1 -1
- data/lib/trestle/form/fields/range_field.rb +2 -4
- data/lib/trestle/form/fields/select.rb +2 -3
- data/lib/trestle/form/fields/static_field.rb +7 -3
- data/lib/trestle/form/fields/tag_select.rb +3 -1
- data/lib/trestle/form/fields/time_select.rb +1 -1
- data/lib/trestle/form/fields/time_zone_select.rb +1 -1
- data/lib/trestle/form/renderer.rb +7 -3
- data/lib/trestle/hook.rb +5 -31
- data/lib/trestle/hook/helpers.rb +33 -0
- data/lib/trestle/hook/set.rb +32 -0
- data/lib/trestle/navigation.rb +3 -6
- data/lib/trestle/navigation/group.rb +4 -0
- data/lib/trestle/navigation/item.rb +4 -0
- data/lib/trestle/reloader.rb +23 -11
- data/lib/trestle/resource.rb +8 -9
- data/lib/trestle/resource/builder.rb +4 -3
- data/lib/trestle/resource/collection.rb +1 -5
- data/lib/trestle/resource/toolbar.rb +42 -0
- data/lib/trestle/scopes.rb +38 -11
- data/lib/trestle/scopes/block.rb +9 -8
- data/lib/trestle/scopes/definition.rb +22 -0
- data/lib/trestle/scopes/scope.rb +6 -2
- data/lib/trestle/tab.rb +2 -0
- data/lib/trestle/table.rb +17 -12
- data/lib/trestle/table/actions_column.rb +6 -6
- data/lib/trestle/table/automatic.rb +3 -3
- data/lib/trestle/table/builder.rb +4 -4
- data/lib/trestle/table/column.rb +29 -24
- data/lib/trestle/table/row.rb +13 -13
- data/lib/trestle/table/select_column.rb +19 -7
- data/lib/trestle/toolbar.rb +4 -11
- data/lib/trestle/version.rb +1 -1
- data/package.json +8 -8
- data/trestle.gemspec +6 -6
- data/webpack.config.js +4 -1
- data/yarn.lock +1871 -1800
- metadata +56 -21
- data/lib/trestle/admin/controller.rb +0 -28
- data/lib/trestle/application_controller.rb +0 -12
- data/lib/trestle/resource/controller.rb +0 -174
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0fbbf8844e06a0b7770f4754ae4b9082d2718705a4636072f5b02b8920cfed43
|
4
|
+
data.tar.gz: 03311a6ef3ef6fc6e95abdb956de744347f44bacdfc0c25253eb6185a1855235
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c3935441a6a9bde8ed536cdd08b3642c7114ac697a1e986d5f189da4ce61c3705df26d7de1383e4644c7391f7cb33be5baf2ddac949a5115ad4ef589f5c505a
|
7
|
+
data.tar.gz: ab4b6fb774080b47600871f008cd3f3cd6aa1a2c2f0b4f9f9cd9536223147c97b8567c67732d2496941a0441535ab0c5e7020f9a5dc62dd465e1a1199110d914
|
data/.travis.yml
CHANGED
@@ -1,27 +1,33 @@
|
|
1
1
|
language: ruby
|
2
2
|
|
3
|
+
cache: bundler
|
4
|
+
|
3
5
|
before_install:
|
4
6
|
- gem update --system
|
5
7
|
- gem install bundler
|
6
8
|
|
7
9
|
rvm:
|
8
|
-
- 2.6.
|
10
|
+
- 2.6.6
|
11
|
+
- 2.7.2
|
9
12
|
|
10
13
|
gemfile:
|
11
|
-
- gemfiles/rails-4.2.gemfile
|
12
14
|
- gemfiles/rails-5.0.gemfile
|
13
15
|
- gemfiles/rails-5.1.gemfile
|
14
16
|
- gemfiles/rails-5.2.gemfile
|
15
17
|
- gemfiles/rails-6.0.gemfile
|
18
|
+
- gemfiles/rails-6.1.gemfile
|
16
19
|
|
17
20
|
addons:
|
18
21
|
chrome: stable
|
19
22
|
|
20
|
-
|
21
|
-
exclude:
|
22
|
-
gemfile: gemfiles/rails-4.2.gemfile
|
23
|
-
|
23
|
+
jobs:
|
24
24
|
include:
|
25
|
-
gemfile: gemfiles/rails-4.2.gemfile
|
26
|
-
|
27
|
-
|
25
|
+
- gemfile: gemfiles/rails-4.2.gemfile
|
26
|
+
before_install:
|
27
|
+
- gem install bundler -v '< 2'
|
28
|
+
|
29
|
+
# - gemfile: gemfiles/rails-6.0.gemfile
|
30
|
+
# rvm: 3.0.0
|
31
|
+
|
32
|
+
- gemfile: gemfiles/rails-6.1.gemfile
|
33
|
+
rvm: 3.0.0
|
data/Gemfile
CHANGED
@@ -4,12 +4,12 @@ source 'https://rubygems.org'
|
|
4
4
|
gemspec
|
5
5
|
|
6
6
|
group :test do
|
7
|
-
gem '
|
8
|
-
gem '
|
9
|
-
gem 'guard-rspec', require: false
|
7
|
+
gem 'coveralls_reborn', require: false
|
8
|
+
gem 'guard-rspec', require: false
|
10
9
|
|
11
10
|
gem 'capybara'
|
12
11
|
gem 'capybara-selenium'
|
12
|
+
gem 'rexml'
|
13
13
|
gem 'selenium-webdriver'
|
14
14
|
gem 'webdrivers'
|
15
15
|
gem 'puma'
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
# Trestle
|
6
6
|
|
7
7
|
[![RubyGem](https://img.shields.io/gem/v/trestle.svg?style=flat&colorB=4065a9)](https://rubygems.org/gems/trestle)
|
8
|
-
[![Travis](https://img.shields.io/travis/TrestleAdmin/trestle.svg?style=flat)](https://travis-ci.
|
8
|
+
[![Travis](https://img.shields.io/travis/TrestleAdmin/trestle.svg?style=flat)](https://travis-ci.com/github/TrestleAdmin/trestle)
|
9
9
|
[![Coveralls](https://img.shields.io/coveralls/TrestleAdmin/trestle.svg?style=flat)](https://coveralls.io/github/TrestleAdmin/trestle)
|
10
10
|
[![Code Climate](https://api.codeclimate.com/v1/badges/c529a7a9c500ed81baed/maintainability)](https://codeclimate.com/github/TrestleAdmin/trestle)
|
11
11
|
|
@@ -28,7 +28,7 @@ Run `bundle install`, and then run the install generator to create the initial c
|
|
28
28
|
|
29
29
|
$ rails generate trestle:install
|
30
30
|
|
31
|
-
Then create your first admin resource:
|
31
|
+
Then create your first admin resource (assuming you have an existing `Article` model):
|
32
32
|
|
33
33
|
$ rails generate trestle:resource Article
|
34
34
|
|
@@ -104,6 +104,8 @@ The following plugins are currently available:
|
|
104
104
|
| *trestle-sidekiq* | [Sidekiq](http://sidekiq.org/) integration | [GitHub](https://github.com/TrestleAdmin/trestle-sidekiq) \| [RubyGems](https://rubygems.org/gems/trestle-sidekiq) |
|
105
105
|
| *trestle-active_storage* | [Active Storage](https://guides.rubyonrails.org/active_storage_overview.html) integration | [GitHub](https://github.com/richardvenneman/trestle-active_storage) \| [RubyGems](https://rubygems.org/gems/trestle-active_storage) |
|
106
106
|
| *trestle-mobility* | [Mobility](https://github.com/shioyama/mobility) integration | [GitHub](https://github.com/richardvenneman/trestle-mobility) \| [RubyGems](https://rubygems.org/gems/trestle-mobility) |
|
107
|
+
| *trestle-omniauth* | OmniAuth authentication plugin | [GitHub](https://github.com/airhorns/trestle-omniauth) \| [RubyGems](https://rubygems.org/gems/trestle-omniauth) |
|
108
|
+
| *trestle-auth-otp* | 2FA/OTP user authentication | [GitHub](https://github.com/McRipper/trestle-auth-otp) \| [RubyGems](https://rubygems.org/gems/trestle-auth-otp) |
|
107
109
|
|
108
110
|
|
109
111
|
## License
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<% flatpickr_locale_conversions = { ca: "cat", el: "gr", nb: "no", vi: "vn" } %>
|
2
|
+
|
3
|
+
<% I18n.available_locales.each do |locale| %>
|
4
|
+
<% Trestle.i18n_fallbacks(locale).each do |candidate| %>
|
5
|
+
<% candidate = flatpickr_locale_conversions[candidate] || candidate %>
|
6
|
+
<% require_asset("trestle/flatpickr/#{candidate}") rescue nil %>
|
7
|
+
<% end %>
|
8
|
+
<% end %>
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Trestle
|
2
|
+
module Controller
|
3
|
+
module Title
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
helper_method :default_title
|
8
|
+
end
|
9
|
+
|
10
|
+
protected
|
11
|
+
def title(title=nil)
|
12
|
+
@_title = title if title
|
13
|
+
end
|
14
|
+
|
15
|
+
def default_title
|
16
|
+
@_title || action_name.titleize
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Trestle
|
2
|
+
module Controller
|
3
|
+
module Toolbars
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
helper_method :toolbars
|
8
|
+
helper_method :toolbar
|
9
|
+
end
|
10
|
+
|
11
|
+
protected
|
12
|
+
def toolbars
|
13
|
+
@_toolbars ||= {}
|
14
|
+
end
|
15
|
+
|
16
|
+
def toolbar(name, options={}, &block)
|
17
|
+
builder = options[:builder] || default_toolbar_builder
|
18
|
+
|
19
|
+
toolbar = (toolbars[name.to_s] ||= Toolbar.new(builder))
|
20
|
+
toolbar.clear! if options[:clear]
|
21
|
+
toolbar.prepend(&block) if block_given?
|
22
|
+
toolbar
|
23
|
+
end
|
24
|
+
|
25
|
+
def default_toolbar_builder
|
26
|
+
Toolbar::Builder
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,133 @@
|
|
1
|
+
module Trestle
|
2
|
+
class Resource
|
3
|
+
module Controller
|
4
|
+
module Actions
|
5
|
+
def index
|
6
|
+
respond_to do |format|
|
7
|
+
format.html
|
8
|
+
format.json { render json: collection }
|
9
|
+
|
10
|
+
yield format if block_given?
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def new
|
15
|
+
respond_to do |format|
|
16
|
+
format.html
|
17
|
+
format.json { render json: instance }
|
18
|
+
|
19
|
+
yield format if block_given?
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def create
|
24
|
+
if save_instance
|
25
|
+
respond_to do |format|
|
26
|
+
format.html do
|
27
|
+
flash[:message] = flash_message("create.success", title: "Success!", message: "The %{lowercase_model_name} was successfully created.")
|
28
|
+
redirect_to_return_location(:create, instance, default: admin.instance_path(instance))
|
29
|
+
end
|
30
|
+
format.json { render json: instance, status: :created, location: admin.instance_path(instance) }
|
31
|
+
|
32
|
+
yield format if block_given?
|
33
|
+
end
|
34
|
+
else
|
35
|
+
respond_to do |format|
|
36
|
+
format.html do
|
37
|
+
flash.now[:error] = flash_message("create.failure", title: "Warning!", message: "Please correct the errors below.")
|
38
|
+
render "new", status: :unprocessable_entity
|
39
|
+
end
|
40
|
+
format.json { render json: instance.errors, status: :unprocessable_entity }
|
41
|
+
|
42
|
+
yield format if block_given?
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def show
|
48
|
+
if admin.singular? && instance.nil?
|
49
|
+
respond_to do |format|
|
50
|
+
format.html { redirect_to action: :new }
|
51
|
+
format.json { head :not_found }
|
52
|
+
|
53
|
+
yield format if block_given?
|
54
|
+
end
|
55
|
+
else
|
56
|
+
respond_to do |format|
|
57
|
+
format.html
|
58
|
+
format.json { render json: instance }
|
59
|
+
|
60
|
+
yield format if block_given?
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def edit
|
66
|
+
if admin.singular? && instance.nil?
|
67
|
+
respond_to do |format|
|
68
|
+
format.html { redirect_to action: :new }
|
69
|
+
format.json { head :not_found }
|
70
|
+
|
71
|
+
yield format if block_given?
|
72
|
+
end
|
73
|
+
else
|
74
|
+
respond_to do |format|
|
75
|
+
format.html
|
76
|
+
format.json { render json: instance }
|
77
|
+
|
78
|
+
yield format if block_given?
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def update
|
84
|
+
if update_instance
|
85
|
+
respond_to do |format|
|
86
|
+
format.html do
|
87
|
+
flash[:message] = flash_message("update.success", title: "Success!", message: "The %{lowercase_model_name} was successfully updated.")
|
88
|
+
redirect_to_return_location(:update, instance, default: admin.instance_path(instance))
|
89
|
+
end
|
90
|
+
format.json { render json: instance, status: :ok }
|
91
|
+
|
92
|
+
yield format if block_given?
|
93
|
+
end
|
94
|
+
else
|
95
|
+
respond_to do |format|
|
96
|
+
format.html do
|
97
|
+
flash.now[:error] = flash_message("update.failure", title: "Warning!", message: "Please correct the errors below.")
|
98
|
+
render "show", status: :unprocessable_entity
|
99
|
+
end
|
100
|
+
format.json { render json: instance.errors, status: :unprocessable_entity }
|
101
|
+
|
102
|
+
yield format if block_given?
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def destroy
|
108
|
+
success = delete_instance
|
109
|
+
|
110
|
+
respond_to do |format|
|
111
|
+
format.html do
|
112
|
+
if success
|
113
|
+
flash[:message] = flash_message("destroy.success", title: "Success!", message: "The %{lowercase_model_name} was successfully deleted.")
|
114
|
+
redirect_to_return_location(:destroy, instance, default: admin.path(:index))
|
115
|
+
else
|
116
|
+
flash[:error] = flash_message("destroy.failure", title: "Warning!", message: "Could not delete %{lowercase_model_name}.")
|
117
|
+
|
118
|
+
if load_instance
|
119
|
+
redirect_to_return_location(:update, instance, default: admin.instance_path(instance))
|
120
|
+
else
|
121
|
+
redirect_to_return_location(:destroy, instance, default: admin.path(:index))
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
format.json { head :no_content }
|
126
|
+
|
127
|
+
yield format if block_given?
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|