From de98ea4f2540f7d614703c6dd11808fc2395801a Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Tue, 6 Aug 2024 16:16:09 +0000 Subject: [PATCH] Bug 37581: Use split button for label creator "new" operations This patch modifies the "New" menu in the label creator so that it is a split button instead of a simple menu. The primary button area will now be a direct link to creating a new entry for whatever area you are in: batches, labels, templates, or printer profiles. The secondary menu offers all options. To test, apply the patch and go to Cataloging -> Labels. - On the label creator page, you should see a split button in the toolbar. The text label should read "New label batch," and clicking it should take you directly to creation of a new label batch. - Clicking the secondary action of the menu item, the down-arrow, should offer a menu of all the other "New" options. - Confirm that the dropdown menu links all work correctly. - Confirm that as you switch to different sections of the label creator the default "new" action of the toolbar button changes: - In label batches, "New label batch" - In label layouts, "New label layout" - In label templates, "New label template" - In printer profiles, "New printer profiles" - When you're on the "Print profile range" page, the default is "New label batch" because there is no "new" action for that page, and label batch seemed like a sensible default. Sponsored-by: Athens County Public Libraries Signed-off-by: Nicolas Hunstein --- .../prog/en/includes/labels-toolbar.inc | 31 +++++++++++++--- labels/label-edit-batch.pl | 13 +++---- labels/label-edit-layout.pl | 3 +- labels/label-edit-profile.pl | 19 +++++----- labels/label-edit-template.pl | 35 ++++++++++--------- 5 files changed, 63 insertions(+), 38 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/labels-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/labels-toolbar.inc index 982892f140..001388d66e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/labels-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/labels-toolbar.inc @@ -1,11 +1,32 @@
- + [% SWITCH label_element %] + [% CASE "batch" %] + [% SET default_new = "/cgi-bin/koha/labels/label-edit-batch.pl?op=new" %] + [% SET new_label_element = "New label batch" %] + [% CASE "layout" %] + [% SET default_new = "/cgi-bin/koha/labels/label-edit-layout.pl?op=new" %] + [% SET new_label_element = "New label layout" %] + [% CASE "template" %] + [% SET default_new = "/cgi-bin/koha/labels/label-edit-template.pl?op=new" %] + [% SET new_label_element = "New label template" %] + [% CASE "profile" %] + [% SET default_new = "/cgi-bin/koha/labels/label-edit-profile.pl?op=new" %] + [% SET new_label_element = "New printer profile" %] + [% CASE %] + [% SET default_new = "/cgi-bin/koha/labels/label-edit-batch.pl?op=new" %] + [% SET new_label_element = "New label batch" %] + [% END %] + [% new_label_element | html %] +
diff --git a/labels/label-edit-batch.pl b/labels/label-edit-batch.pl index 1a8759b49b..bd8ebb987f 100755 --- a/labels/label-edit-batch.pl +++ b/labels/label-edit-batch.pl @@ -133,11 +133,12 @@ $template->param( ) if ($err ne 0); $template->param( - op => $op, - batch_id => $batch_id, - table_loop => $table, - duplicate_message => $duplicate_message, - duplicate_count => $duplicate_count, - ); + op => $op, + batch_id => $batch_id, + table_loop => $table, + duplicate_message => $duplicate_message, + duplicate_count => $duplicate_count, + label_element => "batch", +); output_html_with_http_headers $cgi, $cookie, $template->output; diff --git a/labels/label-edit-layout.pl b/labels/label-edit-layout.pl index bb449d0ee7..325c265385 100755 --- a/labels/label-edit-layout.pl +++ b/labels/label-edit-layout.pl @@ -157,6 +157,7 @@ $template->param( scale_height => $layout->get_attr('scale_height'), callnum_split => $layout->get_attr('callnum_split'), format_string => $layout->get_attr('format_string'), - layout_string => 1, # FIXME: This should not be hard-coded; It should perhaps be yet another syspref... CN + layout_string => 1, # FIXME: This should not be hard-coded; It should perhaps be yet another syspref... CN, + label_element => "layout", ); output_html_with_http_headers $cgi, $cookie, $template->output; diff --git a/labels/label-edit-profile.pl b/labels/label-edit-profile.pl index 2c1a28a51a..de92c70e92 100755 --- a/labels/label-edit-profile.pl +++ b/labels/label-edit-profile.pl @@ -90,15 +90,16 @@ foreach my $unit (@$units) { $template->param(profile_id => $profile->get_attr('profile_id')) if $profile->get_attr('profile_id') > 0; $template->param( - label_template => $label_template[0]->{'template_code'} || '', - printer_name => $profile->get_attr('printer_name'), - paper_bin => $profile->get_attr('paper_bin'), - offset_horz => $profile->get_attr('offset_horz'), - offset_vert => $profile->get_attr('offset_vert'), - creep_horz => $profile->get_attr('creep_horz'), - creep_vert => $profile->get_attr('creep_vert'), - units => $units, - op => $op, + label_template => $label_template[0]->{'template_code'} || '', + printer_name => $profile->get_attr('printer_name'), + paper_bin => $profile->get_attr('paper_bin'), + offset_horz => $profile->get_attr('offset_horz'), + offset_vert => $profile->get_attr('offset_vert'), + creep_horz => $profile->get_attr('creep_horz'), + creep_vert => $profile->get_attr('creep_vert'), + units => $units, + op => $op, + label_element => "profile", ); output_html_with_http_headers $cgi, $cookie, $template->output; diff --git a/labels/label-edit-template.pl b/labels/label-edit-template.pl index bd0ec604ab..323bb58d0d 100755 --- a/labels/label-edit-template.pl +++ b/labels/label-edit-template.pl @@ -132,23 +132,24 @@ foreach my $unit (@$units) { } $template->param( - profile_list => $profile_list, - template_id => ($label_template->get_attr('template_id') > 0) ? $label_template->get_attr('template_id') : '', - template_code => $label_template->get_attr('template_code'), - template_desc => $label_template->get_attr('template_desc'), - page_width => $label_template->get_attr('page_width'), - page_height => $label_template->get_attr('page_height'), - label_width => $label_template->get_attr('label_width'), - label_height => $label_template->get_attr('label_height'), - top_text_margin => $label_template->get_attr('top_text_margin'), - left_text_margin => $label_template->get_attr('left_text_margin'), - top_margin => $label_template->get_attr('top_margin'), - left_margin => $label_template->get_attr('left_margin'), - cols => $label_template->get_attr('cols'), - rows => $label_template->get_attr('rows'), - col_gap => $label_template->get_attr('col_gap'), - row_gap => $label_template->get_attr('row_gap'), - units => $units, + profile_list => $profile_list, + template_id => ( $label_template->get_attr('template_id') > 0 ) ? $label_template->get_attr('template_id') : '', + template_code => $label_template->get_attr('template_code'), + template_desc => $label_template->get_attr('template_desc'), + page_width => $label_template->get_attr('page_width'), + page_height => $label_template->get_attr('page_height'), + label_width => $label_template->get_attr('label_width'), + label_height => $label_template->get_attr('label_height'), + top_text_margin => $label_template->get_attr('top_text_margin'), + left_text_margin => $label_template->get_attr('left_text_margin'), + top_margin => $label_template->get_attr('top_margin'), + left_margin => $label_template->get_attr('left_margin'), + cols => $label_template->get_attr('cols'), + rows => $label_template->get_attr('rows'), + col_gap => $label_template->get_attr('col_gap'), + row_gap => $label_template->get_attr('row_gap'), + units => $units, + label_element => "template", ); output_html_with_http_headers $cgi, $cookie, $template->output; -- 2.39.2