forked from fixin.me/fixin.me
Add Measurements tab and #new form
This commit is contained in:
parent
3d7daa8944
commit
9d60eee16b
1
app/assets/images/pictograms/plus-multiple-outline.svg
Normal file
1
app/assets/images/pictograms/plus-multiple-outline.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" id="icon" viewBox="0 0 24 24"><path d="M6,11H11V6H17V11H22V17H17V22H11V17H6V11M13,15V20H15V15H20V13H15V8H13V13H8V15H13M2,13V7H7V2H13V4H9V9H4V13H2Z" /></svg>
|
After Width: | Height: | Size: 197 B |
1
app/assets/images/pictograms/scale-bathroom.svg
Normal file
1
app/assets/images/pictograms/scale-bathroom.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" id="icon" viewBox="0 0 24 24"><path d="M5,2H19A2,2 0 0,1 21,4V20A2,2 0 0,1 19,22H5A2,2 0 0,1 3,20V4A2,2 0 0,1 5,2M12,4A4,4 0 0,0 8,8H11.26L10.85,5.23L12.9,8H16A4,4 0 0,0 12,4M5,10V20H19V10H5Z" /></svg>
|
After Width: | Height: | Size: 242 B |
@ -200,9 +200,7 @@ textarea:read-only {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.header {
|
header {
|
||||||
display: flex;
|
|
||||||
gap: 0.8em;
|
|
||||||
grid-area: header;
|
grid-area: header;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,6 +241,18 @@ textarea:read-only {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.buttongrid {
|
||||||
|
display: grid;
|
||||||
|
gap: 0.4em;
|
||||||
|
grid-template-areas: "context empty tools";
|
||||||
|
grid-template-columns: auto 1fr auto;
|
||||||
|
grid-template-rows: max-content;
|
||||||
|
}
|
||||||
|
.tools {
|
||||||
|
grid-area: tools;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#flashes {
|
#flashes {
|
||||||
display: grid;
|
display: grid;
|
||||||
gap: 0.2em;
|
gap: 0.2em;
|
||||||
@ -502,6 +512,10 @@ table.items select:focus-visible {
|
|||||||
.extendedright {
|
.extendedright {
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
}
|
}
|
||||||
|
.htoolbox {
|
||||||
|
display: flex;
|
||||||
|
gap: 0.8em;
|
||||||
|
}
|
||||||
[disabled] {
|
[disabled] {
|
||||||
border-color: var(--color-border-gray) !important;
|
border-color: var(--color-border-gray) !important;
|
||||||
color: var(--color-border-gray) !important;
|
color: var(--color-border-gray) !important;
|
||||||
@ -512,15 +526,3 @@ table.items select:focus-visible {
|
|||||||
.unwrappable {
|
.unwrappable {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.buttongrid {
|
|
||||||
display: grid;
|
|
||||||
gap: 0.4em;
|
|
||||||
grid-template-areas: "context empty tools";
|
|
||||||
grid-template-columns: auto 1fr auto;
|
|
||||||
grid-template-rows: max-content;
|
|
||||||
}
|
|
||||||
.tools {
|
|
||||||
grid-area: tools;
|
|
||||||
}
|
|
||||||
|
14
app/controllers/measurements_controller.rb
Normal file
14
app/controllers/measurements_controller.rb
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
class MeasurementsController < ApplicationController
|
||||||
|
def index
|
||||||
|
@quantities = current_user.quantities.ordered
|
||||||
|
end
|
||||||
|
|
||||||
|
def new
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
end
|
||||||
|
end
|
@ -125,6 +125,7 @@ module ApplicationHelper
|
|||||||
|
|
||||||
def navigation_menu
|
def navigation_menu
|
||||||
menu_tabs = [
|
menu_tabs = [
|
||||||
|
['measurements', 'scale-bathroom', :restricted],
|
||||||
['quantities', 'axis-arrow', :restricted, 'right'],
|
['quantities', 'axis-arrow', :restricted, 'right'],
|
||||||
['units', 'weight-gram', :restricted],
|
['units', 'weight-gram', :restricted],
|
||||||
['users', 'account-multiple-outline', :admin],
|
['users', 'account-multiple-outline', :admin],
|
||||||
@ -144,6 +145,11 @@ module ApplicationHelper
|
|||||||
button_to name, options, html_options
|
button_to name, options, html_options
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def image_button_tag(name, image = nil, html_options = {})
|
||||||
|
name, html_options = link_or_button_options(:button, name, image, html_options)
|
||||||
|
button_tag name, html_options
|
||||||
|
end
|
||||||
|
|
||||||
def image_link_to(name, image = nil, options = nil, html_options = {})
|
def image_link_to(name, image = nil, options = nil, html_options = {})
|
||||||
name, html_options = link_or_button_options(:link, name, image, html_options)
|
name, html_options = link_or_button_options(:link, name, image, html_options)
|
||||||
link_to name, options, html_options
|
link_to name, options, html_options
|
||||||
|
2
app/helpers/measurements_helper.rb
Normal file
2
app/helpers/measurements_helper.rb
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
module MeasurementsHelper
|
||||||
|
end
|
@ -23,7 +23,7 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<header class="header">
|
<header class="htoolbox">
|
||||||
<%= image_link_to t(".source_code"), "code-braces", source_code_url %>
|
<%= image_link_to t(".source_code"), "code-braces", source_code_url %>
|
||||||
<%= image_link_to t(".issue_tracker"), "bug-outline", issue_tracker_url,
|
<%= image_link_to t(".issue_tracker"), "bug-outline", issue_tracker_url,
|
||||||
class: "extendedright" %>
|
class: "extendedright" %>
|
||||||
|
16
app/views/measurements/index.html.erb
Normal file
16
app/views/measurements/index.html.erb
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<div class="main">
|
||||||
|
<% if current_user.at_least(:active) %>
|
||||||
|
<%# TODO: show hint when no quantities/units defined %>
|
||||||
|
<%= form_tag new_measurement_path, method: :get, class: "htoolbox",
|
||||||
|
data: {turbo_stream: true} do %>
|
||||||
|
<%= select_tag :id,
|
||||||
|
options_from_collection_for_select(@quantities, :id,
|
||||||
|
->(q) { sanitize('- '*q.depth + q.name) }) %>
|
||||||
|
<%= image_button_tag t('.new_quantity'), 'plus-outline', name: :scope -%>
|
||||||
|
<%= image_button_tag t('.new_children'), 'plus-multiple-outline', name: :scope,
|
||||||
|
value: :children -%>
|
||||||
|
<%= image_button_tag t('.new_subtree'), 'plus-multiple-outline', name: :scope,
|
||||||
|
value: :subtree -%>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
@ -62,6 +62,12 @@ en:
|
|||||||
revert: Revert
|
revert: Revert
|
||||||
sign_out: Sign out
|
sign_out: Sign out
|
||||||
source_code: Get code
|
source_code: Get code
|
||||||
|
measurements:
|
||||||
|
navigation: Measurements
|
||||||
|
index:
|
||||||
|
new_quantity: Add selected
|
||||||
|
new_children: Add children
|
||||||
|
new_subtree: Add subtree
|
||||||
quantities:
|
quantities:
|
||||||
navigation: Quantities
|
navigation: Quantities
|
||||||
no_items: There are no configured quantities. You can Add some or Import from defaults.
|
no_items: There are no configured quantities. You can Add some or Import from defaults.
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
|
resources :measurements
|
||||||
|
|
||||||
resources :quantities, except: [:show], path_names: {new: '(/:id)/new'} do
|
resources :quantities, except: [:show], path_names: {new: '(/:id)/new'} do
|
||||||
member { post :reparent }
|
member { post :reparent }
|
||||||
end
|
end
|
||||||
|
8
test/controllers/measurements_controller_test.rb
Normal file
8
test/controllers/measurements_controller_test.rb
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
require "test_helper"
|
||||||
|
|
||||||
|
class MeasurementsControllerTest < ActionDispatch::IntegrationTest
|
||||||
|
#test "should get index" do
|
||||||
|
# get measurements_index_url
|
||||||
|
# assert_response :success
|
||||||
|
#end
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user