decidim-admin 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of decidim-admin might be problematic. Click here for more details.

Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/decidim/admin/_decidim.scss +9 -0
  3. data/app/assets/stylesheets/decidim/admin/_variables.scss +7 -0
  4. data/app/assets/stylesheets/decidim/admin/application.scss +2 -19
  5. data/app/assets/stylesheets/decidim/admin/extra/_categories.scss +5 -0
  6. data/app/assets/stylesheets/decidim/admin/{_email_preview.scss → extra/_email_preview.scss} +0 -0
  7. data/app/assets/stylesheets/decidim/admin/{_login.scss → extra/_login.scss} +0 -0
  8. data/app/assets/stylesheets/decidim/admin/extra/_select_multiple.scss +3 -0
  9. data/app/assets/stylesheets/decidim/admin/extra/_title_bar.scss +5 -0
  10. data/app/assets/stylesheets/decidim/admin/modules/_action-icon.scss +13 -0
  11. data/app/assets/stylesheets/decidim/admin/modules/_buttons.scss +44 -0
  12. data/app/assets/stylesheets/decidim/admin/modules/_callouts.scss +32 -0
  13. data/app/assets/stylesheets/decidim/admin/modules/_cards.scss +36 -0
  14. data/app/assets/stylesheets/decidim/admin/modules/_char-counter.scss +20 -0
  15. data/app/assets/stylesheets/decidim/admin/modules/_component-counter.scss +17 -0
  16. data/app/assets/stylesheets/decidim/admin/modules/_forms.scss +80 -0
  17. data/app/assets/stylesheets/decidim/admin/modules/_icons.scss +65 -0
  18. data/app/assets/stylesheets/decidim/admin/modules/_layout.scss +67 -0
  19. data/app/assets/stylesheets/decidim/admin/modules/_main-nav.scss +41 -0
  20. data/app/assets/stylesheets/decidim/admin/modules/_modules.scss +24 -0
  21. data/app/assets/stylesheets/decidim/admin/modules/_process-header.scss +11 -0
  22. data/app/assets/stylesheets/decidim/admin/modules/_secondary-nav.scss +95 -0
  23. data/app/assets/stylesheets/decidim/admin/modules/_table-list.scss +78 -0
  24. data/app/assets/stylesheets/decidim/admin/modules/_tabs.scss +49 -0
  25. data/app/assets/stylesheets/decidim/admin/modules/_title-bar.scss +32 -0
  26. data/app/assets/stylesheets/decidim/admin/modules/_typography.scss +15 -0
  27. data/app/assets/stylesheets/decidim/admin/modules/_user-login.scss +23 -0
  28. data/app/assets/stylesheets/decidim/admin/utils/_fontface.scss +27 -0
  29. data/app/assets/stylesheets/decidim/admin/utils/_helpers.scss +25 -0
  30. data/app/assets/stylesheets/decidim/admin/utils/_keyframes.scss +21 -0
  31. data/app/assets/stylesheets/decidim/admin/utils/_mixins.scss +20 -0
  32. data/app/assets/stylesheets/decidim/admin/utils/_settings.scss +590 -0
  33. data/app/assets/stylesheets/decidim/admin/utils/_toggle-expand.scss +8 -0
  34. data/app/commands/decidim/admin/create_attachment.rb +13 -4
  35. data/app/commands/decidim/admin/update_participatory_process.rb +3 -3
  36. data/app/commands/decidim/admin/update_participatory_process_admin.rb +40 -0
  37. data/app/controllers/decidim/admin/application_controller.rb +7 -1
  38. data/app/controllers/decidim/admin/newsletters_controller.rb +1 -1
  39. data/app/controllers/decidim/admin/organization_controller.rb +2 -0
  40. data/app/controllers/decidim/admin/participatory_process_user_roles_controller.rb +29 -0
  41. data/app/controllers/decidim/admin/participatory_processes_controller.rb +2 -2
  42. data/app/controllers/decidim/admin/scopes_controller.rb +2 -0
  43. data/app/controllers/decidim/admin/static_pages_controller.rb +2 -0
  44. data/app/controllers/decidim/admin/user_groups_controller.rb +3 -1
  45. data/app/controllers/decidim/admin/users_controller.rb +1 -1
  46. data/app/helpers/decidim/admin/application_helper.rb +8 -0
  47. data/app/helpers/decidim/admin/icon_link_helper.rb +30 -0
  48. data/app/jobs/decidim/admin/newsletter_job.rb +1 -1
  49. data/app/queries/decidim/admin/process_admin_roles_for_process.rb +1 -1
  50. data/app/views/decidim/admin/attachments/_form.html.erb +29 -8
  51. data/app/views/decidim/admin/attachments/edit.html.erb +3 -5
  52. data/app/views/decidim/admin/attachments/index.html.erb +45 -35
  53. data/app/views/decidim/admin/attachments/new.html.erb +3 -5
  54. data/app/views/decidim/admin/categories/_form.html.erb +18 -10
  55. data/app/views/decidim/admin/categories/edit.html.erb +3 -5
  56. data/app/views/decidim/admin/categories/index.html.erb +57 -42
  57. data/app/views/decidim/admin/categories/new.html.erb +3 -5
  58. data/app/views/decidim/admin/dashboard/show.html.erb +6 -3
  59. data/app/views/decidim/admin/features/_feature.html.erb +11 -11
  60. data/app/views/decidim/admin/features/_form.html.erb +56 -48
  61. data/app/views/decidim/admin/features/edit.html.erb +3 -5
  62. data/app/views/decidim/admin/features/index.html.erb +21 -19
  63. data/app/views/decidim/admin/features/new.html.erb +3 -4
  64. data/app/views/decidim/admin/moderations/index.html.erb +71 -61
  65. data/app/views/decidim/admin/newsletters/_form.html.erb +7 -1
  66. data/app/views/decidim/admin/newsletters/edit.html.erb +10 -8
  67. data/app/views/decidim/admin/newsletters/index.html.erb +50 -43
  68. data/app/views/decidim/admin/newsletters/new.html.erb +10 -8
  69. data/app/views/decidim/admin/newsletters/show.html.erb +20 -12
  70. data/app/views/decidim/admin/organization/_form.html.erb +98 -62
  71. data/app/views/decidim/admin/organization/edit.html.erb +11 -8
  72. data/app/views/decidim/admin/participatory_process_groups/_form.html.erb +4 -4
  73. data/app/views/decidim/admin/participatory_process_groups/edit.html.erb +15 -9
  74. data/app/views/decidim/admin/participatory_process_groups/index.html.erb +37 -35
  75. data/app/views/decidim/admin/participatory_process_groups/new.html.erb +10 -8
  76. data/app/views/decidim/admin/participatory_process_steps/_form.html.erb +21 -11
  77. data/app/views/decidim/admin/participatory_process_steps/edit.html.erb +3 -4
  78. data/app/views/decidim/admin/participatory_process_steps/index.html.erb +60 -51
  79. data/app/views/decidim/admin/participatory_process_steps/new.html.erb +4 -5
  80. data/app/views/decidim/admin/participatory_process_user_roles/_form.html.erb +23 -0
  81. data/app/views/decidim/admin/participatory_process_user_roles/edit.html.erb +7 -0
  82. data/app/views/decidim/admin/participatory_process_user_roles/index.html.erb +46 -34
  83. data/app/views/decidim/admin/participatory_process_user_roles/new.html.erb +7 -0
  84. data/app/views/decidim/admin/participatory_processes/_form.html.erb +103 -72
  85. data/app/views/decidim/admin/participatory_processes/edit.html.erb +15 -17
  86. data/app/views/decidim/admin/participatory_processes/index.html.erb +52 -43
  87. data/app/views/decidim/admin/participatory_processes/new.html.erb +6 -5
  88. data/app/views/decidim/admin/scopes/edit.html.erb +9 -7
  89. data/app/views/decidim/admin/scopes/index.html.erb +37 -36
  90. data/app/views/decidim/admin/scopes/new.html.erb +9 -6
  91. data/app/views/decidim/admin/static_pages/_form.html.erb +3 -3
  92. data/app/views/decidim/admin/static_pages/edit.html.erb +10 -8
  93. data/app/views/decidim/admin/static_pages/index.html.erb +38 -37
  94. data/app/views/decidim/admin/static_pages/new.html.erb +10 -8
  95. data/app/views/decidim/admin/user_groups/index.html.erb +37 -31
  96. data/app/views/decidim/admin/users/_form.html.erb +5 -4
  97. data/app/views/decidim/admin/users/index.html.erb +57 -52
  98. data/app/views/decidim/admin/users/new.html.erb +10 -7
  99. data/app/views/layouts/decidim/admin/_application.html.erb +23 -36
  100. data/app/views/layouts/decidim/admin/_callouts_full.html.erb +10 -0
  101. data/app/views/layouts/decidim/admin/_language_chooser.html.erb +9 -9
  102. data/app/views/layouts/decidim/admin/_main_nav.html.erb +11 -0
  103. data/app/views/layouts/decidim/admin/_template_bottom.html.erb +2 -0
  104. data/app/views/layouts/decidim/admin/_template_top.html.erb +3 -0
  105. data/app/views/layouts/decidim/admin/_title_bar.html.erb +20 -0
  106. data/app/views/layouts/decidim/admin/newsletters.erb +14 -0
  107. data/app/views/layouts/decidim/admin/pages.html.erb +14 -0
  108. data/app/views/layouts/decidim/admin/participatory_process.html.erb +55 -53
  109. data/app/views/layouts/decidim/admin/participatory_process_groups.html.erb +14 -0
  110. data/app/views/layouts/decidim/admin/participatory_processes.html.erb +14 -0
  111. data/app/views/layouts/decidim/admin/settings.html.erb +19 -0
  112. data/app/views/layouts/decidim/admin/users.html.erb +21 -0
  113. data/config/i18n-tasks.yml +1 -0
  114. data/config/locales/ca.yml +77 -22
  115. data/config/locales/en.yml +75 -20
  116. data/config/locales/es.yml +77 -22
  117. data/config/locales/eu.yml +191 -16
  118. data/config/locales/fi.yml +0 -29
  119. data/config/routes.rb +1 -1
  120. data/lib/decidim/admin/test/manage_attachments_examples.rb +11 -11
  121. metadata +54 -18
  122. data/app/assets/stylesheets/decidim/admin/_actions.scss +0 -8
  123. data/app/assets/stylesheets/decidim/admin/_forms.scss +0 -10
  124. data/app/assets/stylesheets/decidim/admin/_foundation_and_overrides.scss +0 -53
  125. data/app/assets/stylesheets/decidim/admin/_icons.scss +0 -9
  126. data/app/assets/stylesheets/decidim/admin/_layout.scss +0 -27
  127. data/app/assets/stylesheets/decidim/admin/_settings.scss +0 -566
  128. data/app/assets/stylesheets/decidim/admin/_tables.scss +0 -21
  129. data/app/views/layouts/decidim/admin/_login_items.html.erb +0 -8
  130. data/app/views/layouts/decidim/admin/_sidebar.html.erb +0 -22
