1
0

Unified hash options style

This commit is contained in:
cryptogopher 2019-11-27 21:24:49 +01:00
parent 1982f3b526
commit 158685459d
21 changed files with 99 additions and 96 deletions

View File

@ -1,5 +1,5 @@
<h2><%= t ".heading" %></h2> <h2><%= t ".heading" %></h2>
<% content_for :sidebar do %> <% content_for :sidebar do %>
<%= render :partial => 'body_trackers/sidebar' %> <%= render partial: 'body_trackers/sidebar' %>
<% end %> <% end %>

View File

@ -1,6 +1,6 @@
<% if User.current.allowed_to?(:manage_common, @project) %> <% if User.current.allowed_to?(:manage_common, @project) %>
<%= link_to t(".link_import_ingredients"), '#', :class => 'icon icon-multiple', <%= link_to t(".link_import_ingredients"), '#', class: 'icon icon-multiple',
:onclick => '$("#import-ingredients").show(); $("#filename").focus(); return false;' %> onclick: '$("#import-ingredients").show(); $("#filename").focus(); return false;' %>
<%= link_to t(".link_new_ingredient"), '#', :class => 'icon icon-add', <%= link_to t(".link_new_ingredient"), '#', class: 'icon icon-add',
:onclick => '$("#add-ingredient").show(); $("#ingredient_name").focus(); return false;' %> onclick: '$("#add-ingredient").show(); $("#ingredient_name").focus(); return false;' %>
<% end %> <% end %>

View File

@ -2,8 +2,8 @@
<h2><%= t ".heading_new_ingredient" %></h2> <h2><%= t ".heading_new_ingredient" %></h2>
<%= labelled_form_for @ingredient, <%= labelled_form_for @ingredient,
:url => project_ingredients_path(@project), url: project_ingredients_path(@project),
:html => {:id => 'ingredient-form'} do |f| %> html: {id: 'ingredient-form'} do |f| %>
<%= error_messages_for @ingredient %> <%= error_messages_for @ingredient %>
<div class="box tabular"> <div class="box tabular">
@ -33,19 +33,20 @@
<%= ff.select :unit_id, unit_options, {label: ''} %> <%= ff.select :unit_id, unit_options, {label: ''} %>
<%= ff.check_box :_destroy, {style: "display:none", label: ''} %> <%= ff.check_box :_destroy, {style: "display:none", label: ''} %>
<%= link_to t(".button_delete_nutrient"), '#', <%= link_to t(".button_delete_nutrient"), '#',
:class => 'icon icon-del', class: 'icon icon-del',
:style => (@ingredient.nutrients.length > 1 ? "" : "display:none"), style: (@ingredient.nutrients.length > 1 ? "" : "display:none"),
:onclick => "deleteNutrient(); return false;" %> onclick: "deleteNutrient(); return false;" %>
</p> </p>
<% end %> <% end %>
<% end %> <% end %>
<p> <p>
<%= link_to t(".button_add_nutrient"), '#', :class => 'icon icon-add', <%= link_to t(".button_add_nutrient"), '#', class: 'icon icon-add',
:onclick => 'addNutrient(); return false;' %> onclick: 'addNutrient(); return false;' %>
</p> </p>
</div> </div>
<%= submit_tag l(:button_create) %> <%= submit_tag l(:button_create) %>
<%= link_to l(:button_cancel), "#", :onclick => '$("#add-ingredient").hide()' %> <%= link_to l(:button_cancel), "#",
onclick: '$("#add-ingredient").hide(); return false;' %>
<% end %> <% end %>
<hr> <hr>
</div> </div>

View File

@ -2,8 +2,8 @@
<h2><%= t ".heading_import_ingredients" %></h2> <h2><%= t ".heading_import_ingredients" %></h2>
<%= form_tag import_project_ingredients_path(@project), <%= form_tag import_project_ingredients_path(@project),
:multipart => true, multipart: true,
:id => 'import-form' do %> id: 'import-form' do %>
<div class="box tabular"> <div class="box tabular">
<p> <p>
<label><%= t ".label_import_select_csv_file" %></label> <label><%= t ".label_import_select_csv_file" %></label>
@ -14,7 +14,8 @@
</p> </p>
</div> </div>
<%= submit_tag l(:button_import) %> <%= submit_tag l(:button_import) %>
<%= link_to l(:button_cancel), "#", :onclick => '$("#import-ingredients").hide()' %> <%= link_to l(:button_cancel), "#",
onclick: '$("#import-ingredients").hide(); return false;' %>
<% end %> <% end %>
<hr> <hr>
</div> </div>

