Skip to content

Commit

Permalink
db click to send to chat
Browse files Browse the repository at this point in the history
  • Loading branch information
tg123 committed May 8, 2020
1 parent 40b5ec7 commit 21167ea
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 9 deletions.
28 changes: 24 additions & 4 deletions gui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1638,8 +1638,6 @@ function GUI:Init()
self.lootLogFrame.frame:SetPoint("TOPLEFT", f, "TOPLEFT", 30, -50)

self.lootLogFrame:RegisterEvents({


["OnClick"] = function (rowFrame, cellFrame, data, cols, row, realrow, column, sttable, button, ...)
clearAllFocus()
local entry, idx = GetEntryFromUI(rowFrame, cellFrame, data, cols, row, realrow, column, sttable)
Expand Down Expand Up @@ -1677,6 +1675,17 @@ function GUI:Init()
ChatEdit_InsertLink(entry["detail"]["item"])
end
end,

["OnDoubleClick"] = function (rowFrame, cellFrame, data, cols, row, realrow, column, sttable, button, ...)
local item, idx = GetEntryFromUI(rowFrame, cellFrame, data, cols, row, realrow, column, sttable)

if not item then
return
end

SendChatMessage(ADDONSELF.GenExportLine(item, item["costcache"], true), f.reportopt.channel)

end,
})
end

Expand Down Expand Up @@ -1713,6 +1722,8 @@ function GUI:Init()
filterzero = false,
}

f.reportopt = optctx

local setReportChannel = function(self)
optctx.channel = self.arg1
b:SetText(self.value)
Expand Down Expand Up @@ -1858,6 +1869,15 @@ function GUI:Init()
end,
notCheckable = true,
},
{
text = L["Expense"],
func = function()
GenReport(Database:GetCurrentLedger()["items"], GUI:GetSplitNumber(), optctx.channel, {
expenseonly = true,
})
end,
notCheckable = true,
},
{
isTitle = true,
text = OPTIONS,
Expand Down Expand Up @@ -1920,13 +1940,13 @@ function GUI:Init()
b:SetScript("OnClick", function()
if exportEditbox:GetParent():IsShown() then
lootLogFrame:Show()
countEdit:Show()
countEdit:Enable()
hidelockedCheck:Show()
exportEditbox:GetParent():Hide()
b:SetText(L["Export as text"])
else
lootLogFrame:Hide()
countEdit:Hide()
countEdit:Disable()
hidelockedCheck:Hide()
exportEditbox:GetParent():Show()
b:SetText(L["Close text export"])
Expand Down
29 changes: 24 additions & 5 deletions utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -162,23 +162,31 @@ end
ADDONSELF.calcavg = calcavg


local function GenExportLine(item, c)
local function GenExportLine(item, c, uselink)
local l = item["beneficiary"] or L["[Unknown]"]
local i = item["detail"]["item"] or ""
local cnt = item["detail"]["count"] or 1
local d = item["detail"]["displayname"] or ""
local t = item["type"]
local ct = item["costtype"]

local n = GetItemInfo(i) or d
n = n ~= "" and n or nil
n = n or L["Other"]
local n, link = GetItemInfo(i)
if uselink then
n = link
end
n = n or d
n = n ~= "" and n or L["Other"]

if t == "DEBIT" then
n = d or L["Compensation"]
end

local s = "[" .. n .. "] " .. " (" .. cnt .. ") " .. l .. " " .. GetMoneyStringL(c)
if not uselink then
n = "[" .. n .. "]"
end


local s = n .. " (" .. cnt .. ") " .. l .. " " .. GetMoneyStringL(c)

if ct == "PROFIT_PERCENT" then
s = s .. " (" .. (item["cost"] or 0) .. " % " .. L["Net Profit"] .. ")"
Expand All @@ -191,6 +199,8 @@ local function GenExportLine(item, c)
return s
end

ADDONSELF.GenExportLine = GenExportLine

local function sendchat(lines, channel)
local SendToChat = SendToCurrrentChannel
if channel then
Expand Down Expand Up @@ -356,6 +366,10 @@ ADDONSELF.genreport = function(items, n, channel, conf)
end
end

if conf.expenseonly then
wipe(lines)
end

if expense > 0 then
table.insert(lines, "RaidLedger:.... " .. L["Debit"] .. " ....")

Expand All @@ -370,6 +384,11 @@ ADDONSELF.genreport = function(items, n, channel, conf)
end
end

if conf.expenseonly then
sendchat(lines, channel)
return
end

if conf.short then
wipe(lines)
end
Expand Down

0 comments on commit 21167ea

Please sign in to comment.