View | Details | Raw Unified | Return to bug 22440
Collapse All | Expand All

(-)a/Koha/REST/V1/Illbackends.pm (+44 lines)
Lines 51-56 sub list { Link Here
51
    return $c->render( status => 200, openapi => \@data );
51
    return $c->render( status => 200, openapi => \@data );
52
}
52
}
53
53
54
=head3 list_statuses
55
56
Return a list of existing ILL statuses
57
58
=cut
59
60
sub list_statuses {
61
    my $c = shift->openapi->valid_input;
62
63
    my $backend_id = $c->validation->param('ill_backend_id');
64
65
    #FIXME: Currently fetching all requests, it'd be great if we could fetch distinct(status).
66
    # Even doing it with distinct status, we need the ILL request object, so that strings_map works and
67
    # the ILL request returns the correct status and info respective to its backend.
68
    my $ill_requests = Koha::Illrequests->search(
69
            {backend => $backend_id},
70
            # {
71
            #     columns => [ qw/status/ ],
72
            #     group_by => [ qw/status/ ],
73
            # }
74
        );
75
76
    my @data;
77
    while (my $request = $ill_requests->next) {
78
        my $status_data = $request->strings_map;
79
80
        foreach my $status_class ( qw(status_alias status) ){
81
            if ($status_data->{$status_class}){
82
                push @data, {
83
                    $status_data->{$status_class}->{str} ? (str => $status_data->{$status_class}->{str}) :
84
                        $status_data->{$status_class}->{code} ? (str => $status_data->{$status_class}->{code}) : (),
85
                    $status_data->{$status_class}->{code} ? (code => $status_data->{$status_class}->{code}) : (),
86
                }
87
            }
88
        }
89
    }
90
91
    # Remove duplicate statuses
92
    my %seen;
93
    @data =  grep { my $e = $_; my $key = join '___', map { $e->{$_}; } sort keys %$_;!$seen{$key}++ } @data;
94
95
    return $c->render( status => 200, openapi => \@data );
96
}
97
54
=head3 get
98
=head3 get
55
99
56
Get one backend
100
Get one backend
(-)a/api/v1/swagger/definitions/ill_status.yaml (+19 lines)
Line 0 Link Here
1
---
2
type: object
3
properties:
4
  str:
5
    type: string
6
    description: Internal ILL status display string
7
  code:
8
    type: string
9
    description: Internal ILL status code or av code
10
  type:
11
    type: string
12
    description: This is 'ill_status' or 'av' depending on if coming from backend or authorised values i.e. alias
13
  backend:
14
    type: string
15
    description: The backend in which this status is used
16
  category:
17
    type: string
18
    description: The AV category in which the status aliases exists in
19
additionalProperties: false
(-)a/api/v1/swagger/definitions/ill_statuses.yaml (+5 lines)
Line 0 Link Here
1
---
2
type: array
3
items:
4
  $ref: "ill_status.yaml"
5
additionalProperties: false
(-)a/api/v1/swagger/paths/ill_backends.yaml (-4 / +50 lines)
Lines 1-10 Link Here
1
---
1
---
2
/ill_backends:
2
/ill/backends:
3
  get:
3
  get:
4
    x-mojo-to: Illbackends#list
4
    x-mojo-to: Illbackends#list
5
    operationId: listIllbackends
5
    operationId: listIllbackends
6
    tags:
6
    tags:
7
      - illbackends
7
      - ill_backends
8
    summary: List ILL backends
8
    summary: List ILL backends
9
    parameters: []
9
    parameters: []
10
    produces:
10
    produces:
Lines 40-51 Link Here
40
    x-koha-authorization:
40
    x-koha-authorization:
41
      permissions:
41
      permissions:
42
        ill: "1"
42
        ill: "1"
43
"/ill_backends/{ill_backend_id}":
43
"/ill/backends/{ill_backend_id}":
44
  get:
44
  get:
45
    x-mojo-to: Illbackends#get
45
    x-mojo-to: Illbackends#get
