lesli_view 1.1.4 → 1.1.6

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.
@@ -29,31 +29,46 @@ Building a better future, one line of code at a time.
29
29
  // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
30
  // ·
31
31
  %>
32
- <article class="lesli-items-discussions bg-white p-4 sm:p-8" id="lesli-items-discussions">
32
+ <article
33
+ class="lesli-items-discussions bg-white p-4 sm:p-8"
34
+ id="<%= dom_id(resource, :discussions) %>">
33
35
  <div class="lesli-items-discussions-form p-4">
34
- <% discussion_class = "#{@resource.class.name.deconstantize}::Items::Discussion".constantize %>
35
- <% scope_key = ActiveSupport::Inflector.underscore(discussion_class.name).tr("/", "_") %>
36
36
  <%= form_with(
37
37
  scope: scope_key,
38
- model: discussion_class.new,
38
+ model: comment,
39
39
  builder: LesliView::Forms::Builder,
40
- url: helpers.polymorphic_path([:items, :discussions],
41
- discussable_type:@resource.class.name,
42
- discussable_id: @resource.id
43
- )) do |form| %>
44
- <%= form.field_control_textarea(:message) %>
45
- <%= form.field_control_submit("Add comment") %>
40
+ url: create_path
41
+ ) do |form| %>
42
+ <%= form.field_control_textarea(:message, rows: 4) %>
43
+ <% if comment.errors[:message].any? %>
44
+ <p class="mt-2 text-sm text-red-600">
45
+ <%= comment.errors.full_messages_for(:message).to_sentence %>
46
+ </p>
47
+ <% end %>
48
+ <%= form.field_control_submit I18n.t(
49
+ "lesli.items.discussions.add",
50
+ default: "Add comment"
51
+ ) %>
46
52
  <% end %>
47
53
  </div>
48
54
  <hr class="my-6 border-0 border-t border-slate-200">
49
55
 
50
56
  <div class="lesli-items-discussions-container p-4">
51
- <ul
52
- id="<%= "#{scope_key}-lesli-items-discussions-list" %>"
53
- class="m-0 list-none space-y-6 p-0">
54
- <% @resource.discussions.order(created_at: :desc).each do |comment| %>
55
- <%= render(LesliView::Items::Discussion.new(comment)) %>
56
- <% end %>
57
- </ul>
57
+ <% if discussions.any? %>
58
+ <ul
59
+ id="<%= "#{scope_key}-lesli-items-discussions-list" %>"
60
+ class="m-0 list-none space-y-6 p-0">
61
+ <% discussions.each do |item| %>
62
+ <%= render(LesliView::Items::Discussion.new(item)) %>
63
+ <% end %>
64
+ </ul>
65
+ <% else %>
66
+ <p class="py-6 text-center text-sm text-slate-500">
67
+ <%= I18n.t(
68
+ "lesli.items.discussions.empty",
69
+ default: "No comments have been added yet."
70
+ ) %>
71
+ </p>
72
+ <% end %>
58
73
  </div>
59
74
  </article>
@@ -32,13 +32,35 @@ Building a better future, one line of code at a time.
32
32
  module LesliView
33
33
  module Items
34
34
  class Discussions < ViewComponent::Base
35
- attr_reader :resource, :path
36
-
37
- delegate :lexxy_rich_textarea_tag, to: :helpers
35
+ attr_reader :comment, :resource
38
36
 
39
- def initialize(resource, path=nil)
37
+ def initialize(resource, comment: nil)
40
38
  @resource = resource
41
- @path = path
39
+ @comment = comment || discussion_class.new
40
+ end
41
+
42
+ def discussion_class
43
+ resource.class.lesli_discussions_class
44
+ end
45
+
46
+ def discussions
47
+ resource.public_send(
48
+ resource.class.lesli_discussions_association_name
49
+ )
50
+ end
51
+
52
+ def create_path
53
+ helpers.polymorphic_path(
54
+ [:items, :discussions],
55
+ discussable_type: resource.class.name,
56
+ discussable_id: resource.id
57
+ )
58
+ end
59
+
60
+ def scope_key
61
+ ActiveSupport::Inflector
62
+ .underscore(discussion_class.name)
63
+ .tr("/", "_")
42
64
  end
43
65
  end
44
66
  end
@@ -32,7 +32,7 @@ Building a better future, one line of code at a time.
32
32
 
33
33
  <li
34
34
  id="<%= dom_id(@resource, @scope_key) %>"
35
- class="lesli-items-tasks-item rounded-xl border transition-colors <%= @resource.done ? "lesli-items-tasks-task-done cursor-not-allowed border-slate-200 bg-slate-50" : "border-slate-200 hover:border-slate-300 hover:bg-slate-50" %>">
35
+ class="lesli-items-tasks-item rounded-xl border transition-colors <%= @resource.done ? "lesli-items-tasks-task-done border-slate-200 bg-slate-50 hover:border-slate-300 hover:bg-slate-100" : "border-slate-200 hover:border-slate-300 hover:bg-slate-50" %>">
36
36
  <%= form_with(
37
37
  url: helpers.polymorphic_path(@resource),
38
38
  method: :patch,
@@ -42,8 +42,11 @@ Building a better future, one line of code at a time.
42
42
  <%= form.hidden_field :id, value: @resource.id %>
43
43
  <%= form.button(
44
44
  type: "submit",
45
- disabled: @resource.done?,
46
- class: "flex w-full cursor-pointer items-center rounded-xl px-4 py-3 text-left text-sm font-medium text-slate-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--lesli-color-primary)] disabled:cursor-not-allowed"
45
+ aria: {
46
+ label: toggle_label,
47
+ pressed: @resource.done?
48
+ },
49
+ class: "flex w-full cursor-pointer items-center rounded-xl px-4 py-3 text-left text-sm font-medium text-slate-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--lesli-color-primary)]"
47
50
  ) do %>
48
51
  <span class="flex min-w-0 items-center gap-3">
49
52
  <span
@@ -51,9 +54,15 @@ Building a better future, one line of code at a time.
51
54
  aria-hidden="true">
52
55
  <%= @resource.done ? "check_box" : "check_box_outline_blank" %>
53
56
  </span>
54
- <span class="min-w-0 break-words <%= "text-slate-500 line-through" if @resource.done %>">
55
- <%= @resource.title %>
56
- </span>
57
+ <% if @resource.done? %>
58
+ <del class="min-w-0 break-words text-slate-500 line-through">
59
+ <%= @resource.title %>
60
+ </del>
61
+ <% else %>
62
+ <span class="min-w-0 break-words">
63
+ <%= @resource.title %>
64
+ </span>
65
+ <% end %>
57
66
  </span>
58
67
  <% end %>
59
68
  <% end %>
@@ -39,6 +39,20 @@ module LesliView
39
39
  @resource = task
40
40
  @scope_key = scope
41
41
  end
42
+
43
+ def toggle_label
44
+ if resource.done?
45
+ I18n.t(
46
+ "lesli.items.tasks.reopen_action",
47
+ default: "Mark task as incomplete"
48
+ )
49
+ else
50
+ I18n.t(
51
+ "lesli.items.tasks.complete_action",
52
+ default: "Mark task as complete"
53
+ )
54
+ end
55
+ end
42
56
  end
43
57
  end
44
58
  end
@@ -33,29 +33,42 @@ Building a better future, one line of code at a time.
33
33
  class="lesli-items-tasks rounded-2xl border border-slate-200 bg-white p-6 shadow-sm"
34
34
  id="<%= dom_id(@resource, :tasks) %>">
35
35
  <div class="lesli-items-tasks-form">
36
- <% task_class = "#{@resource.class.name.deconstantize}::Items::Task".constantize %>
37
- <% scope_key = ActiveSupport::Inflector.underscore(task_class.name).tr("/", "_") %>
38
36
  <%= form_with(
39
37
  scope: scope_key,
40
- model: task_class.new,
38
+ model: task,
41
39
  builder: LesliView::Forms::Builder,
42
- url: helpers.polymorphic_path([:items, :tasks],
43
- taskable_type:@resource.class.name,
44
- taskable_id: @resource.id
45
- )) do |form| %>
40
+ url: create_path
41
+ ) do |form| %>
46
42
  <%= form.field_control_text :title %>
47
- <%= form.field_control_submit "Add task" %>
43
+ <% if task.errors[:title].any? %>
44
+ <p class="mt-2 text-sm text-red-600">
45
+ <%= task.errors.full_messages_for(:title).to_sentence %>
46
+ </p>
47
+ <% end %>
48
+ <%= form.field_control_submit I18n.t(
49
+ "lesli.items.tasks.add",
50
+ default: "Add task"
51
+ ) %>
48
52
  <% end %>
49
53
  </div>
50
54
  <hr class="my-6 border-0 border-t border-slate-200">
51
55
 
52
56
  <div class="lesli-items-tasks-container">
53
- <ul
54
- id="<%= "#{scope_key}-lesli-items-tasks-list" %>"
55
- class="m-0 list-none space-y-3 p-0">
56
- <% @resource.tasks.each do |task| %>
57
- <%= render(LesliView::Items::Task.new(task, scope_key)) %>
58
- <% end %>
59
- </ul>
57
+ <% if tasks.any? %>
58
+ <ul
59
+ id="<%= "#{scope_key}-lesli-items-tasks-list" %>"
60
+ class="m-0 list-none space-y-3 p-0">
61
+ <% tasks.each do |item| %>
62
+ <%= render(LesliView::Items::Task.new(item, scope_key)) %>
63
+ <% end %>
64
+ </ul>
65
+ <% else %>
66
+ <p class="py-6 text-center text-sm text-slate-500">
67
+ <%= I18n.t(
68
+ "lesli.items.tasks.empty",
69
+ default: "No tasks have been added yet."
70
+ ) %>
71
+ </p>
72
+ <% end %>
60
73
  </div>
61
74
  </article>
@@ -33,10 +33,35 @@ Building a better future, one line of code at a time.
33
33
  module LesliView
34
34
  module Items
35
35
  class Tasks < ViewComponent::Base
36
- attr_reader :resource, :path_to_create
36
+ attr_reader :resource, :task
37
37
 
38
- def initialize(resource)
38
+ def initialize(resource, task: nil)
39
39
  @resource = resource
40
+ @task = task || task_class.new
41
+ end
42
+
43
+ def task_class
44
+ resource.class.lesli_tasks_class
45
+ end
46
+
47
+ def tasks
48
+ resource.public_send(
49
+ resource.class.lesli_tasks_association_name
50
+ )
51
+ end
52
+
53
+ def create_path
54
+ helpers.polymorphic_path(
55
+ [:items, :tasks],
56
+ taskable_type: resource.class.name,
57
+ taskable_id: resource.id
58
+ )
59
+ end
60
+
61
+ def scope_key
62
+ ActiveSupport::Inflector
63
+ .underscore(task_class.name)
64
+ .tr("/", "_")
40
65
  end
41
66
  end
42
67
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LesliView
4
- VERSION = "1.1.4"
5
- BUILD = ""
4
+ VERSION = "1.1.6"
5
+ BUILD = "1792716699"
6
6
  end
data/lib/lesli_view.rb CHANGED
@@ -44,6 +44,7 @@ require "lesli_view/items/actions"
44
44
  require "lesli_view/items/activities"
45
45
  require "lesli_view/items/discussion"
46
46
  require "lesli_view/items/discussions"
47
+ require "lesli_view/items/attachment"
47
48
  require "lesli_view/items/attachments"
48
49
 
49
50
 
data/readme.md CHANGED
@@ -8,10 +8,10 @@
8
8
  <br />
9
9
 
10
10
  <div align="center">
11
- <a target="_blank" href="https://github.com/LesliTech/LesliView/actions/workflows/main.yml">
11
+ <a target="_blank" href="https://github.com/LesliTech/LesliView/actions/workflows/lesli-ci-gem.yaml">
12
12
  <img
13
13
  alt="LesliView test status"
14
- src="https://img.shields.io/github/actions/workflow/status/LesliTech/LesliView/main.yml?branch=main&style=for-the-badge&logo=github&label=tests">
14
+ src="https://img.shields.io/github/actions/workflow/status/LesliTech/LesliView/lesli-ci-gem.yaml?branch=main&style=for-the-badge&logo=github&label=tests">
15
15
  </a>
16
16
  <a target="_blank" href="https://rubygems.org/gems/lesli_view">
17
17
  <img alt="Gem Version" src="https://img.shields.io/gem/v/lesli_view?style=for-the-badge&logo=ruby">
@@ -53,7 +53,7 @@ LesliView provides:
53
53
 
54
54
  The current development baseline is:
55
55
 
56
- - Ruby 3.2 or newer
56
+ - Ruby 3.3 or newer (the release workflow uses Ruby 3.3.5)
57
57
  - Rails 8.1
58
58
  - LesliAssets, configured in the host application's asset build
59
59
 
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lesli_view
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Lesli Development Team
8
+ autorequire:
8
9
  bindir: exe
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2026-10-23 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: view_component
@@ -15,28 +16,28 @@ dependencies:
15
16
  requirements:
16
17
  - - "~>"
17
18
  - !ruby/object:Gem::Version
18
- version: 4.8.0
19
+ version: 4.15.0
19
20
  type: :runtime
20
21
  prerelease: false
21
22
  version_requirements: !ruby/object:Gem::Requirement
22
23
  requirements:
23
24
  - - "~>"
24
25
  - !ruby/object:Gem::Version
25
- version: 4.8.0
26
+ version: 4.15.0
26
27
  - !ruby/object:Gem::Dependency
27
28
  name: lexxy
28
29
  requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
31
  - - "~>"
31
32
  - !ruby/object:Gem::Version
32
- version: 0.9.9.beta
33
+ version: 1.0.1
33
34
  type: :runtime
34
35
  prerelease: false
35
36
  version_requirements: !ruby/object:Gem::Requirement
36
37
  requirements:
37
38
  - - "~>"
38
39
  - !ruby/object:Gem::Version
39
- version: 0.9.9.beta
40
+ version: 1.0.1
40
41
  description: "LesliView is a ViewComponent-powered UI library for The Lesli Framework,
41
42
  \nproviding reusable Rails components and form builders to create consistent, \nscalable,
42
43
  and maintainable application interfaces.\n"
@@ -47,6 +48,7 @@ extensions: []
47
48
  extra_rdoc_files: []
48
49
  files:
49
50
  - Rakefile
51
+ - app/assets/stylesheets/lesli_view/view.css
50
52
  - lib/lesli_view.rb
51
53
  - lib/lesli_view/charts/bar.rb
52
54
  - lib/lesli_view/charts/general.html.erb
@@ -87,6 +89,8 @@ files:
87
89
  - lib/lesli_view/items/actions.rb
88
90
  - lib/lesli_view/items/activities.html.erb
89
91
  - lib/lesli_view/items/activities.rb
92
+ - lib/lesli_view/items/attachment.html.erb
93
+ - lib/lesli_view/items/attachment.rb
90
94
  - lib/lesli_view/items/attachments.html.erb
91
95
  - lib/lesli_view/items/attachments.rb
92
96
  - lib/lesli_view/items/discussion.html.erb
@@ -116,13 +120,14 @@ files:
116
120
  - readme.md
117
121
  homepage: https://www.lesli.dev/
118
122
  licenses:
119
- - GPL-3.0
123
+ - GPL-3.0-or-later
120
124
  metadata:
121
125
  homepage_uri: https://www.lesli.dev/
122
126
  changelog_uri: https://github.com/LesliTech/LesliView/releases
123
127
  source_code_uri: https://github.com/LesliTech/LesliView
124
128
  bug_tracker_uri: https://github.com/LesliTech/LesliView/issues
125
129
  documentation_uri: https://www.lesli.dev/gems/view/
130
+ post_install_message:
126
131
  rdoc_options: []
127
132
  require_paths:
128
133
  - lib
@@ -130,14 +135,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
130
135
  requirements:
131
136
  - - ">="
132
137
  - !ruby/object:Gem::Version
133
- version: '0'
138
+ version: '3.3'
139
+ - - "<"
140
+ - !ruby/object:Gem::Version
141
+ version: '4.0'
134
142
  required_rubygems_version: !ruby/object:Gem::Requirement
135
143
  requirements:
136
144
  - - ">="
137
145
  - !ruby/object:Gem::Version
138
146
  version: '0'
139
147
  requirements: []
140
- rubygems_version: 3.7.1
148
+ rubygems_version: 3.5.16
149
+ signing_key:
141
150
  specification_version: 4
142
151
  summary: A Rails ViewComponent-based UI library for The Lesli Framework.
143
152
  test_files: []