decidim-posts 1.0.0 → 2.0.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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +60 -5
  3. data/app/cells/decidim/posts/content_blocks/posts/show.erb +41 -3
  4. data/app/cells/decidim/posts/content_blocks/posts_cell.rb +6 -7
  5. data/app/cells/decidim/posts/meeting/show.erb +2 -2
  6. data/app/cells/decidim/posts/meeting_cell.rb +5 -1
  7. data/app/cells/decidim/posts/post/show.erb +2 -2
  8. data/app/cells/decidim/posts/post/survey.erb +6 -6
  9. data/app/cells/decidim/posts/post_attachments/show.erb +1 -1
  10. data/app/cells/decidim/posts/post_cell.rb +0 -1
  11. data/app/cells/decidim/posts/post_comment/show.erb +1 -1
  12. data/app/cells/decidim/posts/post_header/show.erb +4 -4
  13. data/app/cells/decidim/posts/post_host/show.erb +2 -2
  14. data/app/cells/decidim/posts/post_metadata_cell.rb +2 -0
  15. data/app/cells/decidim/posts/reaction_menu/show.erb +1 -1
  16. data/app/controllers/decidim/posts/meetings_controller.rb +28 -12
  17. data/app/helpers/decidim/posts/application_helper.rb +20 -0
  18. data/app/packs/src/decidim/posts/host_status.js +13 -9
  19. data/app/packs/src/decidim/posts/posts.js +38 -1
  20. data/app/packs/stylesheets/decidim/posts/_variables.scss +19 -8
  21. data/app/packs/stylesheets/decidim/posts/posts.scss +219 -164
  22. data/app/views/decidim/posts/meetings/edit.html.erb +15 -14
  23. data/app/views/decidim/posts/meetings/new.html.erb +27 -0
  24. data/app/views/decidim/posts/posts/_attachment.html.erb +1 -1
  25. data/app/views/decidim/posts/posts/_form.html.erb +22 -22
  26. data/app/views/decidim/posts/posts/_index.html.erb +9 -9
  27. data/app/views/decidim/posts/posts/_meeting_form.erb +1 -1
  28. data/app/views/decidim/posts/posts/_new_survey.html.erb +1 -1
  29. data/app/views/decidim/posts/posts/_new_survey_question.html.erb +1 -1
  30. data/app/views/decidim/posts/posts/_post.html.erb +1 -1
  31. data/app/views/decidim/posts/posts/_sidebar.html.erb +19 -19
  32. data/app/views/decidim/posts/posts/edit.html.erb +7 -6
  33. data/app/views/decidim/posts/posts/index.html.erb +1 -1
  34. data/config/assets.rb +1 -1
  35. data/config/locales/bs.yml +11 -3
  36. data/config/locales/de.yml +11 -3
  37. data/config/locales/en.yml +11 -3
  38. data/config/locales/hr.yml +11 -3
  39. data/config/locales/it.yml +11 -3
  40. data/config/locales/sr.yml +11 -4
  41. data/config/locales/tr.yml +11 -3
  42. data/lib/decidim/posts/component.rb +4 -0
  43. data/lib/decidim/posts/content_blocks/content_blocks_homepage.rb +16 -12
  44. data/lib/decidim/posts/version.rb +2 -2
  45. metadata +5 -5
  46. data/app/views/decidim/posts/posts/_new.html.erb +0 -33
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 19e659db435e89deb7080d4a371f2583b59d98572f4d8f47be5c0b9b8dfe6208
4
- data.tar.gz: a08c84232bfe45b86193e2525a87b765c0ceabd8eb08cfe6242766fb5ecde47d
3
+ metadata.gz: 1f81b68dbcbce53c688236a18f5bf1783cee0065e670281ef71e3585656a1516
4
+ data.tar.gz: ce7afa875e613b88dbd9ab8125f7de1c654f79889738cdcf75bbc7fc6e03ce8e
5
5
  SHA512:
6
- metadata.gz: 76836076454d822cb81f28f7a6dca9dbf64c58a50804a84ba5d221eabee3d384f834dd6507069fc2a2e224843f6de78dac0d59d962fa67a19adddb4fc981242e
7
- data.tar.gz: 38f674b9b12b724d1023a2e0f6a42e9292f21b669068e8a4de576cc08793fb34d9cecebe24c265e4fe48675308ea3030fc92b7b98e71630ae8200cd22395f605
6
+ metadata.gz: 25e5cf2c16fbdeb6e786a62d398ec4c9300822d546cda9d147a3c07185175a6cb4fcedb9255150a62e8cc2b5e87b20404ed7797c766b05f85e22fda7985d6cce
7
+ data.tar.gz: a9e6a304790c9f6d98dac6145a848f4ff41b5b05328bf4e26c5e103896f665c38cfee729139fcae8e8d582ca9cf175e5262839eeb82ae02585c57dd9e503b521
data/README.md CHANGED
@@ -1,20 +1,75 @@
1
- # Decidim::Posts component (under development)
1
+ # Decidim::Posts component
2
2
 
3
3
  This Feeds component adds social posts functionality to Decidim.
4
4
 
5
- **The module is currently in development and not yet ready.**
5
+ ## Constraints
6
+
7
+ **Participatory Space**
8
+
9
+ Until now this component was only tested with the "feeds" Participatory space, but it should also work within other PS.
10
+
11
+ **Content Block**
12
+
13
+ We tried to implement everything as a content block to display the social feed on the start page, but decidim makes it very hard to add actions on content block elements, because at that point you are in the homepage controller and not in your components controller, so everything would have to work with AJAX. Because of that we didn't put much effort into creating the content block. But this can be improved to nicely display a read only version of the latest posts.
14
+
15
+ ## Features
16
+
17
+ - social posts
18
+ - attached images
19
+ - comments
20
+ - reactions with emojis
21
+ - different categories of posts (post, share&care, survey, host/admin)
22
+ - simple surveys
23
+ - meetings can be displayed as posts
24
+ - Highlighting posts
25
+ - Fix posts on top of the feed
26
+
27
+ ## Categories
28
+
29
+ Posts can be of different categories/types which have individual features.
30
+
31
+ ### post
32
+
33
+ A normal social post. It contains a body text and you can attach images to it that are then displayed with a kind of simple carousel.
34
+
35
+ ### share&care
36
+
37
+ This is a category for people to offer things or services within their community or ask for favors or borrowing items.
38
+
39
+ ### survey
40
+
41
+ You can create a very simple survey that can have multiple single- and multiple-choice questions.
42
+
43
+ ### host/admin
44
+
45
+ This category is designed for members to have a way to contact the admins/hosts of the platform with issues.
46
+
47
+ It is then possible for admins to change the status of those issues/posts to:
48
+
49
+ - Unread
50
+ - Processing
51
+ - Done
52
+
53
+ This way people can always see the status of this issue without having to ask multiple times.
54
+
55
+ ### meeting
56
+
57
+ Meeting is not really a category of post, but it actually displays and creates meetings in a separate decidim-meetings component that has to exist in the same participatory space.
58
+
59
+ We added some functionality to allow a simplified way of creating new meetings directly within the posts/feed.
6
60
 
7
61
  ## Usage
8
62
 
9
- Feeds will be available as a Component for a Participatory
10
- Space.
63
+ Posts is a component that can be added to a participatory space. All posts are displayed in a chronological list. They can have a body, attached images, comments and reactions.
64
+
65
+ Reactions are part of this module and are an alternative to endorsements. The idea is that endorsements are a more official way to support something, but in social feeds you want to be able to react in different ways to posts without endorsing it. You can react with a few selected emojis. Similar to other social media platforms.
11
66
 
12
67
  ## Installation
13
68
 
14
69
  Add this line to your application's Gemfile:
15
70
 
16
71
  ```ruby
17
- gem "decidim-posts", git: "https://github.com/DecidimAustria/decidim-module-posts.git", branch: "main"
72
+ gem "decidim-posts", "~> 2.0"
18
73
  ```
19
74
 
20
75
  And then execute:
@@ -1,3 +1,41 @@
1
- <section id="feeds" class="home__section feeds">
2
- <%= render partial: "decidim/posts/posts/index.html" %>
3
- </section>
1
+ <section id="feeds" class="home__section feeds feeds__container">
2
+ <div class="home__section-header">
3
+ <h2 class="home__section-title">
4
+ <%= t('decidim.posts.content_blocks.posts.title')%>
5
+ </h2>
6
+ <%= link_to posts_path, class: "button button__sm button__text-secondary" do %>
7
+ <%= t('decidim.posts.content_blocks.posts.seeall')%>
8
+ <%= icon "arrow-right-line", class: "fill-current" %>
9
+ <% end %>
10
+ </div>
11
+ <div class="card__grid-home feeds__body items-start auto-rows-auto">
12
+ <% @posts.each do |post| %>
13
+ <div class="card__grid posts__post hover:cursor-default ring-1 <%= post.attachments.any? ? '' : '' %>" data-content="<%= post.category %>">
14
+ <% if post.attachments.any? %>
15
+ <div class="card__grid-img">
16
+ <%= image_tag post.attachments.first.url, class: "object-cover w-full h-full" %>
17
+ </div>
18
+ <% end %>
19
+ <div class="card__grid-text">
20
+ <% if post.title[I18n.locale.to_s].present? %>
21
+ <h3 class="h4 text-secondary !no-underline">Title if present -> meetings</h3>
22
+ <% end %>
23
+ <p><%= post.body[I18n.locale.to_s] %></p>
24
+ <div class="card__grid-metadata">
25
+ <% filters = {
26
+ post: 'home-5-line',
27
+ sharecare: 'shake-hands-line',
28
+ calendar: 'calendar-line',
29
+ survey: 'draft-line',
30
+ host: 'home-gear-line'
31
+ } %>
32
+ <span>
33
+ <%= icon filters[post.category.to_sym], class:'!text-black' %> von <%= 'post.author' %>
34
+ </span>
35
+ <time><%= '@time_since_update' %></time>
36
+ </div>
37
+ </div>
38
+ </div>
39
+ <% end %>
40
+ </div>
41
+ </section>
@@ -5,21 +5,20 @@ module Decidim
5
5
  module ContentBlocks
6
6
  class PostsCell < Decidim::ViewModel
7
7
  include Cell::ViewModel::Partial
8
- include FormFactory
9
-
8
+ include PostCellsHelper
10
9
  def show
11
10
  @posts = Decidim::Posts::Post
12
11
  .where(decidim_component_id: component_id)
13
12
  .filter_category(params[:filter_post_category])
14
13
  .order(created_at: :desc)
15
- .limit(10)
14
+ .limit(6)
16
15
  extra_context = {
17
16
  current_component: component,
18
17
  current_organization: component.organization,
19
18
  current_user:,
20
19
  current_participatory_space: component.participatory_space
21
20
  }
22
- @form = form(Decidim::Posts::PostForm).from_params(params, extra_context)
21
+ # @form = form(Decidim::Posts::PostForm).from_params(params, extra_context)
23
22
  render :show
24
23
  end
25
24
 
@@ -41,9 +40,9 @@ module Decidim
41
40
  @component ||= Decidim::Component.find(component_id)
42
41
  end
43
42
 
44
- def post_creation_params
45
- params[:post]
46
- end
43
+ # def post_creation_params
44
+ # params[:post]
45
+ # end
47
46
  end
48
47
  end
49
48
  end
@@ -1,4 +1,4 @@
1
- <article class="card__grid posts__post" data-content="calendar">
1
+ <article class="card__grid posts__post gap-4 ring-1 hover:cursor-default md:col-start-1 md:col-end-4 lg:col-start-2 lg:col-end-8 xl:col-start-2 xl:col-end-10" data-content="calendar">
2
2
  <%= cell("decidim/posts/post_header", meeting) %>
3
3
  <div class="flex gap-4 py-2 px-2">
4
4
  <div class="card__grid-text--meta flex flex-col gap-2">
@@ -16,7 +16,7 @@
16
16
  </time>
17
17
  <% end %>
18
18
  </div>
19
- <div class="card__grid-text p-0">
19
+ <div class="card__grid-text p-0 py-2 text-pretty">
20
20
  <h2 class="h3"><%= link_to meeting_title, Decidim::EngineRouter.main_proxy(meeting.component).meeting_path(meeting) %></h2>
21
21
  <% should_truncate = strip_tags(meeting_description).length > 300 %>
22
22
  <div class="content-block__description editor-content" <%= "data-component='accordion'" if should_truncate %>>
@@ -24,7 +24,11 @@ module Decidim
24
24
  end
25
25
 
26
26
  def meeting_description
27
- translated_attribute model.description
27
+ simple_format(meeting_presenter.description(links: true))
28
+ end
29
+
30
+ def meeting_presenter
31
+ @meeting_presenter ||= present(model)
28
32
  end
29
33
 
30
34
  def meeting_address
@@ -1,6 +1,6 @@
1
1
  <%= cell("decidim/posts/post_header", post) %>
2
2
  <%= cell("decidim/posts/post_attachments", post) %>
3
- <div class="card__grid-text">
3
+ <div class="card__grid-text py-2 text-pretty">
4
4
  <% should_truncate = strip_tags(post_body).length > 300 %>
5
5
  <div class="content-block__description editor-content" <%= "data-component='accordion'" if should_truncate %>>
6
6
  <% if should_truncate %>
@@ -27,4 +27,4 @@
27
27
  <%= render :survey %>
28
28
  <% end %>
29
29
  <%= cell("decidim/posts/post_comment", post) %>
30
- <%= cell("decidim/posts/post_metadata", post) %>
30
+ <%= cell("decidim/posts/post_metadata", post) %>
@@ -1,14 +1,14 @@
1
- <div class="posts__post_survey" id="post_<%= post.id %>_survey">
1
+ <div class="posts__post_survey flex flex-col gap-2 text-sm font-bold px-2" id="post_<%= post.id %>_survey">
2
2
  <span class="text-right py-2">
3
3
  <%= t("decidim.posts.survey.participated", count: post.survey_responses_count) %>
4
4
  </span>
5
5
  <% post.questions.each do |question| %>
6
6
  <% if question.question_type == "single_choice" %>
7
- <fieldset class="posts__post_survey-question">
7
+ <fieldset class="posts__post_survey-question flex flex-col p-2 gap-2 rounded bg-feeds-bg">
8
8
  <legend><%= translated_attribute question.title %></legend>
9
9
  <% question.answers.each do |answer| %>
10
- <div class="posts__post_survey-question-answer">
11
- <div class="posts__post_survey-question-answerInput">
10
+ <div class="posts__post_survey-question-answer font-medium flex flex-col px-2">
11
+ <div class="posts__post_survey-question-answerInput flex py-1 gap-2">
12
12
  <%= radio_button_tag "post[questions][#{question.id}]", answer.id, answer.user_answers.find_by(decidim_posts_answer_id: answer.id, decidim_user_id: current_user.id).present?, class: "survey-answer-checkbox", data: { question_id: question.id, answer_id: answer.id } %>
13
13
  <%= label_tag "post_questions_#{question.id}_#{answer.id}" do %>
14
14
  <%= translated_attribute answer.title %>
@@ -37,8 +37,8 @@
37
37
  <fieldset class="posts__post_survey-question">
38
38
  <legend><%= translated_attribute question.title %></legend>
39
39
  <% question.answers.each do |answer| %>
40
- <div class="posts__post_survey-question-answer">
41
- <div class="posts__post_survey-question-answerInput">
40
+ <div class="posts__post_survey-question-answer font-medium flex flex-col px-2">
41
+ <div class="posts__post_survey-question-answerInput flex py-1 gap-2">
42
42
  <%= check_box_tag "post[questions][#{question.id}][#{answer.id}]", answer.id, answer.user_answers.find_by(decidim_posts_answer_id: answer.id, decidim_user_id: current_user.id).present?, class: "survey-answer-checkbox", data: { question_id: question.id, answer_id: answer.id } %>
43
43
  <%= label_tag "post_questions_#{question.id}_#{answer.id}" do %>
44
44
  <%= translated_attribute answer.title %>
@@ -4,7 +4,7 @@
4
4
  <div class="flex flex-col items-center">
5
5
  <ul id="galleryItems_<%= post.id %>" class="posts__post_gallery flex overflow-hidden">
6
6
  <% post.attachments.select { |a| a.url.match(/\.(jpg|jpeg|png|svg|webp|mp4|webm)$/i) }.each_with_index do |attachment, index| %>