@@ -0,0 +1,8 @@
1
+ //Generic toggle expand
2
+
3
+ .toggle-show{
4
+ display: none;
5
+ &.is-expanded{
6
+ display: block;
7
+ }
8
+ }
@@ -22,16 +22,25 @@ module Decidim
22
22
  def call
23
23
  return broadcast(:invalid) if form.invalid?
24
24
 
25
- create_attachment
26
- broadcast(:ok)
25
+ build_attachment
26
+
27
+ if @attachment.valid?
28
+ @attachment.save!
29
+ broadcast(:ok)
30
+ else
31
+ if @attachment.errors.has_key? :file
32
+ @form.errors.add :file, @attachment.errors[:file]
33
+ end
34
+ broadcast(:invalid)
35
+ end
27
36
  end
28
37
 
29
38
  private
30
39
 
31
40
  attr_reader :form
32
41
 
33
- def create_attachment
34
- Attachment.create!(
42
+ def build_attachment
43
+ @attachment = Attachment.new(
35
44
  title: form.title,
36
45
  description: form.description,
37
46
  file: form.file,
@@ -34,7 +34,7 @@ module Decidim
34
34
 
35
35
  private
36
36
 
37
- attr_reader :form
37
+ attr_reader :form, :participatory_process
38
38
 
39
39
  def update_participatory_process
40
40
  @participatory_process.assign_attributes(attributes)
@@ -47,8 +47,8 @@ module Decidim
47
47
  subtitle: form.subtitle,
48
48
  slug: form.slug,
49
49
  hashtag: form.hashtag,
50
- hero_image: form.hero_image,
51
- banner_image: form.banner_image,
50
+ hero_image: form.hero_image || participatory_process.hero_image,
51
+ banner_image: form.banner_image || participatory_process.banner_image,
52
52
  promoted: form.promoted,
53
53
  description: form.description,
54
54
  short_description: form.short_description,
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+ module Decidim
3
+ module Admin
4
+ # A command with all the business logic when updated a participatory
5
+ # process admin in the system.
6
+ class UpdateParticipatoryProcessAdmin < Rectify::Command
7
+ # Public: Initializes the command.
8
+ #
9
+ # form - A form object with the params.
10
+ # participatory_process - The ParticipatoryProcess that will hold the
11
+ # user role
12
+ def initialize(form, user_role)
13
+ @form = form
14
+ @user_role = user_role
15
+ end
16
+
17
+ # Executes the command. Broadcasts these events:
18
+ #
19
+ # - :ok when everything is valid.
20
+ # - :invalid if the form wasn't valid and we couldn't proceed.
21
+ #
22
+ # Returns nothing.
23
+ def call
24
+ return broadcast(:invalid) if form.invalid?
25
+ return broadcast(:invalid) unless user_role
26
+
27
+ update_role!
28
+ broadcast(:ok)
29
+ end
30
+
31
+ private
32
+
33
+ attr_reader :form, :user_role
34
+
35
+ def update_role!
36
+ user_role.update_attributes!(role: form.role)
37
+ end
38
+ end
39
+ end
40
+ end
@@ -2,12 +2,18 @@
2
2
  module Decidim
3
3
  module Admin
4
4
  # The main application controller that inherits from Rails.
5
- class ApplicationController < ActionController::Base
5
+ class ApplicationController < ::DecidimController
6
6
  include NeedsOrganization
7
7
  include NeedsAuthorization
8
8
  include FormFactory
9
9
  include LocaleSwitcher
10
10
  include PayloadInfo
11
+ helper Decidim::Admin::ApplicationHelper
12
+ helper Decidim::Admin::AttributesDisplayHelper
13
+ helper Decidim::Admin::FeatureSettingsHelper
14
+ helper Decidim::Admin::ProcessGroupsForSelectHelper
15
+ helper Decidim::Admin::ProcessesForSelectHelper
16
+ helper Decidim::Admin::IconLinkHelper
11
17
  helper Decidim::DecidimFormHelper
12
18
  helper Decidim::ReplaceButtonsHelper
13
19
  helper Decidim::OrganizationScopesHelper
@@ -28,7 +28,7 @@ module Decidim
28
28
  email = NewsletterMailer.newsletter(current_user, @newsletter)
29
29
  Premailer::Rails::Hook.perform(email)
30
30
 
31
- render text: email.html_part.body.decoded
31
+ render html: email.html_part.body.decoded
32
32
  end
33
33
 
34
34
  def create
@@ -6,6 +6,8 @@ module Decidim
6
6
  # Controller that allows managing the user organization.
7
7
  #
8
8
  class OrganizationController < ApplicationController
9
+ layout "decidim/admin/settings"
10
+
9
11
  def edit
10
12
  authorize! :update, current_organization
11
13
  @form = form(OrganizationForm).from_model(current_organization)
@@ -14,6 +14,11 @@ module Decidim
14
14
  authorize! :read, Decidim::Admin::ParticipatoryProcessUserRole
15
15
  end
16
16
 
17
+ def new
18
+ authorize! :create, Decidim::Admin::ParticipatoryProcessUserRole
19
+ @form = form(ParticipatoryProcessUserRoleForm).instance
20
+ end
21
+
17
22
  def create
18
23
  authorize! :create, Decidim::Admin::ParticipatoryProcessUserRole
19
24
  @form = form(ParticipatoryProcessUserRoleForm).from_params(params)
@@ -30,6 +35,30 @@ module Decidim
30
35
  end
31
36
  end
32
37
 
38
+ def edit
39
+ @user_role = collection.find(params[:id])
40
+ authorize! :update, @user_role
41
+ @form = form(ParticipatoryProcessUserRoleForm).from_model(@user_role.user, current_process: participatory_process)
42
+ end
43
+
44
+ def update
45
+ @user_role = collection.find(params[:id])
46
+ authorize! :update, @user_role
47
+ @form = form(ParticipatoryProcessUserRoleForm).from_params(params)
48
+
49
+ UpdateParticipatoryProcessAdmin.call(@form, @user_role) do
50
+ on(:ok) do
51
+ flash[:notice] = I18n.t("participatory_process_user_roles.update.success", scope: "decidim.admin")
52
+ redirect_to participatory_process_user_roles_path(participatory_process)
53
+ end
54
+
55
+ on(:invalid) do
56
+ flash.now[:alert] = I18n.t("participatory_process_user_roles.update.error", scope: "decidim.admin")
57
+ render :edit
58
+ end
59
+ end
60
+ end
61
+
33
62
  def destroy
34
63
  @participatory_process_user_role = collection.find(params[:id])
35
64
  authorize! :destroy, @participatory_process_user_role
@@ -8,7 +8,6 @@ module Decidim
8
8
  class ParticipatoryProcessesController < ApplicationController
9
9
  helper_method :participatory_process
10
10
  helper Decidim::OrganizationScopesHelper
11
- layout "decidim/admin/participatory_process", only: [:show, :edit, :update]
12
11
 
13
12
  def index
14
13
  authorize! :index, Decidim::ParticipatoryProcess
@@ -41,6 +40,7 @@ module Decidim
41
40
  @participatory_process = collection.find(params[:id])
42
41
  authorize! :update, @participatory_process
43
42
  @form = form(ParticipatoryProcessForm).from_model(@participatory_process)
43
+ render layout: "decidim/admin/participatory_process"
44
44
  end
45
45
 
46
46
  def update
@@ -51,7 +51,7 @@ module Decidim
51
51
  UpdateParticipatoryProcess.call(@participatory_process, @form) do
52
52
  on(:ok) do |participatory_process|
53
53
  flash[:notice] = I18n.t("participatory_processes.update.success", scope: "decidim.admin")
54
- redirect_to participatory_process_path(participatory_process)
54
+ redirect_to edit_participatory_process_path(participatory_process)
55
55
  end
56
56
 
57
57
  on(:invalid) do
@@ -6,6 +6,8 @@ module Decidim
6
6
  # Controller that allows managing all scopes at the admin panel.
7
7
  #
8
8
  class ScopesController < ApplicationController
9
+ layout "decidim/admin/settings"
10
+
9
11
  def index
10
12
  authorize! :index, Scope
11
13
  @scopes = collection
@@ -6,6 +6,8 @@ module Decidim
6
6
  # Controller that allows managing all pages at the admin panel.
7
7
  #
8
8
  class StaticPagesController < ApplicationController
9
+ layout "decidim/admin/pages"
10
+
9
11
  def index
10
12
  authorize! :index, StaticPage
11
13
  @pages = collection
@@ -5,9 +5,11 @@ module Decidim
5
5
  # Controller that allows managing user groups at the admin panel.
6
6
  #
7
7
  class UserGroupsController < ApplicationController
8
+ layout "decidim/admin/users"
9
+
8
10
  def index
9
11
  authorize! :index, UserGroup
10
- @user_groups = collection
12
+ @user_groups = collection.page(params[:page]).per(15)
11
13
  end
12
14
 
13
15
  def verify
@@ -8,7 +8,7 @@ module Decidim
8
8
  class UsersController < Admin::ApplicationController
9
9
  def index
10
10
  authorize! :index, :admin_users
11
- @users = collection
11
+ @users = collection.page(params[:page]).per(15)
12
12
  end
13
13
 
14
14
  def new
@@ -14,6 +14,14 @@ module Decidim
14
14
  def title
15
15
  current_organization.name
16
16
  end
17
+
18
+ def admin_menu_item_to(name, url, options={})
19
+ content_tag :li, class: options[:active_class] || active_link_to_class(url, active: options[:active], class_active: "is-active") do
20
+ active_link_to url, active: options[:active], class_active: "is-active" do
21
+ icon(options[:icon_name] || name) + I18n.t("menu.#{name}", scope: "decidim.admin")
22
+ end
23
+ end
24
+ end
17
25
  end
18
26
  end
19
27
  end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+ module Decidim
3
+ module Admin
4
+ module IconLinkHelper
5
+ # This helper adds the necessary boilerplate for the admin icon links.
6
+ #
7
+ # icon_name - A String representing the icon name from Iconic
8
+ # http://useiconic.com/open
9
+ # link - The path or url where the link should point to.
10
+ # title - A String that will be shown when hovering the icon.
11
+ # options - An optional Hash containing extra data for the link:
12
+ # method - Symbol of HTTP verb. Supported verbs are :post, :get, :delete, :patch, and :put.
13
+ # class - Any extra class that will be added to the link.
14
+ # data - This option can be used to add custom data attributes.
15
+ #
16
+ def icon_link_to(icon_name, link, title, options = {})
17
+ link_to(link,
18
+ method: options[:method],
19
+ class: "action-icon #{options[:class]}",
20
+ data: { tooltip: true, disable_hover: false }.merge(options[:data] || {}),
21
+ tooltip: true,
22
+ disable_hover: false,
23
+ title: title,
24
+ target: options[:target]) do
25
+ icon(icon_name)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -25,7 +25,7 @@ module Decidim
25
25
  private
26
26
 
27
27
  def recipients
28
- @recipients ||= User.where(newsletter_notifications: true).where.not(email: nil)
28
+ @recipients ||= User.where(newsletter_notifications: true).where.not(email: nil, confirmed_at: nil)
29
29
  end
30
30
  end
31
31
  end
@@ -24,7 +24,7 @@ module Decidim
24
24
  # Returns an ActiveRecord::Relation.
25
25
  def query
26
26
  ParticipatoryProcessUserRole
27
- .where(participatory_process: process, role: :admin)
27
+ .where(participatory_process: process, role: [:admin, :collaborator])
28
28
  end
29
29
 
30
30
  private
@@ -1,11 +1,32 @@
1
- <div class="field">
2
- <%= form.translated :text_field, :title, autofocus: true %>
3
- </div>
1
+ <div class="card">
2
+ <div class="card-divider">
3
+ <h2 class="card-title">
4
+ <%= title %>
5
+ </h2>
6
+ </div>
4
7
 
5
- <div class="field">
6
- <%= form.translated :text_field, :description %>
7
- </div>
8
+ <div class="card-section">
9
+ <div class="row column">
10
+ <%= form.translated :text_field, :title, autofocus: true %>
11
+ </div>
12
+
13
+ <div class="row column">
14
+ <%= form.translated :text_field, :description %>
15
+ </div>
16
+
17
+ <div class="row column">
18
+ <%= form.file_field :file %>
19
+ </div>
8
20
 
9
- <div class="field">
10
- <%= form.file_field :file %>
21
+ <% if @attachment && @attachment.file.present? %>
22
+ <div class="row column">
23
+ <label><%= t('.current_file') %></label>
24
+ <% if @attachment.photo? %>
25
+ <%= image_tag form.object.file.url(:thumbnail) %>
26
+ <% end %>
27
+ <label><%= t('.url') %></label>
28
+ <%= link_to @attachment.file.url, @attachment.file.url, target: "_blank" %>
29
+ </div>
30
+ <% end %>
31
+ </div>
11
32
  </div>
@@ -1,9 +1,7 @@
1
- <h3><%= t ".title" %></h3>
1
+ <%= decidim_form_for(@form, url: url_for([@attachment.attached_to, @attachment]), html: { class: "form edit_participatory_process_attachment" }) do |f| %>
2
+ <%= render partial: 'decidim/admin/attachments/form', object: f, locals: { title: t(".title") } %>
2
3
 
3
- <%= decidim_form_for(@form, url: url_for([@attachment.attached_to, @attachment])) do |f| %>
4
- <%= render partial: 'decidim/admin/attachments/form', object: f %>
5
-
6
- <div class="actions">
4
+ <div class="button--double form-general-submit">
7
5
  <%= f.submit t(".update") %>
8
6
  </div>
9
7
  <% end %>
@@ -1,37 +1,47 @@
1
- <section id="attachments">
2
- <h4><%= t(".attachments_title", scope: "decidim.admin") %></h4>
1
+ <div class='card' id="attachments">
2
+ <div class="card-divider">
3
+ <h2 class="card-title">
4
+ <%= t(".attachments_title", scope: "decidim.admin") %>
5
+ <% if can? :create, authorization_object %>
6
+ <%= link_to t("actions.new", scope: "decidim.admin", name: t("models.attachment.name", scope: "decidim.admin")), url_for(action: :new), class: 'button tiny button--title new' %>
7
+ <% end %>
8
+ </h2>
9
+ </div>
3
10
 
4
- <% if can? :create, authorization_object %>
5
- <div class="actions title">
6
- <%= link_to t("actions.new", scope: "decidim.admin", name: t("models.attachment.name", scope: "decidim.admin")), url_for(action: :new), class: 'new' %>
7
- </div>
8
- <% end %>
11
+ <div class="card-section">
12
+ <% if attached_to.attachments.any? %>
13
+ <div class="table-scroll">
14
+ <table class="table-list">
15
+ <thead>
16
+ <tr>
17
+ <th><%= t("models.attachment.fields.title", scope: "decidim.admin") %></th>
18
+ <th><%= t("models.attachment.fields.content_type", scope: "decidim.admin") %></th>
19
+ <th class="actions"></th>
20
+ </tr>
21
+ </thead>
22
+ <tbody>
23
+ <% attached_to.attachments.each do |attachment| %>
24
+ <tr data-id="<%= attachment.id %>">
25
+ <td>
26
+ <%= link_to translated_attribute(attachment.title), edit_polymorphic_path([attached_to, attachment]) %><br />
27
+ </td>
28
+ <td>
29
+ <%= attachment.file_type %>
30
+ </td>
31
+ <td class="table-list__actions">
32
+ <% if can? :update, authorization_object %>
33
+ <%= icon_link_to "pencil", edit_polymorphic_path([attached_to, attachment]), t("actions.edit", scope: "decidim.admin"), class: "action-icon--edit" %>
34
+ <% end %>
9
35
 
10
- <% if attached_to.attachments.any? %>
11
- <table class="stack">
12
- <thead>
13
- <tr>
14
- <th><%= t("models.attachment.fields.title", scope: "decidim.admin") %></th>
15
- <th><%= t("models.attachment.fields.content_type", scope: "decidim.admin") %></th>
16
- <th class="actions"><%= t("actions.title", scope: "decidim.admin") %></th>
17
- </tr>
18
- </thead>
19
- <tbody>
20
- <% attached_to.attachments.each do |attachment| %>
21
- <tr data-id="<%= attachment.id %>">
22
- <td>
23
- <%= link_to translated_attribute(attachment.title), polymorphic_path([attached_to, attachment]) %><br />
24
- </td>
25
- <td>
26
- <%= attachment.file_type %>
27
- </td>
28
- <td class="actions">
29
- <%= link_to t("actions.edit", scope: "decidim.admin"), edit_polymorphic_path([attached_to, attachment]) if can? :update, authorization_object %>
30
- <%= link_to t("actions.destroy", scope: "decidim.admin"), polymorphic_path([attached_to, attachment]), method: :delete, class: "small alert button", data: { confirm: t("actions.confirm_destroy", scope: "decidim.admin") } if can? :destroy, authorization_object %>
31
- </td>
32
- </tr>
33
- <% end %>
34
- </tbody>
35
- </table>
36
- <% end %>
37
- </section>
36
+ <% if can? :destroy, authorization_object %>
37
+ <%= icon_link_to "circle-x", polymorphic_path([attached_to, attachment]), t("actions.destroy", scope: "decidim.admin"), class: "action-icon--remove", method: :delete, data: { confirm: t("actions.confirm_destroy", scope: "decidim.admin") } %>
38
+ <% end %>
39
+ </td>
40
+ </tr>
41
+ <% end %>
42
+ </tbody>
43
+ </table>
44
+ </div>
45
+ <% end %>
46
+ </div>
47
+ </div>