View File

@ -1,5 +1,5 @@
<%= render :partial => 'ingredients/filters', <%= render partial: 'ingredients/filters',
:locals => {:url => filter_project_ingredients_path(@project)} %> locals: {url: filter_project_ingredients_path(@project)} %>
<% if @ingredients.any? { |i| i.persisted? } %> <% if @ingredients.any? { |i| i.persisted? } %>
<table class="list"> <table class="list">

View File

@ -1,8 +1,8 @@
<%= render :partial => 'ingredients/filters', <%= render partial: 'ingredients/filters',
:locals => {:url => filter_nutrients_project_ingredients_path(@project)} %> locals: {url: filter_nutrients_project_ingredients_path(@project)} %>
<% if @nutrients.any? %> <% if @nutrients.any? %>
<%= render :partial => 'ingredients/options' %> <%= render partial: 'ingredients/options' %>
<table class="nutrients list odd-even"> <table class="nutrients list odd-even">
<thead> <thead>

View File

@ -1,18 +1,18 @@
<% content_for :sidebar do %> <% content_for :sidebar do %>
<%= render :partial => 'body_trackers/sidebar' %> <%= render partial: 'body_trackers/sidebar' %>
<% end %> <% end %>
<div class="contextual"> <div class="contextual">
<%= link_to t(".heading_nutrient_view"), nutrients_project_ingredients_path(@project), <%= link_to t(".heading_nutrient_view"), nutrients_project_ingredients_path(@project),
:class => 'icon icon-stats' %> class: 'icon icon-stats' %>
<%= render :partial => 'ingredients/contextual' %> <%= render partial: 'ingredients/contextual' %>
</div> </div>
<%= render :partial => 'ingredients/import' %> <%= render partial: 'ingredients/import' %>
<%= render :partial => 'ingredients/form' %> <%= render partial: 'ingredients/form' %>
<h2><%= t ".heading" %></h2> <h2><%= t ".heading" %></h2>
<div id='ingredients'> <div id='ingredients'>
<%= render :partial => 'ingredients/list' %> <%= render partial: 'ingredients/list' %>
</div> </div>

View File

@ -1,18 +1,18 @@
<% content_for :sidebar do %> <% content_for :sidebar do %>
<%= render :partial => 'body_trackers/sidebar' %> <%= render partial: 'body_trackers/sidebar' %>
<% end %> <% end %>
<div class="contextual"> <div class="contextual">
<%= link_to t(".heading_ingredient_list"), project_ingredients_path(@project), <%= link_to t(".heading_ingredient_list"), project_ingredients_path(@project),
:class => 'icon icon-list' %> class: 'icon icon-list' %>
<%= render :partial => 'ingredients/contextual' %> <%= render partial: 'ingredients/contextual' %>
</div> </div>
<%= render :partial => 'ingredients/import' %> <%= render partial: 'ingredients/import' %>
<%= render :partial => 'ingredients/form' %> <%= render partial: 'ingredients/form' %>
<h2><%= t ".heading" %></h2> <h2><%= t ".heading" %></h2>
<div id='nutrients'> <div id='nutrients'>
<%= render :partial => 'ingredients/list_nutrients' %> <%= render partial: 'ingredients/list_nutrients' %>
</div> </div>

View File

@ -1,3 +1,3 @@
$('div[id^=flash_]').remove(); $('div[id^=flash_]').remove();
$('#content').prepend('<%= escape_javascript(render_flash_messages) %>'); $('#content').prepend('<%= escape_javascript(render_flash_messages) %>');
$('#ingredients').html('<%= escape_javascript(render :partial => 'ingredients/list') %>'); $('#ingredients').html('<%= escape_javascript(render partial: 'ingredients/list') %>');

View File

@ -1,3 +1,3 @@
$('div[id^=flash_]').remove(); $('div[id^=flash_]').remove();
$('#content').prepend('<%= escape_javascript(render_flash_messages) %>'); $('#content').prepend('<%= escape_javascript(render_flash_messages) %>');
$('#nutrients').html('<%= escape_javascript(render :partial => 'ingredients/list_nutrients') %>'); $('#nutrients').html('<%= escape_javascript(render partial: 'ingredients/list_nutrients') %>');

View File

@ -1,3 +1,3 @@
<% content_for :header_tags do %> <% content_for :header_tags do %>
<%= stylesheet_link_tag 'body_tracking', :plugin => 'body_tracking' %> <%= stylesheet_link_tag 'body_tracking', plugin: 'body_tracking' %>
<% end %> <% end %>

View File

