Added about page; fixed bulk editing
This commit is contained in:
parent
422c77b131
commit
3ca786281d
@ -102,12 +102,12 @@
|
||||
function addIngredient(item) {
|
||||
$("#ingredient-list").one("cocoon:before-insert", function(e, $container) {
|
||||
var $ingredientId = $container.find("input.ingredient_id");
|
||||
var $name = $container.find("input.ingredient-typeahead.tt-input");
|
||||
var $name = $container.find("input.ingredient-typeahead");
|
||||
var $quantity = $container.find("input.quantity");
|
||||
var $units = $container.find("input.units");
|
||||
var $preparation = $container.find("input.preparation");
|
||||
|
||||
$name.typeahead("val", item.name);
|
||||
$name.val(item.name);
|
||||
$ingredientId.val(item.ingredient_id);
|
||||
$units.val(item.units);
|
||||
$quantity.val(item.quantity);
|
||||
@ -143,6 +143,19 @@
|
||||
$("#addStepButton").trigger("click");
|
||||
}
|
||||
|
||||
function getSteps() {
|
||||
var data = [];
|
||||
$("#step-list .step-editor").each(function() {
|
||||
var $container = $(this);
|
||||
|
||||
var $step = $container.find("textarea.step");
|
||||
|
||||
data.push($step.val());
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
$(document).on("ready page:load", function() {
|
||||
|
||||
var $ingredientList = $("#ingredient-list");
|
||||
@ -160,6 +173,7 @@
|
||||
initializeStepEditor(item);
|
||||
})
|
||||
.on("cocoon:after-remove", function(e, item) {
|
||||
item.detach().appendTo("#deleted_steps");
|
||||
reorder($(this));
|
||||
})
|
||||
.on('changed', 'input.sort_order', function() {
|
||||
@ -177,6 +191,7 @@
|
||||
initializeIngredientEditor(item, ingredientSearchEngine);
|
||||
})
|
||||
.on("cocoon:after-remove", function(e, item) {
|
||||
item.detach().appendTo("#deleted_ingredients");
|
||||
reorder($ingredientList);
|
||||
})
|
||||
.on("typeahead:change", function(evt, value) {
|
||||
@ -340,6 +355,8 @@
|
||||
var parsed = $bulkIngredientsModal.data("bulkData");
|
||||
var x;
|
||||
|
||||
$("#ingredient-list").find(".remove-button").trigger("click");
|
||||
|
||||
if (parsed && parsed.length) {
|
||||
for (x = 0; x < parsed.length; x++) {
|
||||
var item = parsed[x];
|
||||
@ -362,14 +379,7 @@
|
||||
var $stepBulkList = $("#step_bulk_parsed_list");
|
||||
autosize($stepBulkInput);
|
||||
|
||||
$bulkStepsModal
|
||||
.on('show.bs.modal', function (event) {
|
||||
$stepBulkInput.val('');
|
||||
$stepBulkList.empty();
|
||||
autosize.update($stepBulkInput);
|
||||
});
|
||||
|
||||
$stepBulkInput.on('keyup', function() {
|
||||
var parseBulkSteps = function() {
|
||||
var data = $stepBulkInput.val();
|
||||
$stepBulkList.empty();
|
||||
|
||||
@ -402,12 +412,30 @@
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$bulkStepsModal
|
||||
.on('show.bs.modal', function (event) {
|
||||
var data = getSteps();
|
||||
$stepBulkInput.val(data.join("\n\n"));
|
||||
$stepBulkList.empty();
|
||||
|
||||
setTimeout(function() {
|
||||
parseBulkSteps();
|
||||
autosize.update($stepBulkInput);
|
||||
}, 250);
|
||||
});
|
||||
|
||||
$stepBulkInput.on('keyup', function() {
|
||||
parseBulkSteps();
|
||||
});
|
||||
|
||||
$("#bulkStepAddSubmit").on("click", function() {
|
||||
var parsed = $bulkStepsModal.data("bulkData");
|
||||
var x;
|
||||
|
||||
$("#step-list").find(".remove-button").trigger("click");
|
||||
|
||||
if (parsed && parsed.length) {
|
||||
for (x = 0; x < parsed.length; x++) {
|
||||
var item = parsed[x];
|
||||
|
5
app/controllers/home_controller.rb
Normal file
5
app/controllers/home_controller.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class HomeController < ApplicationController
|
||||
def about
|
||||
|
||||
end
|
||||
end
|
@ -7,7 +7,8 @@ module ApplicationHelper
|
||||
def nav_items
|
||||
[
|
||||
nav_item('Recipes', recipes_path, 'recipes'),
|
||||
nav_item('Ingredients', ingredients_path, 'ingredients')
|
||||
nav_item('Ingredients', ingredients_path, 'ingredients'),
|
||||
nav_item('About', about_path, 'home')
|
||||
]
|
||||
end
|
||||
|
||||
|
@ -4,7 +4,6 @@ class RecipeIngredient < ActiveRecord::Base
|
||||
belongs_to :recipe, inverse_of: :recipe_ingredients
|
||||
|
||||
validates :sort_order, presence: true
|
||||
validates :custom_density, density: true, allow_blank: true
|
||||
|
||||
def name
|
||||
if self.ingredient_id.present?
|
||||
|
24
app/views/home/about.html.erb
Normal file
24
app/views/home/about.html.erb
Normal file
@ -0,0 +1,24 @@
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
|
||||
<div class="page-header">
|
||||
<h1>About</h1>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
A Recipe manager. Source available on <a href="https://github.com/DanElbert/parsley">GitHub</a>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Parsley is released under the MIT License. All code © Dan Elbert 2016.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Food data provided by:<br/>
|
||||
<cite>
|
||||
US Department of Agriculture, Agricultural Research Service, Nutrient Data Laboratory. USDA National Nutrient Database for Standard Reference, Release 28. Version Current: September 2015. Internet: <a href="http://www.ars.usda.gov/nea/bhnrc/ndl">http://www.ars.usda.gov/nea/bhnrc/ndl</a>
|
||||
</cite>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
</div>
|
@ -50,15 +50,15 @@
|
||||
|
||||
</div><!-- /.container -->
|
||||
|
||||
<footer class="footer">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<p class="text-muted text-right">© Dan Elbert 2016</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
<!--<footer class="footer">-->
|
||||
<!--<div class="container-fluid">-->
|
||||
<!--<div class="row">-->
|
||||
<!--<div class="col-xs-12">-->
|
||||
<!--<p class="text-muted text-right">© Dan Elbert 2016</p>-->
|
||||
<!--</div>-->
|
||||
<!--</div>-->
|
||||
<!--</div>-->
|
||||
<!--</footer>-->
|
||||
|
||||
|
||||
</body>
|
||||
|
@ -54,6 +54,8 @@
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div id="deleted_ingredients"></div>
|
||||
|
||||
<%= link_to_add_association 'Add Ingredient', f, :recipe_ingredients, partial: 'recipes/editor/ingredient', :'data-association-insertion-node' => '#ingredient-list', :'data-association-insertion-method' => 'append', class: 'btn btn-primary', id: 'addIngredientButton' %>
|
||||
|
||||
|
||||
@ -65,6 +67,8 @@
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div id="deleted_steps"></div>
|
||||
|
||||
<%= link_to_add_association 'Add Step', f, :recipe_steps, partial: 'recipes/editor/step', :'data-association-insertion-node' => '#step-list', :'data-association-insertion-method' => 'append', class: 'btn btn-primary', id: 'addStepButton' %>
|
||||
<br/><br/>
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
</div>
|
||||
|
||||
<div class="col-xs-6">
|
||||
<table class="table">
|
||||
<table class="table table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
|
@ -26,6 +26,8 @@ Rails.application.routes.draw do
|
||||
post '/login' => 'users#verify_login'
|
||||
get '/logout' => 'users#logout', as: :logout
|
||||
|
||||
get '/about' => 'home#about', as: :about
|
||||
|
||||
root 'recipes#index'
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user