Bugzilla – Attachment 63587 Details for
Bug 18060
Add onboarding functionality to guide users through setting up labels for the first time
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
Bug 18060 - Working label onboarding tool for creating a layout and a template
Bug-18060---Working-label-onboarding-tool-for-crea.patch (text/plain), 24.34 KB, created by
Alex Buckley
on 2017-05-21 08:03:10 UTC
(
hide
)
Description:
Bug 18060 - Working label onboarding tool for creating a layout and a template
Filename:
MIME Type:
Creator:
Alex Buckley
Created:
2017-05-21 08:03:10 UTC
Size:
24.34 KB
patch
obsolete
>From 0275c26626346a3958a06c37e9cd750af2f6e2d7 Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Wed, 17 May 2017 03:27:40 +0000 >Subject: [PATCH] Bug 18060 - Working label onboarding tool for creating a > layout and a template > >--- > C4/Creators/Layout.pm | 10 +- > C4/Creators/Template.pm | 8 +- > .../prog/en/includes/onboardinginclude1.inc | 149 ++++++++++++++++++++- > .../prog/en/includes/onboardinginclude2.inc | 117 +++++++++++++++- > .../prog/en/modules/acqui/acqui-home.tt | 2 +- > .../prog/en/modules/labels/label-home.tt | 7 +- > labels/label-edit-layout.pl | 14 +- > labels/label-home.pl | 79 ++++++++++- > 8 files changed, 356 insertions(+), 30 deletions(-) > >diff --git a/C4/Creators/Layout.pm b/C4/Creators/Layout.pm >index de2ee45..e806499 100644 >--- a/C4/Creators/Layout.pm >+++ b/C4/Creators/Layout.pm >@@ -8,6 +8,7 @@ use autouse 'Data::Dumper' => qw(Dumper); > use C4::Context; > use C4::Debug; > use C4::Creators::PDF; >+use C4::Creators; > > > # FIXME: Consider this style parameter verification instead... >@@ -113,9 +114,13 @@ sub retrieve { > > sub retrieve_all { > my $dbh = C4::Context->dbh; >- my $sth = $dbh->prepare("select count(*) from creator_layouts w here creator = 'Labels'"); >+ my $sth = $dbh->prepare("select count(*) from creator_layouts where creator = 'Labels' group by creator"); > my $layout = $sth->execute(); >- return $layout; >+ if ($layout == '0E0'){ >+ return 0; >+ } else { >+ return $layout; >+ } > } > > sub delete { >@@ -241,6 +246,7 @@ sub get_text_wrap_cols { > return $col_count; > } > >+ > 1; > __END__ > >diff --git a/C4/Creators/Template.pm b/C4/Creators/Template.pm >index e9f9d55..87240b9 100644 >--- a/C4/Creators/Template.pm >+++ b/C4/Creators/Template.pm >@@ -133,9 +133,13 @@ sub retrieve { > > sub retrieve_all { > my $dbh = C4::Context->dbh; >- my $sth = $dbh->prepare("select count(*) from creator_templates where creator = 'Labels'"); >+ my $sth = $dbh->prepare("select count(*) FROM creator_templates ct where creator = 'Labels' group by creator"); > my $templatecount = $sth->execute(); >- return $templatecount; >+ if ($templatecount == '0E0'){ >+ return 0; >+ } else { >+ return $templatecount; >+ } > } > > sub delete { >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/onboardinginclude1.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/onboardinginclude1.inc >index 057a074..55324ee 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/onboardinginclude1.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/onboardinginclude1.inc >@@ -12,7 +12,25 @@ > } > </style> > >-[% IF onboarding =="acqui" %] >+[% BLOCK translate_justification_types %] >+ [% SWITCH type %] >+ [% CASE 'L' %]Left >+ [% CASE 'C' %]Center >+ [% CASE 'R' %]Right >+ [% END %] >+[% END %] >+ >+[% BLOCK translate_label_types %] >+ [% SWITCH type %] >+ [% CASE 'BIB' %]Biblio >+ [% CASE 'BARBIB' %]Barcode/Biblio >+ [% CASE 'BIBBAR' %]Biblio/Barcode >+ [% CASE 'ALT' %]Alternating >+ [% CASE 'BAR' %]Barcode >+ [% END %] >+[% END %] >+ >+[% IF displayonboarding =="acqui" %] > <div id="onboardingModal"> > <h2> Acquisition onboarding wizard</h2> > <h3> This onboarding wizard will take you through the process of setting up Acquistions </h3> >@@ -62,9 +80,128 @@ > </form> > </div> > >-[% ELSIF onboarding == "label" %] >- >-hello there >- >- >+[% ELSIF displayonboarding == "label" %] >+<div id="onboardingModal"> >+ <form name="input" action="/cgi-bin/koha/labels/label-edit-layout.pl" method="get"> >+ <fieldset class="rows"> >+ <legend>[% IF ( layout_id ) %]Edit[% ELSE %]Create[% END %] label layout</legend> >+ <ol> >+ <li> >+ <label for="layout_name">Layout name: </label> >+ <input type="text" name="layout_name" id="layout_name" size="20" value="[% layout_name %]" /> >+ </li> >+ <li> >+ <label for="barcode_type">Choose barcode type (encoding): </label> >+ <select name="barcode_type" id="barcode_type"> >+ [% FOREACH barcode_type IN barcode_types %] >+ [% IF ( barcode_type.selected ) %] >+ <option value="[% barcode_type.type %]" selected="selected">[% barcode_type.name %]</option> >+ [% ELSE %] >+ <option value="[% barcode_type. type %]">[% barcode_type.name %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ </li> >+ <li> >+ <label for="printing_type">Choose layout type: </label> >+ <select name="printing_type" id="printing_type"> >+ [% FOREACH label_type IN label_types %] >+ [% IF ( label_type.selected ) %] >+ <option value="[% label_type.type %]" selected="selected">[% PROCESS translate_label_types type=label_type.type %]</option> >+ [% ELSE %] >+ <option value="[% label_type.type %]">[% PROCESS translate_label_types type=label_type.type %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ </li> >+ <li> >+ <fieldset> >+ <legend>Bibliographic data to print</legend> >+ <ol> >+ <li class="radio">[% IF ( layout_string ) %] >+ <input type="radio" name="layout_choice" id="layout_choice_order" value="layout_table" checked="checked" /><label for="layout_choice_order">Choose order of text fields to print</label> >+ [% ELSE %] >+ <input type="radio" name="layout_choice" id="layout_choice_order" value="layout_table" /><label for="layout_choice_order">Choose Order Of Text Fields to Print</label> >+ [% END %] >+ <div id="layout_table"> >+ <p> >+ [% FOREACH text_field IN fields %] >+ <select name="[% text_field.field_name %]" id="[% text_field.field_name |url %]"> >+ <option value=""></option> >+ [% FOREACH orde IN [1..field_count] %] >+ [% IF ( orde == text_field.order ) %] >+ <option value="[% orde %]" selected="1">[% orde %]</option> >+ [% ELSE %] >+ <option value="[% orde %]">[% orde %]</option> >+ [% END %] >+ [% END %] >+ </select> <label for="[% text_field.field_name |url %]">[% text_field.field_label %]</label> >+ >+ [% END %] >+ </p> >+ </div> >+ </fieldset> >+ </li> >+ <li> >+ <label for="guidebox">Draw guide boxes: </label> >+ [% IF ( guidebox ) %] >+ <input type="checkbox" name="guidebox" id="guidebox" value="1" checked="checked" /> >+ [% ELSE %] >+ <input type="checkbox" name="guidebox" id="guidebox" value="1" /> >+ [% END %] >+ </li> >+ <li> >+ <label for="callnum_split">Split call numbers: </label> >+ [% IF ( callnum_split ) %] >+ <input type="checkbox" name="callnum_split" id="callnum_split" value="1" checked="checked" /> >+ [% ELSE %] >+ <input type="checkbox" name="callnum_split" id="callnum_split" value="1" /> >+ [% END %] >+ </li> >+ <li> >+ <label for="text_justify">Text justification: </label> >+ <select name="text_justify" id="text_justify"> >+ [% FOREACH text_justification_type IN text_justification_types %] >+ [% IF ( text_justification_type.selected ) %] >+ <option value="[% text_justification_type.type %]" selected="selected">[% PROCESS translate_justification_types type=text_justification_type.type %]</option> >+ [% ELSE %] >+ <option value="[% text_justification_type.type %]">[% PROCESS translate_justification_types type=text_justification_type.type %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ </li> >+ <li> >+ <label for="font">Font: </label> >+ <select name="font" id="font"> >+ [% FOREACH font_type IN font_types %] >+ [% IF ( font_type.selected ) %] >+ <option value="[% font_type.type %]" selected="selected">[% font_type.name %]</option> >+ [% ELSE %] >+ <option value="[% font_type.type %]">[% font_type.name %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ </li> >+ <li> >+ <label for="font_size">Font size: </label> >+ <input type="text" name="font_size" id="font_size" size="2" value="[% font_size |html %]" /> >+ </li> >+ <li> >+ <label for="oblique_title">Oblique title: </label> >+ [% IF ( oblique_title ) %] >+ <input type="checkbox" name="oblique_title" id="oblique_title" value="1" checked="checked" /> >+ [% ELSE %] >+ <input type="checkbox" name="oblique_title" id="oblique_title" value="1" /> >+ [% END %] >+ </li> >+ </ol> >+ </fielset> >+ <fieldset class="action"> >+ <input type="submit" value="Save" /> >+ <a class="cancel" href="/cgi-bin/koha/labels/label-manage.pl?label_element=layout">Cancel</a> >+ <input type="hidden" name="op" value="save" /> >+ <input type="hidden" name="layout_id" value="[% layout_id %]" /> >+ </fieldset> >+ </form> >+</div> > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/onboardinginclude2.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/onboardinginclude2.inc >index 7646eb8..08d2bc4 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/onboardinginclude2.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/onboardinginclude2.inc >@@ -11,8 +11,8 @@ > bottom:auto; > } > </style> >- <div id="onboardingModal"> >- [% IF displayonboardscreen == "acquisitions" %] >+<div id="onboardingModal"> >+ [% IF displayonboarding == "acquisitions" %] > <h2> Acquisition onboarding wizard</h2> > <p> Create a budget which is the highest level value in acquisitions accountancy. <br> > After creating this budget you will be prompted to create a fund which is what you will use to set up orders. >@@ -59,7 +59,112 @@ > </a> > </fieldset> > </form> >- </div> >- [% ELSIF displayonboardscreen == "label" %] >- <h2>testing</h2> >- [% END %] >+ [% ELSIF displayonboarding == "label" %] >+ <form name="input" action="/cgi-bin/koha/labels/label-edit-template.pl" method="get"> >+ <fieldset class="rows"> >+ <ol> >+ <li> >+ <span class="label">Template ID:</span>[% IF ( template_id ) %][% template_id %][% ELSE %]N/A[% END %] >+ </li> >+ <li> >+ <label for="template_code">Template code:</label> >+ <input type="text" size="30" maxlength="43" name="template_code" id="template_code" value="[% template_code %]" /> >+ </li> >+ <li> >+ <label for="template_desc">Template description:</label> >+ <textarea cols="30" rows="3" id="template_desc" name="template_desc">[% template_desc %]</textarea> >+ </li> >+ <li> >+ <label for="units">Units:</label> >+ <select id="units" name="units"> >+ [% FOREACH unit IN units %] >+ [% IF ( unit.selected ) %] >+ <option value="[% unit.type %]" selected="selected"> >+ [% ELSE %] >+ <option value="[% unit.type %]"> >+ [% END %] >+ [% unit.desc %] >+ </option> >+ [% END %] >+ </select> >+ </li> >+ <li> >+ <label for="page_height">Page height:</label> >+ <input type="text" size="4" name="page_height" id="page_height" value="[% page_height %]" /> >+ </li> >+ <li> >+ <label for="page_width">Page width:</label> >+ <input type="text" size="4" name="page_width" id="page_width" value="[% page_width %]" /> >+ </li> >+ <li> >+ <label for="label_width">Label width:</label> >+ <input type="text" size="4" name="label_width" id="label_width" value="[% label_width %]" /> >+ </li> >+ <li> >+ <label for="label_height">Label height:</label> >+ <input type="text" size="4" name="label_height" id="label_height" value="[% label_height %]" /> >+ </li> >+ </ol> >+ </fieldset> >+ <fieldset class="rows"> >+ <ol><li> >+ <label for="top_margin">Top page margin:</label> >+ <input type="text" size="4" name="top_margin" id="top_margin" value="[% top_margin %]" /> >+ </li> >+ <li> >+ <label for="left_margin">Left page margin:</label> >+ <input type="text" size="4" name="left_margin" id="left_margin" value="[% left_margin %]" /> >+ </li> >+ <li> >+ <label for="top_text_margin">Top text margin:</label> >+ <input type="text" size="4" name="top_text_margin" id="top_text_margin" value="[% top_text_margin %]" /> >+ </li> >+ <li> >+ <label for="left_text_margin">Left text margin:</label> >+ <input type="text" size="4" name="left_text_margin" id="left_text_margin" value="[% left_text_margin %]" /> >+ </li> >+ <li> >+ <label for="cols">Number of columns:</label> >+ <input type="text" size="4" name="cols" id="cols" value="[% cols %]" /> >+ </li> >+ <li> >+ <label for="rows">Number of rows:</label> >+ <input type="text" size="4" name="rows" id="rows" value="[% rows %]" /> >+ </li> >+ <li> >+ <label for="col_gap">Gap between columns:</label> >+ <input type="text" size="4" name="col_gap" id="col_gap" value="[% col_gap %]" /> >+ </li> >+ <li> >+ <label for="row_gap">Gap between rows:</label> >+ <input type="text" size="4" name="row_gap" id="row_gap" value="[% row_gap %]" /> >+ </li> >+ >+ <li> >+ <label for="profile_id">Profile:</label> >+ [% IF ( profile_list ) %] >+ <select id="profile_id" name="profile_id"> >+ [% FOREACH profile_lis IN profile_list %] >+ [% IF ( profile_lis.selected ) %] >+ <option value="[% profile_lis.profile_id %]" selected="selected"> >+ [% ELSE %] >+ <option value="[% profile_lis.profile_id %]"> >+ [% END %] >+ [% profile_lis.printer_name %]/[% profile_lis.paper_bin %] >+ </option> >+ [% END %] >+ </select> >+ [% ELSE %] >+ <a href="/cgi-bin/koha/labels/label-edit-profile.pl?op=new">Click here to define a printer profile.</a> >+ [% END %] >+ </li> >+ </ol> >+ <input type="submit" class="submit" value="Save" /><a class="cancel" href="/cgi-bin/koha/labels/label-manage.pl?label_element=template">Cancel</a> >+ <input type="hidden" name="op" value="save" /> >+ [% IF ( template_id ) %] >+ <input type="hidden" name="template_id" value="[% template_id %]" /> >+ [% END %] >+ </fieldset> >+</form> >+[% END %] >+</div> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt >index 72336ac..70bcd09 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt >@@ -113,7 +113,7 @@ $(document).ready(function() { > [% INCLUDE 'acquisitions-toolbar.inc' %] > [% UNLESS ( loop_budget ) %] > [% IF ( CAN_user_acquisition_period_manage ) %] >- [% displayonboardscreen = "acquisitions" %] >+ [% displayonboarding = "acquisitions" %] > [% IF step == 1 %] > [% INCLUDE onboardinginclude1.inc %] > [% ELSIF step == 2 %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-home.tt >index e2004d4..c20ccce 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-home.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-home.tt >@@ -20,9 +20,12 @@ > <div class="yui-g"> > [% INCLUDE 'labels-toolbar.inc' %] > <div class="yui-u first"> >- [% IF !(layout || template) %] >- [% onboarding = "label" %] >+ [% IF !(layoutvalue) %] >+ [% displayonboarding = "label" %] > [% INCLUDE 'onboardinginclude1.inc' %] >+ [% ELSIF !(templatevalue) %] >+ [% displayonboarding = "label" %] >+ [% INCLUDE 'onboardinginclude2.inc' %] > [% END %] > </div> > </div> >diff --git a/labels/label-edit-layout.pl b/labels/label-edit-layout.pl >index c1aafd4..f9e9e9d 100755 >--- a/labels/label-edit-layout.pl >+++ b/labels/label-edit-layout.pl >@@ -130,13 +130,13 @@ else { # if we get here, this is a new layout > $layout = C4::Labels::Layout->new(); > } > >-my $barcode_types = _set_selected(get_barcode_types(), $layout, 'barcode_type'); >-my $label_types = _set_selected(get_label_types(), $layout, 'printing_type'); >-my $font_types = _set_selected(get_font_types(), $layout, 'font'); >-my $text_justification_types = _set_selected(get_text_justification_types(), $layout, 'text_justify'); >-my ($select_text_fields, $select_text_fields_cnt) = _select_format_string($layout->get_attr('format_string')); >+ my $barcode_types = _set_selected(get_barcode_types(), $layout, 'barcode_type'); >+ my $label_types = _set_selected(get_label_types(), $layout, 'printing_type'); >+ my $font_types = _set_selected(get_font_types(), $layout, 'font'); >+ my $text_justification_types = _set_selected(get_text_justification_types(), $layout, 'text_justify'); >+ my ($select_text_fields, $select_text_fields_cnt) = _select_format_string($layout->get_attr('format_string')); > >-$template->param( >+ $template->param( > barcode_types => $barcode_types, > label_types => $label_types, > font_types => $font_types, >@@ -151,5 +151,5 @@ $template->param( > 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 >-); >+ ); > output_html_with_http_headers $cgi, $cookie, $template->output; >diff --git a/labels/label-home.pl b/labels/label-home.pl >index 075162d..44dbf0c 100755 >--- a/labels/label-home.pl >+++ b/labels/label-home.pl >@@ -22,11 +22,14 @@ use strict; > use warnings; > > use CGI qw ( -utf8 ); >+use POSIX; > > use C4::Auth qw(get_template_and_user); > use C4::Output qw(output_html_with_http_headers); > use C4::Creators::Layout; > use C4::Creators::Template; >+use C4::Creators; >+use C4::Labels; > > my $cgi = new CGI; > my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >@@ -40,9 +43,77 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > } > ); > >-my $layout = C4::Creators::Layout->retrieve_all(); >-my $templatecount = C4::Creators::Template->retrieve_all(); >-$template->param( layout => $layout, >- template => $templatecount); >+warn my $layoutvalue = C4::Creators::Layout->retrieve_all(); >+warn my $templatecount = C4::Creators::Template->retrieve_all(); >+$template->param( layoutvalue => $layoutvalue, >+ templatevalue => $templatecount, >+); >+ >+my $op = $cgi->param('op') || ''; >+my $layout_id = $cgi->param('layout_id') || $cgi->param('element_id') || ''; >+my $layout_choice = $cgi->param('layout_choice') || ''; >+my $layout = C4::Labels::Layout->new(); >+ >+ >+sub _set_selected { >+ my ($type_list, $object, $data_type) = @_; >+ SET_SELECTED: >+ foreach my $type (@$type_list) { >+ if ($layout->get_attr($data_type)) { >+ if ($type->{'type'} eq $layout->get_attr($data_type)) { >+ $type->{'selected'} = 1; >+ } >+ } >+ else { >+ $type->{'selected'} = 1; >+ last SET_SELECTED; >+ } >+}; >+return $type_list; >+} >+ >+sub _select_format_string { # generate field table based on format_string >+ my $format_string = shift; >+ >+ my @text_fields = grep /\w/, split /\s*,\s/, $format_string; >+ my %tf = map {$_ => 1} @text_fields; >+ my @missing_fields = grep { !$tf{$_} } @{ C4::Labels::Layout->PRESET_FIELDS }; >+# >+ my $field_count = scalar(@text_fields) + scalar( @missing_fields); >+ >+ my @fields; >+ my $field_index = 1; >+ foreach my $f (@text_fields) { >+ push @fields, {field_name => ($f . "_tbl"), field_label => $f, order => $field_index}; >+ $field_index++; >+ } >+ foreach my $f (@missing_fields) { >+ push @fields, {field_name => ($f . "_tbl"), field_label => $f}; >+ } >+ return (\@fields, $field_count); >+} >+ >+my $barcode_types = _set_selected(get_barcode_types(), $layout, 'barcode_type'); >+my $label_types = _set_selected(get_label_types(), $layout, 'printing_type'); >+my $font_types = _set_selected(get_font_types(), $layout, 'font'); >+my $text_justification_types = _set_selected(get_text_justification_types(), $layout, 'text_justify'); >+my ($select_text_fields, $select_text_fields_cnt) = _select_format_string($layout->get_attr('format_string')); >+ >+$template->param( >+ barcode_types => $barcode_types, >+# label_types => $label_types, >+ font_types => $font_types, >+ text_justification_types => $text_justification_types, >+ fields => $select_text_fields, >+ field_count => $select_text_fields_cnt, >+# layout_id => $layout->get_attr('layout_id') > -1 ? $layout->get_attr('layout_id') : '', >+# layout_name => $layout->get_attr('layout_name'), >+# guidebox => $layout->get_attr('guidebox'), >+# oblique_title => $layout->get_attr('oblique_title'), >+# font_size => $layout->get_attr('font_size'), >+# 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 >+); > > output_html_with_http_headers $cgi, $cookie, $template->output; >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 18060
:
63224
|
63225
|
63228
|
63229
|
63587
|
63588
|
63589
|
64733
|
64766
|
64951
|
67663