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

(-)a/Koha/REST/V1/Tickets.pm (-4 / +23 lines)
Lines 116-127 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();
122
        return $c->render( status => 200, openapi => $c->objects->to_api($ticket), );
123
123
    }
124
        # Create update if assignee changed
124
    catch {
125
        if ( $assignee_before ne $ticket->assignee_id ) {
126
            my $patron = $c->stash('koha.user');
127
            my $update = {
128
                user_id     => $patron->id,
129
                ticket_id   => $ticket->id,
130
                public      => 0,
131
                assignee_id => $ticket->assignee_id,
132
                message     => ''
133
            };
134
            Koha::Ticket::Update->new($update)->store();
135
        }
136
        return $c->render( status => 200, openapi => $c->objects->to_api($ticket) );
137
    } catch {
125
        $c->unhandled_exception($_);
138
        $c->unhandled_exception($_);
126
    };
139
    };
127
}
140
}
Lines 197-203 sub add_update { Link Here
197
        );
210
        );
198
    }
211
    }
199
212
200
     # Set reporter from session
213
     # Set user from session
201
     $ticket_update->{user_id} = $patron->id;
214
     $ticket_update->{user_id} = $patron->id;
202
     # FIXME: We should allow impersonation at a later date to
215
     # FIXME: We should allow impersonation at a later date to
203
     # allow an API user to submit on behalf of a user
216
     # 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;
239
            $ticket->set( { status => $ticket_update->{status} } )->store;
227
        }
240
        }
228
241
242
        # Update ticket assignee if needed
243
        if ( $ticket_update->{assignee_id} ) {
244
            my $ticket = $update->ticket;
245
            $ticket->set( { assignee_id => $ticket_update->{assignee_id} } )->store;
246
        }
247
229
        # Optionally add to message_queue here to notify reporter
248
        # Optionally add to message_queue here to notify reporter
230
        if ( $update->public ) {
249
        if ( $update->public ) {
231
            my $notice =
250
            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 46-51 properties: Link Here
46
  reporter_id:
46
  reporter_id:
47
    type: integer
47
    type: integer
48
    description: Internal identifier for the patron who reported the ticket
48
    description: Internal identifier for the patron who reported the ticket
49
  assignee:
50
    type:
51
      - object
52
      - "null"
53
  assignee_id:
54
    type:
55
      - integer
56
      - "null"
49
  resolver:
57
  resolver:
50
    type:
58
    type:
51
      - object
59
      - 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 104-109 Link Here
104
                    "url": tickets_url
104
                    "url": tickets_url
105
                },
105
                },
106
                "embed": [
106
                "embed": [
107
                    "assignee",
107
                    "reporter",
108
                    "reporter",
108
                    "resolver",
109
                    "resolver",
109
                    "biblio",
110
                    "biblio",
Lines 162-168 Link Here
162
                        "orderable": true
163
                        "orderable": true
163
                    },
164
                    },
164
                    {
165
                    {
165
                        "data": "resolver.firstname:resolver.surname:resolved_date:status",
166
                        "data": "assignee.firstname:assignee.surname:resolver.firstname:resolver.surname:resolved_date:status",
166
                        "render": function(data, type, row, meta) {
167
                        "render": function(data, type, row, meta) {
167
                            let result = '';
168
                            let result = '';
168
                            if (row.resolved_date) {
169
                            if (row.resolved_date) {
169
- 

Return to bug 35657