46
    operationId: getIllbackends
46
    operationId: getIllbackends
47
    tags:
47
    tags:
48
      - illbackends
48
      - ill_backends
49
    summary: Get ILL backend
49
    summary: Get ILL backend
50
    parameters:
50
    parameters:
51
      - name: ill_backend_id
51
      - name: ill_backend_id
Lines 86-88 Link Here
86
    x-koha-authorization:
86
    x-koha-authorization:
87
      permissions:
87
      permissions:
88
        ill: "1"
88
        ill: "1"
89
"/ill/backends/{ill_backend_id}/statuses":
90
  get:
91
    x-mojo-to: Illbackends#list_statuses
92
    operationId: getIllbackendsStatuses
93
    tags:
94
      - ill_backends
95
    summary: Get existing ILL statuses
96
    parameters:
97
      - name: ill_backend_id
98
        in: path
99
        description: ILL backend id/name
100
        required: true
101
        type: string
102
    produces:
103
      - application/json
104
    responses:
105
      "200":
106
        description: A list of existing ILL statuses
107
        schema:
108
          $ref: "../swagger.yaml#/definitions/ill_statuses"
109
      "401":
110
        description: Authentication required
111
        schema:
112
          $ref: "../swagger.yaml#/definitions/error"
113
      "403":
114
        description: Access forbidden
115
        schema:
116
          $ref: "../swagger.yaml#/definitions/error"
117
      "404":
118
        description: ILL backends not found
119
        schema:
120
          $ref: "../swagger.yaml#/definitions/error"
121
      "500":
122
        description: |
123
          Internal server error. Possible `error_code` attribute values:
124
125
          * `internal_server_error`
126
        schema:
127
          $ref: "../swagger.yaml#/definitions/error"
128
      "503":
129
        description: Under maintenance
130
        schema:
131
          $ref: "../swagger.yaml#/definitions/error"
132
    x-koha-authorization:
133
      permissions:
134
        ill: "1"
(-)a/api/v1/swagger/paths/illrequests.yaml (-1 / +1 lines)
Lines 1-5 Link Here
1
---
1
---
2
/ill_requests:
2
/ill/requests:
3
  get:
3
  get:
4
    x-mojo-to: Illrequests#list
4
    x-mojo-to: Illrequests#list
5
    operationId: listIllrequests
5
    operationId: listIllrequests
(-)a/api/v1/swagger/swagger.yaml (-10 / +14 lines)
Lines 52-57 definitions: Link Here
52
    $ref: ./definitions/ill_backend.yaml
52
    $ref: ./definitions/ill_backend.yaml
53
  ill_backends:
53
  ill_backends:
54
    $ref: ./definitions/ill_backends.yaml
54
    $ref: ./definitions/ill_backends.yaml
55
  ill_status:
56
    $ref: ./definitions/ill_status.yaml
57
  ill_statuses:
58
    $ref: ./definitions/ill_statuses.yaml
55
  ill_request:
59
  ill_request:
56
    $ref: ./definitions/ill_request.yaml
60
    $ref: ./definitions/ill_request.yaml
57
  import_batch_profile:
61
  import_batch_profile:
Lines 241-254 paths: Link Here
241
    $ref: "./paths/holds.yaml#/~1holds~1{hold_id}~1priority"
245
    $ref: "./paths/holds.yaml#/~1holds~1{hold_id}~1priority"
242
  "/holds/{hold_id}/suspension":
246
  "/holds/{hold_id}/suspension":
243
    $ref: "./paths/holds.yaml#/~1holds~1{hold_id}~1suspension"
247
    $ref: "./paths/holds.yaml#/~1holds~1{hold_id}~1suspension"
244
  /ill_backends:
248
  /ill/backends:
245
    $ref: ./paths/ill_backends.yaml#/~1ill_backends
249
    $ref: ./paths/ill_backends.yaml#/~1ill~1backends
246
  "/ill_backends/{ill_backend_id}":
250
  "/ill/backends/{ill_backend_id}":
