generic_resources 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9fd8f90a5ebe10b1e6c3dcfe49bddb14bb4f7941
|
4
|
+
data.tar.gz: 5ad47fff12155be3f8c7f66b188deabf6ca140d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40c19f363f364f5ab1255082c406535987123a8825fc62231586b8f016ccb81438b2b5505904bee1110c4b50a8f6f0cb22c31a27846a6014426f9f99ecd2e72e
|
7
|
+
data.tar.gz: f387e580781b4eb2b14bec0f5f0dc6fe4c64b9c91e6b6452dd926333f9e50b0acfa356dc50f5a043ad5e4c5635da2635b5545b534c079b29a6c650b8e6b7f8a9
|
@@ -43,6 +43,13 @@ class GenericResources::ResourcesController < GenericResources.configuration.par
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def destroy
|
46
|
+
if GenericResource.resources[params[:resource_name]][:resource_deleteable]
|
47
|
+
@resource.destroy
|
48
|
+
flash[:notice] = I18n.t('generic_resources.controller.flash.notice.destroyed', resource_name: @resource_class.model_name.human)
|
49
|
+
else
|
50
|
+
flash[:notice] = I18n.t('generic_resources.controller.flash.error.not_destroyed', resource_name: @resource_class.model_name.human)
|
51
|
+
end
|
52
|
+
redirect_to_index
|
46
53
|
end
|
47
54
|
|
48
55
|
private
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= form_for @resource, url: generic_resources.generic_resources_resource_path, html: { method: :patch} do |f| %>
|
1
|
+
<%= form_for @resource, url: generic_resources.generic_resources_resource_path, html: { method: :patch, multipart: true} do |f| %>
|
2
2
|
<%= render "generic_resources/resources/forms/#{params[:resource_name]}", f: f %>
|
3
3
|
<br />
|
4
4
|
<%= f.submit t("generic_resources.forms.save_resource", resource_name: @resource_class.model_name.human) %>
|
data/lib/generic_resource.rb
CHANGED
@@ -2,12 +2,13 @@ module GenericResource
|
|
2
2
|
|
3
3
|
mattr_accessor :resources
|
4
4
|
|
5
|
-
def self.register_resource!(klass, permitted_attributes: [], overview_attributes: [])
|
5
|
+
def self.register_resource!(klass, permitted_attributes: [], overview_attributes: [], resource_deleteable: false)
|
6
6
|
@@resources ||= {}
|
7
7
|
@@resources[klass.name.underscore.gsub("/","_")] = {
|
8
8
|
class: klass,
|
9
9
|
permitted_attributes: permitted_attributes,
|
10
|
-
overview_attributes: overview_attributes
|
10
|
+
overview_attributes: overview_attributes,
|
11
|
+
resource_deleteable: resource_deleteable
|
11
12
|
}
|
12
13
|
end
|
13
14
|
|
@@ -8,7 +8,10 @@ module GenericResources
|
|
8
8
|
end
|
9
9
|
|
10
10
|
module ClassMethods
|
11
|
-
def acts_as_generic_resource(permitted_attributes: [], overview_attributes: [])
|
11
|
+
def acts_as_generic_resource(permitted_attributes: [], overview_attributes: [], deleteable: false)
|
12
|
+
|
13
|
+
resource_deleteable = true if deleteable == true
|
14
|
+
|
12
15
|
if !self.table_exists?
|
13
16
|
Rails.logger.warn "Try to add generic resource #{self.name} - table does not exist"
|
14
17
|
return false
|
@@ -22,7 +25,10 @@ module GenericResources
|
|
22
25
|
overview_attributes = permitted_attributes
|
23
26
|
end
|
24
27
|
|
25
|
-
GenericResource.register_resource!(self,
|
28
|
+
GenericResource.register_resource!(self,
|
29
|
+
permitted_attributes: permitted_attributes, overview_attributes: overview_attributes,
|
30
|
+
resource_deleteable: resource_deleteable
|
31
|
+
)
|
26
32
|
end
|
27
33
|
end
|
28
34
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: generic_resources
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Eck
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|