Module:SOM.meta.DateBounded.Role.OrgPerson

From SunshinePPS Wiki

Not documented.

(/doc page)


--XXXX local meta = require("Module:SOM.meta.DateBounded.CompositeProperty")
local DBA = require("Module:SOM.meta.DateBoundedAttribute")
local util = require("Module:SOM.util")

local p = {}

-- args = {
--   class_name
--   org_arg
--   org_label
--   org_input_category
--   role_title
--   docstring
--
function p.generate(args)
	local role_layout = { "person", args.org_arg }
	local role_attributes = nil
	if args.role_attributes then
		--local value_map = {}
		local field_values = {}
		for attr, label in pairs(args.role_attributes) do
			-- value_map[attr] = attr
			table.insert(field_values, attr)
		end
		
		role_attributes = {
			smw = {
				property = "Has role attribute",
				ignore_missing = true,
			},
			field = {
				label = "Role Attributes",
				input_type = "checkboxes",
				extra_args = {
					"hide select all",
					["values"] = table.concat(field_values, ","),
					},
				--map = value_map,
				},
			multivalued = true,
			value_delimiter = ",",
	--		render_formatter = util.show_as_link,
			render_formater = (function (attr) return args.role_attributes[attr] end),
		}	
	end
	if role_attributes then
		table.insert(role_layout, "role_attributes" )
	end

	return DBA.generate_composite({
		class_name = args.class_name,

		elements = {
			[args.org_arg] = {
				smw = { property = "Relates to organization" },
				field = {
					label = args.org_label,
					input_type = "combobox",
					extra_args = {
						["values from category"] = args.org_input_category,
					},
				},
				render_formatter = util.show_as_link,
			},
			person = {
				smw = {
					property = "Relates to person"
				},
				field = {
					label = "Person",
					input_type = "combobox",
					extra_args = {
						["values from category"] = "Person",
					},
				},
				render_formatter = util.show_as_link,
			},
			role = {
				smw = { property = "Has role" },
				fixed_value = args.role_title,
--				label = "Role",
			},
			role_attributes = role_attributes,
		},
		form_layout = {
			util.list_join(nil, role_layout, DBA.DATEBOUNDS_FORM_ROW),
		},
		title_key = "person",
		docstring = args.docstring
		})
end



if false then
function p.generate(args)
	return meta.generate_composite({
		class_name = args.class_name,

		elements = {
			org = {
				property_root = "Relates to organization",
				arg = args.org_arg,
				lua_type = "string",
				label = args.org_label,
				input_type = "combobox",
				input_category = args.org_input_category,
				attribute_label = args.org_attribute_label
			},
			person = {
				property_root = "Relates to person",
				arg = "person",
				lua_type = "string",
				label = "Person",
				input_type = "combobox",
				input_category = "Person",
				attribute_label = "Person"
			},
			role = {
				property_root = "Has role",
				fixed_value = args.role_title,
				lua_type = "string",
				label = "Role",
				attribute_label = "Role"
			},
		},
		title_key = "person",
		docstring = args.docstring
		})
end
end

function p.documentation(args)
	return [=[
Meta-module to generate modules representing a date-bounded, organization-person role.

;generate
: class_name
: role_title
: org_arg
: org_label
: org_input_category
: org_attribute_label
: docstring

;documentation
	]=]
end


return p