mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 04:12:59 +00:00
Implemented new Userfield type "Select list" (closes #325)
This commit is contained in:
@@ -112,3 +112,8 @@ FindAllObjectsInArrayByPropertyValue = function(array, propertyName, propertyVal
|
||||
|
||||
return returnArray;
|
||||
}
|
||||
|
||||
$.fn.hasAttr = function(name)
|
||||
{
|
||||
return this.attr(name) !== undefined;
|
||||
};
|
||||
|
@@ -14,7 +14,7 @@ Grocy.Components.UserfieldsForm.Save = function(success, error)
|
||||
|
||||
var jsonData = { };
|
||||
|
||||
$("#userfields-form .userfield-input").each(function()
|
||||
$("#userfields-form .userfield-input").not("div").each(function()
|
||||
{
|
||||
var input = $(this);
|
||||
var fieldName = input.attr("data-userfield-name");
|
||||
@@ -28,6 +28,10 @@ Grocy.Components.UserfieldsForm.Save = function(success, error)
|
||||
jsonData[fieldName] = "1";
|
||||
}
|
||||
}
|
||||
else if ($(this).hasAttr("multiple"))
|
||||
{
|
||||
jsonData[fieldName] = $(this).val().join(",");
|
||||
}
|
||||
else
|
||||
{
|
||||
jsonData[fieldName] = fieldValue;
|
||||
@@ -70,6 +74,11 @@ Grocy.Components.UserfieldsForm.Load = function()
|
||||
{
|
||||
input.prop("checked", true);
|
||||
}
|
||||
else if (input.hasAttr("multiple"))
|
||||
{
|
||||
input.val(value.split(","));
|
||||
$(".selectpicker").selectpicker("render");
|
||||
}
|
||||
else
|
||||
{
|
||||
input.val(value);
|
||||
|
@@ -72,7 +72,7 @@ $("#type").on("change", function(e)
|
||||
{
|
||||
var value = $(this).val();
|
||||
|
||||
if (value === "preset-list")
|
||||
if (value === "preset-list" || value === "preset-checklist")
|
||||
{
|
||||
$("#config").parent().removeClass("d-none");
|
||||
$("#config-hint").text(__t("A predefined list of values, one per line"));
|
||||
|
Reference in New Issue
Block a user