@ -2,8 +2,8 @@
<h2><%= t ".heading_new_measurement" %></h2> <h2><%= t ".heading_new_measurement" %></h2>
<%= labelled_form_for @measurement, <%= labelled_form_for @measurement,
:url => project_measurements_path(@project), url: project_measurements_path(@project),
:html => {:id => 'measurement-form'} do |f| %> html: {id: 'measurement-form'} do |f| %>
<%= error_messages_for @measurement %> <%= error_messages_for @measurement %>
<div class="box tabular"> <div class="box tabular">
@ -17,19 +17,20 @@
<%= ff.select :unit_id, unit_options, {label: ''} %> <%= ff.select :unit_id, unit_options, {label: ''} %>
<%= ff.check_box :_destroy, {style: "display:none", label: ''} %> <%= ff.check_box :_destroy, {style: "display:none", label: ''} %>
<%= link_to t(".button_delete_readout"), '#', <%= link_to t(".button_delete_readout"), '#',
:class => 'icon icon-del', class: 'icon icon-del',
:style => (@measurement.readouts.length > 1 ? "" : "display:none"), style: (@measurement.readouts.length > 1 ? "" : "display:none"),
:onclick => "deleteReadout(); return false;" %> onclick: "deleteReadout(); return false;" %>
</p> </p>
<% end %> <% end %>
<% end %> <% end %>
<p> <p>
<%= link_to t(".button_add_readout"), '#', :class => 'icon icon-add', <%= link_to t(".button_add_readout"), '#', class: 'icon icon-add',
:onclick => 'addReadout(); return false;' %> onclick: 'addReadout(); return false;' %>
</p> </p>
</div> </div>
<%= submit_tag l(:button_create) %> <%= submit_tag l(:button_create) %>
<%= link_to l(:button_cancel), "#", :onclick => '$("#add-measurement").hide()' %> <%= link_to l(:button_cancel), "#",
onclick: '$("#add-measurement").hide(); return false;' %>
<% end %> <% end %>
<hr> <hr>
</div> </div>

View File

@ -1,17 +1,17 @@
<% content_for :sidebar do %> <% content_for :sidebar do %>
<%= render :partial => 'body_trackers/sidebar' %> <%= render partial: 'body_trackers/sidebar' %>
<% end %> <% end %>
<div class="contextual"> <div class="contextual">
<% if User.current.allowed_to?(:manage_common, @project) %> <% if User.current.allowed_to?(:manage_common, @project) %>
<%= link_to t(".link_new_measurement"), '#', :class => 'icon icon-add', <%= link_to t(".link_new_measurement"), '#', class: 'icon icon-add',
:onclick => '$("#add-measurement").show(); $("#measurement_name").focus(); return false;' %> onclick: '$("#add-measurement").show(); $("#measurement_name").focus(); return false;' %>
<% end %> <% end %>
</div> </div>
<%= render :partial => 'measurements/form' %> <%= render partial: 'measurements/form' %>
<h2><%= t ".heading" %></h2> <h2><%= t ".heading" %></h2>
<div id='measurements'> <div id='measurements'>
<%= render :partial => 'measurements/list' %> <%= render partial: 'measurements/list' %>
</div> </div>

View File

@ -1,5 +1,5 @@
<%= render :partial => 'quantities/filters', <%= render partial: 'quantities/filters',
:locals => {:url => filter_project_quantities_path(@project)} %> locals: {url: filter_project_quantities_path(@project)} %>
<% if @quantities.any? { |q| q.persisted? } %> <% if @quantities.any? { |q| q.persisted? } %>
<table class="list"> <table class="list">
@ -68,7 +68,7 @@
<%= labelled_form_for @quantity, url: quantity_path(@quantity), method: :patch, <%= labelled_form_for @quantity, url: quantity_path(@quantity), method: :patch,
remote: true, html: {id: 'quantity-edit-form'} do |f| %> remote: true, html: {id: 'quantity-edit-form'} do |f| %>
<%= render :partial => 'quantities/form', :locals => { :f => f } %> <%= render partial: 'quantities/form', locals: {f: f} %>
<%= submit_tag l(:button_save) %> <%= submit_tag l(:button_save) %>
<%= <%=
link_to l(:button_cancel), "#", link_to l(:button_cancel), "#",

View File

