2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2012-04-10 14:06:46 +00:00
|
|
|
class TicketOverviewsController < ApplicationController
|
2017-02-15 12:29:25 +00:00
|
|
|
prepend_before_action :authentication_check
|
2012-04-10 14:06:46 +00:00
|
|
|
|
2021-08-25 12:24:42 +00:00
|
|
|
# GET /api/v1/ticket_overview
|
|
|
|
def data
|
|
|
|
|
|
|
|
# get attributes to update
|
|
|
|
attributes_to_change = Ticket::ScreenOptions.attributes_to_change(
|
|
|
|
view: 'ticket_overview',
|
2022-06-02 13:13:04 +00:00
|
|
|
screen: 'overview_bulk',
|
2021-08-25 12:24:42 +00:00
|
|
|
current_user: current_user,
|
|
|
|
)
|
|
|
|
render json: attributes_to_change
|
|
|
|
end
|
|
|
|
|
2013-08-19 06:29:49 +00:00
|
|
|
# GET /api/v1/ticket_overviews
|
2012-04-10 14:06:46 +00:00
|
|
|
def show
|
|
|
|
|
2012-07-20 11:23:09 +00:00
|
|
|
# get navbar overview data
|
|
|
|
if !params[:view]
|
2016-03-03 01:51:24 +00:00
|
|
|
index_and_lists = Ticket::Overviews.index(current_user)
|
|
|
|
indexes = []
|
2017-10-01 12:25:52 +00:00
|
|
|
index_and_lists.each do |index|
|
2016-03-03 01:51:24 +00:00
|
|
|
overview = Overview.lookup(id: index[:overview][:id])
|
|
|
|
meta = {
|
2018-12-19 17:31:51 +00:00
|
|
|
name: overview.name,
|
|
|
|
prio: overview.prio,
|
|
|
|
link: overview.link,
|
2016-03-03 01:51:24 +00:00
|
|
|
count: index[:count],
|
|
|
|
}
|
|
|
|
indexes.push meta
|
2017-10-01 12:25:52 +00:00
|
|
|
end
|
2016-03-03 01:51:24 +00:00
|
|
|
render json: indexes
|
2012-11-26 23:22:52 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2016-03-03 01:51:24 +00:00
|
|
|
index_and_lists = Ticket::Overviews.index(current_user)
|
2012-04-10 14:06:46 +00:00
|
|
|
|
2016-03-03 01:51:24 +00:00
|
|
|
assets = {}
|
|
|
|
result = {}
|
2017-10-01 12:25:52 +00:00
|
|
|
index_and_lists.each do |index|
|
2016-03-03 01:51:24 +00:00
|
|
|
next if index[:overview][:view] != params[:view]
|
|
|
|
|
|
|
|
overview = Overview.lookup(id: index[:overview][:id])
|
|
|
|
assets = overview.assets(assets)
|
2017-10-01 12:25:52 +00:00
|
|
|
index[:tickets].each do |ticket_meta|
|
2016-03-03 01:51:24 +00:00
|
|
|
ticket = Ticket.lookup(id: ticket_meta[:id])
|
|
|
|
assets = ticket.assets(assets)
|
2017-10-01 12:25:52 +00:00
|
|
|
end
|
2016-03-03 01:51:24 +00:00
|
|
|
result = index
|
2017-10-01 12:25:52 +00:00
|
|
|
end
|
2012-04-10 14:06:46 +00:00
|
|
|
|
2015-04-27 13:42:53 +00:00
|
|
|
render json: {
|
|
|
|
assets: assets,
|
2018-12-19 17:31:51 +00:00
|
|
|
index: result,
|
2012-04-14 16:47:37 +00:00
|
|
|
}
|
2012-04-10 14:06:46 +00:00
|
|
|
end
|
|
|
|
|
2013-06-12 15:59:58 +00:00
|
|
|
end
|