log work
This commit is contained in:
parent
e6a9e00f82
commit
51a3be23e9
@ -21,3 +21,10 @@
|
|||||||
//= require chosen.jquery
|
//= require chosen.jquery
|
||||||
//= require underscore
|
//= require underscore
|
||||||
//= require_tree .
|
//= require_tree .
|
||||||
|
|
||||||
|
// Setup star rating automagic
|
||||||
|
$(document).on("turbolinks:load", function() {
|
||||||
|
|
||||||
|
$("input[data-rating='true']").starRating();
|
||||||
|
|
||||||
|
});
|
@ -2,9 +2,6 @@
|
|||||||
|
|
||||||
$(document).on("turbolinks:load", function() {
|
$(document).on("turbolinks:load", function() {
|
||||||
$(".log-form input.datepicker").datepicker({autoclose: true, todayBtn: "linked", format: "yyyy-mm-dd"});
|
$(".log-form input.datepicker").datepicker({autoclose: true, todayBtn: "linked", format: "yyyy-mm-dd"});
|
||||||
$(".log-form input.rating").starRating();
|
|
||||||
|
|
||||||
$(".log-table input.rating").starRating({readOnly: true});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
})(jQuery);
|
})(jQuery);
|
@ -3,8 +3,6 @@
|
|||||||
$(document).on("turbolinks:load", function() {
|
$(document).on("turbolinks:load", function() {
|
||||||
$(".recipe-view ul.ingredients").checkable();
|
$(".recipe-view ul.ingredients").checkable();
|
||||||
$(".recipe-view ol.steps").checkable();
|
$(".recipe-view ol.steps").checkable();
|
||||||
|
|
||||||
$(".recipe-table input.rating").starRating({readOnly: true, interval: 0.25, size: '20px'});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
@ -13,8 +13,10 @@
|
|||||||
initialize: function(opts) {
|
initialize: function(opts) {
|
||||||
return this.each(function() {
|
return this.each(function() {
|
||||||
var $input = $(this);
|
var $input = $(this);
|
||||||
|
var attrOpts = {};
|
||||||
|
var inputData = $input.data();
|
||||||
|
|
||||||
if ($input.data(pluginName.toLowerCase()) === true) {
|
if (inputData[pluginName.toLowerCase()] === true) {
|
||||||
if (console && console.log) {
|
if (console && console.log) {
|
||||||
console.log("star rating has already been initialized; skipping...");
|
console.log("star rating has already been initialized; skipping...");
|
||||||
}
|
}
|
||||||
@ -23,7 +25,23 @@
|
|||||||
|
|
||||||
$input.attr("data-" + pluginName.toLowerCase(), "true");
|
$input.attr("data-" + pluginName.toLowerCase(), "true");
|
||||||
|
|
||||||
var options = _.extend({}, defaultOptions, opts);
|
if (inputData.interval) {
|
||||||
|
attrOpts.interval = inputData.interval;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inputData.starcount) {
|
||||||
|
attrOpts.starCount = inputData.starcount;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inputData.size) {
|
||||||
|
attrOpts.size = inputData.size;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($input.is(":disabled")) {
|
||||||
|
attrOpts.readOnly = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var options = _.extend({}, defaultOptions, attrOpts, opts);
|
||||||
|
|
||||||
var $widget = $("<span />").addClass("star-rating").css({'font-size': options.size});
|
var $widget = $("<span />").addClass("star-rating").css({'font-size': options.size});
|
||||||
var $emptySet = $("<span />").addClass("empty-set").appendTo($widget);
|
var $emptySet = $("<span />").addClass("empty-set").appendTo($widget);
|
||||||
|
@ -21,7 +21,7 @@ class LogsController < ApplicationController
|
|||||||
def update
|
def update
|
||||||
ensure_owner(@log) do
|
ensure_owner(@log) do
|
||||||
if @log.update(log_params)
|
if @log.update(log_params)
|
||||||
redirect_to @log, notice: 'Log Entry was successfully updated.'
|
redirect_to logs_path, notice: 'Log Entry was successfully updated.'
|
||||||
else
|
else
|
||||||
render :edit
|
render :edit
|
||||||
end
|
end
|
||||||
@ -45,7 +45,7 @@ class LogsController < ApplicationController
|
|||||||
@log.source_recipe = @recipe
|
@log.source_recipe = @recipe
|
||||||
|
|
||||||
if @log.save
|
if @log.save
|
||||||
redirect_to @log, notice: 'Log Entry was successfully created.'
|
redirect_to logs_path, notice: 'Log Entry was successfully created.'
|
||||||
else
|
else
|
||||||
render :new
|
render :new
|
||||||
end
|
end
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<div class="col-xs-6">
|
<div class="col-xs-6">
|
||||||
<div class="form-group form-group-sm">
|
<div class="form-group form-group-sm">
|
||||||
<%= f.label :rating, class: 'control-label' %>
|
<%= f.label :rating, class: 'control-label' %>
|
||||||
<%= f.text_field :rating, class: 'form-control rating' %>
|
<%= f.text_field :rating, class: 'form-control', data: {rating: 'true'} %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
12
app/views/logs/edit.html.erb
Normal file
12
app/views/logs/edit.html.erb
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-12">
|
||||||
|
<div class="page-header">
|
||||||
|
<h1>Edit Log Entry</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= render 'form' %>
|
||||||
|
|
||||||
|
<%= link_to 'Back', logs_path, class: 'btn btn-default' %>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -25,8 +25,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td><%= link_to log.recipe.short_name, log %></td>
|
<td><%= link_to log.recipe.short_name, log %></td>
|
||||||
<td><%= log.date %></td>
|
<td><%= log.date %></td>
|
||||||
<td><input type="hidden" class="rating" value="<%= log.rating %>" /></td>
|
<td><%= text_field_tag('rating', log.rating, disabled: true, data: {rating: true}) %></td>
|
||||||
<td><%= %></td>
|
<td><%= log.notes %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -0,0 +1,96 @@
|
|||||||
|
|
||||||
|
<%
|
||||||
|
@log = decorate(@log, LogDecorator)
|
||||||
|
@recipe = @log.recipe
|
||||||
|
%>
|
||||||
|
|
||||||
|
<div class="recipe-view">
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-12">
|
||||||
|
<div class="page-header">
|
||||||
|
<h1>
|
||||||
|
[Log Entry] <%= @recipe.name %>
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p>Date: <%= @log.date %></p>
|
||||||
|
<p>Rating: <%= text_field_tag('rating', @log.rating, disabled: true, data: {rating: true}) %></p>
|
||||||
|
<p>Notes: <%= @log.notes %></p>
|
||||||
|
|
||||||
|
<p class="lead">
|
||||||
|
<%= @recipe.description %>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<% if @recipe.total_time.present? || @recipe.active_time.present? %>
|
||||||
|
<div class="col-xs-3">
|
||||||
|
<p><%= recipe_time(@recipe) %></p>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% if @recipe.yields.present? %>
|
||||||
|
<div class="col-xs-3">
|
||||||
|
<p>Yields</p><p><%= @recipe.yields %></p>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% if @recipe.source.present? %>
|
||||||
|
<div class="source">
|
||||||
|
<p>Source</p><p><%= @recipe.source_markup %></p>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-12 col-sm-5 col-md-4">
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<h3 class="panel-title col-xs-7">Ingredients</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<ul class="ingredients">
|
||||||
|
<% @recipe.recipe_ingredients.each do |i| %>
|
||||||
|
<li><div><%= i.display_name %></div></li>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-xs-12 col-sm-7 col-md-8">
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<h3 class="panel-title">Directions</h3>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<ol class="steps">
|
||||||
|
<% @recipe.recipe_steps.each do |s| %>
|
||||||
|
<li><div><%= "#{s.step}" %></div></li>
|
||||||
|
<% end %>
|
||||||
|
</ol>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-12">
|
||||||
|
|
||||||
|
<%= link_to 'Edit', edit_log_path(@log), class: 'btn btn-default' %>
|
||||||
|
<%= link_to 'Back', logs_path, class: 'btn btn-default' %>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
@ -30,7 +30,7 @@
|
|||||||
<td><%= link_to recipe.short_name, recipe %></td>
|
<td><%= link_to recipe.short_name, recipe %></td>
|
||||||
<td>
|
<td>
|
||||||
<% if recipe.average_rating > 0 %>
|
<% if recipe.average_rating > 0 %>
|
||||||
<input type="hidden" class="rating" value="<%= recipe.average_rating %>" />
|
<%= text_field_tag('rating', recipe.average_rating, disabled: true, data: {rating: true, size: '20px', interval: '0.25'}) %>
|
||||||
<% else %>
|
<% else %>
|
||||||
--
|
--
|
||||||
<% end %>
|
<% end %>
|
||||||
|
Loading…
Reference in New Issue
Block a user