@ -1,11 +1,11 @@
<% content_for :sidebar do %> <% content_for :sidebar do %>
<%= render :partial => 'body_trackers/sidebar' %> <%= render partial: 'body_trackers/sidebar' %>
<% end %> <% end %>
<div class="contextual"> <div class="contextual">
<% if User.current.allowed_to?(:manage_common, @project) %> <% if User.current.allowed_to?(:manage_common, @project) %>
<%= link_to t(".link_new_quantity"), '#', :class => 'icon icon-add', <%= link_to t(".link_new_quantity"), '#', class: 'icon icon-add',
:onclick => '$("#add-quantity").toggle(); $("#quantity_name").focus(); return false;' %> onclick: '$("#add-quantity").toggle(); $("#quantity_name").focus(); return false;' %>
<% end %> <% end %>
</div> </div>
@ -13,9 +13,9 @@
<h2><%= t ".heading_new_quantity" %></h2> <h2><%= t ".heading_new_quantity" %></h2>
<%= labelled_form_for @quantity, <%= labelled_form_for @quantity,
:url => project_quantities_path(@project), url: project_quantities_path(@project),
:html => {:id => 'quantity-add-form'} do |f| %> html: {id: 'quantity-add-form'} do |f| %>
<%= render :partial => 'quantities/form', :locals => { :f => f } %> <%= render partial: 'quantities/form', locals: {f: f} %>
<%= submit_tag l(:button_create) %> <%= submit_tag l(:button_create) %>
<%= link_to l(:button_cancel), "#", onclick: '$("#add-quantity").hide(); return false;' %> <%= link_to l(:button_cancel), "#", onclick: '$("#add-quantity").hide(); return false;' %>
<% end %> <% end %>
@ -24,5 +24,5 @@
<h2><%= t ".heading" %></h2> <h2><%= t ".heading" %></h2>
<div id='quantities'> <div id='quantities'>
<%= render :partial => 'quantities/index' %> <%= render partial: 'quantities/index' %>
</div> </div>

View File

@ -1,4 +1,4 @@
$('div[id^=flash_]').remove(); $('div[id^=flash_]').remove();
$('#content').prepend('<%= escape_javascript(render_flash_messages) %>'); $('#content').prepend('<%= escape_javascript(render_flash_messages) %>');
$('#quantities').html('<%= escape_javascript(render :partial => 'quantities/index') %>'); $('#quantities').html('<%= escape_javascript(render partial: 'quantities/index') %>');
$('#quantity_domain').trigger('change'); $('#quantity_domain').trigger('change');

View File

@ -1,11 +1,11 @@
<% content_for :sidebar do %> <% content_for :sidebar do %>
<%= render :partial => 'body_trackers/sidebar' %> <%= render partial: 'body_trackers/sidebar' %>
<% end %> <% end %>
<div class="contextual"> <div class="contextual">
<% if User.current.allowed_to?(:manage_common, @project) %> <% if User.current.allowed_to?(:manage_common, @project) %>
<%= link_to t(".link_new_source"), '#', :class => 'icon icon-add', <%= link_to t(".link_new_source"), '#', class: 'icon icon-add',
:onclick => '$("#add-source").show(); $("#source_name").focus(); return false;' %> onclick: '$("#add-source").show(); $("#source_name").focus(); return false;' %>
<% end %> <% end %>
</div> </div>
@ -13,11 +13,11 @@
<h2><%= t ".heading_new_source" %></h2> <h2><%= t ".heading_new_source" %></h2>
<%= labelled_form_for @source, <%= labelled_form_for @source,
:url => project_sources_path(@project), url: project_sources_path(@project),
:html => {:id => 'source-form'} do |f| %> html: {id: 'source-form'} do |f| %>
<%= render :partial => 'sources/form', :locals => { :f => f } %> <%= render partial: 'sources/form', locals: {f: f} %>
<%= submit_tag l(:button_create) %> <%= submit_tag l(:button_create) %>
<%= link_to l(:button_cancel), "#", :onclick => '$("#add-source").hide()' %> <%= link_to l(:button_cancel), "#", onclick: '$("#add-source").hide(); return false;' %>
<% end %> <% end %>
<hr> <hr>
</div> </div>

View File

