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

(-)a/Koha/Library/Group.pm (-3 / +24 lines)
Lines 37-43 Koha::Library::Group - Koha Library::Group object class Link Here
37
37
38
=cut
38
=cut
39
39
40
=head3 my @children = $self->get_children()
40
=head3 my @parent = $self->parent()
41
42
=cut
43
44
sub parent {
45
    my ($self) = @_;
46
47
    $self->{_parent} ||= Koha::Library::Groups->find( $self->parent_id );
48
49
    return $self->{_parent};
50
}
51
52
=head3 my @children = $self->children()
41
53
42
=cut
54
=cut
43
55
Lines 63-69 sub library { Link Here
63
75
64
    return unless $self->branchcode;
76
    return unless $self->branchcode;
65
77
66
    return Koha::Libraries->find( $self->branchcode );
78
    $self->{_library} ||= Koha::Libraries->find( $self->branchcode );
79
80
    return $self->{_library};
67
}
81
}
68
82
69
=head3 libraries_not_direct_children
83
=head3 libraries_not_direct_children
Lines 87-93 sub libraries_not_direct_children { Link Here
87
101
88
    my @branchcodes = map { $_->branchcode } @children;
102
    my @branchcodes = map { $_->branchcode } @children;
89
103
90
    return Koha::Libraries->search( { branchcode => { -not_in => \@branchcodes } } );
104
    return Koha::Libraries->search(
105
        {
106
            branchcode => { -not_in => \@branchcodes }
107
        },
108
        {
109
            order_by => 'branchname'
110
        }
111
    );
91
}
112
}
92
113
93
=head3 store
114
=head3 store
(-)a/koha-tmpl/intranet-tmpl/prog/css/staff-global.css (+5 lines)
Lines 2969-2971 fieldset.rows + fieldset.action { Link Here
2969
.yui-u .rows li p label.widelabel {
2969
.yui-u .rows li p label.widelabel {
2970
    width: auto;
2970
    width: auto;
2971
}
2971
}
2972
2973
span.name {
2974
    font-weight: bold;
2975
    font-style: italic;
2976
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/library_groups.tt (-25 / +53 lines)
Lines 6-18 Link Here
6
<script type="text/javascript">
6
<script type="text/javascript">
7
//<![CDATA[
7
//<![CDATA[
8
    $(document).ready(function() {
8
    $(document).ready(function() {
9
        $(".library-groups").treetable(
9
        $('.library-groups').treetable(
10
            {
10
            {
11
                expandable: true,
11
                expandable: true,
12
                initialState: "expanded",
12
                initialState: 'expanded',
13
                clickableNodeNames: true,
13
                clickableNodeNames: true,
14
            }
14
            }
15
        );
15
        );
16
17
        $('.add-group').on('click', function() {
18
            var id = $(this).data('groupId');
19
            add_group( id );
20
        });
21
22
        $('.edit-group').on('click', function() {
23
            var id = $(this).data('groupId');
24
            var title = $(this).data('groupTitle');
25
            var description = $(this).data('groupDescription');
26
            edit_group( id, title, description );
27
        });
28
29
        $('.delete-group').on('click', function() {
30
            var id = $(this).data('groupId');
31
            var title = $(this).data('groupTitle');
32
            delete_group( id, title );
33
        });
34
35
        $('.remove-library').on('click', function() {
36
            var id = $(this).data('groupId');
37
            var library = $(this).data('groupLibrary');
38
            var parent_title = $(this).data('groupParentTitle');
39
            remove_library( id, library, parent_title );
40
        });
16
    });
41
    });
17
42
18
    function add_group( parent_id ) {
43
    function add_group( parent_id ) {
Lines 40-54 Link Here
40
        $('#edit-group-modal').modal('show');
65
        $('#edit-group-modal').modal('show');
41
    }
66
    }
42
67
43
    function remove_library( id ) {
68
    function delete_group( id, title ) {
69
        $('#delete-group-modal-title').html(title);
70
        $('#delete-group-modal-id').val( id );
71
        $('#delete-group-modal').modal('show');
72
    }
73
74
    function remove_library( id, library, parent_title ) {
75
        $('#remove-library-modal-library').html( library );
76
        $('#remove-library-modal-group').html(parent_title);
44
        $('#remove-library-modal-id').val( id );
77
        $('#remove-library-modal-id').val( id );
45
        $('#remove-library-modal').modal('show');
78
        $('#remove-library-modal').modal('show');
46
    }
79
    }
47
80
48
    function delete_group( id ) {
49
        $('#delete-group-modal-id').val( id );
50
        $('#delete-group-modal').modal('show');
51
    }
52
//]]>
81
//]]>
53
</script>
82
</script>
54
</head>
83
</head>
Lines 63-69 Link Here
63
</div>
92
</div>
64
93
65
[% IF added %]
94
[% IF added %]
66
    <div class="dialog alert group-added">
95
    <div class="dialog message group-added">
67
        [% IF added.branchcode %]
96
        [% IF added.branchcode %]
68
            <i>[% added.library.branchname %]</i> added to group.
97
            <i>[% added.library.branchname %]</i> added to group.
69
        [% ELSE %]
98
        [% ELSE %]
Lines 71-77 Link Here
71
        [% END %]
100
        [% END %]
72
    </div>
101
    </div>
73
[% ELSIF deleted %]
102
[% ELSIF deleted %]
74
    <div class="dialog alert group-deleted">
103
    <div class="dialog message group-deleted">
75
        [% IF deleted.title %]
104
        [% IF deleted.title %]
76
            Group <i>[% deleted.title %]</i> has been deleted.
105
            Group <i>[% deleted.title %]</i> has been deleted.
77
        [% ELSE %]
106
        [% ELSE %]
Lines 87-94 Link Here
87
                <div class="yui-g">
116
                <div class="yui-g">
88
                    <div id="toolbar" class="btn-toolbar">
117
                    <div id="toolbar" class="btn-toolbar">
89
                        <div class="btn-group">
118
                        <div class="btn-group">
90
                            <a id="add-group-[% group.id %]" class="btn btn-small" href="#" onclick="add_group()">
119
                            <a id="add-group-root" class="btn btn-small add-group" href="#">
91
                                <i class="fa fa-plus-circle"></i> Add group
120
                                <i class="fa fa-plus"></i> Add group
92
                            </a>
121
                            </a>
93
                        </div>
122
                        </div>
94
                    </div>
123
                    </div>
Lines 170-179 Link Here
170
            <input id="delete-group-modal-action" type="hidden" name="action" value="delete" />
199
            <input id="delete-group-modal-action" type="hidden" name="action" value="delete" />
171
            <input id="delete-group-modal-id" type="hidden" name="id" value="" />
200
            <input id="delete-group-modal-id" type="hidden" name="id" value="" />
172
            <div class="modal-header">
201
            <div class="modal-header">
173
                <h3 id="delete-group-modal-label">Delete group or library</h3>
202
                <h3 id="delete-group-modal-label">Delete group</h3>
174
            </div>
203
            </div>
175
            <div class="modal-body">
204
            <div class="modal-body">
176
                Are you sure you want to delete this?
205
                Are you sure you want to delete <span id="delete-group-modal-title" class="name"></span>?
177
            </div>
206
            </div>
178
            <div class="modal-footer">
207
            <div class="modal-footer">
179
                <button type="submit" class="btn btn-danger"><i class="fa fa-trash"></i> Delete</button>
208
                <button type="submit" class="btn btn-danger"><i class="fa fa-trash"></i> Delete</button>
Lines 190-199 Link Here
190
                <h3 id="remove-library-modal-label">Remove library from group</h3>
219
                <h3 id="remove-library-modal-label">Remove library from group</h3>
191
            </div>
220
            </div>
192
            <div class="modal-body">
221
            <div class="modal-body">
193
                Are you sure you want to remove this library?
222
                Are you sure you want to remove <span id="remove-library-modal-library" class="name"></span> from <span id="remove-library-modal-group" class="name"><span>?
194
            </div>
223
            </div>
195
            <div class="modal-footer">
224
            <div class="modal-footer">
196
                <button type="submit" class="btn btn-danger"><i class="fa fa-minus-circle"></i> Remove</button>
225
                <button type="submit" class="btn btn-danger"><i class="fa fa-trash"></i> Remove</button>
197
                <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
226
                <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
198
            </div>
227
            </div>
199
        </form>
228
        </form>
Lines 206-214 Link Here
206
    <tr data-tt-id="[% group.id %]" data-tt-parent-id="[% group.parent_id %]">
235
    <tr data-tt-id="[% group.id %]" data-tt-parent-id="[% group.parent_id %]">
207
        <td>
236
        <td>
208
            [% IF group.branchcode %]
237
            [% IF group.branchcode %]
209
                <i class="fa fa-home"></i> [% group.branchcode %]
238
                [% group.branchcode %]
210
            [% ELSE %]
239
            [% ELSE %]
211
                <i class="fa fa-object-group"></i> [% group.title %]
240
                [% group.title %]
212
            [% END %]
241
            [% END %]
213
        </td>
242
        </td>
214
        <td>
243
        <td>
Lines 220-244 Link Here
220
        </td>
249
        </td>
221
        <td>
250
        <td>
222
            [% IF group.branchcode %]
251
            [% IF group.branchcode %]
223
                <button class="btn btn-small delete-library" onclick="remove_library([% group.id %])"><i class="fa fa-minus-circle"></i> Remove from group</button>
252
                <button class="btn btn-small remove-library" data-group-id="[% group.id %]" data-group-library="[% group.library.branchname %]" data-group-parent-title="[% group.parent.title %]" ><i class="fa fa-trash"></i> Remove from group</button>
224
            [% ELSE %]
253
            [% ELSE %]
225
                <div class="btn-group">
254
                <div class="btn-group">
226
                    <button class="btn btn-small dropdown-toggle" data-toggle="dropdown"><i class="fa fa-wrench"></i> Actions <span class="caret"></span></button>
255
                    <button class="btn btn-small dropdown-toggle" data-toggle="dropdown"><i class="fa fa-wrench"></i> Actions <span class="caret"></span></button>
227
                    <ul class="dropdown-menu">
256
                    <ul class="dropdown-menu">
228
                        <li>
257
                        <li>
229
                            <a id="add-group-[% group.id %]" href="#" onclick="add_group([% group.id %])">
258
                            <a id="add-group-[% group.id %]" href="#" class="add-group" data-group-id="[% group.id %]">
230
                                <i class="fa fa-plus-circle"></i> Add sub-group
259
                                <i class="fa fa-plus"></i> Add sub-group
231
                            </a>
260
                            </a>
232
                       </li>
261
                       </li>
233
262
234
                        <li>
263
                        <li>
235
                            <a class="delete-group" id="delete-group-[% group.id %]" href="#" onclick="edit_group([% group.id %], '[% group.title | replace('\'', '\\\'') | html %]', '[% group.description | replace('\'', '\\\'') | html %]')">
264
                            <a class="edit-group" id="edit-group-[% group.id %]" href="#" class="edit-group" data-group-id="[% group.id %]" data-group-title="[% group.title | html %]" data-group-description="[% group.description | html %]">
236
                                <i class="fa fa-edit"></i> Edit
265
                                <i class="fa fa-pencil"></i> Edit
237
                            </a>
266
                            </a>
238
                       </li>
267
                       </li>
239
268
240
                        <li>
269
                        <li>
241
                            <a class="delete-group" id="delete-group-[% group.id %]" href="#" onclick="delete_group([% group.id %])">
270
                            <a class="delete-group" id="delete-group-[% group.id %]" href="#" class="delete-group" data-group-id="[% group.id %]" data-group-title="[% group.title | html %]">
242
                                <i class="fa fa-trash"></i> Delete
271
                                <i class="fa fa-trash"></i> Delete
243
                            </a>
272
                            </a>
244
                       </li>
273
                       </li>
Lines 246-252 Link Here
246
                </div>
275
                </div>
247
276
248
                <div class="btn-group">
277
                <div class="btn-group">
249
                    <button class="btn btn-small dropdown-toggle" data-toggle="dropdown"><i class="fa fa-home"></i> Add library <span class="caret"></span></button>
278
                    <button class="btn btn-small dropdown-toggle" data-toggle="dropdown"><i class="fa fa-plus"></i> Add library <span class="caret"></span></button>
250
                    <ul class="dropdown-menu">
279
                    <ul class="dropdown-menu">
251
                        [% FOREACH library IN group.libraries_not_direct_children %]
280
                        [% FOREACH library IN group.libraries_not_direct_children %]
252
                            <li>
281
                            <li>
253
- 

Return to bug 15707