Update supported ingredient name and separator characters

This is a part of work towards fixing #4 and #3 - this will allow more
characters, but doesn't address validation failures.
This commit is contained in:
Chris 2019-09-25 21:25:26 +01:00
parent db076ef787
commit 0872033b21
9 changed files with 18 additions and 11 deletions

View File

@ -52,6 +52,7 @@ RECIPE_ING_ING_PH = Ingredient
RECIPE_ING_NOTE_PH = Notes RECIPE_ING_NOTE_PH = Notes
RECIPE_ING_SEP_PH = Separator text RECIPE_ING_SEP_PH = Separator text
RECIPE_ING_DELETE = Delete RECIPE_ING_DELETE = Delete
RECIPE_ING_FORMAT = Ingredient names and separators may only contain alphanumrics, -, _, comma, period, colon, semi-colon, parenthesis, ampersand, octothorpe, * and backslash
RECIPE_METHOD = Method RECIPE_METHOD = Method
RECIPE_NOTES = Notes RECIPE_NOTES = Notes

View File

@ -77,8 +77,8 @@ sub new {
"recipename" => '^[-\w,. ]+$', "recipename" => '^[-\w,. ]+$',
"tags" => '^[-\w ]+$', "tags" => '^[-\w ]+$',
"quantity" => '^[\d\w./]+$', "quantity" => '^[\d\w./]+$',
"sepname" => '^[-\w,. ]{1,255}$', "sepname" => '^[-\w,.:()&;#*\ ]{1,255}$',
"ingredient" => '^[-\w,. ]{1,255}$', "ingredient" => '^[-\w,.:()&;#*\ ]{1,255}$',
"notes" => '^[-()\w,."!\'\\/£$%;:@#?><* ]{1,255}$', "notes" => '^[-()\w,."!\'\\/£$%;:@#?><* ]{1,255}$',
}; };

View File

@ -126,7 +126,7 @@
</select> </select>
</div> </div>
<div class="small-3 cell"> <div class="small-3 cell">
<input type="text" class="ingredient" placeholder="{L_RECIPE_ING_ING_PH}" /> <input type="text" class="ingredient" pattern="[-\w,.:()\x26;#*\\ ]+" title="{L_RECIPE_ING_FORMAT}" placeholder="{L_RECIPE_ING_ING_PH}" />
</div> </div>
<div class="small-3 cell"> <div class="small-3 cell">
<input type="text" class="notes" placeholder="{L_RECIPE_ING_NOTE_PH}" /> <input type="text" class="notes" placeholder="{L_RECIPE_ING_NOTE_PH}" />
@ -139,7 +139,7 @@
<li class="separator"> <li class="separator">
<div class="grid-x"> <div class="grid-x">
<div class="small-11 cell"> <div class="small-11 cell">
<input type="text" class="separator" placeholder="Separator text"> <input type="text" class="separator" pattern="[-\w,.:()\x26;#*\\ ]+" title="{L_RECIPE_ING_FORMAT}" placeholder="Separator text">
</div> </div>
<div class="small-1 cell"> <div class="small-1 cell">
<button class="button alert deletectrl" type="button" title="Delete"><i class="fa fa-trash" aria-hidden="true"></i></button> <button class="button alert deletectrl" type="button" title="Delete"><i class="fa fa-trash" aria-hidden="true"></i></button>

View File

@ -14,7 +14,7 @@
</select> </select>
</div> </div>
<div class="small-3 cell"> <div class="small-3 cell">
<input type="text" class="ingredient" placeholder="{L_RECIPE_ING_ING_PH}" value="%(name)s" /> <input type="text" class="ingredient" pattern="[-\w,.:()\x26;#*\\ ]+" title="{L_RECIPE_ING_FORMAT}" placeholder="{L_RECIPE_ING_ING_PH}" value="%(name)s" />
</div> </div>
<div class="small-3 cell"> <div class="small-3 cell">
<input type="text" class="notes" placeholder="{L_RECIPE_ING_NOTE_PH}" value="%(notes)s" /> <input type="text" class="notes" placeholder="{L_RECIPE_ING_NOTE_PH}" value="%(notes)s" />

View File

