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

(-)a/C4/Serials.pm (-4 / +4 lines)
Lines 281-290 sub GetSubscription { Link Here
281
    });
281
    });
282
    $subscription->{additional_fields} = $additional_field_values->{$subscriptionid};
282
    $subscription->{additional_fields} = $additional_field_values->{$subscriptionid};
283
283
284
    if ( my $mana_id = $subscription->{mana_id} ) {
284
    if ( C4::Context->preference('Mana') == 1 ) {
285
        my $mana_subscription = Koha::SharedContent::get_entity_by_id(
285
        $subscription->{comments} = Koha::SharedContent::get_entity_comments(
286
            'subscription', $mana_id, {usecomments => 1});
286
            'subscription', $subscription->{mana_id}
287
        $subscription->{comments} = $mana_subscription->{data}->{comments};
287
        );
288
    }
288
    }
289
289
290
    return $subscription;
290
    return $subscription;
(-)a/Koha/SharedContent.pm (+30 lines)
Lines 134-139 sub get_entity_by_id { Link Here
134
    return process_request(build_request('getwithid', @_));
134
    return process_request(build_request('getwithid', @_));
135
}
135
}
136
136
137
=head3 get_entity_comments
138
139
=cut
140
141
sub get_entity_comments {
142
    my ($resource, $id) = @_;
143
144
    unless ($id) {
145
        return [];
146
    }
147
148
    my $entity = get_entity_by_id(
149
        $resource, $id, { usecomments => 1 }
150
    );
151
152
    return $entity->{data}->{comments};
153
}
154
155
=head3 send_entity_comment
156
157
=cut
158
159
sub send_entity_comment {
160
    my ($content) = @_;
161
162
    my $result = process_request(build_request('post', 'resource_comment', $content));
163
164
    return $result;
165
}
166
137
=head3 search_entities
167
=head3 search_entities
138
168
139
=cut
169
=cut
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/mana.inc (-3 / +15 lines)
Lines 7-22 $(document).ready(function() { Link Here
7
            url: "/cgi-bin/koha/svc/mana/increment",
7
            url: "/cgi-bin/koha/svc/mana/increment",
8
            data: {id: mana_id, resource: resource, field: fieldvalue, step: stepvalue},
8
            data: {id: mana_id, resource: resource, field: fieldvalue, step: stepvalue},
9
            datatype: "json",
9
            datatype: "json",
10
        })
10
        }).done(function(result) {
11
            data = JSON.parse(result);
12
13
            html = data.message + ' (' + data.new_count + ')';
14
            comment = $('li.mana-comment[data-id="' + data.id + '"] a').html(html);
15
        });
11
    }
16
    }
12
17
13
    function mana_comment( target_id, manamsg, resource_type ) {
18
    function mana_comment( target_id, manamsg, resource_type ) {
14
        $.ajax( {
19
        $.ajax( {
15
            type: "POST",
20
            type: "POST",
16
            url: "/cgi-bin/koha/svc/mana/share",
21
            url: "/cgi-bin/koha/svc/mana/comment",
17
            data: {message: manamsg, resource: resource_type , resource_id: target_id},
22
            data: {message: manamsg, resource: resource_type , resource_id: target_id},
18
            datatype: "json",
23
            datatype: "json",
19
        })
24
        }).done(function(result) {
25
            data = JSON.parse(result);
26
            comment = $('<li></li>').addClass('mana-comment')
27
                .attr('data-id', data.id)
28
                .append('<a>' + manamsg + ' (1)</a>');
29
30
            $('.mana-comment-divider').before(comment);
31
        });
20
    }
32
    }
21
33
22
    $(document).on('click', 'ul li.mana-comment', function() {
34
    $(document).on('click', 'ul li.mana-comment', function() {
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-toolbar.inc (-2 / +2 lines)
Lines 70-77 Link Here
70
                            <a href="#">[% c.message | html %] ([% c.nb | html %])</a>
70
                            <a href="#">[% c.message | html %] ([% c.nb | html %])</a>
71
                        </li>
71
                        </li>
72
                    [% END %]
72
                    [% END %]
73
                    <li role="separator" class="divider"></li>
73
                    <li role="separator" class="divider mana-comment-divider"></li>
74
                    <li class="mana-other-comment"><a href="#">Other</a> </li>
74
                    <li class="mana-other-comment"><a href="#">New</a> </li>
75
                </ul>
75
                </ul>
76
            </div>
76
            </div>
77
77
(-)a/svc/mana/share (-22 / +3 lines)
Lines 44-69 my $content; Link Here
44
$content->{resource_id} = $input->param("resource_id");
44
$content->{resource_id} = $input->param("resource_id");
45
$content->{resource_type} = $input->param("resource");
45
$content->{resource_type} = $input->param("resource");
46
$content->{message} = $input->param("message");
46
$content->{message} = $input->param("message");
47
Koha::SharedContent::send_entity('', undef, undef, 'resource_comment', $content);
48
my $package = "Koha::".ucfirst($input->param('resource'));
49
my $resource;
50
my $result;
51
eval{
52
    $result = Koha::SharedContent::get_entity_by_id(
53
        scalar $input->param('resource'),
54
        scalar $input->param('id')
55
    );
56
};
57
if ( $@ or $result->{code} == 500 ){
58
    $resource->{errmsg} =  "Error: mana access got broken, please try again later\n\n ( error: $@ )";
59
}
60
else{
61
    if ( $input->param( 'saveinbase' )) {
62
        $resource = { id => $package->new_from_mana($result->{data})->id };
63
    }
64
    else{
65
        $resource = $result->{data};
66
    }
67
}
68
47
69
print(to_json($resource));
48
my $result = Koha::SharedContent::send_entity_comment($content);
49
50
print(to_json($result));
(-)a/svc/mana/increment (-2 / +9 lines)
Lines 45-48 my $result = Koha::SharedContent::increment_entity_value( Link Here
45
    scalar $input->param('step')
45
    scalar $input->param('step')
46
);
46
);
47
47
48
return $result;
48
my $entity = Koha::SharedContent::get_entity_by_id(
49
    scalar $input->param('resource'),
50
    scalar $input->param('id')
51
);
52
53
$result->{new_count} = $entity->{data}->{nb};
54
$result->{message} = $entity->{data}->{message};
55
56
print(to_json($result));
49
- 

Return to bug 22193