luck_remover 0.1.0 → 0.2.1
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/application_controller.rb +1 -0
- data/app/controllers/luck_remover/goals_controller.rb +48 -0
- data/app/models/luck_remover/goal.rb +1 -0
- data/app/views/luck_remover/goals/_form.html.erb +12 -0
- data/app/views/luck_remover/goals/edit.html.erb +10 -0
- data/app/views/luck_remover/goals/index.html.erb +21 -0
- data/app/views/luck_remover/goals/new.html.erb +7 -0
- data/config/routes.rb +1 -0
- data/lib/luck_remover/metric_registry.rb +4 -0
- data/lib/luck_remover/version.rb +1 -1
- data/lib/luck_remover.rb +4 -0
- metadata +20 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1967a2ea5bdb16091fa57ae44a15e6a6d7ce41a3c23c91c1bad24a8520ff81b0
|
|
4
|
+
data.tar.gz: d8f41aff30a6b3b74ba81433b09e78bd46d41a6dc34688fb8ffc1917e60a0796
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c75087a236f27d0007a6756c72c2bbedf53f31c8e06582f676756ea739876f08899bdf7889fe060b56568b39491edd3acfa85c177ed1bd81e1d4f2539e642b74
|
|
7
|
+
data.tar.gz: 766896c86c8f421efaf80e5e0986d409e381313ba5df97d9acf9a4f6d450d19123791396fd27eb9f1e1492742df1057be3858c54e59b647ff9f3050fdedce4d8
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
module LuckRemover
|
|
2
|
+
class GoalsController < LuckRemover.parent_controller.constantize
|
|
3
|
+
def index
|
|
4
|
+
@goals = goal_scope.order(:name)
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def new
|
|
8
|
+
@goal = goal_scope.new
|
|
9
|
+
@metrics = LuckRemover.metrics.all
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def create
|
|
13
|
+
@goal = goal_scope.new(goal_params)
|
|
14
|
+
return redirect_to goals_path if @goal.save
|
|
15
|
+
|
|
16
|
+
@metrics = LuckRemover.metrics.all
|
|
17
|
+
render :new, status: :unprocessable_content
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def edit
|
|
21
|
+
@goal = goal_scope.find(params[:id])
|
|
22
|
+
@metrics = LuckRemover.metrics.all
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def update
|
|
26
|
+
@goal = goal_scope.find(params[:id])
|
|
27
|
+
return redirect_to goals_path if @goal.update(goal_params)
|
|
28
|
+
|
|
29
|
+
@metrics = LuckRemover.metrics.all
|
|
30
|
+
render :edit, status: :unprocessable_content
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def destroy
|
|
34
|
+
goal_scope.find(params[:id]).destroy!
|
|
35
|
+
redirect_to goals_path
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
private
|
|
39
|
+
|
|
40
|
+
def goal_params
|
|
41
|
+
params.expect(goal: [ :name, :metric_key, :target, :direction, :period ])
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def goal_scope
|
|
45
|
+
Goal.for_owner(send(LuckRemover.current_owner_method))
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -9,6 +9,7 @@ module LuckRemover
|
|
|
9
9
|
enum :direction, { at_least: "at_least", at_most: "at_most" }, validate: true
|
|
10
10
|
enum :period, { week: "week", month: "month" }, validate: true
|
|
11
11
|
|
|
12
|
+
validates :name, :target, presence: true
|
|
12
13
|
validate :metric_is_registered
|
|
13
14
|
|
|
14
15
|
def standing(now: Time.current)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<%= ui_form_field(attribute: "goal[name]", label: "Name", required: true, value: goal.name, errors: goal.errors[:name]) %>
|
|
2
|
+
|
|
3
|
+
<% goal.errors[:metric_key].each do |message| %>
|
|
4
|
+
<%= ui_alert(message: "Metric #{message}", type: :error) %>
|
|
5
|
+
<% end %>
|
|
6
|
+
<% metrics.each do |metric| %>
|
|
7
|
+
<%= ui_radio_card(name: "goal[metric_key]", value: metric.key, label: metric.title, hint: metric.definition, checked: goal.metric_key.to_s == metric.key.to_s) %>
|
|
8
|
+
<% end %>
|
|
9
|
+
|
|
10
|
+
<%= ui_form_field(attribute: "goal[target]", label: "Target", type: :number, step: "any", required: true, value: goal.target, errors: goal.errors[:target]) %>
|
|
11
|
+
<%= ui_form_field(attribute: "goal[direction]", label: "Direction", type: :select, required: true, options: [["At least", "at_least"], ["At most", "at_most"]], value: goal.direction, errors: goal.errors[:direction]) %>
|
|
12
|
+
<%= ui_form_field(attribute: "goal[period]", label: "Period", type: :select, required: true, options: [["Week", "week"], ["Month", "month"]], value: goal.period, errors: goal.errors[:period]) %>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<%= ui_form_page(title: "Edit", subtitle: @goal.name) %>
|
|
2
|
+
<%= ui_page(max_width: :md) do %>
|
|
3
|
+
<%= ui_form(action: luck_remover.goal_path(@goal), method: :patch) do %>
|
|
4
|
+
<%= render "luck_remover/goals/form", goal: @goal, metrics: @metrics %>
|
|
5
|
+
<%= ui_button(label: "Save") %>
|
|
6
|
+
<% end %>
|
|
7
|
+
<%= ui_action_menu do %>
|
|
8
|
+
<%= ui_action_menu_item(label: "Delete", href: luck_remover.goal_path(@goal), method: :delete) %>
|
|
9
|
+
<% end %>
|
|
10
|
+
<% end %>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<%= ui_show_page(title: "Goals") %>
|
|
2
|
+
<%= ui_page(max_width: :xl) do %>
|
|
3
|
+
<%= ui_page_header(title: "Goals", action_url: luck_remover.new_goal_path, action_label: "Add") do |header| %>
|
|
4
|
+
<% header.action do %>
|
|
5
|
+
<%= ui_button(label: "Add", href: luck_remover.new_goal_path) %>
|
|
6
|
+
<% end %>
|
|
7
|
+
<% end %>
|
|
8
|
+
<% rows = @goals.map do |goal|
|
|
9
|
+
{ name: goal.name,
|
|
10
|
+
edit_url: luck_remover.edit_goal_path(goal),
|
|
11
|
+
metric: LuckRemover.metric(goal.metric_key).title,
|
|
12
|
+
target: number_with_precision(goal.target, precision: 2, strip_insignificant_zeros: true),
|
|
13
|
+
direction: goal.direction.humanize,
|
|
14
|
+
period: goal.period.humanize }
|
|
15
|
+
end %>
|
|
16
|
+
<%= ui_data_table(
|
|
17
|
+
items: rows,
|
|
18
|
+
columns: [{ name: "Name" }, { metric: "Metric" }, { target: "Target" }, { direction: "Direction" }, { period: "Period" }],
|
|
19
|
+
empty_message: "No goals yet."
|
|
20
|
+
) { |table| table.link(:name) { |row| row[:edit_url] } } %>
|
|
21
|
+
<% end %>
|
data/config/routes.rb
CHANGED
data/lib/luck_remover/version.rb
CHANGED
data/lib/luck_remover.rb
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
require "readout"
|
|
2
|
+
require "keystone_ui"
|
|
2
3
|
require "luck_remover/version"
|
|
3
4
|
require "luck_remover/engine"
|
|
4
5
|
require "luck_remover/metric_registry"
|
|
5
6
|
|
|
6
7
|
module LuckRemover
|
|
8
|
+
mattr_accessor :parent_controller, default: "LuckRemover::ApplicationController"
|
|
9
|
+
mattr_accessor :current_owner_method, default: nil
|
|
10
|
+
|
|
7
11
|
def self.metrics
|
|
8
12
|
@metrics ||= MetricRegistry.new
|
|
9
13
|
end
|
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.1
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tyler Schneider
|
|
@@ -51,6 +51,20 @@ dependencies:
|
|
|
51
51
|
- - ">="
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
53
|
version: 0.2.0
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: keystone_ui
|
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - ">="
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: 0.51.0
|
|
61
|
+
type: :runtime
|
|
62
|
+
prerelease: false
|
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - ">="
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: 0.51.0
|
|
54
68
|
description: LuckRemover stores goals that name a registered readout Stat, a target,
|
|
55
69
|
a direction and a period, and reports whether the current period met each one.
|
|
56
70
|
email:
|
|
@@ -64,6 +78,7 @@ files:
|
|
|
64
78
|
- Rakefile
|
|
65
79
|
- app/assets/stylesheets/luck_remover/application.css
|
|
66
80
|
- app/controllers/luck_remover/application_controller.rb
|
|
81
|
+
- app/controllers/luck_remover/goals_controller.rb
|
|
67
82
|
- app/helpers/luck_remover/application_helper.rb
|
|
68
83
|
- app/jobs/luck_remover/application_job.rb
|
|
69
84
|
- app/mailers/luck_remover/application_mailer.rb
|
|
@@ -71,6 +86,10 @@ files:
|
|
|
71
86
|
- app/models/luck_remover/goal.rb
|
|
72
87
|
- app/models/luck_remover/standing.rb
|
|
73
88
|
- app/views/layouts/luck_remover/application.html.erb
|
|
89
|
+
- app/views/luck_remover/goals/_form.html.erb
|
|
90
|
+
- app/views/luck_remover/goals/edit.html.erb
|
|
91
|
+
- app/views/luck_remover/goals/index.html.erb
|
|
92
|
+
- app/views/luck_remover/goals/new.html.erb
|
|
74
93
|
- config/routes.rb
|
|
75
94
|
- db/migrate/20261022212722_create_luck_remover_goals.rb
|
|
76
95
|
- lib/luck_remover.rb
|