[% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'above' ) %]
@@ -1059,6 +1092,136 @@ Note that permanent location is a code, and location may be an authval.
[% END %]
+
+
+
+
+
+
+
+
+
+ Are you sure you want to delete this item group?
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Are you sure you want to remove these item(s) from their item group(s)?
+
+
+
+
+
+
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'catalog-strings.inc' %]
[% Asset.js("js/catalog.js") | $raw %]
@@ -1419,6 +1582,251 @@ Note that permanent location is a code, and location may be an authval.
if ( search_value ){ $('#cat-search-block #search-form').val(search_value)};
});
[% END %]
+
+ [% IF Koha.Preference('EnableItemGroups') %]
+ // Load item groups table
+ var itemGroupsTable = KohaTable("items-group-table", {
+ "bAutoWidth": false,
+ 'sDom': '<"top pager"ilp>t<"bottom pager"ip>r',
+ "aoColumns": [
+ {
+ "mDataProp": function( oObj ) {
+ return oObj.display_order;
+ },
+ },
+ {
+ "mDataProp": function( oObj ) {
+ return oObj.description;
+ },
+ },
+ {
+ "mDataProp": function( oObj ) {
+ [% IF CAN_user_editcatalogue_manage_item_groups %]
+ return `
`
+ + ' '
+ + `
`;
+ [% ELSE %]
+ return "";
+ [% END %]
+ },
+ },
+ ],
+ "bPaginate": false,
+ "bProcessing": true,
+ "bServerSide": false,
+ "sAjaxSource": `/api/v1/biblios/${biblionumber}/item_groups?_per_page=-1`,
+ "sAjaxDataProp": "",
+ "fnServerData": function ( sSource, aoData, fnCallback ) {
+ $.getJSON( sSource, aoData, function (json) {
+ fnCallback(json)
+ } );
+ },
+ });
+
+ // Create new item groups
+ $('.item-group-create').on('click', function(){
+ $('#modal-item-group-create-form-description').val("");
+ $('#modal-item-group-create-submit').removeAttr('disabled');
+ $('#modal-item-group-create').modal('show');
+ });
+
+ $("#modal-item-group-create-form").validate({
+ submitHandler: function(form) {
+ $.ajax({
+ url: `/api/v1/biblios/${biblionumber}/item_groups`,
+ headers: { "x-koha-embed": "items" },
+ success: function(item_groups){
+ $('#modal-item-group-create-submit').attr('disabled', 'disabled');
+
+ var settings = {
+ "url": `/api/v1/biblios/${biblionumber}/item_groups`,
+ "method": "POST",
+ "headers": {
+ "Content-Type": "application/json"
+ },
+ "data": JSON.stringify(
+ {
+ "description": $("#modal-item-group-create-form-description").val(),
+ "display_order": $("#modal-item-group-create-form-display_order").val(),
+ }
+ ),
+ };
+
+ $.ajax(settings)
+ .done(function (response) {
+ $('#item-group-add-form-select').append($('