Module:Employee: Difference between revisions

From TwogPedia
(Created page with "local getArgs = require('Module:Arguments').getArgs VariablesLua = mw.ext.VariablesLua local Employee = {} function Employee.main(frame) local args = getArgs(frame) local employees = '' local newEmployee = { id=args.id, position=args.position, joindate=args.joindate, leavedate=args.leavedate, inactivedate=args.inactivedate, newcompany=args.newcompany } if VariablesLua.varexists('Employees') then employees = VariablesLua.var('Employees') employe...")
 
No edit summary
Line 19: Line 19:
if VariablesLua.varexists('Employees') then
if VariablesLua.varexists('Employees') then
employees = VariablesLua.var('Employees')
employees = VariablesLua.var('Employees')
employees = employees .. ',' .. mw.text.jsonEncode(newEmployee)
employees = employees .. '&&&' .. mw.text.jsonEncode(newEmployee)
else
else
employees = mw.text.jsonEncode(newEmployee)
employees = mw.text.jsonEncode(newEmployee)

Revision as of 22:34, 6 May 2023

Documentation for this module may be created at Module:Employee/doc

local getArgs = require('Module:Arguments').getArgs
VariablesLua = mw.ext.VariablesLua
local Employee = {}

function Employee.main(frame)
	local args = getArgs(frame)

	local employees = ''
	
	local newEmployee = {
		id=args.id,
		position=args.position,
		joindate=args.joindate,
		leavedate=args.leavedate,
		inactivedate=args.inactivedate,
		newcompany=args.newcompany
	}
	
	if VariablesLua.varexists('Employees') then
		employees = VariablesLua.var('Employees')
		employees = employees .. '&&&' .. mw.text.jsonEncode(newEmployee)
	else
		employees = mw.text.jsonEncode(newEmployee)
	end
	
	VariablesLua.vardefine( 'Employees', employees )

	return 'yes'
end

return Employee