7
- <li class="<%= attachment.url.match(/\.(mp4|webm)$/i) ? 'video' : 'image' %> <%= index.zero? ? 'active' : '' %> aspect-4/3 overflow-hidden flex justify-center items-center" data-src="<%= attachment.url %>">
7
+ <li class="<%= attachment.url.match(/\.(mp4|webm)$/i) ? 'video' : 'image' %> <%= index.zero? ? 'active' : '' %> aspect-[4/3] overflow-hidden flex justify-center items-center" data-src="<%= attachment.url %>">
8
8
  <% if attachment.url.match(/\.(mp4|webm)$/i) %>
9
9
  <%= video_tag(attachment.url, class: "object-cover w-full h-full", controls: true, preload: "auto") %>
10
10
  <% else %>
@@ -16,7 +16,6 @@ module Decidim
16
16
 
17
17
  def post_body
18
18
  simple_format(post_presenter.body)
19
- # translated_attribute model.body
20
19
  end
21
20
 
22
21
  def post_presenter
@@ -1,5 +1,5 @@
1
1
  <% if post_commentable? %>
2
- <div class="posts__post_comments" data-post-id="<%= post.id %>">
2
+ <div class="posts__post_comments px-2" data-post-id="<%= post.id %>">
3
3
  <button class="button button__sm button__transparent-primary absolute newCommentBtn" data-post-id="<%= post.id %>" data-model-type="<%= model_type %>" aria-expanded="false" aria-controls="new_comment_for_<%= model_type %>_<%= post.id %> comments-for-<%= model_type %>-<%= post.id %>-threads"><%= t(".comment") %></button>
4
4
  <%#= comments_for post %>
5
5
  <%= cell(
@@ -1,4 +1,4 @@
1
- <div class="card__grid-metadata">
1
+ <div class="card__grid-metadata gap-2 items-center flex-nowrap text-black px-2 pt-2">
2
2
  <% if post.is_a?(Decidim::Posts::Post) && post.highlighted %>
3
3
  <div></div>
4
4
  <% else %>
@@ -8,15 +8,15 @@
8
8
  <%= cell("decidim/author", Decidim::Meetings::OfficialAuthorPresenter.new, layout: :compact) %>
9
9
  <% end %>
10
10
  <% end %>
11
- <div class="posts__post_actions">
11
+ <div class="posts__post_actions flex gap-4">
12
12
  <div class="posts__post_actions_submenu relative self-start">
13
13
  <% if show_menu? %>
14
14
  <button type="button" aria-expanded="false" aria-haspopup="true" aria-controls="<%= dom_id(post) %>_posts__post_actions_submenu" id="<%= dom_id(post) %>_posts__post_actions_submenuButton" class="flex justify-center items-start min-w-[24px] min-h-[24px] openButton">
15
15
  <span class="sr-only"><%= t('decidim.components.posts.actions.openMenu') %></span>
16
- <span aria-hidden="true">...</span>
16
+ <span aria-hidden="true" class="leading-[0] text-3xl text-feeds-sidebar">...</span>
17
17
  </button>
18
18
 
19
- <ul id="<%= dom_id(post) %>_posts__post_actions_submenu" role="menu" aria-orientation="vertical" aria-labelledby="<%= dom_id(post) %>_posts__post_actions_submenuButton" class="absolute right-0 mt-2 px-4 py-2 bg-white divide-y divide-dashed divide-gray-100 rounded-md shadow-feedMenu overflow-hidden hidden z-10">
19
+ <ul id="<%= dom_id(post) %>_posts__post_actions_submenu" role="menu" aria-orientation="vertical" aria-labelledby="<%= dom_id(post) %>_posts__post_actions_submenuButton" class="absolute right-0 mt-2 px-4 py-2 bg-white divide-y divide-dashed divide-gray-100 rounded-md shadow shadow-feedMenu overflow-hidden hidden z-10">
20
20
  <% if show_report_button? %>
21
21
  <li class="text-right py-1 text-feeds-sidebar" role="menuitem">
22
22
  <%= cell("decidim/report_button", post, button_classes: "hover:text-black dropdown__item flex-row-reverse min-h-[24px]", modal_id: "flagModalPost#{post.id}") %>
@@ -2,12 +2,12 @@
2
2
 
3
3
  <% unless post_highlighted %>
4
4
  <% if official_post %>
5
- <%= icon "home-gear-line", class: 'host-icon' %>
5
+ <%= icon "home-gear-line", class: 'host-icon absolute -right-2 -top-2 bg-white fill-feeds-host' %>
6
6
  <% end %>
7
7
  <% end %>
8
8
 
9
9
  <%= cell("decidim/posts/post_attachments", post) %>
10
- <div class="card__grid-text">
10
+ <div class="card__grid-text py-2 text-pretty">
11
11
  <% should_truncate = strip_tags(post_body).length > 300 %>
12
12
  <div class="content-block__description editor-content" <%= "data-component='accordion'" if should_truncate %>>
13
13
  <% if should_truncate %>
@@ -48,6 +48,8 @@ module Decidim
48
48
  ]
49
49
 
50
50
  current_filter = filters.find { |f| f[:filter] == category }
51
+ return nil if current_filter.blank?
52
+
51
53
  {
52
54
  icon: current_filter[:icon],
53
55
  label: t("decidim.components.posts.filter.#{current_filter[:filter]}")
@@ -5,7 +5,7 @@
5
5
  <span class="text-sm"><%= t("decidim.endorsement_buttons_cell.already_endorsed") %></span>
6
6
  <span class="reaction_icon text-black"><%= icon('heart-add-line', class: 'text-black') %></span>
7
7
  </button>
8
- <ul id="<%= dom_id(post) %>_posts__post_reactions_submenu" role="menu" aria-orientation="vertical" aria-labelledby="<%= dom_id(post) %>_posts__post_reactions_submenuButton" class="absolute left-[60px] -top-[40px] p-2 flex gap-2 bg-white rounded-md shadow-feedMenu overflow-hidden hidden" aria-label="<%= t("decidim.components.posts.reactions.title") %>">
8
+ <ul id="<%= dom_id(post) %>_posts__post_reactions_submenu" role="menu" aria-orientation="vertical" aria-labelledby="<%= dom_id(post) %>_posts__post_reactions_submenuButton" class="absolute left-[60px] -top-[40px] p-2 flex gap-2 bg-white rounded-md shadow shadow-feedMenu overflow-hidden hidden" aria-label="<%= t("decidim.components.posts.reactions.title") %>">
9
9
  <% reaction_types.each do |reaction_type| %>
10
10
  <li role="menuitem">
11
11
  <a href="#" class="reaction_btn block text-xl w-[24px] h-[24px]" data-reaction="<%= reaction_type.name %>" data-reaction-id="<%= reaction_type.id %>" data-reaction-url="<%= reactions_path %>" data-reactionable-id="<%= post.to_global_id.to_s %>">
@@ -28,8 +28,7 @@ module Decidim
28
28
  def create
29
29
  enforce_permission_to :create, :meeting
30
30
 
31
- # Duplicate location to address field
32
- params[:meeting][:address] = params[:meeting][:location] if params[:meeting][:address].blank?
31
+ copy_location_to_address
33
32
 
34
33
  @form = meeting_form.from_params(params, current_component: meetings_component)
35
34
 
@@ -40,8 +39,15 @@ module Decidim
40
39
  end
41
40
 
42
41
  on(:invalid) do
43
- flash.now[:alert] = I18n.t("meetings.create.invalid", scope: "decidim.meetings")
44
- redirect_to posts_path
42
+ error_messages = @form.errors.full_messages.join(", ")
43
+ general_error_message = I18n.t("meetings.create.invalid", scope: "decidim.meetings")
44
+ flash.now[:alert] = [general_error_message, error_messages].join(": ")
45
+
46
+ set_meeting_context
47
+
48
+ render template: "decidim/posts/meetings/new", status: :unprocessable_entity
49
+ #render template: "decidim/posts/posts/index", layout: "decidim/application", status: :unprocessable_entity
50
+ #redirect_to posts_path
45
51
  end
46
52
  end
47
53
  end
@@ -49,20 +55,15 @@ module Decidim
49
55
  def edit
50
56
  enforce_permission_to(:update, :meeting, meeting:)
51
57
 
52
- @context = {
53
- current_organization: @controller.try(:current_organization),
54
- current_component: @controller.try(:current_component),
55
- current_user: @controller.try(:current_user),
56
- current_participatory_space: @controller.try(:current_participatory_space)
57
- }
58
- @feeds_component = current_component.participatory_space.components.find_by(manifest_name: "posts")
59
- @target_participatory_space = @feeds_component.participatory_space
58
+ set_meeting_context
60
59
  @form = meeting_form.from_model(meeting).with_context(@context)
61
60
  end
62
61
 
63
62
  def update
64
63
  enforce_permission_to(:update, :meeting, meeting:)
65
64
 
65
+ copy_location_to_address
66
+
66
67
  @form = meeting_form.from_params(params)
67
68
 
68
69
  Decidim::Meetings::UpdateMeeting.call(@form, current_user, meeting) do
@@ -171,6 +172,21 @@ module Decidim
171
172
  }
