forked from fixin.me/fixin.me
Unit: limit symbol length, change name:string -> description:text
Closes #11 Closes #12
This commit is contained in:
parent
d6fdff252a
commit
3711251656
@ -98,16 +98,21 @@ input[type=submit] {
|
|||||||
width: fit-content;
|
width: fit-content;
|
||||||
}
|
}
|
||||||
input:not([type=submit]):not([type=checkbox]),
|
input:not([type=submit]):not([type=checkbox]),
|
||||||
select {
|
select,
|
||||||
|
textarea {
|
||||||
padding: 0.2em 0.4em;
|
padding: 0.2em 0.4em;
|
||||||
}
|
}
|
||||||
.button,
|
.button,
|
||||||
button,
|
button,
|
||||||
input,
|
input,
|
||||||
select {
|
select,
|
||||||
|
textarea {
|
||||||
border: solid 1px var(--color-gray);
|
border: solid 1px var(--color-gray);
|
||||||
border-radius: 0.25em;
|
border-radius: 0.25em;
|
||||||
}
|
}
|
||||||
|
textarea {
|
||||||
|
margin: 0
|
||||||
|
}
|
||||||
.button > svg,
|
.button > svg,
|
||||||
.tab > svg,
|
.tab > svg,
|
||||||
button > svg {
|
button > svg {
|
||||||
@ -151,7 +156,8 @@ input[type=checkbox]:checked {
|
|||||||
-webkit-appearance: checkbox;
|
-webkit-appearance: checkbox;
|
||||||
}
|
}
|
||||||
input:hover,
|
input:hover,
|
||||||
select:hover {
|
select:hover,
|
||||||
|
textarea:hover {
|
||||||
border-color: #009ade;
|
border-color: #009ade;
|
||||||
outline: solid 1px #009ade;
|
outline: solid 1px #009ade;
|
||||||
}
|
}
|
||||||
@ -160,11 +166,13 @@ select:hover {
|
|||||||
}
|
}
|
||||||
input:focus-visible,
|
input:focus-visible,
|
||||||
select:focus-within,
|
select:focus-within,
|
||||||
select:focus-visible {
|
select:focus-visible,
|
||||||
|
textarea:focus-visible {
|
||||||
accent-color: #006c9b;
|
accent-color: #006c9b;
|
||||||
background-color: var(--color-focus-gray);
|
background-color: var(--color-focus-gray);
|
||||||
}
|
}
|
||||||
input[type=text]:read-only {
|
input[type=text]:read-only,
|
||||||
|
textarea:read-only {
|
||||||
border: none;
|
border: none;
|
||||||
padding-left: 0;
|
padding-left: 0;
|
||||||
padding-right: 0;
|
padding-right: 0;
|
||||||
@ -336,7 +344,7 @@ table.items th,
|
|||||||
table.items td {
|
table.items td {
|
||||||
padding-inline: 1em 0;
|
padding-inline: 1em 0;
|
||||||
}
|
}
|
||||||
table.items td:has(input) {
|
table.items td:has(input, textarea) {
|
||||||
padding-inline-start: calc(0.6em - 0.9px);
|
padding-inline-start: calc(0.6em - 0.9px);
|
||||||
}
|
}
|
||||||
table.items th:last-child {
|
table.items th:last-child {
|
||||||
@ -367,7 +375,7 @@ table.items td.link a::after {
|
|||||||
table.items td.subunit {
|
table.items td.subunit {
|
||||||
padding-inline-start: 1.8em;
|
padding-inline-start: 1.8em;
|
||||||
}
|
}
|
||||||
table.items td.subunit:has(input) {
|
table.items td.subunit:has(input, textarea) {
|
||||||
padding-inline-start: calc(1.4em - 1px);
|
padding-inline-start: calc(1.4em - 1px);
|
||||||
}
|
}
|
||||||
table.items td.actions {
|
table.items td.actions {
|
||||||
@ -390,6 +398,9 @@ table.items tr.dropzone::after {
|
|||||||
table.items td.handle {
|
table.items td.handle {
|
||||||
cursor: move;
|
cursor: move;
|
||||||
}
|
}
|
||||||
|
table.items tr.form td {
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
|
||||||
/* TODO: replace :hover:focus-visible combos with proper LOVE stye order */
|
/* TODO: replace :hover:focus-visible combos with proper LOVE stye order */
|
||||||
/* TODO: Update styling, including rem removal. */
|
/* TODO: Update styling, including rem removal. */
|
||||||
@ -440,7 +451,8 @@ table.items input[type=submit] {
|
|||||||
table.items .button:not(:hover),
|
table.items .button:not(:hover),
|
||||||
table.items button:not(:hover),
|
table.items button:not(:hover),
|
||||||
table.items input:not(:hover),
|
table.items input:not(:hover),
|
||||||
table.items select:not(:hover) {
|
table.items select:not(:hover),
|
||||||
|
table.items textarea:not(:hover) {
|
||||||
border-color: var(--color-border-gray);
|
border-color: var(--color-border-gray);
|
||||||
}
|
}
|
||||||
table.items .button:not(:hover),
|
table.items .button:not(:hover),
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
class Unit < ApplicationRecord
|
class Unit < ApplicationRecord
|
||||||
ATTRIBUTES = [:symbol, :name, :multiplier, :base_id]
|
ATTRIBUTES = [:symbol, :description, :multiplier, :base_id]
|
||||||
|
|
||||||
belongs_to :user, optional: true
|
belongs_to :user, optional: true
|
||||||
belongs_to :base, optional: true, class_name: "Unit"
|
belongs_to :base, optional: true, class_name: "Unit"
|
||||||
@ -11,7 +11,7 @@ class Unit < ApplicationRecord
|
|||||||
end
|
end
|
||||||
validates :symbol, presence: true, uniqueness: {scope: :user_id},
|
validates :symbol, presence: true, uniqueness: {scope: :user_id},
|
||||||
length: {maximum: columns_hash['symbol'].limit}
|
length: {maximum: columns_hash['symbol'].limit}
|
||||||
validates :name, length: {maximum: columns_hash['name'].limit}
|
validates :description, length: {maximum: columns_hash['description'].limit}
|
||||||
validates :multiplier, numericality: {equal_to: 1}, unless: :base
|
validates :multiplier, numericality: {equal_to: 1}, unless: :base
|
||||||
validates :multiplier, numericality: {other_than: 0}, if: :base
|
validates :multiplier, numericality: {other_than: 0}, if: :base
|
||||||
|
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
maxlength: @unit.class.columns_hash['symbol'].limit, autocomplete: "off" %>
|
maxlength: @unit.class.columns_hash['symbol'].limit, autocomplete: "off" %>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<%= form.text_field :name, form: :unit_form, size: 30,
|
<%= form.text_area :description, form: :unit_form, cols: 30, rows: 1, escape: false,
|
||||||
maxlength: @unit.class.columns_hash['name'].limit, autocomplete: "off" %>
|
maxlength: @unit.class.columns_hash['description'].limit, autocomplete: "off" %>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<% unless @unit.base.nil? %>
|
<% unless @unit.base.nil? %>
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<%= link_to unit, edit_unit_path(unit), id: dom_id(unit, :edit),
|
<%= link_to unit, edit_unit_path(unit), id: dom_id(unit, :edit),
|
||||||
onclick: 'this.blur();', data: {turbo_stream: true} %>
|
onclick: 'this.blur();', data: {turbo_stream: true} %>
|
||||||
</td>
|
</td>
|
||||||
<td><%= unit.name %></td>
|
<td><%= unit.description %></td>
|
||||||
<td class="number"><%= scientifize(unit.multiplier) %></td>
|
<td class="number"><%= scientifize(unit.multiplier) %></td>
|
||||||
|
|
||||||
<% if current_user.at_least(:active) %>
|
<% if current_user.at_least(:active) %>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th><%= User.human_attribute_name(:symbol).capitalize %></th>
|
<th><%= User.human_attribute_name(:symbol).capitalize %></th>
|
||||||
<th><%= User.human_attribute_name(:name).capitalize %></th>
|
<th><%= User.human_attribute_name(:description).capitalize %></th>
|
||||||
<th><%= User.human_attribute_name(:multiplier).capitalize %></th>
|
<th><%= User.human_attribute_name(:multiplier).capitalize %></th>
|
||||||
<% if current_user.at_least(:active) %>
|
<% if current_user.at_least(:active) %>
|
||||||
<th><%= t :actions %></th>
|
<th><%= t :actions %></th>
|
||||||
|
@ -2,8 +2,8 @@ class CreateUnits < ActiveRecord::Migration[7.0]
|
|||||||
def change
|
def change
|
||||||
create_table :units do |t|
|
create_table :units do |t|
|
||||||
t.references :user, foreign_key: true
|
t.references :user, foreign_key: true
|
||||||
t.string :symbol, null: false
|
t.string :symbol, null: false, limit: 15
|
||||||
t.string :name
|
t.text :description
|
||||||
t.decimal :multiplier, null: false, precision: 30, scale: 15, default: 1.0
|
t.decimal :multiplier, null: false, precision: 30, scale: 15, default: 1.0
|
||||||
t.references :base
|
t.references :base
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user