From 09ac08508bbf314151d3b199906c6e1b4cef50aa Mon Sep 17 00:00:00 2001 From: Gerhard Jungwirth Date: Thu, 22 May 2014 11:28:29 +0200 Subject: [PATCH] MT#7119 API document sortable columns for collections, as query parameters --- lib/NGCP/Panel/Controller/API/Root.pm | 12 +++++++++++- share/templates/api/root/collection.tt | 6 ++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/NGCP/Panel/Controller/API/Root.pm b/lib/NGCP/Panel/Controller/API/Root.pm index c75990e8ea..de380cc9b3 100644 --- a/lib/NGCP/Panel/Controller/API/Root.pm +++ b/lib/NGCP/Panel/Controller/API/Root.pm @@ -70,8 +70,17 @@ sub GET : Allow { my $actions = [ keys %{ $full_mod->config->{action} } ]; my $item_actions = $full_item_mod->can('config') ? [ keys %{ $full_item_mod->config->{action} } ] : []; - my $form = $full_mod->get_form($c); + + my $sorting_cols = []; + my $item_rs; + try { + $item_rs = $full_mod->item_rs($c, ""); + } + if ($item_rs) { + $sorting_cols = [$item_rs->result_source->columns]; + } + $c->stash->{collections}->{$rel} = { name => $mod, description => $full_mod->api_description, @@ -79,6 +88,7 @@ sub GET : Allow { query_params => $query_params, actions => $actions, item_actions => $item_actions, + sorting_cols => $sorting_cols, }; } diff --git a/share/templates/api/root/collection.tt b/share/templates/api/root/collection.tt index 32ef0a2c06..2cec7c7760 100644 --- a/share/templates/api/root/collection.tt +++ b/share/templates/api/root/collection.tt @@ -51,15 +51,13 @@ See description how to obtain properties, if any. Query Parameters -[% UNLESS col.query_params.size -%] -None. -[% ELSE -%] -[% END -%] Examples