round out queue and call with individual call input and clearing
This commit is contained in:
+23
-5
@@ -22,6 +22,13 @@ end
|
|||||||
|
|
||||||
function GetControls(props)
|
function GetControls(props)
|
||||||
local controls = {
|
local controls = {
|
||||||
|
{
|
||||||
|
Name = "Clear",
|
||||||
|
ControlType = "Button",
|
||||||
|
ButtonType = "Trigger",
|
||||||
|
PinStyle = "Input",
|
||||||
|
UserPin = true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Name = "QueueUp",
|
Name = "QueueUp",
|
||||||
ControlType = "Button",
|
ControlType = "Button",
|
||||||
@@ -48,14 +55,25 @@ end
|
|||||||
function Initialize()
|
function Initialize()
|
||||||
end
|
end
|
||||||
|
|
||||||
function SetupControlHandlers()
|
function CreateCall(name, queue)
|
||||||
Controls["QueueUp"].EventHandler = function (ctrl)
|
|
||||||
local call = {
|
local call = {
|
||||||
Queue = ctrl.Boolean,
|
Queue = queue,
|
||||||
Name = Controls["CallerName"].String,
|
Name = name,
|
||||||
Time = os.time()
|
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)
|
Controls["CallOut"].String = json.encode(call)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+33
-10
@@ -37,37 +37,55 @@ function GetControls(props)
|
|||||||
UserPin = true
|
UserPin = true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name = "TopCallName",
|
Name = "CallList",
|
||||||
ControlType = "Text",
|
ControlType = "Text",
|
||||||
PinStyle = "Output",
|
PinStyle = "Output",
|
||||||
UserPin = true
|
UserPin = true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name = "ClearAll",
|
||||||
|
ControlType = "Button",
|
||||||
|
ButtonType = "Trigger",
|
||||||
|
Pinstyle = "Input",
|
||||||
|
UserPin = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for i=1,props["Call Count"].Value do
|
for i=1,props["Call Count"].Value do
|
||||||
print(i)
|
|
||||||
local name = "Call" .. i
|
local name = "Call" .. i
|
||||||
table.insert(controls, {
|
table.insert(controls, {
|
||||||
Name = name,
|
Name = name .. "In",
|
||||||
ControlType = "Text",
|
ControlType = "Text",
|
||||||
PinStyle = "Input",
|
PinStyle = "Input",
|
||||||
UserPin = true
|
UserPin = true
|
||||||
})
|
})
|
||||||
|
table.insert(controls, {
|
||||||
|
Name = name .. "Clear",
|
||||||
|
ControlType = "Button",
|
||||||
|
ButttonType = "Trigger",
|
||||||
|
PinStyle = "Output",
|
||||||
|
UserPin = true
|
||||||
|
})
|
||||||
end
|
end
|
||||||
return controls
|
return controls
|
||||||
end
|
end
|
||||||
|
|
||||||
function ClearCalls()
|
function ClearCalls()
|
||||||
CallList = {}
|
CallList = {}
|
||||||
|
for i=1, Properties["Call Count"].Value do
|
||||||
|
Controls["Call"..i.."Clear"]:Trigger()
|
||||||
|
end
|
||||||
|
UpdateOutputs()
|
||||||
end
|
end
|
||||||
|
|
||||||
function UpdateOutputs()
|
function UpdateOutputs()
|
||||||
local topCall = CallList[1]
|
local listString = ""
|
||||||
if topCall == nil then
|
if (#CallList > 0) then
|
||||||
Controls["TopCallName"].String = ""
|
for i, v in pairs(CallList) do
|
||||||
else
|
listString = listString .. v.Name .. "\n"
|
||||||
Controls["TopCallName"].String = topCall.Name
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Controls["CallList"].String = listString
|
||||||
|
end
|
||||||
|
|
||||||
function PushCall(call)
|
function PushCall(call)
|
||||||
for i, value in pairs(CallList) do
|
for i, value in pairs(CallList) do
|
||||||
@@ -85,6 +103,7 @@ function PopCall()
|
|||||||
call = table.remove(CallList,1)
|
call = table.remove(CallList,1)
|
||||||
if call then
|
if call then
|
||||||
print("call for " .. call.Name .. " at position " .. call.Position .. " popped")
|
print("call for " .. call.Name .. " at position " .. call.Position .. " popped")
|
||||||
|
Controls["Call"..call.Position.."Clear"]:Trigger()
|
||||||
end
|
end
|
||||||
UpdateOutputs()
|
UpdateOutputs()
|
||||||
end
|
end
|
||||||
@@ -94,9 +113,9 @@ function RemoveCall(call)
|
|||||||
if value.Position == call.Position then
|
if value.Position == call.Position then
|
||||||
print("removing call for position " .. call.Position)
|
print("removing call for position " .. call.Position)
|
||||||
table.remove(CallList, i)
|
table.remove(CallList, i)
|
||||||
return
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
UpdateOutputs()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Initialize()
|
function Initialize()
|
||||||
@@ -108,8 +127,12 @@ function SetupControlHandlers()
|
|||||||
PopCall()
|
PopCall()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Controls["ClearAll"].EventHandler = function (ctrl)
|
||||||
|
ClearCalls()
|
||||||
|
end
|
||||||
|
|
||||||
for i=1, Properties["Call Count"].Value do
|
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
|
if ctrl.String ~= "" then
|
||||||
local call = json.decode(ctrl.String)
|
local call = json.decode(ctrl.String)
|
||||||
call.Position = i
|
call.Position = i
|
||||||
|
|||||||
Reference in New Issue
Block a user