2014-02-03 19:24:49 +00:00
|
|
|
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
|
2013-06-12 15:59:58 +00:00
|
|
|
|
2013-08-21 18:35:22 +00:00
|
|
|
require 'ticket/overviews'
|
|
|
|
|
2012-04-10 14:06:46 +00:00
|
|
|
class TicketOverviewsController < ApplicationController
|
2015-05-07 11:23:55 +00:00
|
|
|
before_action :authentication_check
|
2012-04-10 14:06:46 +00:00
|
|
|
|
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 = []
|
|
|
|
index_and_lists.each { |index|
|
|
|
|
assets = {}
|
|
|
|
overview = Overview.lookup(id: index[:overview][:id])
|
|
|
|
meta = {
|
|
|
|
name: overview.name,
|
|
|
|
prio: overview.prio,
|
|
|
|
link: overview.link,
|
|
|
|
count: index[:count],
|
|
|
|
}
|
|
|
|
indexes.push meta
|
2012-07-20 13:47:04 +00:00
|
|
|
}
|
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 = {}
|
|
|
|
index_and_lists.each { |index|
|
|
|
|
next if index[:overview][:view] != params[:view]
|
|
|
|
|
|
|
|
overview = Overview.lookup(id: index[:overview][:id])
|
|
|
|
assets = overview.assets(assets)
|
2016-06-30 20:04:48 +00:00
|
|
|
index[:tickets].each { |ticket_meta|
|
2016-03-03 01:51:24 +00:00
|
|
|
ticket = Ticket.lookup(id: ticket_meta[:id])
|
|
|
|
assets = ticket.assets(assets)
|
2013-06-12 15:59:58 +00:00
|
|
|
}
|
2016-03-03 01:51:24 +00:00
|
|
|
result = index
|
2012-04-10 14:06:46 +00:00
|
|
|
}
|
|
|
|
|
2015-04-27 13:42:53 +00:00
|
|
|
render json: {
|
|
|
|
assets: assets,
|
2016-03-03 01:51:24 +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
|