round out queue and call with individual call input and clearing

This commit is contained in:
2026-05-02 00:11:02 +00:00
parent 453940146b
commit 3f19c32acc
2 changed files with 234 additions and 193 deletions
+23 -5
View File
@@ -22,6 +22,13 @@ end
function GetControls(props)
local controls = {
{
Name = "Clear",
ControlType = "Button",
ButtonType = "Trigger",
PinStyle = "Input",
UserPin = true
},
{
Name = "QueueUp",
ControlType = "Button",
@@ -48,14 +55,25 @@ end
function Initialize()
end
function SetupControlHandlers()
Controls["QueueUp"].EventHandler = function (ctrl)
function CreateCall(name, queue)
local call = {
Queue = ctrl.Boolean,
Name = Controls["CallerName"].String,
Queue = queue,
Name = name,
Time = os.time()
}
local callString = json.encode(call)
return call
end
function SetupControlHandlers()
Controls["QueueUp"].EventHandler = function (ctrl)
local call = CreateCall(Controls["CallerName"].String, Controls["QueueUp"].Boolean)
Controls["CallOut"].String = json.encode(call)
end
Controls["Clear"].EventHandler = function (ctrl)
Controls["QueueUp"].Boolean = false
local call = CreateCall(Controls["CallerName"].String, false)
Controls["CallOut"].String = json.encode(call)
end
end
+33 -10
View File
@@ -37,36 +37,54 @@ function GetControls(props)
UserPin = true
},
{
Name = "TopCallName",
Name = "CallList",
ControlType = "Text",
PinStyle = "Output",
UserPin = true
},
{
Name = "ClearAll",
ControlType = "Button",
ButtonType = "Trigger",
Pinstyle = "Input",
UserPin = true
}
}
for i=1,props["Call Count"].Value do
print(i)
local name = "Call" .. i
table.insert(controls, {
Name = name,
Name = name .. "In",
ControlType = "Text",
PinStyle = "Input",
UserPin = true
})
table.insert(controls, {
Name = name .. "Clear",
ControlType = "Button",
ButttonType = "Trigger",
PinStyle = "Output",
UserPin = true
})
end
return controls
end
function ClearCalls()
CallList = {}
for i=1, Properties["Call Count"].Value do
Controls["Call"..i.."Clear"]:Trigger()
end
UpdateOutputs()
end
function UpdateOutputs()
local topCall = CallList[1]
if topCall == nil then
Controls["TopCallName"].String = ""
else
Controls["TopCallName"].String = topCall.Name
local listString = ""
if (#CallList > 0) then
for i, v in pairs(CallList) do
listString = listString .. v.Name .. "\n"
end
end
Controls["CallList"].String = listString
end
function PushCall(call)
@@ -85,6 +103,7 @@ function PopCall()
call = table.remove(CallList,1)
if call then
print("call for " .. call.Name .. " at position " .. call.Position .. " popped")
Controls["Call"..call.Position.."Clear"]:Trigger()
end
UpdateOutputs()
end
@@ -94,9 +113,9 @@ function RemoveCall(call)
if value.Position == call.Position then
print("removing call for position " .. call.Position)
table.remove(CallList, i)
return
end
end
UpdateOutputs()
end
function Initialize()
@@ -108,8 +127,12 @@ function SetupControlHandlers()
PopCall()
end
Controls["ClearAll"].EventHandler = function (ctrl)
ClearCalls()
end
for i=1, Properties["Call Count"].Value do
Controls["Call"..i].EventHandler = function (ctrl)
Controls["Call"..i.."In"].EventHandler = function (ctrl)
if ctrl.String ~= "" then
local call = json.decode(ctrl.String)
call.Position = i