effective_committees 0.7.1 → 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: 73acb7e4afcaf588a31ea4e43b0e8b87a5f01809190184c3b886458e49acea84
4
- data.tar.gz: 22dc3c3d8090896218ddf76f03698127ec4f14a4c4cb6247165d229cbfa8ef8c
3
+ metadata.gz: b0b2195404483ec93cb13fb7f17348c27f0433cbb6a6f0c94533cf8b8f0a98b2
4
+ data.tar.gz: f9ec6c5d7bb9d128f84411fc0d00d5f4df4607bb82064e0be57a655eabbfb852
5
5
  SHA512:
6
- metadata.gz: e440e4b631686691497795937aa4957bc487ecd0cadc2e80f52f451f6fb7cdd630ed54288d5fbff8b8ab48352af612b3f1c8a553d94bc85e9cd510bbf59126eb
7
- data.tar.gz: a40ed0a255a7fdeef2ee10040673de0c67021bd5d0c79e88b17211d1b99263cff62782bff90ce264b459742b5d87002c98d9e453aec878aecfc16e12e1fa2d42
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
@@ -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,15 +6,15 @@
6
6
  - log = logs.first
7
7
 
8
8
  - committee = log.changes_to
9
- - committee_folder = log.associated.try(:committee_folder) || log.associated
10
- - committee_file = log.associated.try(:file).try(:blob)
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')
11
11
 
12
12
  - next if committee.blank?
13
13
  - next if committee_folder.blank?
14
14
 
15
15
  - link_to_committee = link_to(committee, effective_committees.committee_path(committee))
16
16
  - link_to_committee_folder = link_to(committee_folder, effective_committees.committee_committee_folder_path(committee, committee_folder))
17
- - link_to_file = link_to(log.associated, (committee_file ? url_for(committee_file) : '#'))
17
+ - link_to_file = link_to(committee_file.to_s, (committee_file ? url_for(committee_file.file) : '#'))
18
18
 
19
19
  - if logs.length == 1 && log.associated_type == 'Effective::CommitteeFolder'
20
20
  %li Folder #{link_to_committee_folder} was added to #{link_to_committee}.
@@ -1,3 +1,3 @@
1
1
  module EffectiveCommittees
2
- VERSION = '0.7.1'.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.1
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-11-05 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