luck_remover 0.8.0 → 0.9.0
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 +4 -4
- data/app/controllers/luck_remover/goals_controller.rb +7 -3
- data/app/models/luck_remover/goal.rb +8 -0
- data/app/views/luck_remover/goals/_form.html.erb +3 -0
- data/app/views/luck_remover/goals/edit.html.erb +5 -0
- data/app/views/luck_remover/goals/index.html.erb +5 -0
- data/db/migrate/20261028152059_add_archived_to_luck_remover_goals.rb +5 -0
- data/lib/luck_remover/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ce01c50a6acd9c471ac05b2089f50b37cf5018b52ac8477e0d93e1cf4c55a7ca
|
|
4
|
+
data.tar.gz: b400f56a1f90c208ed3898aa3950d70e9b126e72e7469eb4d5c85bbf8bfc99bf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 538b819d7c67047da6bd1982ff9c289c292e767f4c9c7f589574f55c304b74ae44bb89cd06e4e31ab12b5be6fed6f9028a67c3ac45983ae62ff36a440fce1f89
|
|
7
|
+
data.tar.gz: ab3b709e3421ad8c96694a08e00b33467ec72ea987258cae4cd19ae0fb2c4881d5df6660289b733382b3b30e3f8c92642667adffd36f4401efe69b499241623a
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
module LuckRemover
|
|
2
2
|
class GoalsController < LuckRemover.parent_controller.constantize
|
|
3
|
-
helper_method :page_query
|
|
3
|
+
helper_method :page_query, :archived_list?
|
|
4
4
|
|
|
5
5
|
def index
|
|
6
|
-
@readings = goals_in_area.order(:name).map { |goal| Reading.of(goal) }
|
|
6
|
+
@readings = goals_in_area.where(archived: archived_list?).order(:name).map { |goal| Reading.of(goal) }
|
|
7
7
|
@person_names = LuckRemover.people(current_goal_owner).to_h { |label, id| [ id, label ] }
|
|
8
8
|
end
|
|
9
9
|
|
|
@@ -50,7 +50,7 @@ module LuckRemover
|
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
def goal_params
|
|
53
|
-
params.expect(goal: [ :name, :metric_key, :person_id, :target, :direction, :period, :status ])
|
|
53
|
+
params.expect(goal: [ :name, :metric_key, :person_id, :target, :direction, :period, :status, :archived ])
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
def goal_scope
|
|
@@ -69,6 +69,10 @@ module LuckRemover
|
|
|
69
69
|
url_from(params[:return_to]) || goals_path
|
|
70
70
|
end
|
|
71
71
|
|
|
72
|
+
def archived_list?
|
|
73
|
+
params[:archived] == "true"
|
|
74
|
+
end
|
|
75
|
+
|
|
72
76
|
def area
|
|
73
77
|
params[:area].presence
|
|
74
78
|
end
|
|
@@ -5,6 +5,7 @@ module LuckRemover
|
|
|
5
5
|
belongs_to :owner, polymorphic: true
|
|
6
6
|
|
|
7
7
|
scope :for_owner, ->(owner) { where(owner: owner) }
|
|
8
|
+
scope :unarchived, -> { where(archived: false) }
|
|
8
9
|
scope :in_area, ->(area) { where(metric_key: LuckRemover.metrics.in_area(area).map { |stat| stat.key.to_s }) }
|
|
9
10
|
|
|
10
11
|
enum :direction, { at_least: "at_least", at_most: "at_most" }, validate: true
|
|
@@ -15,6 +16,7 @@ module LuckRemover
|
|
|
15
16
|
validate :metric_is_registered
|
|
16
17
|
validate :person_is_one_the_host_gives, if: :person_id
|
|
17
18
|
validate :metric_is_readable_for_one_person, if: :person_id
|
|
19
|
+
validate :only_finished_goals_are_archived, if: :archived
|
|
18
20
|
|
|
19
21
|
def standing(now: Time.current, **inputs)
|
|
20
22
|
value = LuckRemover.metric(metric_key).read(range: current_period(now), **for_person, **inputs).value
|
|
@@ -44,6 +46,12 @@ module LuckRemover
|
|
|
44
46
|
errors.add(:metric_key, "#{metric_key} cannot be read for one person")
|
|
45
47
|
end
|
|
46
48
|
|
|
49
|
+
def only_finished_goals_are_archived
|
|
50
|
+
return if achieved? || abandoned?
|
|
51
|
+
|
|
52
|
+
errors.add(:base, "Only achieved or abandoned goals can be archived")
|
|
53
|
+
end
|
|
54
|
+
|
|
47
55
|
def metric_is_registered
|
|
48
56
|
return if LuckRemover.metrics.registered?(metric_key.to_s)
|
|
49
57
|
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
<% goal.errors[:base].each do |message| %>
|
|
2
|
+
<%= ui_alert(message: message, type: :error) %>
|
|
3
|
+
<% end %>
|
|
1
4
|
<%= ui_form_field(attribute: "goal[name]", label: "Name", required: true, value: goal.name, errors: goal.errors[:name]) %>
|
|
2
5
|
|
|
3
6
|
<% goal.errors[:metric_key].each do |message| %>
|
|
@@ -5,6 +5,11 @@
|
|
|
5
5
|
<%= ui_button(label: "Save") %>
|
|
6
6
|
<% end %>
|
|
7
7
|
<%= ui_action_menu do %>
|
|
8
|
+
<% if @goal.archived %>
|
|
9
|
+
<%= ui_action_menu_item(label: "Unarchive", href: luck_remover.goal_path(@goal, **page_query, goal: { archived: false }), method: :patch) %>
|
|
10
|
+
<% else %>
|
|
11
|
+
<%= ui_action_menu_item(label: "Archive", href: luck_remover.goal_path(@goal, **page_query, goal: { archived: true }), method: :patch) %>
|
|
12
|
+
<% end %>
|
|
8
13
|
<%= ui_action_menu_item(label: "Delete", href: luck_remover.goal_path(@goal, **page_query), method: :delete) %>
|
|
9
14
|
<% end %>
|
|
10
15
|
<% end %>
|
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
<%= ui_page(max_width: :xl) do %>
|
|
4
4
|
<%= ui_page_header(title: "Goals", action_url: new_goal_path, action_label: "Add") do |header| %>
|
|
5
5
|
<% header.action do %>
|
|
6
|
+
<% if archived_list? %>
|
|
7
|
+
<%= ui_button(label: "Show current", href: luck_remover.goals_path(**page_query), variant: :secondary) %>
|
|
8
|
+
<% else %>
|
|
9
|
+
<%= ui_button(label: "Show archived", href: luck_remover.goals_path(**page_query, archived: true), variant: :secondary) %>
|
|
10
|
+
<% end %>
|
|
6
11
|
<%= ui_button(label: "Add", href: new_goal_path) %>
|
|
7
12
|
<% end %>
|
|
8
13
|
<% end %>
|
data/lib/luck_remover/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: luck_remover
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tyler Schneider
|
|
@@ -95,6 +95,7 @@ files:
|
|
|
95
95
|
- db/migrate/20261022212722_create_luck_remover_goals.rb
|
|
96
96
|
- db/migrate/20261023134729_add_person_id_to_luck_remover_goals.rb
|
|
97
97
|
- db/migrate/20261028142026_add_status_to_luck_remover_goals.rb
|
|
98
|
+
- db/migrate/20261028152059_add_archived_to_luck_remover_goals.rb
|
|
98
99
|
- lib/luck_remover.rb
|
|
99
100
|
- lib/luck_remover/engine.rb
|
|
100
101
|
- lib/luck_remover/metric_registry.rb
|