effective_committees 0.7.0 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0bc2c949cff1b747488c7c18ea3def8acb9541e3278b5ae7e6f82cccf6d45c60
4
- data.tar.gz: ea5794494521b25fa243a7c9bce9cf491cbeb49204c1d8405f0cd1a87b67ae07
3
+ metadata.gz: b0b2195404483ec93cb13fb7f17348c27f0433cbb6a6f0c94533cf8b8f0a98b2
4
+ data.tar.gz: f9ec6c5d7bb9d128f84411fc0d00d5f4df4607bb82064e0be57a655eabbfb852
5
5
  SHA512:
6
- metadata.gz: 7ba1a02a5ae937c6d409c7828038e2217ea94c03ef545b01d530e1309738f03a520f7cf173a0d697cbfe92daffc8202998093c29a8d3187a3bfcddced5dfde35
7
- data.tar.gz: dfe2891d1b287231ac3a987503eb16f3b00d4a55508a073abf9ee3eaa2b444b5d43a4a8c2e44dd578e96283fe971b16bab17c87a11c262b9ad177150f5fab79e
6
+ metadata.gz: 4ac652618bd32cc6336df7b2122f28b741df5e735ebb556e9a0410a5036f3ddf011df0657a6316c041e62eb1a6bf4d938f09661791482dadc8095f6aec9e5736
7
+ data.tar.gz: 294969d8a9a2714403a6064bdc18c3decc8db3150b92c8da3451919794217f136fef7eea199dcd613d47ed178b5e11800f3467cc8b4bed68daacd7b301ea0533
@@ -14,7 +14,10 @@ module Admin
14
14
  admin_committees_parents(committee_file.committee_folder)
15
15
  end
16
16
 
17
- col :file, label: "Files"
17
+ col(:to_s, label: 'Files') do |committee_file|
18
+ link_to(committee_file.to_s, url_for(committee_file.file), title: committee_file.to_s, target: '_blank')
19
+ end
20
+
18
21
  col :title, visible: false
19
22
  col :notes
20
23
 
@@ -29,18 +29,26 @@ module Effective
29
29
  end
30
30
 
31
31
  before_validation(if: -> { file.attached? }) do
32
- assign_attributes(title: file.filename.to_s, file_id: file.attachment.blob.id, file_created_at: file.attachment.blob.created_at)
32
+ assign_attributes(file_id: file.attachment.blob.id, file_created_at: file.attachment.blob.created_at)
33
+ end
34
+
35
+ validate(if: -> { title.present? }) do
36
+ errors.add(:title, 'must end with a file extension') unless title.include?('.')
37
+ end
38
+
39
+ before_save(if: -> { title.present? && file.attached? }) do
40
+ file.update(filename: title)
33
41
  end
34
42
 
35
43
  scope :deep, -> { with_attached_file.includes(:committee, :committee_folder) }
36
44
  scope :sorted, -> { order(:position) }
37
45
 
38
- validates :title, presence: true
46
+ validates :title, uniqueness: { scope: :committee_folder_id, allow_blank: true }
39
47
  validates :file, presence: true
40
48
  validates :position, presence: true, if: -> { committee_folder.present? }
41
49
 
42
50
  def to_s
43
- title.presence || 'file'
51
+ title.presence || file&.filename.to_s.presence || 'file'
44
52
  end
45
53
 
46
54
  def parents
@@ -47,6 +47,10 @@ module Effective
47
47
  true
48
48
  end
49
49
 
50
+ def top_level?
51
+ committee_folder.blank?
52
+ end
53
+
50
54
  def parent
51
55
  committee_folder || committee
52
56
  end
@@ -18,6 +18,10 @@
18
18
  = f.select :committee_folder_id, Effective::CommitteeFolder.sorted.where(committee: f.object.committee), label: "Folder"
19
19
 
20
20
  = f.file_field :file
21
+
22
+ - if f.object.persisted?
23
+ = f.text_field :title
24
+
21
25
  = f.text_area :notes
22
26
 
23
27
  = effective_submit(f)
@@ -2,9 +2,9 @@
2
2
  - if parent.kind_of?(Effective::CommitteeFolder)
3
3
  = link_to(parent.title, effective_committees.edit_admin_committee_folder_path(parent))
4
4
  - elsif parent.kind_of?(Effective::Committee)
5
- = link_to(parent.title, effective_committees.edit_admin_committee_path(parent))
5
+ = link_to(parent.to_s, effective_committees.edit_admin_committee_path(parent))
6
6
  - elsif parent.kind_of?(Effective::CommitteeFile)
7
- = link_to(parent.title, effective_committees.edit_admin_committee_file_path(parent))
7
+ = link_to(parent.to_s, effective_committees.edit_admin_committee_file_path(parent))
8
8
  - else
9
9
  - raise("unexpected parent")
10
10
 
@@ -6,13 +6,15 @@
6
6
  - log = logs.first
7
7
 
8
8
  - committee = log.changes_to
9
- - link_to_committee = link_to(committee, effective_committees.committee_path(committee))
9
+ - committee_folder = log.associated.try(:committee_folder) || (log.associated if log.associated_type == 'Effective::CommitteeFolder')
10
+ - committee_file = (log.associated if log.associated_type == 'Effective::CommitteeFile')
10
11
 
11
- - committee_folder = log.associated.try(:committee_folder) || log.associated
12
- - link_to_committee_folder = link_to(committee_folder, effective_committees.committee_committee_folder_path(committee, committee_folder))
12
+ - next if committee.blank?
13
+ - next if committee_folder.blank?
13
14
 
14
- - committee_file = log.associated.try(:file).try(:blob)
15
- - link_to_file = link_to(log.associated, (committee_file ? url_for(committee_file) : '#'))
15
+ - link_to_committee = link_to(committee, effective_committees.committee_path(committee))
16
+ - link_to_committee_folder = link_to(committee_folder, effective_committees.committee_committee_folder_path(committee, committee_folder))
17
+ - link_to_file = link_to(committee_file.to_s, (committee_file ? url_for(committee_file.file) : '#'))
16
18
 
17
19
  - if logs.length == 1 && log.associated_type == 'Effective::CommitteeFolder'
18
20
  %li Folder #{link_to_committee_folder} was added to #{link_to_committee}.
@@ -22,10 +22,12 @@
22
22
  .mb-5
23
23
  %h3= link_to(committee.to_s, effective_committees.committee_path(committee), style: "text-decoration: none;")
24
24
 
25
- - if committee.committee_folders.present?
25
+ - committe_folders = committee.committee_folders.select(&:top_level?)
26
+
27
+ - if committe_folders.present?
26
28
  .card
27
- .list-group.list-grou-flush
28
- - committee.committee_folders.each do |folder|
29
+ .list-group.list-group-flush
30
+ - committe_folders.each do |folder|
29
31
  = link_to(folder.to_s, effective_committees.committee_committee_folder_path(committee, folder), class: 'list-group-item list-group-action')
30
32
  - else
31
33
  %p No files or folders.
@@ -1,3 +1,3 @@
1
1
  module EffectiveCommittees
2
- VERSION = '0.7.0'.freeze
2
+ VERSION = '0.7.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_committees
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-10-31 00:00:00.000000000 Z
11
+ date: 2025-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails