Skip to content

Commit a4eb85d

Browse files
committed
feat(telescope): add tech names in entry (ordinal only)
1 parent bf7727f commit a4eb85d

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lua/telescope/_extensions/glpi/tickets.lua

+11-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ local function get_tickets()
1717
local function extract_ticket(t)
1818
for _, ticket in ipairs(t) do
1919
local id = ticket["2"]
20-
local name = ticket["1"] .. " (" .. ticket["4"] .. ")"
20+
local techs = ticket["5"]
21+
local techs_name = type(techs) == "table" and table.concat(techs, " ") or techs
22+
23+
local name = ticket["1"] .. " (" .. ticket["4"] .. ") users: " .. techs_name
2124
tickets[name] = id
2225
end
2326
end
@@ -40,14 +43,20 @@ return function()
4043
prompt_title = "Tickets en attente",
4144
finder = finders.new_table({
4245
results = get_tickets(),
46+
entry_maker = function(entry)
47+
return {
48+
ordinal = entry,
49+
display = entry:gsub(" users: .*$", ""),
50+
}
51+
end,
4352
}),
4453
sorter = conf.generic_sorter(),
4554
attach_mappings = function(prompt_bufnr, _)
4655
actions.select_default:replace(function()
4756
actions.close(prompt_bufnr)
4857

4958
local selection = state.get_selected_entry()
50-
local ticket_id = tickets[selection[1]]
59+
local ticket_id = tickets[selection.ordinal]
5160
local ticket = api.get_ticket_id(ticket_id)
5261
glpi.load_tickets()
5362
glpi.load_ticket(ticket)

0 commit comments

Comments
 (0)