decidim-core 0.15.0 → 0.15.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd907f208b0e6119def3e21d5aec1deae3572ba56a42a3b45eabd0388b67e023
4
- data.tar.gz: 2dba6d175f38c3b27ae0d844f43138fd6d31e4cb7b70eb21529c0acc5e84ed21
3
+ metadata.gz: 1c3e8587323b6952275094169097efc2f7824cf8691719a12d6ac8582794a12f
4
+ data.tar.gz: 5fe501e6457f7293a0fa84a5121068cae1c98dc7c2ba0165afb8710139232ab8
5
5
  SHA512:
6
- metadata.gz: cf9fa7d9de2f139b2a4dbdd88d1089dc7628210f19339424188d9c70f265a2993b883bcfa2731af706732cb04fe22c2948230d083419c23215c0bf1e40148d91
7
- data.tar.gz: 8f9185e4d5e70e7894a7b497ab15d974fa49f88656060b2ba62d588a4e0f4ef891647a091df3e37d3df3521573fce100f8d302a4cf7cc380d0f5c73de0cbffeb
6
+ metadata.gz: 0cf2cecb09703b533b9b4bc7feef749d769a6f9ac7230ee571962e06ed12ed0afec708dcb9ce3735bf9f9f63b56e13279eab9a52e47eef0f15d1676f95614ab4
7
+ data.tar.gz: 69ec5b7d9e60f9d04faa71da3211708cb41748ec6e5c41062198824fdacf2dfd15dda176ee7d1fe4ec364237056c45c34c2d354834d2c965040921ae2f14256c
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class MoveOrganizationFieldsToHeroContentBlock < ActiveRecord::Migration[5.2]
4
- class Organization < ApplicationRecord
4
+ class ::Decidim::Organization < ApplicationRecord
5
5
  self.table_name = :decidim_organizations
6
6
 
7
7
  mount_uploader :homepage_image, ::Decidim::HomepageImageUploader
@@ -9,7 +9,7 @@ class MoveOrganizationFieldsToHeroContentBlock < ActiveRecord::Migration[5.2]
9
9
 
10
10
  def change
11
11
  Decidim::ContentBlock.reset_column_information
12
- Organization.find_each do |organization|
12
+ Decidim::Organization.find_each do |organization|
13
13
  content_block = Decidim::ContentBlock.find_by(organization: organization, scope: :homepage, manifest_name: :hero)
14
14
  settings = {}
15
15
  welcome_text = organization.welcome_text || {}
@@ -29,6 +29,16 @@ module Decidim
29
29
  end
30
30
 
31
31
  def render_without_link
32
+ if content.is_a?(Hash)
33
+ content.each_with_object({}) do |(locale, string), parsed_content|
34
+ parsed_content[locale] = replace_hashtag_gid_with_hashtag_name(string)
35
+ end
36
+ else
37
+ replace_hashtag_gid_with_hashtag_name(content)
38
+ end
39
+ end
40
+
41
+ def replace_hashtag_gid_with_hashtag_name(content)
32
42
  content.gsub(GLOBAL_ID_REGEX) do |hashtag_gid|
33
43
  begin
34
44
  hashtag = GlobalID::Locator.locate(hashtag_gid)
@@ -4,7 +4,7 @@ module Decidim
4
4
  # This holds the decidim-core version.
5
5
  module Core
6
6
  def self.version
7
- "0.15.0"
7
+ "0.15.1"
8
8
  end
9
9
  end
10
10
  end
@@ -44,7 +44,7 @@ module Decidim
44
44
  )
45
45
  end
46
46
 
47
- tabs_id = options[:tabs_id] || "#{object_name}-#{name}-tabs"
47
+ tabs_id = sanitize_tabs_selector(options[:tabs_id] || "#{object_name}-#{name}-tabs")
48
48
 
49
49
  label_tabs = content_tag(:div, class: "label--tabs") do
50
50
  field_label = label_i18n(name, options[:label] || label_for(name))
@@ -57,7 +57,7 @@ module Decidim
57
57
  title = I18n.with_locale(locale) { I18n.t("name", scope: "locale") }
58
58
  element_class = nil
59
59
  element_class = "is-tab-error" if error?(name_with_locale(name, locale))
60
- tab_content_id = "#{tabs_id}-#{name}-panel-#{index}"
60
+ tab_content_id = sanitize_tabs_selector "#{tabs_id}-#{name}-panel-#{index}"
61
61
  content_tag(:a, title, href: "##{tab_content_id}", class: element_class)
62
62
  end
63
63
  end
@@ -72,9 +72,7 @@ module Decidim
72
72
  tab_content_id = "#{tabs_id}-#{name}-panel-#{index}"
73
73
  string + content_tag(:div, class: tab_element_class_for("panel", index), id: tab_content_id) do
74
74
  if options[:hashtaggable]
75
- content_tag(:div, class: "hashtags__container") do
76
- send(type, name_with_locale(name, locale), options.merge(label: false))
77
- end
75
+ hashtaggable_text_field(type, name, locale, options)
78
76
  else
79
77
  send(type, name_with_locale(name, locale), options.merge(label: false))
80
78
  end
@@ -85,6 +83,23 @@ module Decidim
85
83
  safe_join [label_tabs, tabs_content]
86
84
  end
87
85
 
