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

(-)a/Koha/REST/V1/Tickets.pm (-1 / +16 lines)
Lines 116-124 sub update { Link Here
116
        );
116
        );
117
    }
117
    }
118
118
119
    my $assignee_before = $ticket->assignee_id;
119
    return try {
120
    return try {
120
        $ticket->set_from_api( $c->req->json );
121
        $ticket->set_from_api( $c->req->json );
121
        $ticket->store();
122
        $ticket->store();
123
124
        # Create update if assignee changed
125
        if ( $assignee_before ne $ticket->assignee_id ) {
126
            my $patron = $c->stash('koha.user');
127
            my $update =
128
                { user_id => $patron->id, ticket_id => $ticket->id, public => 0, assignee_id => $ticket->assignee_id };
129
            Koha::Ticket::Updates->new($update)->store();
130
        }
122
        return $c->render( status => 200, openapi => $ticket->to_api );
131
        return $c->render( status => 200, openapi => $ticket->to_api );
123
    }
132
    }
124
    catch {
133
    catch {
Lines 197-203 sub add_update { Link Here
197
        );
206
        );
198
    }
207
    }
199
208
200
     # Set reporter from session
209
     # Set user from session
201
     $ticket_update->{user_id} = $patron->id;
210
     $ticket_update->{user_id} = $patron->id;
202
     # FIXME: We should allow impersonation at a later date to
211
     # FIXME: We should allow impersonation at a later date to
203
     # allow an API user to submit on behalf of a user
212
     # allow an API user to submit on behalf of a user
Lines 226-231 sub add_update { Link Here
226
            $ticket->set( { status => $ticket_update->{status} } )->store;
235
            $ticket->set( { status => $ticket_update->{status} } )->store;
227
        }
236
        }
228
237
238
        # Update ticket assignee if needed
239
        if ( $ticket_update->{assignee_id} ) {
240
            my $ticket = $update->ticket;
241
            $ticket->set( { assignee_id => $ticket_update->{assignee_id} } )->store;
242
        }
243
229
        # Optionally add to message_queue here to notify reporter
244
        # Optionally add to message_queue here to notify reporter
230
        if ( $update->public ) {
245
        if ( $update->public ) {
231
            my $notice =
246
            my $notice =
(-)a/Koha/Ticket.pm (+13 lines)
Lines 47-52 sub reporter { Link Here
47
    return Koha::Patron->_new_from_dbic($rs);
47
    return Koha::Patron->_new_from_dbic($rs);
48
}
48
}
49
49
50
=head3 assignee
51
52
Return the patron who submitted this ticket
53
54
=cut
55
56
sub assignee {
57
    my ($self) = @_;
58
    my $rs = $self->_result->assignee;
59
    return unless $rs;
60
    return Koha::Patron->_new_from_dbic($rs);
61
}
62
50
=head3 resolver
63
=head3 resolver
51
64
52
Return the user who resolved this ticket
65
Return the user who resolved this ticket
(-)a/Koha/Ticket/Update.pm (+13 lines)
Lines 55-60 sub user { Link Here
55
    return Koha::Patron->_new_from_dbic($rs);
55
    return Koha::Patron->_new_from_dbic($rs);
56
}
56
}
57
57
58
=head3 assignee
59
60
Return the patron who is assigned at this update
61
62
=cut
63
64
sub assignee {
65
    my ($self) = @_;
66
    my $rs = $self->_result->assignee;
67
    return unless $rs;
68
    return Koha::Patron->_new_from_dbic($rs);
69
}
70
58
=head2 Internal methods
71
=head2 Internal methods
59
72
60
=head3 to_api_mapping
73
=head3 to_api_mapping
(-)a/api/v1/swagger/definitions/ticket.yaml (+8 lines)
Lines 42-47 properties: Link Here
42
  reporter_id:
42
  reporter_id:
43
    type: integer
43
    type: integer
44
    description: Internal identifier for the patron who reported the ticket
44
    description: Internal identifier for the patron who reported the ticket
45
  assignee:
46
    type:
47
      - object
48
      - "null"
49
  assignee_id:
50
    type:
51
      - integer
52
      - "null"
45
  resolver:
53
  resolver:
46
    type:
54
    type:
47
      - object
55
      - object
(-)a/api/v1/swagger/definitions/ticket_update.yaml (+8 lines)
Lines 18-23 properties: Link Here
18
  user_id:
18
  user_id:
19
    type: integer
19
    type: integer
20
    description: Internal identifier for the patron who added the update
20
    description: Internal identifier for the patron who added the update
21
  assignee:
22
    type:
23
      - object
24
      - "null"
25
  assignee_id:
26
    type:
27
      - integer
28
      - "null"
21
  date:
29
  date:
22
    type:
30
    type:
23
      - string
31
      - string
(-)a/api/v1/swagger/paths/tickets.yaml (+2 lines)
Lines 24-29 Link Here
24
        items:
24
        items:
25
          type: string
25
          type: string
26
          enum:
26
          enum:
27
            - assignee
27
            - reporter
28
            - reporter
28
            - resolver
29
            - resolver
29
            - biblio
30
            - biblio
Lines 237-242 Link Here
237
        items:
238
        items:
238
          type: string
239
          type: string
239
          enum:
240
          enum:
241
            - assignee
240
            - user
242
            - user
241
            - +strings
243
            - +strings
242
        collectionFormat: csv
244
        collectionFormat: csv
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/concerns.tt (-2 / +2 lines)
Lines 102-107 Link Here
102
                    "url": tickets_url
102
                    "url": tickets_url
103
                },
103
                },
104
                "embed": [
104
                "embed": [
105
                    "assignee",
105
                    "reporter",
106
                    "reporter",
106
                    "resolver",
107
                    "resolver",
107
                    "biblio",
108
                    "biblio",
Lines 160-166 Link Here
160
                        "orderable": true
161
                        "orderable": true
161
                    },
162
                    },
162
                    {
163
                    {
163
                        "data": "resolver.firstname:resolver.surname:resolved_date:status",
164
                        "data": "assignee.firstname:assignee.surname:resolver.firstname:resolver.surname:resolved_date:status",
164
                        "render": function(data, type, row, meta) {
165
                        "render": function(data, type, row, meta) {
165
                            let result = '';
166
                            let result = '';
166
                            if (row.resolved_date) {
167
                            if (row.resolved_date) {
167
- 

Return to bug 35657