247
    $ref: "./paths/ill_backends.yaml#/~1ill_backends~1{ill_backend_id}"
251
    $ref: "./paths/ill_backends.yaml#/~1ill~1backends~1{ill_backend_id}"
248
  /illrequests:
252
  "/ill/backends/{ill_backend_id}/statuses":
249
    $ref: ./paths/illrequests.yaml#/~1illrequests
253
    $ref: "./paths/ill_backends.yaml#/~1ill~1backends~1{ill_backend_id}~1statuses"
250
  /ill_requests:
254
  /ill/requests:
251
    $ref: ./paths/illrequests.yaml#/~1ill_requests
255
    $ref: ./paths/ill_requests.yaml#/~1ill~1requests
252
  "/import_batches/{import_batch_id}/records/{import_record_id}/matches/chosen":
256
  "/import_batches/{import_batch_id}/records/{import_record_id}/matches/chosen":
253
    $ref: "./paths/import_batches.yaml#/~1import_batches~1{import_batch_id}~1records~1{import_record_id}~1matches~1chosen"
257
    $ref: "./paths/import_batches.yaml#/~1import_batches~1{import_batch_id}~1records~1{import_record_id}~1matches~1chosen"
254
  /import_batch_profiles:
258
  /import_batch_profiles:
Lines 785-794 tags: Link Here
785
    name: holds
789
    name: holds
786
    x-displayName: Holds
790
    x-displayName: Holds
787
  - description: "Manage ILL module backends\n"
791
  - description: "Manage ILL module backends\n"
788
    name: illbackends
792
    name: ill_backends
789
    x-displayName: ILL backends
793
    x-displayName: ILL backends
790
  - description: "Manage ILL requests\n"
794
  - description: "Manage ILL requests\n"
791
    name: illrequests
795
    name: ill_requests
792
    x-displayName: ILL requests
796
    x-displayName: ILL requests
793
  - description: "Manage import batches\n"
797
  - description: "Manage import batches\n"
794
    name: import_batches
798
    name: import_batches
(-)a/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js (-4 / +3 lines)
Lines 180-186 $(document).ready(function() { Link Here
180
180
181
    var ill_requests_table = $("#ill-requests").kohaTable({
181
    var ill_requests_table = $("#ill-requests").kohaTable({
182
        "ajax": {
182
        "ajax": {
183
            "url": '/api/v1/ill_requests'
183
            "url": '/api/v1/ill/requests'
184
        },
184
        },
185
        "embed": [
185
        "embed": [
186
            '+strings',
186
            '+strings',
Lines 430-436 $(document).ready(function() { Link Here
430
    function populateStatusFilter(backend) {
430
    function populateStatusFilter(backend) {
431
        $.ajax({
431
        $.ajax({
432
            type: "GET",
432
            type: "GET",
433
            url: "/api/v1/ill_backends/"+backend+"/statuses",
433
            url: "/api/v1/ill/backends/"+backend+"/statuses",
434
            success: function(statuses){
434
            success: function(statuses){
435
                $('#illfilter_status').append(
435
                $('#illfilter_status').append(
436
                    '<option value="">'+ill_all_statuses+'</option>'
436
                    '<option value="">'+ill_all_statuses+'</option>'
Lines 448-454 $(document).ready(function() { Link Here
448
    function populateBackendFilter() {
448
    function populateBackendFilter() {
449
        $.ajax({
449
        $.ajax({
450
            type: "GET",
450
            type: "GET",
451
            url: "/api/v1/ill_backends",
451
            url: "/api/v1/ill/backends",
452
            success: function(backends){
452
            success: function(backends){
453
                backends.sort((a, b) => a.ill_backend_id.localeCompare(b.ill_backend_id)).forEach(function(backend) {
453
                backends.sort((a, b) => a.ill_backend_id.localeCompare(b.ill_backend_id)).forEach(function(backend) {
454
                    $('#illfilter_backend').append(
454
                    $('#illfilter_backend').append(
455
- 

Return to bug 22440