decidim-core 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 +5 -11
- data/app/assets/images/decidim/icons.svg +25 -6
- data/app/assets/javascripts/decidim/account_form.js.es6 +8 -8
- data/app/assets/javascripts/decidim/append_elements.js.es6 +1 -1
- data/app/assets/javascripts/decidim/append_redirect_url_to_modals.js.es6 +5 -5
- data/app/assets/javascripts/decidim/data_picker.js.es6 +10 -10
- data/app/assets/javascripts/decidim/editor.js.es6 +37 -22
- data/app/assets/javascripts/decidim/filters.js.es6 +1 -1
- data/app/assets/javascripts/decidim/form_filter.component.js.es6 +15 -15
- data/app/assets/javascripts/decidim/form_filter.component.test.js +29 -29
- data/app/assets/javascripts/decidim/impersonation.js.es6 +3 -3
- data/app/assets/javascripts/decidim/input_mentions.js.es6 +100 -0
- data/app/assets/javascripts/decidim/input_tags.js.es6 +12 -0
- data/app/assets/javascripts/decidim/{map.js.es6.erb → map.js.es6} +9 -9
- data/app/assets/javascripts/decidim/notifications.js.es6 +10 -10
- data/app/assets/javascripts/decidim/orders.js.es6 +5 -5
- data/app/assets/javascripts/decidim/user_registrations.js.es6 +4 -4
- data/app/assets/javascripts/decidim/widget.js.es6 +1 -1
- data/app/assets/javascripts/decidim.js.es6 +10 -0
- data/app/assets/stylesheets/decidim/application.scss.erb +1 -1
- data/app/assets/stylesheets/decidim/modules/_author-avatar.scss +39 -0
- data/app/assets/stylesheets/decidim/modules/_cards.scss +158 -3
- data/app/assets/stylesheets/decidim/modules/_definition-data.scss +6 -0
- data/app/assets/stylesheets/decidim/modules/_extra.scss +1 -3
- data/app/assets/stylesheets/decidim/modules/_icons.scss +14 -6
- data/app/assets/stylesheets/decidim/modules/_inline-filters.scss +61 -0
- data/app/assets/stylesheets/decidim/modules/_input-mentions.scss +124 -0
- data/app/assets/stylesheets/decidim/modules/_input-tags.scss +55 -0
- data/app/assets/stylesheets/decidim/modules/_modules.scss +3 -0
- data/app/assets/stylesheets/decidim/modules/_status-labels.scss +4 -0
- data/app/assets/stylesheets/decidim/modules/_typography.scss +16 -0
- data/app/assets/stylesheets/decidim/utils/_helpers.scss +29 -0
- data/app/assets/stylesheets/decidim/utils/_mixins.scss +6 -0
- data/app/cells/decidim/author_box/show.erb +10 -0
- data/app/cells/decidim/author_box_cell.rb +21 -0
- data/app/cells/decidim/card/show.erb +17 -0
- data/app/cells/decidim/card_cell.rb +29 -0
- data/app/cells/decidim/profile/profile_inline.erb +21 -0
- data/app/cells/decidim/profile/show.erb +13 -0
- data/app/cells/decidim/profile_cell.rb +17 -0
- data/app/commands/decidim/create_omniauth_registration.rb +3 -2
- data/app/commands/decidim/create_report.rb +1 -1
- data/app/commands/decidim/invite_user.rb +2 -0
- data/app/constraints/decidim/current_component.rb +41 -0
- data/app/controllers/concerns/decidim/action_authorization.rb +3 -3
- data/app/controllers/concerns/decidim/devise_controllers.rb +2 -1
- data/app/controllers/concerns/decidim/filter_resource.rb +1 -1
- data/app/controllers/concerns/decidim/form_factory.rb +1 -1
- data/app/controllers/concerns/decidim/impersonate_users.rb +6 -2
- data/app/controllers/concerns/decidim/needs_authorization.rb +2 -2
- data/app/controllers/concerns/decidim/participatory_space_context.rb +15 -0
- data/app/controllers/concerns/decidim/settings.rb +5 -5
- data/app/controllers/decidim/application_controller.rb +2 -1
- data/app/controllers/decidim/{features → components}/base_controller.rb +16 -8
- data/app/controllers/decidim/devise/omniauth_registrations_controller.rb +3 -1
- data/app/controllers/decidim/devise/registrations_controller.rb +1 -3
- data/app/controllers/decidim/doorkeeper/authorizations_controller.rb +16 -0
- data/app/controllers/decidim/doorkeeper/credentials_controller.rb +46 -0
- data/app/controllers/decidim/doorkeeper/token_info_controller.rb +9 -0
- data/app/controllers/decidim/doorkeeper/tokens_controller.rb +9 -0
- data/app/controllers/decidim/widgets_controller.rb +1 -1
- data/app/forms/decidim/follow_form.rb +1 -1
- data/app/forms/decidim/form.rb +1 -1
- data/app/forms/decidim/omniauth_registration_form.rb +1 -0
- data/app/forms/decidim/registration_form.rb +5 -5
- data/app/helpers/decidim/card_helper.rb +16 -0
- data/app/helpers/decidim/component_path_helper.rb +36 -0
- data/app/helpers/decidim/icon_helper.rb +7 -7
- data/app/helpers/decidim/messaging/conversation_helper.rb +4 -3
- data/app/helpers/decidim/paginate_helper.rb +1 -1
- data/app/helpers/decidim/resource_helper.rb +2 -2
- data/app/jobs/decidim/export_job.rb +3 -3
- data/app/mailers/decidim/messaging/conversation_mailer.rb +0 -2
- data/app/middleware/decidim/current_organization.rb +2 -2
- data/app/models/decidim/abilities/admin_ability.rb +1 -1
- data/app/models/decidim/abilities/everyone_ability.rb +1 -1
- data/app/models/decidim/abilities/participatory_process_admin_ability.rb +2 -2
- data/app/models/decidim/abilities/participatory_process_collaborator_ability.rb +2 -2
- data/app/models/decidim/action_log.rb +7 -5
- data/app/models/decidim/area.rb +7 -0
- data/app/models/decidim/authorization.rb +14 -0
- data/app/models/decidim/{feature.rb → component.rb} +15 -15
- data/app/models/decidim/moderation.rb +1 -1
- data/app/models/decidim/oauth_application.rb +24 -0
- data/app/models/decidim/organization.rb +5 -0
- data/app/models/decidim/participatory_space_link.rb +20 -0
- data/app/models/decidim/participatory_space_private_user.rb +19 -0
- data/app/models/decidim/user.rb +7 -0
- data/app/presenters/decidim/admin_log/area_presenter.rb +38 -0
- data/app/presenters/decidim/admin_log/{feature_presenter.rb → component_presenter.rb} +5 -5
- data/app/presenters/decidim/admin_log/newsletter_resource_presenter.rb +1 -1
- data/app/presenters/decidim/admin_log/oauth_application_presenter.rb +50 -0
- data/app/presenters/decidim/admin_log/oauth_application_resource_presenter.rb +18 -0
- data/app/presenters/decidim/home_stats_presenter.rb +7 -7
- data/app/presenters/decidim/log/value_types/area_presenter.rb +1 -1
- data/app/presenters/decidim/log/value_types/area_type_presenter.rb +28 -0
- data/app/presenters/decidim/log/value_types/currency_presenter.rb +20 -0
- data/app/presenters/decidim/log/value_types/scope_presenter.rb +1 -1
- data/app/presenters/decidim/log/value_types/scope_type_presenter.rb +1 -1
- data/app/presenters/decidim/resource_locator_presenter.rb +3 -3
- data/app/services/decidim/action_authorizer.rb +9 -9
- data/app/services/decidim/action_logger.rb +9 -7
- data/app/services/decidim/email_notification_generator.rb +1 -1
- data/app/services/decidim/notification_generator_for_recipient.rb +1 -1
- data/app/services/decidim/resource_search.rb +8 -8
- data/app/services/decidim/settings_change.rb +5 -5
- data/app/services/decidim/static_map_generator.rb +1 -1
- data/app/types/decidim/core/attachment_type.rb +14 -0
- data/app/types/decidim/core/category_type.rb +16 -0
- data/app/types/decidim/core/coordinates_type.rb +19 -0
- data/app/types/decidim/core/scope_api_type.rb +16 -0
- data/app/uploaders/decidim/oauth_application_logo_uploader.rb +9 -0
- data/app/validators/geocoding_validator.rb +2 -2
- data/app/views/decidim/account/delete.html.erb +7 -7
- data/app/views/decidim/application/_collection.html.erb +1 -1
- data/app/views/decidim/application/_document.html.erb +1 -1
- data/app/views/decidim/application/_photos.html.erb +1 -1
- data/app/views/decidim/devise/invitations/edit.html.erb +1 -1
- data/app/views/decidim/devise/omniauth_registrations/new.html.erb +1 -1
- data/app/views/decidim/devise/registrations/new.html.erb +1 -1
- data/app/views/decidim/devise/sessions/new.html.erb +2 -2
- data/app/views/decidim/devise/shared/_omniauth_buttons.html.erb +1 -1
- data/app/views/decidim/devise/shared/_omniauth_buttons_mini.html.erb +1 -1
- data/app/views/decidim/doorkeeper/authorizations/new.html.erb +58 -0
- data/app/views/decidim/messaging/conversations/_show.html.erb +1 -1
- data/app/views/decidim/messaging/conversations/index.html.erb +1 -1
- data/app/views/decidim/notifications/index.html.erb +1 -1
- data/app/views/decidim/notifications_settings/show.html.erb +2 -2
- data/app/views/decidim/own_user_groups/index.html.erb +3 -3
- data/app/views/decidim/scopes/_scopes_picker_input.html.erb +4 -4
- data/app/views/decidim/scopes/picker.html.erb +3 -3
- data/app/views/decidim/shared/_action_authorization_modal.html.erb +1 -1
- data/app/views/decidim/shared/_author.html.erb +1 -1
- data/app/views/decidim/shared/_author_reference.html.erb +1 -12
- data/app/views/decidim/shared/{_feature_announcement.html.erb → _component_announcement.html.erb} +2 -2
- data/app/views/decidim/shared/_embed_modal.html.erb +1 -1
- data/app/views/decidim/shared/_flag_modal.html.erb +5 -5
- data/app/views/decidim/shared/_login_modal.html.erb +3 -3
- data/app/views/decidim/shared/_private_participatory_space.html.erb +5 -0
- data/app/views/decidim/shared/_share_modal.html.erb +1 -1
- data/app/views/decidim/shared/_tags.html.erb +1 -1
- data/app/views/decidim/shared/_version_author.html.erb +1 -1
- data/app/views/decidim/widgets/_data_picker.html.erb +4 -4
- data/app/views/devise/mailer/confirmation_instructions.html.erb +3 -3
- data/app/views/devise/mailer/invite_private_user.html.erb +17 -0
- data/app/views/devise/mailer/invite_private_user.text.erb +15 -0
- data/app/views/devise/mailer/password_change.html.erb +2 -2
- data/app/views/devise/mailer/reset_password_instructions.html.erb +5 -5
- data/app/views/kaminari/decidim/_first_page.html.erb +2 -3
- data/app/views/kaminari/decidim/_gap.html.erb +2 -3
- data/app/views/kaminari/decidim/_last_page.html.erb +2 -3
- data/app/views/kaminari/decidim/_next_page.html.erb +2 -3
- data/app/views/kaminari/decidim/_page.html.erb +2 -3
- data/app/views/kaminari/decidim/_paginator.html.erb +1 -2
- data/app/views/kaminari/decidim/_prev_page.html.erb +2 -3
- data/app/views/layouts/decidim/_application.html.erb +4 -4
- data/app/views/layouts/decidim/_component_authorization_modals.html.erb +5 -0
- data/app/views/layouts/decidim/_cookie_warning.html.erb +2 -2
- data/app/views/layouts/decidim/_head.html.erb +4 -4
- data/app/views/layouts/decidim/_impersonation_warning.html.erb +4 -4
- data/app/views/layouts/decidim/_language_chooser.html.erb +1 -1
- data/app/views/layouts/decidim/_social_media_links.html.erb +5 -5
- data/app/views/layouts/decidim/_wrapper.html.erb +5 -5
- data/app/views/layouts/decidim/mailer.html.erb +1 -1
- data/app/views/layouts/decidim/widget.html.erb +5 -5
- data/app/views/pages/home/_hero.html.erb +1 -1
- data/app/views/pages/home.html.erb +6 -6
- data/config/locales/ca.yml +66 -27
- data/config/locales/en.yml +69 -30
- data/config/locales/es.yml +66 -27
- data/config/locales/eu.yml +69 -30
- data/config/locales/fi.yml +69 -30
- data/config/locales/fr.yml +85 -46
- data/config/locales/gl.yml +69 -30
- data/config/locales/it.yml +69 -30
- data/config/locales/nl.yml +122 -83
- data/config/locales/pl.yml +69 -30
- data/config/locales/pt-BR.yml +69 -30
- data/config/locales/pt.yml +69 -30
- data/config/locales/ru.yml +0 -7
- data/config/locales/sv.yml +69 -30
- data/config/locales/uk.yml +0 -13
- data/config/routes.rb +8 -0
- data/db/migrate/20180206183235_create_participatory_space_private_users.rb +15 -0
- data/db/migrate/20180221101934_fix_nickname_index.rb +5 -6
- data/db/migrate/20180226140756_add_version_to_action_logs.rb +5 -1
- data/db/migrate/20180227131727_create_participatory_space_links.rb +12 -0
- data/db/migrate/20180305132906_rename_features_to_components.rb +13 -0
- data/db/migrate/20180308113207_doorkeeper_models.rb +85 -0
- data/db/migrate/20180314085339_rename_maximum_votes_per_proposal_to_threshold_per_proposal.rb +2 -2
- data/db/migrate/{20180326075746_change_event_name_and_class_to_rename_to_publish_proposal_event.rb → 20180323102631_change_event_name_and_class_to_rename_to_publish_proposal_event.rb} +0 -0
- data/db/seeds.rb +12 -2
- data/lib/decidim/api/attachable_interface.rb +13 -0
- data/lib/decidim/api/authorable_interface.rb +13 -0
- data/lib/decidim/api/categorizable_interface.rb +13 -0
- data/lib/decidim/api/participatory_space_interface.rb +4 -4
- data/lib/decidim/api/scopable_interface.rb +13 -0
- data/lib/decidim/authorable.rb +8 -0
- data/lib/decidim/{feature_manifest.rb → component_manifest.rb} +24 -21
- data/lib/decidim/{feature_validator.rb → component_validator.rb} +6 -6
- data/lib/decidim/{features → components}/export_manifest.rb +4 -4
- data/lib/decidim/components/namer.rb +35 -0
- data/lib/decidim/components.rb +9 -0
- data/lib/decidim/content_parsers/user_parser.rb +1 -1
- data/lib/decidim/core/api.rb +13 -0
- data/lib/decidim/core/engine.rb +76 -3
- data/lib/decidim/core/test/factories.rb +43 -10
- data/lib/decidim/core/test/shared_examples/announcements_examples.rb +9 -9
- data/lib/decidim/core/test/shared_examples/attachable_interface_examples.rb +16 -0
- data/lib/decidim/core/test/shared_examples/authorable_interface_examples.rb +33 -0
- data/lib/decidim/core/test/shared_examples/categorizable_interface_examples.rb +19 -0
- data/lib/decidim/core/test/shared_examples/comments_examples.rb +3 -3
- data/lib/decidim/core/test/shared_examples/follows_examples.rb +1 -1
- data/lib/decidim/core/test/shared_examples/has_component.rb +21 -0
- data/lib/decidim/core/test/shared_examples/has_reference.rb +2 -2
- data/lib/decidim/core/test/shared_examples/localised_email.rb +1 -1
- data/lib/decidim/core/test/shared_examples/paginated_resource_examples.rb +1 -1
- data/lib/decidim/core/test/shared_examples/reportable.rb +8 -6
- data/lib/decidim/core/test/shared_examples/reports_examples.rb +1 -1
- data/lib/decidim/core/test/shared_examples/scopable_interface_examples.rb +19 -0
- data/lib/decidim/core/test/shared_examples/scope_helper_examples.rb +8 -3
- data/lib/decidim/core/test/shared_examples/simple_event.rb +1 -1
- data/lib/decidim/core/test/shared_examples/user_localised_email_examples.rb +1 -1
- data/lib/decidim/core/test.rb +1 -1
- data/lib/decidim/core/version.rb +1 -1
- data/lib/decidim/core.rb +35 -37
- data/lib/decidim/events/base_event.rb +5 -5
- data/lib/decidim/events/simple_event.rb +8 -8
- data/lib/decidim/form_builder.rb +48 -3
- data/lib/decidim/has_attachment_collections.rb +1 -1
- data/lib/decidim/has_attachments.rb +1 -1
- data/lib/decidim/has_category.rb +2 -2
- data/lib/decidim/has_component.rb +23 -0
- data/lib/decidim/has_private_users.rb +26 -0
- data/lib/decidim/has_reference.rb +3 -3
- data/lib/decidim/page_finder.rb +1 -1
- data/lib/decidim/participatory_space_manifest.rb +3 -3
- data/lib/decidim/participatory_space_resourceable.rb +80 -0
- data/lib/decidim/publicable.rb +2 -2
- data/lib/decidim/query_extensions.rb +2 -2
- data/lib/decidim/rectify_ext.rb +32 -0
- data/lib/decidim/reportable.rb +1 -1
- data/lib/decidim/resource_manifest.rb +13 -13
- data/lib/decidim/resourceable.rb +8 -8
- data/lib/decidim/scopable.rb +1 -1
- data/lib/decidim/{scopable_feature.rb → scopable_component.rb} +1 -1
- data/lib/decidim/settings_manifest.rb +1 -1
- data/lib/decidim/stats_registry.rb +1 -1
- data/lib/decidim/view_model.rb +9 -0
- data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.fr.js +4 -1
- data/vendor/assets/javascripts/form_datepicker.js.es6 +10 -10
- data/vendor/assets/javascripts/quill.min.js +2 -2
- data/vendor/assets/javascripts/quill.min.js.map +1 -1
- data/vendor/assets/javascripts/tagsinput.js +683 -0
- data/vendor/assets/javascripts/tribute.js +1607 -0
- data/vendor/assets/stylesheets/quill.bubble.css +30 -16
- data/vendor/assets/stylesheets/quill.core.css +19 -9
- data/vendor/assets/stylesheets/quill.snow.css +30 -16
- data/vendor/assets/stylesheets/tagsinput.css +55 -0
- data/vendor/assets/stylesheets/tribute.css +27 -0
- metadata +164 -27
- data/app/constraints/decidim/current_feature.rb +0 -41
- data/app/helpers/decidim/feature_path_helper.rb +0 -36
- data/app/views/layouts/decidim/_feature_authorization_modals.html.erb +0 -5
- data/lib/decidim/core/test/shared_examples/has_feature.rb +0 -21
- data/lib/decidim/features/namer.rb +0 -35
- data/lib/decidim/features.rb +0 -9
- data/lib/decidim/has_feature.rb +0 -23
data/lib/decidim/page_finder.rb
CHANGED
@@ -24,7 +24,7 @@ module Decidim
|
|
24
24
|
|
25
25
|
attribute :query_type, String, default: "Decidim::Core::ParticipatorySpaceType"
|
26
26
|
|
27
|
-
# A String with the
|
27
|
+
# A String with the component's icon. The icon must be stored in the
|
28
28
|
# engine's assets path.
|
29
29
|
attribute :icon, String
|
30
30
|
|
@@ -56,14 +56,14 @@ module Decidim
|
|
56
56
|
@contexts.fetch(name)
|
57
57
|
end
|
58
58
|
|
59
|
-
# Public: A block that gets called when seeding for this
|
59
|
+
# Public: A block that gets called when seeding for this component takes place.
|
60
60
|
#
|
61
61
|
# Returns nothing.
|
62
62
|
def seeds(&block)
|
63
63
|
@seeds = block
|
64
64
|
end
|
65
65
|
|
66
|
-
# Public: Creates the seeds for this
|
66
|
+
# Public: Creates the seeds for this components in order to populate the database.
|
67
67
|
#
|
68
68
|
# Returns nothing.
|
69
69
|
def seed!
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/concern"
|
4
|
+
|
5
|
+
module Decidim
|
6
|
+
# Participatory Space Resourceable is a concern with the
|
7
|
+
# features needed when you want to link a space
|
8
|
+
# (for example `Participatory Process`) to another space (`Assembly`).
|
9
|
+
#
|
10
|
+
# The main difference between the two concerns `Resourceable` and
|
11
|
+
# `ParticipatorySpaceResourceable` is that the first one is linking
|
12
|
+
# component types between them, for example `Budgets` with `Proposals` and
|
13
|
+
# therefore depend on a `Component`.
|
14
|
+
#
|
15
|
+
# The second one, `ParticipatorySpaceResourceable`, it is used for linking
|
16
|
+
# `ParticipatorySpaces` to each other, and therefore don't depend on a
|
17
|
+
# `Component` but rather that they depend to the `Organization`.
|
18
|
+
|
19
|
+
module ParticipatorySpaceResourceable
|
20
|
+
extend ActiveSupport::Concern
|
21
|
+
|
22
|
+
included do
|
23
|
+
# An association with all the links that point to this model.
|
24
|
+
has_many :participatory_space_resource_links_to, as: :to, class_name: "Decidim::ParticipatorySpaceLink"
|
25
|
+
|
26
|
+
# An association with all the links that are originated from this model.
|
27
|
+
has_many :participatory_space_resource_links_from, as: :from, class_name: "Decidim::ParticipatorySpaceLink"
|
28
|
+
|
29
|
+
# Finds all the linked resources to or from this model for a given resource
|
30
|
+
# name and link name.
|
31
|
+
#
|
32
|
+
# resource_name - The String name of the resource manifest exposed by a feature.
|
33
|
+
# link_name - The String name of the link between this model and the target resource.
|
34
|
+
|
35
|
+
def linked_participatory_space_resources(resource_name, link_name)
|
36
|
+
klass = "Decidim::#{resource_name.to_s.classify}"
|
37
|
+
klass = klass.constantize
|
38
|
+
from = klass
|
39
|
+
.joins(:participatory_space_resource_links_from)
|
40
|
+
.where(decidim_participatory_space_links: { name: link_name, to_id: id, to_type: self.class.name })
|
41
|
+
|
42
|
+
to = klass
|
43
|
+
.joins(:participatory_space_resource_links_to)
|
44
|
+
.where(decidim_participatory_space_links: { name: link_name, from_id: id, from_type: self.class.name })
|
45
|
+
|
46
|
+
klass.where(id: from).or(klass.where(id: to))
|
47
|
+
end
|
48
|
+
|
49
|
+
def participatory_space_sibling_scope(participatory_space_name)
|
50
|
+
manifest = Decidim.find_participatory_space_manifest(participatory_space_name)
|
51
|
+
return self.class.none unless manifest
|
52
|
+
|
53
|
+
scope = manifest.participatory_spaces.call(organization)
|
54
|
+
|
55
|
+
scope
|
56
|
+
end
|
57
|
+
|
58
|
+
# Links the given resources to this model, replaces any previous links with the same name.
|
59
|
+
#
|
60
|
+
# resources - An Array or ActiveRecord::Base object to link to.
|
61
|
+
# link_name - The String name to use as the name between the resources.
|
62
|
+
# data - An optional Hash to add to the link.
|
63
|
+
#
|
64
|
+
# Returns nothing.
|
65
|
+
def link_participatory_spaces_resources(resources, link_name, data = {})
|
66
|
+
transaction do
|
67
|
+
participatory_space_resource_links_from.where(name: link_name).delete_all
|
68
|
+
Array.wrap(resources).each do |resource|
|
69
|
+
Decidim::ParticipatorySpaceLink.create!(
|
70
|
+
from: self,
|
71
|
+
to: resource,
|
72
|
+
name: link_name,
|
73
|
+
data: data
|
74
|
+
)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
data/lib/decidim/publicable.rb
CHANGED
@@ -31,7 +31,7 @@ module Decidim
|
|
31
31
|
end
|
32
32
|
|
33
33
|
#
|
34
|
-
# Public: Publishes this
|
34
|
+
# Public: Publishes this component
|
35
35
|
#
|
36
36
|
# Returns true if the record was properly saved, false otherwise.
|
37
37
|
def publish!
|
@@ -39,7 +39,7 @@ module Decidim
|
|
39
39
|
end
|
40
40
|
|
41
41
|
#
|
42
|
-
# Public: Unpublishes this
|
42
|
+
# Public: Unpublishes this component
|
43
43
|
#
|
44
44
|
# Returns true if the record was properly saved, false otherwise.
|
45
45
|
def unpublish!
|
@@ -44,8 +44,8 @@ module Decidim
|
|
44
44
|
argument :id, !types.ID, "The ID of the component to be found"
|
45
45
|
|
46
46
|
resolve lambda { |_, args, ctx|
|
47
|
-
|
48
|
-
|
47
|
+
component = Decidim::Component.published.find_by(id: args[:id])
|
48
|
+
component&.organization == ctx[:current_organization] ? component : nil
|
49
49
|
}
|
50
50
|
end
|
51
51
|
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Rectify
|
4
|
+
class FormatAttributesHash
|
5
|
+
private
|
6
|
+
|
7
|
+
def convert_indexed_hashes_to_arrays(attributes_hash)
|
8
|
+
array_attributes.each do |array_attribute|
|
9
|
+
name = array_attribute.name
|
10
|
+
attribute = attributes_hash[name]
|
11
|
+
next unless attribute.is_a?(Hash)
|
12
|
+
|
13
|
+
attributes_hash[name] = transform_values_for_type(
|
14
|
+
attribute.values,
|
15
|
+
array_attribute.member_type.primitive
|
16
|
+
)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def transform_values_for_type(values, element_type)
|
21
|
+
return values unless element_type < Rectify::Form
|
22
|
+
|
23
|
+
values.map do |value|
|
24
|
+
self.class.new(element_type.attribute_set).format(value)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def array_attributes
|
29
|
+
attribute_set.select { |attribute| attribute.primitive == Array }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/decidim/reportable.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Decidim
|
4
|
-
#
|
5
|
-
# will be used to be linked between each other and other possible
|
4
|
+
# Components inside a component can expose different Resources, these resources
|
5
|
+
# will be used to be linked between each other and other possible components.
|
6
6
|
#
|
7
7
|
# This class sets a scheme to expose these resources. It shouldn't be
|
8
|
-
# used directly, you should use `register_resource` inside a
|
8
|
+
# used directly, you should use `register_resource` inside a component.
|
9
9
|
#
|
10
10
|
# Example:
|
11
|
-
#
|
11
|
+
# component.register_resource do |resource|
|
12
12
|
# resource.model_class = Decidim::MyEngine::MyModel
|
13
13
|
# resource.template = "decidim/myengine/myengine/linked_models"
|
14
14
|
# end
|
@@ -20,8 +20,8 @@ module Decidim
|
|
20
20
|
# The name of the resource we are exposing.
|
21
21
|
attribute :name, String
|
22
22
|
|
23
|
-
# The parent
|
24
|
-
attribute :
|
23
|
+
# The parent component manifest
|
24
|
+
attribute :component_manifest, Decidim::ComponentManifest
|
25
25
|
|
26
26
|
# The ActiveRecord class name of the model we're exposing
|
27
27
|
attribute :model_class_name, String
|
@@ -33,20 +33,20 @@ module Decidim
|
|
33
33
|
# The template to use to render the collection of a resource.
|
34
34
|
attribute :template, String
|
35
35
|
|
36
|
-
validates :
|
36
|
+
validates :component_manifest, :model_class_name, :route_name, presence: true
|
37
37
|
|
38
38
|
# Finds an ActiveRecord::Relation of the resource `model_class`, scoped to the
|
39
|
-
# given
|
39
|
+
# given component. This way you can find resources from another engine without
|
40
40
|
# actually coupling both engines.
|
41
41
|
#
|
42
|
-
#
|
42
|
+
# component - a Decidim::Component
|
43
43
|
#
|
44
44
|
# Returns an ActiveRecord::Relation.
|
45
|
-
def resource_scope(
|
46
|
-
|
47
|
-
return model_class.none if
|
45
|
+
def resource_scope(component)
|
46
|
+
component_ids = Decidim::Component.where(participatory_space: component.participatory_space, manifest_name: component_manifest.name).pluck(:id)
|
47
|
+
return model_class.none if component_ids.empty?
|
48
48
|
|
49
|
-
model_class.where(
|
49
|
+
model_class.where(component: component_ids)
|
50
50
|
end
|
51
51
|
|
52
52
|
# Finds the current class with the given `model_class_name`
|
data/lib/decidim/resourceable.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require "active_support/concern"
|
4
4
|
|
5
5
|
module Decidim
|
6
|
-
# A concern with the
|
6
|
+
# A concern with the components needed when you want a model to be able to create
|
7
7
|
# links from it to another resource.
|
8
8
|
module Resourceable
|
9
9
|
extend ActiveSupport::Concern
|
@@ -18,7 +18,7 @@ module Decidim
|
|
18
18
|
# Finds all the linked resources to or from this model for a given resource
|
19
19
|
# name and link name.
|
20
20
|
#
|
21
|
-
# resource_name - The String name of the resource manifest exposed by a
|
21
|
+
# resource_name - The String name of the resource manifest exposed by a component.
|
22
22
|
# link_name - The String name of the link between this model and the target resource.
|
23
23
|
#
|
24
24
|
# Returns an ActiveRecord::Relation.
|
@@ -39,14 +39,14 @@ module Decidim
|
|
39
39
|
# Builds an ActiveRecord::Relation in order to load all the resources
|
40
40
|
# that are in the same parent as this model.
|
41
41
|
#
|
42
|
-
# resource_name - The String name of the resource manifest exposed by a
|
42
|
+
# resource_name - The String name of the resource manifest exposed by a component.
|
43
43
|
#
|
44
44
|
# Returns an ActiveRecord::Relation.
|
45
45
|
def sibling_scope(resource_name)
|
46
46
|
manifest = Decidim.find_resource_manifest(resource_name)
|
47
47
|
return self.class.none unless manifest
|
48
48
|
|
49
|
-
scope = manifest.resource_scope(
|
49
|
+
scope = manifest.resource_scope(component)
|
50
50
|
scope = scope.where("#{self.class.table_name}.id != ?", id) if manifest.model_class == self.class
|
51
51
|
|
52
52
|
scope
|
@@ -85,13 +85,13 @@ module Decidim
|
|
85
85
|
|
86
86
|
class_methods do
|
87
87
|
# Finds the name of the classes that have been linked to this model for the given
|
88
|
-
# `
|
88
|
+
# `component`.
|
89
89
|
#
|
90
|
-
#
|
90
|
+
# component - a Decidim::Component instance where the links will be scoped to.
|
91
91
|
#
|
92
92
|
# Returns an Array of Strings.
|
93
|
-
def linked_classes_for(
|
94
|
-
scope = where(
|
93
|
+
def linked_classes_for(component)
|
94
|
+
scope = where(component: component)
|
95
95
|
|
96
96
|
from = scope
|
97
97
|
.joins(:resource_links_from)
|
data/lib/decidim/scopable.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require "active_support/concern"
|
4
4
|
|
5
5
|
module Decidim
|
6
|
-
# A concern with the
|
6
|
+
# A concern with the components needed when you want a model to have a scope.
|
7
7
|
#
|
8
8
|
# The including model needs to implement the following interface:
|
9
9
|
#
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Decidim
|
4
4
|
# This class serves as a DSL that enables specifying an arbitrary settings
|
5
|
-
# to a
|
5
|
+
# to a component, so the admin panel can show a standarized UI to configure them.
|
6
6
|
#
|
7
7
|
class SettingsManifest
|
8
8
|
attr_reader :attributes
|
@@ -22,7 +22,7 @@ module Decidim
|
|
22
22
|
# options - A hash of options
|
23
23
|
# * primary: Whether the stat is primary or not.
|
24
24
|
# * priority: The priority of the stat used for render issues.
|
25
|
-
# block - A block that receive the
|
25
|
+
# block - A block that receive the components to filter out the stat.
|
26
26
|
def register(name, options = {}, &block)
|
27
27
|
stat = @stats.detect { |s| s[:name] == name }
|
28
28
|
raise StandardError, "Stats '#{name}' is already registered." if stat.present?
|
@@ -9,6 +9,9 @@
|
|
9
9
|
daysMin: ["D", "L", "Ma", "Me", "J", "V", "S", "D"],
|
10
10
|
months: ["Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"],
|
11
11
|
monthsShort: ["Jan", "Fev", "Mar", "Avr", "Mai", "Jui", "Jul", "Aou", "Sep", "Oct", "Nov", "Dec"],
|
12
|
-
today: "Aujourd'hui"
|
12
|
+
today: "Aujourd'hui",
|
13
|
+
clear: "Effacer",
|
14
|
+
weekStart: 1,
|
15
|
+
format: "dd/mm/yyyy"
|
13
16
|
};
|
14
17
|
}(jQuery));
|
@@ -1,11 +1,11 @@
|
|
1
1
|
((exports) => {
|
2
2
|
const formDatePicker = () => {
|
3
|
-
$(
|
4
|
-
const language = $(
|
5
|
-
const initialDate = $(node).data(
|
6
|
-
const pickTime = $(node).data(
|
3
|
+
$("[data-datepicker]").each((_index, node) => {
|
4
|
+
const language = $("html").attr("lang") || "en";
|
5
|
+
const initialDate = $(node).data("startdate") || "";
|
6
|
+
const pickTime = $(node).data("timepicker") === "";
|
7
7
|
const languageProps = $(node).fdatepicker.dates[language] && $(node).fdatepicker.dates[language].format;
|
8
|
-
let format = languageProps ||
|
8
|
+
let format = languageProps || "mm/dd/yyyy";
|
9
9
|
|
10
10
|
if (pickTime) {
|
11
11
|
format = `${format}, hh:ii`;
|
@@ -17,14 +17,14 @@
|
|
17
17
|
language,
|
18
18
|
pickTime,
|
19
19
|
disableDblClickSelection: true,
|
20
|
-
leftArrow:
|
21
|
-
rightArrow:
|
22
|
-
}).on(
|
20
|
+
leftArrow: "<<",
|
21
|
+
rightArrow: ">>"
|
22
|
+
}).on("changeDate", (ev) => {
|
23
23
|
let newDate = "";
|
24
24
|
if (ev.date !== null) {
|
25
|
-
newDate = exports.moment.utc(ev.date).format(
|
25
|
+
newDate = exports.moment.utc(ev.date).format("YYYY-MM-DDTHH:mm:ss");
|
26
26
|
}
|
27
|
-
$(ev.target).siblings(
|
27
|
+
$(ev.target).siblings("input").val(newDate);
|
28
28
|
});
|
29
29
|
});
|
30
30
|
};
|