hobo_rapid 2.1.1 → 2.1.2

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: b7572196f26e54e4873b8bbc0f47dba3622c4fb8
4
- data.tar.gz: 2c7ec48b0d13d00df65523bee4e083d98f424431
3
+ metadata.gz: 9c315bf6c9cc975bbb615c85cf9bbf1f7f64b3b8
4
+ data.tar.gz: 41b597e0a0e35c44ca514f18e99f6b3a8fd59b66
5
5
  SHA512:
6
- metadata.gz: b8865f8373ddb01749042e848b45f9625db791cc3f1233e430bce1b452aa755bb1042e5086d11da0735b2ac25f2faab4fbec661898ead4a8a54c17b8bf0c4f09
7
- data.tar.gz: f24803c9b53f9d0ccaab34e555637b557cd4fe11a2e51851964dc3bb049ca33b9c54dda01f1aec4e97a8aff456913763fe4eb81553eccfe3273c6efbebf259f9
6
+ metadata.gz: 26ab08c92cdb76ec208f9b04d936ce93e641cefa3fbf1706a14a1393f9c266f036dac7d647379055d7e7c1910973c4737a094d21e524cd405ce0801b2c88f1cc
7
+ data.tar.gz: 2130965d96ba503771c857c4085f4390b040255fa8df5e992033e920ade5d6c2c730db298d44a30d516a200eb1a77702e874d85697b7baa798cf3dfc05fd4c20
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.1
1
+ 2.1.2
@@ -54,8 +54,7 @@ All the standard ajax attributes *except the callbacks* are supported (see the m
54
54
  attributes[:type] ||= 'submit'
55
55
  end
56
56
  label ||= t("hobo.actions.remove", :default=>"Remove")
57
- confirm = t("hobo.messages.confirm", :default=>"Are you sure?") if confirm.nil?
58
- ajax_attrs[:confirm] = confirm if confirm
57
+ ajax_attrs[:confirm] = confirm ? confirm : t("hobo.messages.confirm_delete", :name => this.to_s, :default=>"Are you sure that you want to delete #{this.to_s}?")
59
58
 
60
59
  add_classes!(attributes,
61
60
  image ? "image-button" : "button",
@@ -137,6 +137,8 @@ The standard AJAX attributes are supported.
137
137
  href = object_url(target, "new", params)
138
138
 
139
139
  if href && (force || can_create?(new_record))
140
+ # Remove the object from memory after checking permissions
141
+ target.delete(new_record) if new_record && target.respond_to?(:build)
140
142
  new_class_name = if target.respond_to?(:proxy_association)
141
143
  target.proxy_association.reflection.klass.name
142
144
  else
@@ -9,10 +9,8 @@
9
9
  <def tag="check-many" attrs="options, disabled"><%
10
10
  collection = this
11
11
  param_name = param_name_for_this
12
- options ||= begin
13
- conditions = ActiveRecord::Associations::BelongsToAssociation.new(this_parent, this_field_reflection).send(:conditions)
14
- this_field_reflection.klass.all(:conditions => conditions, :limit => 100).select {|x| can_view?(x)}
15
- end
12
+ options ||= \
13
+ this_field_reflection.klass.all.merge(this_field_reflection.scope).limit(100).select {|x| can_view?(x)}
16
14
  -%>
17
15
  <ul class="check-many" param="default" merge-attrs>
18
16
  <input type="hidden" name="#{param_name}[]" value=""/><% # ensure all items are removed when nothing checked
@@ -17,9 +17,10 @@ To use this tag, the model of the items the user is chosing *must* have unique n
17
17
  `name`: the parameter name. Defaults to `param_name_for_this`.
18
18
 
19
19
  %>
20
- <def tag="select-many" attrs="options, remove-label, prompt, disabled, name"><%
20
+ <def tag="select-many" polymorphic attrs="options, remove-label, prompt, disabled, name"><%
21
21
  prompt ||= ht("#{this_field_reflection.klass.to_s.underscore}.form.select_many.prompt", :default=>"Add #{this_field.titleize.singularize}")
22
- options ||= this_field_reflection.klass.where(this_field_reflection.options[:conditions]).select {|x| can_view?(x)}
22
+ options ||= \
23
+ this_field_reflection.klass.all.merge(this_field_reflection.scope).select {|x| can_view?(x)}
23
24
  name ||= param_name_for_this
24
25
 
25
26
  values = this
@@ -6,7 +6,7 @@ This is the default input that Rapid uses for `belongs_to` associations. The men
6
6
 
7
7
  - `include-none` - whether to include a 'none' option (i.e. set the foreign key to null). If this value is not supplied, the default is "true" if the current value is nil; otherwise the default is "false". One implication of this is that the default may change when the form is re-rendered due to a validation failure. Setting this value explicitly is recommended.
8
8
  - `blank-message` - the message for the 'none' option. Defaults to "(No `<model-name-human>`)", e.g. "(No Product)"
9
- - `options` - an array of records to include in the menu. Defaults to the all the records in the target table that match any `:conditions` declared on the `belongs_to` (subject to `limit`)
9
+ - `options` - an array of records to include in the menu. Defaults to the all the records in the target table that match any scope declared on the `has_many` (subject to `limit`)
10
10
  - `sort` - whether to sort the array of options. Defaults to no sorting.
11
11
  - `limit` - if `options` is not specified, this limits the number of records. Default: 100
12
12
  - `text_method` - The method to call on each record to get the text for the option. Multiple methods are supported ie "institution.name"
@@ -16,16 +16,13 @@ This is the default input that Rapid uses for `belongs_to` associations. The men
16
16
  For situations where there are too many target records to practically include in a menu, `<name-one>` provides an autocompleter which would be more suitable.
17
17
 
18
18
  -->
19
- <def tag="select-one" attrs="include-none, blank-message, options, sort, limit, text-method"><%
19
+ <def tag="select-one" polymorphic attrs="include-none, blank-message, options, sort, limit, text-method"><%
20
20
  raise Hobo::PermissionDeniedError.new("Not allowed to edit #{this_field}") if !attributes[:disabled] && !can_edit?
21
21
  blank_message ||= ht("#{this_type.name.underscore}.messages.none", :default=>"No #{this_type.model_name.human} available.")
22
22
  limit ||= 100
23
23
 
24
- options ||= begin
25
- conditions = ActiveRecord::Associations::BelongsToAssociation.new(this_parent, this_field_reflection).options[:conditions]
26
- order = this_field_reflection.klass.default_order
27
- this_field_reflection.klass.where(conditions).limit(limit).order(order).select {|x| can_view?(x)}
28
- end
24
+ options ||= \
25
+ this_field_reflection.klass.all.merge(this_field_reflection.scope).limit(limit).select {|x| can_view?(x)}
29
26
 
30
27
  id_method = this_field_reflection.options[:primary_key] || this_field_reflection.klass.primary_key
31
28
  if text_method.nil?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hobo_rapid
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Locke, Bryan Larsen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-17 00:00:00.000000000 Z
11
+ date: 2015-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hobo
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 2.1.1
19
+ version: 2.1.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 2.1.1
26
+ version: 2.1.2
27
27
  description: The RAPID tag library for Hobo
28
28
  email: tom@tomlocke.com
29
29
  executables: []