172
173
  ] + attachments_tab_panel_items(@meeting)
173
174
  end
175
+
176
+ def set_meeting_context
177
+ @context = {
178
+ current_organization: @controller.try(:current_organization),
179
+ current_component: @controller.try(:current_component),
180
+ current_user: @controller.try(:current_user),
181
+ current_participatory_space: @controller.try(:current_participatory_space)
182
+ }
183
+ @feeds_component = current_component.participatory_space.components.find_by(manifest_name: "posts")
184
+ @target_participatory_space = @feeds_component.participatory_space
185
+ end
186
+
187
+ def copy_location_to_address
188
+ params[:meeting][:address] = params[:meeting][:location] if params[:meeting][:address].blank?
189
+ end
174
190
  end
175
191
  end
176
192
  end
@@ -15,6 +15,26 @@ module Decidim
15
15
  def posts_component_for_meeting(meeting)
16
16
  meeting.component.participatory_space.components.find_by(manifest_name: "posts")
17
17
  end
18
+
19
+ def category_label(category, posts_settings)
20
+ if category == :host
21
+ translated_attribute(posts_settings.host_category_label_plural).presence || t("decidim.components.posts.filter.host")
22
+ elsif category == :sharecare
23
+ translated_attribute(posts_settings.sharecare_category_label_plural).presence || t("decidim.components.posts.filter.sharecare")
24
+ else
25
+ t("decidim.components.posts.filter.#{category}")
26
+ end
27
+ end
28
+
29
+ def category_label_singular(category, posts_settings)
30
+ if category == :host
31
+ translated_attribute(posts_settings.host_category_label_singular).presence || t("decidim.components.posts.filter.host_singular")
32
+ elsif category == :sharecare
33
+ translated_attribute(posts_settings.sharecare_category_label_singular).presence || t("decidim.components.posts.filter.sharecare_singular")
34
+ else
35
+ t("decidim.components.posts.filter.#{category}_singular")
36
+ end
37
+ end
18
38
  end
19
39
  end
20
40
  end
