decidim-core 0.6.4 → 0.6.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: e779623f418954e17c49bbbe1aed14d42299398e
4
- data.tar.gz: e8e12710f5181dc29d7b8fa72e665eb1ece8eb90
3
+ metadata.gz: a44a608e2104f1c2957a934c2940245631472e7b
4
+ data.tar.gz: f55a0b7a343b75d25b86748edb2e609fa5fa5dd5
5
5
  SHA512:
6
- metadata.gz: 5be5179eeed80a0941a93b1fdb1c3e18c0a3f688d4876be4abf0fd7bbeb013b212cdbb784bce864ba40c34e829cdd090dd768f90a5442564a1cf4162d7b84228
7
- data.tar.gz: bf4373a5f5e9be5ceb6ee9edb388293d515891de27ffd1aff0dc66097b418f76ab17dda44edd364c57935e90c6fc0a36b2ccadeb23ebe0f7060a233b0ea6d4ac
6
+ metadata.gz: 7b91649a0423ac242042cc8b9c6e48c15a79ba1fb4314938a5534e51fd0c835ffc0eed7cee2d52332adafe9961d257241f168ce6f5a20f493d3ddd8362c63c49
7
+ data.tar.gz: 3d28ef9ad8d03ba09921d9cacd07c1375d010478200d816ed3422545b10577148085cfa6c6d0d9d8fadaa1a88d6dd447ded49a89b4aaabf92f830f96bc28def6
@@ -5,6 +5,7 @@ module Decidim
5
5
  skip_authorization_check only: :show
6
6
  skip_before_action :verify_authenticity_token
7
7
  after_action :allow_iframe, only: :show
8
+ helper ResourceHelper
8
9
 
9
10
  layout "decidim/widget"
10
11
 
@@ -83,8 +83,10 @@ module Decidim
83
83
  locales.each_with_index.inject("".html_safe) do |string, (locale, index)|
84
84
  string + content_tag(:li, class: tab_element_class_for("title", index)) do
85
85
  title = I18n.with_locale(locale) { I18n.t("name", scope: "locale") }
86
+ element_class = nil
87
+ element_class = "is-tab-error" if form_field_has_error?(options[:object], name_with_locale(name, locale))
86
88
  tab_content_id = "#{tabs_id}-#{name}-panel-#{index}"
87
- content_tag(:a, title, href: "##{tab_content_id}")
89
+ content_tag(:a, title, href: "##{tab_content_id}", class: element_class)
88
90
  end
89
91
  end
90
92
  end
@@ -116,5 +118,9 @@ module Decidim
116
118
  def name_with_locale(name, locale)
117
119
  "#{name}_#{locale.to_s.gsub("-", "__")}"
118
120
  end
121
+
122
+ def form_field_has_error?(object, attribute)
123
+ object.respond_to?(:errors) && object.errors[attribute].present?
124
+ end
119
125
  end
120
126
  end
@@ -7,6 +7,8 @@ module Decidim
7
7
  @resource = resource
8
8
  end
9
9
 
10
+ attr_reader :resource
11
+
10
12
  # Builds the path to the resource. Useful when linking to a resource from
11
13
  # another engine.
12
14
  #
@@ -24,7 +26,7 @@ module Decidim
24
26
  #
25
27
  # Returns a String.
26
28
  def url(options = {})
27
- member_route("url", options.merge(host: @resource.organization.host))
29
+ member_route("url", options.merge(host: resource.organization.host))
28
30
  end
29
31
 
30
32
  # Builds the index path to the associated collection of resources.
@@ -42,7 +44,7 @@ module Decidim
42
44
  #
43
45
  # Returns a String.
44
46
  def member_route(route_type, options)
45
- route_proxy.send("#{member_route_name}_#{route_type}", @resource, options)
47
+ route_proxy.send("#{member_route_name}_#{route_type}", resource, options)
46
48
  end
47
49
 
48
50
  # Private: Build the route to the associated collection of resources.
@@ -53,11 +55,12 @@ module Decidim
53
55
  end
54
56
 
55
57
  def manifest
56
- @resource.class.resource_manifest
58
+ resource.class.try(:resource_manifest) ||
59
+ resource.class.try(:participatory_space_manifest)
57
60
  end
58
61
 
59
62
  def feature
60
- @resource.feature
63
+ resource.feature if resource.respond_to?(:feature)
61
64
  end
62
65
 
63
66
  def member_route_name
@@ -69,7 +72,7 @@ module Decidim
69
72
  end
70
73
 
71
74
  def route_proxy
72
- @route_proxy ||= EngineRouter.main_proxy(feature)
75
+ @route_proxy ||= EngineRouter.main_proxy(feature || resource)
73
76
  end
74
77
  end
75
78
  end
@@ -39,7 +39,11 @@ module Decidim
39
39
  # `"global"` as parameter, and in the method we do the needed changes to search
40
40
  # properly.
41
41
  def search_scope_id
42
- clean_scope_ids = [scope_id].flatten
42
+ clean_scope_ids = if scope_id.is_a?(Hash)
43
+ scope_id.values
44
+ else
45
+ [scope_id].flatten
46
+ end
43
47
 
44
48
  conditions = []
45
49
  conditions << "decidim_scope_id IS NULL" if clean_scope_ids.delete("global")
@@ -13,7 +13,7 @@
13
13
  <%= content_for(:header) %>
14
14
  <% else %>
15
15
  <div class="participatory-process">
16
- <%= link_to translated_attribute(current_participatory_space.title), polymorphic_path(current_participatory_space), target: "_blank" %>
16
+ <%= link_to translated_attribute(current_participatory_space.title), resource_locator(current_participatory_space).path, target: "_blank" %>
17
17
  </div>
