decidim-pages 0.10.1 → 0.11.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/commands/decidim/pages/copy_page.rb +4 -4
- data/app/commands/decidim/pages/create_page.rb +5 -5
- data/app/commands/decidim/pages/destroy_page.rb +5 -5
- data/app/controllers/decidim/pages/admin/application_controller.rb +1 -1
- data/app/controllers/decidim/pages/admin/pages_controller.rb +1 -1
- data/app/controllers/decidim/pages/application_controller.rb +3 -3
- data/app/models/decidim/pages/page.rb +4 -4
- data/app/views/decidim/pages/admin/pages/_form.html.erb +1 -1
- data/app/views/decidim/pages/admin/pages/edit.html.erb +2 -2
- data/app/views/decidim/pages/application/show.html.erb +1 -1
- data/config/locales/ca.yml +1 -1
- data/config/locales/en.yml +1 -1
- data/config/locales/es.yml +1 -1
- data/config/locales/eu.yml +1 -1
- data/config/locales/fi.yml +1 -1
- data/config/locales/fr.yml +1 -1
- data/config/locales/gl.yml +1 -1
- data/config/locales/it.yml +1 -1
- data/config/locales/nl.yml +1 -1
- data/config/locales/pl.yml +1 -1
- data/config/locales/pt-BR.yml +1 -1
- data/config/locales/pt.yml +1 -1
- data/config/locales/ru.yml +1 -1
- data/config/locales/sv.yml +1 -1
- data/config/locales/uk.yml +1 -1
- data/db/migrate/20180305133658_rename_features_to_components_at_pages.rb +11 -0
- data/lib/decidim/pages.rb +1 -1
- data/lib/decidim/pages/{feature.rb → component.rb} +17 -17
- data/lib/decidim/pages/version.rb +1 -1
- metadata +12 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68b528a51e27c9477871e1672455bc17fd13858b780047e4b6f32e2f4249f5f6
|
4
|
+
data.tar.gz: c16bd8b714f0dc34531942f06ab3d09cf29d8f31156672802e7c3dfc780c6045
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3f58344649804c0d1f99bd99a0354787065d97003205920f6032712fa76efd979d5d71e28f9f7ed0dd6e2843f2e60d850825dc6d36270a88c139a5685d2a816
|
7
|
+
data.tar.gz: fca5a38905d2ceea8917d38083520f8096be0ccf424624f08f068a2ede42c4de87f944dc0ca35d87b2d1b83b35b08c4d1ead7967d15389c406ad30e77898d525
|
data/README.md
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
module Decidim
|
4
4
|
module Pages
|
5
|
-
# Command that gets called whenever a
|
6
|
-
# It's need a context with the old
|
5
|
+
# Command that gets called whenever a component's page has to be duplicated.
|
6
|
+
# It's need a context with the old component that
|
7
7
|
# is going to be duplicated on the new one
|
8
8
|
class CopyPage < Rectify::Command
|
9
9
|
def initialize(context)
|
@@ -12,9 +12,9 @@ module Decidim
|
|
12
12
|
|
13
13
|
def call
|
14
14
|
Decidim::Pages::Page.transaction do
|
15
|
-
pages = Decidim::Pages::Page.where(
|
15
|
+
pages = Decidim::Pages::Page.where(component: @context[:old_component])
|
16
16
|
pages.each do |page|
|
17
|
-
Decidim::Pages::Page.create!(
|
17
|
+
Decidim::Pages::Page.create!(component: @context[:new_component], body: page.body)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
broadcast(:ok)
|
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
module Decidim
|
4
4
|
module Pages
|
5
|
-
# Command that gets called whenever a
|
6
|
-
# usually happens as a callback when the
|
5
|
+
# Command that gets called whenever a component's page has to be created. It
|
6
|
+
# usually happens as a callback when the component itself is created.
|
7
7
|
class CreatePage < Rectify::Command
|
8
|
-
def initialize(
|
9
|
-
@
|
8
|
+
def initialize(component)
|
9
|
+
@component = component
|
10
10
|
end
|
11
11
|
|
12
12
|
def call
|
13
|
-
@page = Page.new(
|
13
|
+
@page = Page.new(component: @component)
|
14
14
|
|
15
15
|
@page.save ? broadcast(:ok) : broadcast(:invalid)
|
16
16
|
end
|
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
module Decidim
|
4
4
|
module Pages
|
5
|
-
# Command that gets called when the page of this
|
6
|
-
# destroyed. It usually happens as a callback when the
|
5
|
+
# Command that gets called when the page of this component needs to be
|
6
|
+
# destroyed. It usually happens as a callback when the component is removed.
|
7
7
|
class DestroyPage < Rectify::Command
|
8
|
-
def initialize(
|
9
|
-
@
|
8
|
+
def initialize(component)
|
9
|
+
@component = component
|
10
10
|
end
|
11
11
|
|
12
12
|
def call
|
13
|
-
Page.where(
|
13
|
+
Page.where(component: @component).destroy_all
|
14
14
|
broadcast(:ok)
|
15
15
|
end
|
16
16
|
end
|
@@ -6,7 +6,7 @@ module Decidim
|
|
6
6
|
# Base controller for the administration of this module. It inherits from
|
7
7
|
# Decidim's admin base controller in order to inherit the layout and other
|
8
8
|
# convenience methods relevant to a this component.
|
9
|
-
class ApplicationController < Decidim::Admin::
|
9
|
+
class ApplicationController < Decidim::Admin::Components::BaseController
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -5,11 +5,11 @@ module Decidim
|
|
5
5
|
# This controller is the abstract class from which all other controllers of
|
6
6
|
# this engine inherit.
|
7
7
|
#
|
8
|
-
# Note that it inherits from `Decidim::
|
8
|
+
# Note that it inherits from `Decidim::Components::Basecontroller`, which
|
9
9
|
# override its layout and provide all kinds of useful methods.
|
10
|
-
class ApplicationController < Decidim::
|
10
|
+
class ApplicationController < Decidim::Components::BaseController
|
11
11
|
def show
|
12
|
-
@page = Page.find_by(
|
12
|
+
@page = Page.find_by(component: current_component)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -6,19 +6,19 @@ module Decidim
|
|
6
6
|
# title, description and any other useful information to render a custom page.
|
7
7
|
class Page < Pages::ApplicationRecord
|
8
8
|
include Decidim::Resourceable
|
9
|
-
include Decidim::
|
9
|
+
include Decidim::HasComponent
|
10
10
|
include Decidim::Traceable
|
11
11
|
include Decidim::Loggable
|
12
12
|
|
13
|
-
|
13
|
+
component_manifest_name "pages"
|
14
14
|
|
15
15
|
def self.log_presenter_class_for(_log)
|
16
16
|
Decidim::Pages::AdminLog::PagePresenter
|
17
17
|
end
|
18
18
|
|
19
|
-
# Public: Pages doesn't have title so we assign the
|
19
|
+
# Public: Pages doesn't have title so we assign the component one to it.
|
20
20
|
def title
|
21
|
-
|
21
|
+
component.name
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -4,7 +4,7 @@
|
|
4
4
|
</div>
|
5
5
|
<div class="card-section">
|
6
6
|
<div class="row column">
|
7
|
-
<%= form.translated :editor, :body, toolbar: :full, lines: 30, label: t("models.components.body", scope: "decidim.pages.admin")
|
7
|
+
<%= form.translated :editor, :body, toolbar: :full, lines: 30, label: t("models.components.body", scope: "decidim.pages.admin") %>
|
8
8
|
</div>
|
9
9
|
</div>
|
10
10
|
</div>
|
@@ -1,5 +1,5 @@
|
|
1
|
-
<%=
|
2
|
-
<%= render partial:
|
1
|
+
<%= decidim_form_for(@form, url: page_path, method: :post, html: { class: "form edit_page" }) do |form| %>
|
2
|
+
<%= render partial: "form", object: form, locals: { title: t(".title") } %>
|
3
3
|
|
4
4
|
<div class="button--double form-general-submit">
|
5
5
|
<%= form.submit t(".save") %>
|
data/config/locales/ca.yml
CHANGED
data/config/locales/en.yml
CHANGED
data/config/locales/es.yml
CHANGED
data/config/locales/eu.yml
CHANGED
data/config/locales/fi.yml
CHANGED
data/config/locales/fr.yml
CHANGED
data/config/locales/gl.yml
CHANGED
data/config/locales/it.yml
CHANGED
data/config/locales/nl.yml
CHANGED
data/config/locales/pl.yml
CHANGED
data/config/locales/pt-BR.yml
CHANGED
data/config/locales/pt.yml
CHANGED
data/config/locales/ru.yml
CHANGED
data/config/locales/sv.yml
CHANGED
data/config/locales/uk.yml
CHANGED
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class RenameFeaturesToComponentsAtPages < ActiveRecord::Migration[5.1]
|
4
|
+
def change
|
5
|
+
rename_column :decidim_pages_pages, :decidim_feature_id, :decidim_component_id
|
6
|
+
|
7
|
+
if index_name_exists?(:decidim_pages_pages, "index_decidim_pages_pages_on_decidim_feature_id")
|
8
|
+
rename_index :decidim_pages_pages, "index_decidim_pages_pages_on_decidim_feature_id", "index_decidim_pages_pages_on_decidim_component_id"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
data/lib/decidim/pages.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require "decidim/pages/admin"
|
4
4
|
require "decidim/pages/engine"
|
5
5
|
require "decidim/pages/admin_engine"
|
6
|
-
require "decidim/pages/
|
6
|
+
require "decidim/pages/component"
|
7
7
|
|
8
8
|
module Decidim
|
9
9
|
# This namespace holds the logic of the `Pages` component. This component
|
@@ -1,59 +1,59 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "decidim/
|
3
|
+
require "decidim/components/namer"
|
4
4
|
|
5
|
-
Decidim.
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
Decidim.register_component(:pages) do |component|
|
6
|
+
component.engine = Decidim::Pages::Engine
|
7
|
+
component.admin_engine = Decidim::Pages::AdminEngine
|
8
|
+
component.icon = "decidim/pages/icon.svg"
|
9
9
|
|
10
|
-
|
10
|
+
component.on(:create) do |instance|
|
11
11
|
Decidim::Pages::CreatePage.call(instance) do
|
12
12
|
on(:invalid) { raise "Can't create page" }
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
|
16
|
+
component.on(:destroy) do |instance|
|
17
17
|
Decidim::Pages::DestroyPage.call(instance) do
|
18
18
|
on(:error) { raise "Can't destroy page" }
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
|
22
|
+
component.on(:copy) do |context|
|
23
23
|
Decidim::Pages::CopyPage.call(context) do
|
24
24
|
on(:invalid) { raise "Can't duplicate page" }
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
pages = Decidim::Pages::Page.where(
|
28
|
+
component.register_stat :pages_count do |components, start_at, end_at|
|
29
|
+
pages = Decidim::Pages::Page.where(component: components)
|
30
30
|
pages = pages.where("created_at >= ?", start_at) if start_at.present?
|
31
31
|
pages = pages.where("created_at <= ?", end_at) if end_at.present?
|
32
32
|
pages.count
|
33
33
|
end
|
34
34
|
|
35
|
-
|
35
|
+
component.settings(:global) do |settings|
|
36
36
|
settings.attribute :announcement, type: :text, translated: true, editor: true
|
37
37
|
end
|
38
38
|
|
39
|
-
|
39
|
+
component.settings(:step) do |settings|
|
40
40
|
settings.attribute :announcement, type: :text, translated: true, editor: true
|
41
41
|
end
|
42
42
|
|
43
|
-
|
43
|
+
component.register_resource do |resource|
|
44
44
|
resource.model_class_name = "Decidim::Pages::Page"
|
45
45
|
end
|
46
46
|
|
47
|
-
|
48
|
-
|
49
|
-
name: Decidim::
|
47
|
+
component.seeds do |participatory_space|
|
48
|
+
component = Decidim::Component.create!(
|
49
|
+
name: Decidim::Components::Namer.new(participatory_space.organization.available_locales, :pages).i18n_name,
|
50
50
|
manifest_name: :pages,
|
51
51
|
published_at: Time.current,
|
52
52
|
participatory_space: participatory_space
|
53
53
|
)
|
54
54
|
|
55
55
|
Decidim::Pages::Page.create!(
|
56
|
-
|
56
|
+
component: component,
|
57
57
|
body: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
|
58
58
|
Decidim::Faker::Localized.paragraph(3)
|
59
59
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decidim-pages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0.pre1
|
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-04-
|
13
|
+
date: 2018-04-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: decidim-core
|
@@ -18,42 +18,42 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.
|
21
|
+
version: 0.11.0.pre1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - '='
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: 0.
|
28
|
+
version: 0.11.0.pre1
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: decidim-dev
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
33
|
- - '='
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: 0.
|
35
|
+
version: 0.11.0.pre1
|
36
36
|
type: :development
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - '='
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 0.
|
42
|
+
version: 0.11.0.pre1
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: decidim-participatory_processes
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
47
|
- - '='
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 0.
|
49
|
+
version: 0.11.0.pre1
|
50
50
|
type: :development
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
54
|
- - '='
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: 0.
|
56
|
+
version: 0.11.0.pre1
|
57
57
|
description: A pages component for decidim's participatory processes.
|
58
58
|
email:
|
59
59
|
- josepjaume@gmail.com
|
@@ -100,11 +100,12 @@ files:
|
|
100
100
|
- db/migrate/20161214150429_add_commentable_to_pages.rb
|
101
101
|
- db/migrate/20170110145040_remove_commentable_flag_from_pages.rb
|
102
102
|
- db/migrate/20170220091402_remove_page_feature_titles.rb
|
103
|
+
- db/migrate/20180305133658_rename_features_to_components_at_pages.rb
|
103
104
|
- lib/decidim/pages.rb
|
104
105
|
- lib/decidim/pages/admin.rb
|
105
106
|
- lib/decidim/pages/admin_engine.rb
|
107
|
+
- lib/decidim/pages/component.rb
|
106
108
|
- lib/decidim/pages/engine.rb
|
107
|
-
- lib/decidim/pages/feature.rb
|
108
109
|
- lib/decidim/pages/version.rb
|
109
110
|
homepage: https://github.com/decidim/decidim
|
110
111
|
licenses:
|
@@ -121,9 +122,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
121
122
|
version: '2.3'
|
122
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
124
|
requirements:
|
124
|
-
- - "
|
125
|
+
- - ">"
|
125
126
|
- !ruby/object:Gem::Version
|
126
|
-
version:
|
127
|
+
version: 1.3.1
|
127
128
|
requirements: []
|
128
129
|
rubyforge_project:
|
129
130
|
rubygems_version: 2.7.3
|