Swshop: Add option to show out of stock items
- Make ShopView use colors from ui.theme
This commit is contained in:
@@ -29,10 +29,13 @@ local wizardPage = UI.WizardPage {
|
|||||||
[3] = UI.Checkbox {
|
[3] = UI.Checkbox {
|
||||||
formLabel = 'Single shop', formKey = 'refundInvalid',
|
formLabel = 'Single shop', formKey = 'refundInvalid',
|
||||||
help = 'Only this shop uses this domain',
|
help = 'Only this shop uses this domain',
|
||||||
limit = 64,
|
|
||||||
},
|
},
|
||||||
[4] = UI.Chooser {
|
[4] = UI.Checkbox {
|
||||||
formLabel = 'RS Signal', formKey = 'rsSide', formIndex = 5,
|
formLabel = 'Show out of stock', formKey = 'showOutOfStock',
|
||||||
|
help = 'Show out of stock items in red',
|
||||||
|
},
|
||||||
|
[5] = UI.Chooser {
|
||||||
|
formLabel = 'RS Signal', formKey = 'rsSide', formIndex = 6,
|
||||||
width = 10,
|
width = 10,
|
||||||
nochoice = 'Top',
|
nochoice = 'Top',
|
||||||
choices = {
|
choices = {
|
||||||
@@ -45,9 +48,9 @@ local wizardPage = UI.WizardPage {
|
|||||||
},
|
},
|
||||||
required = true,
|
required = true,
|
||||||
},
|
},
|
||||||
[5] = UI.Chooser {
|
[6] = UI.Chooser {
|
||||||
width = 9,
|
width = 9,
|
||||||
formIndex = 6,
|
formIndex = 7,
|
||||||
formLabel = 'Font Size', formKey = 'textScale',
|
formLabel = 'Font Size', formKey = 'textScale',
|
||||||
nochoice = 'Small',
|
nochoice = 'Small',
|
||||||
choices = {
|
choices = {
|
||||||
|
|||||||
@@ -49,15 +49,15 @@ local function createPage(node)
|
|||||||
local page = UI.Page {
|
local page = UI.Page {
|
||||||
parent = monitor,
|
parent = monitor,
|
||||||
header = UI.Window {
|
header = UI.Window {
|
||||||
backgroundColor = colors.cyan,
|
backgroundColor = 'primary',
|
||||||
ey = 3,
|
ey = 3,
|
||||||
},
|
},
|
||||||
grid = UI.Grid {
|
grid = UI.Grid {
|
||||||
y = 4, ey = -7,
|
y = 4, ey = -7,
|
||||||
headerHeight = 3,
|
headerHeight = 3,
|
||||||
headerBackgroundColor = colors.gray,
|
headerBackgroundColor = 'tertiary',
|
||||||
backgroundSelectedColor = colors.black,
|
backgroundSelectedColor = colors.black,
|
||||||
unfocusedBackgroundSelectedColor = colors.gray,
|
unfocusedBackgroundSelectedColor = 'tertiary',
|
||||||
columns = {
|
columns = {
|
||||||
{ heading = 'Stock', key = 'count', width = 6, align = 'right' },
|
{ heading = 'Stock', key = 'count', width = 6, align = 'right' },
|
||||||
{ heading = 'Name', key = 'displayName' },
|
{ heading = 'Name', key = 'displayName' },
|
||||||
@@ -68,17 +68,17 @@ local function createPage(node)
|
|||||||
},
|
},
|
||||||
footer = UI.Window {
|
footer = UI.Window {
|
||||||
y = -6,
|
y = -6,
|
||||||
backgroundColor = colors.gray,
|
backgroundColor = 'tertiary',
|
||||||
prevButton = UI.Button {
|
prevButton = UI.Button {
|
||||||
x = 2, y = 3, height = 3, width = 5,
|
x = 2, y = 3, height = 3, width = 5,
|
||||||
event = 'previous',
|
event = 'previous',
|
||||||
backgroundColor = colors.lightGray,
|
backgroundColor = 'secondary',
|
||||||
text = ' \017 ',
|
text = ' \017 ',
|
||||||
},
|
},
|
||||||
nextButton = UI.Button {
|
nextButton = UI.Button {
|
||||||
x = -6, y = 3, height = 3, width = 5,
|
x = -6, y = 3, height = 3, width = 5,
|
||||||
event = 'next',
|
event = 'next',
|
||||||
backgroundColor = colors.lightGray,
|
backgroundColor = 'secondary',
|
||||||
text = ' \016 ',
|
text = ' \016 ',
|
||||||
},
|
},
|
||||||
info = UI.Window {
|
info = UI.Window {
|
||||||
@@ -94,7 +94,7 @@ local function createPage(node)
|
|||||||
if node.header then
|
if node.header then
|
||||||
self:centeredWrite(2, node.header, nil, colors.white)
|
self:centeredWrite(2, node.header, nil, colors.white)
|
||||||
end
|
end
|
||||||
self:write(self.width - 15, 3, 'powered by Milo', nil, colors.gray)
|
self:write(self.width - 15, 3, 'powered by Milo', nil, 'tertiary')
|
||||||
end
|
end
|
||||||
|
|
||||||
function page.footer.info:draw()
|
function page.footer.info:draw()
|
||||||
@@ -112,6 +112,9 @@ local function createPage(node)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function page.grid:getRowTextColor(row, selected)
|
function page.grid:getRowTextColor(row, selected)
|
||||||
|
if row.count < 1 then
|
||||||
|
return colors.red
|
||||||
|
end
|
||||||
if selected then
|
if selected then
|
||||||
return colors.yellow
|
return colors.yellow
|
||||||
end
|
end
|
||||||
@@ -151,11 +154,11 @@ local function createPage(node)
|
|||||||
local list = Milo:listItems()
|
local list = Milo:listItems()
|
||||||
self.grid.values = { }
|
self.grid.values = { }
|
||||||
for k,v in pairs(config) do
|
for k,v in pairs(config) do
|
||||||
local item = list[k]
|
local item = list[k] or itemDB:get(k)
|
||||||
if item and item.count > 0 then
|
if item and (node.showOutOfStock or item.count > 0) then
|
||||||
table.insert(self.grid.values, {
|
table.insert(self.grid.values, {
|
||||||
displayName = item.displayName,
|
displayName = item.displayName,
|
||||||
count = item.count,
|
count = item.count or 0,
|
||||||
name = v.name,
|
name = v.name,
|
||||||
price = v.price,
|
price = v.price,
|
||||||
info = v.info,
|
info = v.info,
|
||||||
|
|||||||
Reference in New Issue
Block a user