18
18
  <% end %>
19
19
  <div class="row collapse">
@@ -3,7 +3,7 @@
3
3
  # This holds Decidim's version and the Rails version on which it depends.
4
4
  module Decidim
5
5
  def self.version
6
- "0.6.4"
6
+ "0.6.5"
7
7
  end
8
8
 
9
9
  def self.rails_version
@@ -142,6 +142,7 @@ module Decidim
142
142
  def scopes_select(name, options = {})
143
143
  selected = object.send(name)
144
144
  if selected.present?
145
+ selected = selected.values if selected.is_a?(Hash)
145
146
  selected = [selected] unless selected.is_a?(Array)
146
147
  scopes = Decidim::Scope.where(id: selected.map(&:to_i)).map { |scope| [scope.name[I18n.locale.to_s], scope.id] }
147
148
  else
@@ -17,6 +17,13 @@ module Decidim
17
17
 
18
18
  attribute :name, Symbol
19
19
 
20
+ # The ActiveRecord class name of the model we're exposing
21
+ attribute :model_class_name, String
22
+
23
+ # The name of the named Rails route to create the url to the resource.
24
+ # When not explicitly set, it will use the model name.
25
+ attribute :route_name, String
26
+
20
27
  # A String with the feature's icon. The icon must be stored in the
21
28
  # engine's assets path.
22
29
  attribute :icon, String
@@ -36,5 +43,12 @@ module Decidim
36
43
  def seed!
37
44
  @seeds&.call
38
45
  end
46
+
47
+ # The name of the named Rails route to create the url to the resource.
48
+ #
49
+ # Returns a String.
50
+ def route_name
51
+ super || model_class_name.demodulize.underscore
52
+ end
39
53
  end
40
54
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josep Jaume Rey Peroy
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-09-21 00:00:00.000000000 Z
13
+ date: 2017-09-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -466,84 +466,84 @@ dependencies:
466
466
  requirements:
467
467
  - - '='
468
468
  - !ruby/object:Gem::Version
469
- version: 0.6.4
469
+ version: 0.6.5
470
470
  type: :runtime
471
471
  prerelease: false
472
472
  version_requirements: !ruby/object:Gem::Requirement
473
473
  requirements:
474
474
  - - '='
475
475
  - !ruby/object:Gem::Version
476
- version: 0.6.4
476
+ version: 0.6.5
477
477
  - !ruby/object:Gem::Dependency
478
478
  name: decidim-dev
479
479
  requirement: !ruby/object:Gem::Requirement
480
480
  requirements:
481
481
  - - '='
482
482
  - !ruby/object:Gem::Version
483
- version: 0.6.4
483
+ version: 0.6.5
484
484
  type: :development
485
485
  prerelease: false
486
486
  version_requirements: !ruby/object:Gem::Requirement
487
487
  requirements:
488
488
  - - '='
489
489
  - !ruby/object:Gem::Version
490
- version: 0.6.4
490
+ version: 0.6.5
491
491
  - !ruby/object:Gem::Dependency
492
492
  name: decidim-participatory_processes
493
493
  requirement: !ruby/object:Gem::Requirement
494
494
  requirements:
495
495
  - - '='
496
496
  - !ruby/object:Gem::Version
497
- version: 0.6.4
497
+ version: 0.6.5
498
498
  type: :development
499
499
  prerelease: false
500
500
  version_requirements: !ruby/object:Gem::Requirement
501
501
  requirements:
502
502
  - - '='
503
503
  - !ruby/object:Gem::Version
504
- version: 0.6.4
504
+ version: 0.6.5
505
505
  - !ruby/object:Gem::Dependency
506
506
  name: decidim-proposals
507
507
  requirement: !ruby/object:Gem::Requirement
508
508
  requirements:
509
509
  - - '='
510
510
  - !ruby/object:Gem::Version
511
- version: 0.6.4
511
+ version: 0.6.5
512
512
  type: :development
513
513
  prerelease: false
514
514
  version_requirements: !ruby/object:Gem::Requirement
515
515
  requirements:
516
516
  - - '='
517
517
  - !ruby/object:Gem::Version
518
- version: 0.6.4
518
+ version: 0.6.5
519
519
  - !ruby/object:Gem::Dependency
520
520
  name: decidim-meetings
521
521
  requirement: !ruby/object:Gem::Requirement
522
522
  requirements:
523
523
  - - '='
524
524
  - !ruby/object:Gem::Version
525
- version: 0.6.4
525
+ version: 0.6.5
526
526
  type: :development
527
527
  prerelease: false
528
528
  version_requirements: !ruby/object:Gem::Requirement
529
529
  requirements:
530
530
  - - '='
531
531
  - !ruby/object:Gem::Version
532
- version: 0.6.4
532
+ version: 0.6.5
533
533
  - !ruby/object:Gem::Dependency
534
534
  name: decidim-results
535
535
  requirement: !ruby/object:Gem::Requirement
536
536
  requirements:
537
537
  - - '='
538
538
  - !ruby/object:Gem::Version
539
- version: 0.6.4
539
+ version: 0.6.5
540
540
  type: :development
541
541
  prerelease: false
542
542
  version_requirements: !ruby/object:Gem::Requirement
543
543
  requirements:
544
544
  - - '='
545
545
  - !ruby/object:Gem::Version
546
- version: 0.6.4
546
+ version: 0.6.5
547
547
  description: Adds core features so other engines can hook into the framework.
548
548
  email:
549
549
  - josepjaume@gmail.com