86
+ # Public: Generates a field for hashtaggable type.
87
+ # type - The form field's type, like `text_area` or `text_input`
88
+ # name - The name of the field
89
+ # handlers - The social handlers to be created
90
+ # options - The set of options to send to the field
91
+ #
92
+ # Renders form fields for each locale.
93
+ def hashtaggable_text_field(type, name, locale, options = {})
94
+ content_tag(:div, class: "hashtags__container") do
95
+ if options[:value]
96
+ send(type, name_with_locale(name, locale), options.merge(label: false, value: options[:value][locale]))
97
+ else
98
+ send(type, name_with_locale(name, locale), options.merge(label: false))
99
+ end
100
+ end
101
+ end
102
+
88
103
  # Public: Generates an form field for each social.
89
104
  #
90
105
  # type - The form field's type, like `text_area` or `text_input`
@@ -94,7 +109,7 @@ module Decidim
94
109
  #
95
110
  # Renders form fields for each locale.
96
111
  def social_field(type, name, handlers, options = {})
97
- tabs_id = options[:tabs_id] || "#{object_name}-#{name}-tabs"
112
+ tabs_id = sanitize_tabs_selector(options[:tabs_id] || "#{object_name}-#{name}-tabs")
98
113
 
99
114
  label_tabs = content_tag(:div, class: "label--tabs") do
100
115
  field_label = label_i18n(name, options[:label] || label_for(name))
@@ -105,7 +120,7 @@ module Decidim
105
120
  handlers.each_with_index.inject("".html_safe) do |string, (handler, index)|
106
121
  string + content_tag(:li, class: tab_element_class_for("title", index)) do
107
122
  title = I18n.t(".#{handler}", scope: "activemodel.attributes.#{object_name}")
108
- tab_content_id = "#{tabs_id}-#{name}-panel-#{index}"
123
+ tab_content_id = sanitize_tabs_selector "#{tabs_id}-#{name}-panel-#{index}"
109
124
  content_tag(:a, title, href: "##{tab_content_id}")
110
125
  end
111
126
  end
@@ -117,7 +132,7 @@ module Decidim
117
132
 
118
133
  tabs_content = content_tag(:div, class: "tabs-content", data: { tabs_content: tabs_id }) do
119
134
  handlers.each_with_index.inject("".html_safe) do |string, (handler, index)|
120
- tab_content_id = "#{tabs_id}-#{name}-panel-#{index}"
135
+ tab_content_id = sanitize_tabs_selector "#{tabs_id}-#{name}-panel-#{index}"
121
136
  string + content_tag(:div, class: tab_element_class_for("panel", index), id: tab_content_id) do
122
137
  send(type, "#{handler}_handler", options.merge(label: false))
123
138
  end
@@ -606,5 +621,9 @@ module Decidim
606
621
  def ruby_format_to_datepicker(ruby_date_format)
607
622
  ruby_date_format.gsub("%d", "dd").gsub("%m", "mm").gsub("%Y", "yyyy").gsub("%H", "hh").gsub("%M", "ii")
608
623
  end
624
+
625
+ def sanitize_tabs_selector(id)
626
+ id.tr("[", "-").tr("]", "-")
627
+ end
609
628
  end
610
629
  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.15.0
4
+ version: 0.15.1
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: 2018-11-12 00:00:00.000000000 Z
13
+ date: 2018-11-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: active_link_to
@@ -456,6 +456,20 @@ dependencies:
456
456
  - - "~>"
457
457
  - !ruby/object:Gem::Version
458
458
  version: '1.9'
459
+ - !ruby/object:Gem::Dependency
460
+ name: rack
461
+ requirement: !ruby/object:Gem::Requirement
462
+ requirements:
463
+ - - ">="
464
+ - !ruby/object:Gem::Version
465
+ version: 2.0.6
466
+ type: :runtime
467
+ prerelease: false
468
+ version_requirements: !ruby/object:Gem::Requirement
469
+ requirements:
470
+ - - ">="
471
+ - !ruby/object:Gem::Version
472
+ version: 2.0.6
459
473
  - !ruby/object:Gem::Dependency
460
474
  name: rack-attack
461
475
  requirement: !ruby/object:Gem::Requirement
@@ -676,28 +690,28 @@ dependencies:
676
690
  requirements:
677
691
  - - '='
678
692
  - !ruby/object:Gem::Version
679
- version: 0.15.0
693
+ version: 0.15.1
680
694
  type: :runtime
681
695
  prerelease: false
682
696
  version_requirements: !ruby/object:Gem::Requirement
683
697
  requirements:
684
698
  - - '='
685
699
  - !ruby/object:Gem::Version
686
- version: 0.15.0
700
+ version: 0.15.1
687
701
  - !ruby/object:Gem::Dependency
688
702
  name: decidim-dev
689
703
  requirement: !ruby/object:Gem::Requirement
690
704
  requirements:
691
705
  - - '='
692
706
  - !ruby/object:Gem::Version
693
- version: 0.15.0
707
+ version: 0.15.1
694
708
  type: :development
695
709
  prerelease: false
696
710
  version_requirements: !ruby/object:Gem::Requirement
697
711
  requirements:
698
712
  - - '='
699
713
  - !ruby/object:Gem::Version
700
- version: 0.15.0
714
+ version: 0.15.1
701
715
  description: Adds core features so other engines can hook into the framework.
702
716
  email:
703
717
  - josepjaume@gmail.com