@ -1,11 +1,11 @@
<% content_for :sidebar do %> <% content_for :sidebar do %>
<%= render :partial => 'body_trackers/sidebar' %> <%= render partial: 'body_trackers/sidebar' %>
<% end %> <% end %>
<div class="contextual"> <div class="contextual">
<% if User.current.allowed_to?(:manage_common, @project) %> <% if User.current.allowed_to?(:manage_common, @project) %>
<%= link_to t(".link_new_unit"), '#', :class => 'icon icon-add', <%= link_to t(".link_new_unit"), '#', class: 'icon icon-add',
:onclick => '$("#add-unit").show(); $("#unit_shortname").focus(); return false;' %> onclick: '$("#add-unit").show(); $("#unit_shortname").focus(); return false;' %>
<% end %> <% end %>
</div> </div>
@ -13,11 +13,11 @@
<h2><%= t ".heading_new_unit" %></h2> <h2><%= t ".heading_new_unit" %></h2>
<%= labelled_form_for @unit, <%= labelled_form_for @unit,
:url => project_units_path(@project), url: project_units_path(@project),
:html => {:id => 'unit-form'} do |f| %> html: {id: 'unit-form'} do |f| %>
<%= render :partial => 'units/form', :locals => { :f => f } %> <%= render partial: 'units/form', locals: {f: f} %>
<%= submit_tag l(:button_create) %> <%= submit_tag l(:button_create) %>
<%= link_to l(:button_cancel), "#", :onclick => '$("#add-unit").hide()' %> <%= link_to l(:button_cancel), "#", onclick: '$("#add-unit").hide(); return false;' %>
<% end %> <% end %>
<hr> <hr>
</div> </div>

View File

@ -3,13 +3,13 @@
resources :projects do resources :projects do
shallow do shallow do
resources :body_trackers, :only => [:index] do resources :body_trackers, only: [:index] do
post 'defaults', on: :collection post 'defaults', on: :collection
end end
resources :measurements, :only => [:index, :create, :destroy] do resources :measurements, only: [:index, :create, :destroy] do
post 'toggle', on: :member post 'toggle', on: :member
end end
resources :ingredients, :only => [:index, :create, :destroy] do resources :ingredients, only: [:index, :create, :destroy] do
post 'toggle', on: :member post 'toggle', on: :member
collection do collection do
get 'nutrients' get 'nutrients'
@ -19,8 +19,8 @@ resources :projects do
post 'import' post 'import'
end end
end end
resources :sources, :only => [:index, :create, :destroy] resources :sources, only: [:index, :create, :destroy]
resources :quantities, :only => [:index, :create, :edit, :update, :destroy] do resources :quantities, only: [:index, :create, :edit, :update, :destroy] do
member do member do
post 'toggle' post 'toggle'
post 'move/:direction', to: 'quantities#move', as: :move post 'move/:direction', to: 'quantities#move', as: :move
@ -30,6 +30,6 @@ resources :projects do
get 'filter' get 'filter'
end end
end end
resources :units, :only => [:index, :create, :destroy] resources :units, only: [:index, :create, :destroy]
end end
end end

View File

@ -16,8 +16,8 @@ class CreateSchema < ActiveRecord::Migration
t.boolean :primary t.boolean :primary
# fields for awesome_nested_set # fields for awesome_nested_set
t.references :parent t.references :parent
t.integer :lft, :null => false, :index => true t.integer :lft, null: false, index: true
t.integer :rgt, :null => false, :index => true t.integer :rgt, null: false, index: true
t.timestamps null: false t.timestamps null: false
end end

28
init.rb
View File

@ -15,23 +15,23 @@ Redmine::Plugin.register :body_tracking do
project_module :body_tracking do project_module :body_tracking do
permission :view_body_trackers, { permission :view_body_trackers, {
:body_trackers => [:index], body_trackers: [:index],
:measurements => [:index], measurements: [:index],
:ingredients => [:index, :nutrients, :filter, :filter_nutrients], ingredients: [:index, :nutrients, :filter, :filter_nutrients],
:sources => [:index], sources: [:index],
:quantities => [:index, :parents, :filter], quantities: [:index, :parents, :filter],
:units => [:index], units: [:index],
}, read: true }, read: true
permission :manage_common, { permission :manage_common, {
:body_trackers => [:defaults], body_trackers: [:defaults],
:measurements => [:create, :destroy, :toggle], measurements: [:create, :destroy, :toggle],
:ingredients => [:create, :destroy, :toggle, :import, :toggle_nutrient_column], ingredients: [:create, :destroy, :toggle, :import, :toggle_nutrient_column],
:sources => [:create, :destroy], sources: [:create, :destroy],
:quantities => [:create, :edit, :update, :destroy, :toggle, :move], quantities: [:create, :edit, :update, :destroy, :toggle, :move],
:units => [:create, :destroy], units: [:create, :destroy],
}, require: :loggedin }, require: :loggedin
end end
menu :project_menu, :body_trackers, {:controller => 'body_trackers', :action => 'index'}, menu :project_menu, :body_trackers, {controller: 'body_trackers', action: 'index'},
:caption => :body_trackers_menu_caption, :before => :settings, :param => :project_id caption: :body_trackers_menu_caption, before: :settings, param: :project_id
end end