@@ -1,17 +1,21 @@
1
1
  export function host_status() {
2
2
  const changeStatusButtons = document.querySelectorAll('.changeStatusButton');
3
-
4
- changeStatusButtons.forEach(function (button) {
5
- button.addEventListener('click', handleStatusChange);
6
- });
7
-
8
3
  const cancelButton = document.getElementById(
9
4
  'confirmationModal__cancelButton'
10
5
  );
11
- cancelButton.addEventListener('click', function () {
12
- const confirmationModal = document.getElementById('confirmationModal');
13
- confirmationModal.close();
14
- });
6
+
7
+ if (changeStatusButtons) {
8
+ changeStatusButtons.forEach(function (button) {
9
+ button.addEventListener('click', handleStatusChange);
10
+ });
11
+ }
12
+
13
+ if (cancelButton) {
14
+ cancelButton.addEventListener('click', function () {
15
+ const confirmationModal = document.getElementById('confirmationModal');
16
+ confirmationModal.close();
17
+ });
18
+ }
15
19
 
16
20
  function handleStatusChange(event) {
17
21
  const button = event.currentTarget;
@@ -5,8 +5,43 @@ import { closeDialog, activateCategory, hideAllForms } from './newFeeds.js';
5
5
  import Submenu from './submenu.js';
6
6
  import CommentsComponent from "src/decidim/comments/comments.component"
7
7
 
8
+ import RemoteModal from "src/decidim/remote_modal"
9
+ import selectActiveIdentity from "src/decidim/identity_selector_dialog"
10
+ import createTooltip from "src/decidim/tooltips"
11
+ import createToggle from "src/decidim/toggle"
12
+ import {
13
+ createAccordion,
14
+ createDialog,
15
+ createDropdown,
16
+ Dialogs
17
+ } from "src/decidim/a11y"
18
+ import changeReportFormBehavior from "src/decidim/change_report_form_behavior"
19
+
8
20
  document.addEventListener('DOMContentLoaded', function () {
9
- function addEventListeners(rootElement) {
21
+ function initializeDecidimComponents() {
22
+ document.querySelectorAll('[data-component="accordion"]').forEach((component) => createAccordion(component))
23
+
24
+ document.querySelectorAll('[data-component="dropdown"]').forEach((component) => createDropdown(component))
25
+
26
+ // initialize a11y dialog-open buttons
27
+ document.querySelectorAll("[data-dialog]").forEach((component) => createDialog(component))
28
+
29
+ // Initialize available remote modals (ajax-fetched contents)
30
+ document.querySelectorAll("[data-dialog-remote-url]").forEach((elem) => new RemoteModal(elem))
31
+
32
+ // Add event listeners to identity modal
33
+ document.querySelectorAll("[data-user-identity]").forEach((elem) => selectActiveIdentity(elem))
34
+
35
+ // Initialize data-tooltips
36
+ document.querySelectorAll("[data-tooltip]").forEach((elem) => createTooltip(elem))
37
+
38
+ // Initialize data-toggles
39
+ document.querySelectorAll("[data-toggle]").forEach((elem) => createToggle(elem))
40
+
41
+ document.querySelectorAll(".new_report").forEach((elem) => changeReportFormBehavior(elem))
42
+ }
43
+
44
+ function addEventListeners(rootElement) {
10
45
  rootElement.querySelectorAll("[data-decidim-posts-comments]").forEach((el) => {
11
46
  const $el = $(el);
12
47
  let comments = $(el).data("comments");
@@ -183,6 +218,8 @@ document.addEventListener('DOMContentLoaded', function () {
183
218
  newButton.addEventListener('click', loadMoreButtonClicked);
184
219
  observer.observe(newButton);
185
220
  }
221
+
222
+ initializeDecidimComponents();
186
223
  })
187
224
  .catch((error) => {
188
225
  // enable the button again
@@ -1,10 +1,21 @@
1
1
  :root {
2
- --dg-color-white: 255 255 255;
3
- --dg-color-black: 60 57 52;
4
- --dg-color-post: 229 57 144;
5
- --dg-color-help: 1 114 187;
6
- --dg-color-sharecare: 36 166 32;
7
- --dg-color-host: 219 15 16;
8
- --dg-color-survey: 50 49 143;
9
- --dg-color-calendar: 253 182 32;
2
+ --feeds-post: #1786c2;
3
+ --feeds-sharecare: #80cc28;
4
+ --feeds-host: #e81067;
5
+ --feeds-calendar: #fdb620;
6
+ --feeds-survey: #19619a;
7
+
8
+ --feeds-notification: 151, 71, 255;
9
+
10
+ --feeds-black: 60, 57, 52;
11
+ --feeds-bg: #fafafa;
12
+ --feeds-formBody: #f9f8f8;
13
+ --feeds-sidebar: #6d6b67;
14
+
15
+ --shadow-feedBox: -1px -1px 4px 0px rgba(0, 0, 0, 0.25),
16
+ 1px 1px 4px 0px rgba(0, 0, 0, 0.25);
17
+ --shadow-feedMenu: -1px -1px 8px 0px rgba(0, 0, 0, 0.05),
18
+ 1px 1px 8px 0px rgba(0, 0, 0, 0.05);
19
+ --shadow-feedNotification: -1px -1px 8px 0px rgba(var(--feeds-notification), 0.5),
20
+ 1px 1px 8px 0px rgba(var(--feeds-notification), 0.5);
10
21
  }