@ -1,7 +1,7 @@
<li class="separator"> <li class="separator">
<div class="grid-x"> <div class="grid-x">
<div class="small-11 cell"> <div class="small-11 cell">
<input type="text" class="separator" placeholder="{L_RECIPE_ING_SEP_PH}" value="%(name)s" /> <input type="text" class="separator" pattern="[-\w,.:()\x26;#*\\ ]+" title="{L_RECIPE_ING_FORMAT}" placeholder="{L_RECIPE_ING_SEP_PH}" value="%(name)s" />
</div> </div>
<div class="small-1 cell"> <div class="small-1 cell">
<button class="button alert deletectrl" type="button" title="{L_RECIPE_ING_DELETE}"><i class="fa fa-trash" aria-hidden="true"></i></button> <button class="button alert deletectrl" type="button" title="{L_RECIPE_ING_DELETE}"><i class="fa fa-trash" aria-hidden="true"></i></button>

View File

@ -42,6 +42,10 @@ function add_ingredient(count)
function build_ingdata() function build_ingdata()
{ {
if(!document.forms['recipeform'].reportValidity()) {
return false;
}
var values = new Array(); var values = new Array();
// Go through all the children of the ingredient list // Go through all the children of the ingredient list
@ -72,6 +76,8 @@ function build_ingdata()
}); });
$('#ingdata').val(JSON.stringify({ "ingredients": values })); $('#ingdata').val(JSON.stringify({ "ingredients": values }));
return true;
} }
@ -140,5 +146,5 @@ $(function() {
}); });
// Build the ingredient list before submitting // Build the ingredient list before submitting
$('#recipeform').on('submit', function() { build_ingdata(); return true }); $('#recipeform').on('submit', function() { return build_ingdata(); });
}); });

View File

@ -126,7 +126,7 @@
</select> </select>
</div> </div>
<div class="small-3 cell"> <div class="small-3 cell">
<input type="text" class="ingredient" placeholder="{L_RECIPE_ING_ING_PH}" /> <input type="text" class="ingredient" pattern="[-\w,.:()\x26;#*\\ ]+" title="{L_RECIPE_ING_FORMAT}" placeholder="{L_RECIPE_ING_ING_PH}" />
</div> </div>
<div class="small-3 cell"> <div class="small-3 cell">
<input type="text" class="notes" placeholder="{L_RECIPE_ING_NOTE_PH}" /> <input type="text" class="notes" placeholder="{L_RECIPE_ING_NOTE_PH}" />
@ -139,7 +139,7 @@
<li class="separator"> <li class="separator">
<div class="grid-x"> <div class="grid-x">
<div class="small-11 cell"> <div class="small-11 cell">
<input type="text" class="separator" placeholder="Separator text"> <input type="text" class="separator" pattern="[-\w,.:()\x26;#*\\ ]+" title="{L_RECIPE_ING_FORMAT}" placeholder="Separator text">
</div> </div>
<div class="small-1 cell"> <div class="small-1 cell">
<button class="button alert deletectrl" type="button" title="Delete"><i class="fa fa-trash" aria-hidden="true"></i></button> <button class="button alert deletectrl" type="button" title="Delete"><i class="fa fa-trash" aria-hidden="true"></i></button>

View File

@ -14,7 +14,7 @@
</select> </select>
</div> </div>
<div class="small-3 cell"> <div class="small-3 cell">
<input type="text" class="ingredient" placeholder="{L_RECIPE_ING_ING_PH}" value="%(name)s" /> <input type="text" class="ingredient" pattern="[-\w,.:()\x26;#*\\ ]+" title="{L_RECIPE_ING_FORMAT}" placeholder="{L_RECIPE_ING_ING_PH}" value="%(name)s" />
</div> </div>
<div class="small-3 cell"> <div class="small-3 cell">
<input type="text" class="notes" placeholder="{L_RECIPE_ING_NOTE_PH}" value="%(notes)s" /> <input type="text" class="notes" placeholder="{L_RECIPE_ING_NOTE_PH}" value="%(notes)s" />

View File

@ -1,7 +1,7 @@
<li class="separator"> <li class="separator">
<div class="grid-x"> <div class="grid-x">
<div class="small-11 cell"> <div class="small-11 cell">
<input type="text" class="separator" placeholder="{L_RECIPE_ING_SEP_PH}" value="%(name)s" /> <input type="text" class="separator" pattern="[-\w,.:()\x26;#*\\ ]+" title="{L_RECIPE_ING_FORMAT}" placeholder="{L_RECIPE_ING_SEP_PH}" value="%(name)s" />
</div> </div>
<div class="small-1 cell"> <div class="small-1 cell">
<button class="button alert deletectrl" type="button" title="{L_RECIPE_ING_DELETE}"><i class="fa fa-trash" aria-hidden="true"></i></button> <button class="button alert deletectrl" type="button" title="{L_RECIPE_ING_DELETE}"><i class="fa fa-trash" aria-hidden="true"></i></button>