rails_admin_discard 0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6273787e905d505d2482856b367d125e9e803dc64f2927d386414f7f38242c70
4
+ data.tar.gz: 4a87633a9f231d7560a0b1bc807938b16b79c8407f8b60721ebf70bc766948d3
5
+ SHA512:
6
+ metadata.gz: 6a0905f1fa0019df5cd7aa8fb830679c3596dd7e90a3a7ee5f675d1296625d65386d965ca58279c48d075ebf13266d9369c87e259c7a77713aa3f5c21e9cdbaa
7
+ data.tar.gz: 1d123e2487a13ee3b3e38261399112f650fa2e2c7d778be6fac95dea9dc96d3fd4c55c818e1b53ab6e5a46c8be077cba2577e471c0dfcc9dd40d42e9c2bdc00b
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2020
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
+ # RailsAdminDiscard
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 'rails_admin_discard'
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install rails_admin_discard
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](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,19 @@
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 = 'RailsAdminDiscard'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ load 'rails/tasks/statistics.rake'
18
+
19
+ require 'bundler/gem_tasks'
@@ -0,0 +1,18 @@
1
+ %h4
2
+ = t("admin.form.are_you_sure_you_want_to_delete_the_object", model_name: @abstract_model.pretty_name.downcase)
3
+ &ldquo;
4
+ %strong>= @model_config.with(object: @object).object_label
5
+ \&rdquo;
6
+ %span>
7
+ = t("admin.form.all_of_the_following_related_items_will_be_deleted")
8
+
9
+ %ul= render partial: "delete_notice", object: @object
10
+ = form_for(@object, url: discard_path(model_name: @abstract_model.to_param, id: @object.id), html: {method: "delete"}) do
11
+ %input{type: :hidden, name: 'return_to', value: (params[:return_to].presence || request.referer)}
12
+ .form-actions
13
+ %button.btn.btn-danger{type: "submit", :'data-disable-with' => t("admin.form.confirmation")}
14
+ %i.icon-white.icon-ok
15
+ = t("admin.form.confirmation")
16
+ %button.btn{type: "submit", name: "_continue", :'data-disable-with' => t("admin.form.cancel")}
17
+ %i.icon-remove
18
+ = t("admin.form.cancel")
@@ -0,0 +1,11 @@
1
+
2
+ en:
3
+ admin:
4
+ actions:
5
+ discard:
6
+ title: "Discard"
7
+ menu: "Discard for %{model_label} '%{object_label}'"
8
+ breadcrumb: "Discard"
9
+ link: "Discard"
10
+ bulk_link: "Discard selected %{model_label_plural}"
11
+ done: "Discarded"
@@ -0,0 +1,4 @@
1
+ module RailsAdminDiscard
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module RailsAdminDiscard
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,68 @@
1
+ require "rails_admin_discard/engine"
2
+
3
+ module RailsAdminDiscard
4
+ # Your code goes here...
5
+ end
6
+
7
+ require 'rails_admin/config/actions'
8
+
9
+ module RailsAdmin
10
+ module Config
11
+ module Actions
12
+ class Discard < Base
13
+ RailsAdmin::Config::Actions.register(self)
14
+
15
+ register_instance_option :object_level do
16
+ true
17
+ end
18
+
19
+ register_instance_option :member do
20
+ true
21
+ end
22
+
23
+ register_instance_option :route_fragment do
24
+ 'discard'
25
+ end
26
+
27
+ register_instance_option :http_methods do
28
+ [:get, :delete]
29
+ end
30
+
31
+ register_instance_option :authorization_key do
32
+ :destroy
33
+ end
34
+
35
+ register_instance_option :controller do
36
+ proc do
37
+ if request.get? # DELETE
38
+
39
+ respond_to do |format|
40
+ format.html { render @action.template_name }
41
+ format.js { render @action.template_name, layout: false }
42
+ end
43
+
44
+ elsif request.delete? # DESTROY
45
+ redirect_path = nil
46
+ @auditing_adapter && @auditing_adapter.delete_object(@object, @abstract_model, _current_user)
47
+ if @object.discard
48
+ flash[:success] = t('admin.flash.successful', name: @model_config.label, action: t('admin.actions.delete.done'))
49
+ redirect_path = index_path
50
+ else
51
+ flash[:error] = t('admin.flash.error', name: @model_config.label, action: t('admin.actions.delete.done'))
52
+ redirect_path = back_or_index
53
+ end
54
+
55
+ redirect_to redirect_path
56
+
57
+ end
58
+ end
59
+ end
60
+
61
+ register_instance_option :link_icon do
62
+ 'icon-remove'
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
68
+
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_admin_discard
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Dayves
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-01-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 5.2.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 5.2.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: discard
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ description: A poor implementation of custom actions of rails admin to use discard
42
+ gem.
43
+ email:
44
+ - dayves.dias@gmail.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - MIT-LICENSE
50
+ - README.md
51
+ - Rakefile
52
+ - app/views/rails_admin/main/discard.html.haml
53
+ - config/locales/discard.en.yml
54
+ - lib/rails_admin_discard.rb
55
+ - lib/rails_admin_discard/engine.rb
56
+ - lib/rails_admin_discard/version.rb
57
+ homepage: https://jera.com.br
58
+ licenses:
59
+ - MIT
60
+ metadata: {}
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubygems_version: 3.0.3
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: A poor implementation of custom actions of rails admin to use discard gem.
80
+ test_files: []