From 7e395e86aa324556a747f5d7a69a44ce58030746 Mon Sep 17 00:00:00 2001
From: Owen Leonard <oleonard@myacpl.org>
Date: Thu, 15 Nov 2018 13:39:33 +0000
Subject: [PATCH] Bug 21838: Wrong alignment of instructors in course reserves

This patch adds CSS to course reserve pages so that multiple instructors
on a course are displayed well.

To test, apply the patch and:

 - Add or edit a course.
   - Test adding and removing instructors, saving, and adding and removing
     again.
 - View a course with multiple instructors and confirm that they are
   displayed well.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Awesome, Owen :-D
---
 .../modules/course_reserves/course-details.tt | 19 ++++++++++-
 .../prog/en/modules/course_reserves/course.tt | 32 +++++++++++++------
 2 files changed, 40 insertions(+), 11 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-details.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-details.tt
index c34d14eaab..931a355d5c 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-details.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-details.tt
@@ -10,6 +10,14 @@
 [% INCLUDE 'doc-head-close.inc' %]
 
 [% Asset.css("css/datatables.css") | $raw %]
+<style>
+    #instructors {
+        float: left;
+    }
+    .instructor_line {
+        padding: 0 .1em;
+    }
+</style>
 </head>
 
 <body id="courses_course_details" class="course">
@@ -45,7 +53,16 @@
                 <li><span class="label">Department</span> [% AuthorisedValues.GetByCode( 'DEPARTMENT', course.department ) | html %]</li>
                 <li><span class="label">Course number</span> [% course.course_number | html %]</li>
                 <li><span class="label">Section</span> [% course.section | html %]</li>
-                <li><span class="label">Instructors</span> [% FOREACH i IN course.instructors %]<div class="instructor"><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% i.borrowernumber | uri %]">[% i.firstname | html %] [% i.surname | html %]</a></div>[% END %]</li>
+                <li>
+                    <span class="label">Instructors</span>
+                    <div id="instructors">
+                        [% FOREACH i IN course.instructors %]
+                            <div class="instructor_line">
+                                <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% i.borrowernumber | uri %]">[% i.firstname | html %] [% i.surname | html %]</a>
+                            </div>
+                        [% END %]
+                    </div>
+                </li>
                 <li><span class="label">Staff note</span> [% course.staff_note | html %]</li>
                 <li><span class="label">Public note</span> [% course.public_note | html %]</li>
                 <li><span class="label">Student count</span> [% course.students_count | html %]</li>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course.tt
index 91db22b430..a47195d8bf 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course.tt
@@ -2,6 +2,14 @@
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Course reserves &rsaquo; [% IF course_name %] Edit [% course_name | html %] [% ELSE %] New course [% END %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
+<style>
+    #course_instructors {
+        float: left;
+    }
+    .instructor_line {
+        padding: .3em;
+    }
+</style>
 </head>
 
 <body id="courses_course" class="course">
@@ -78,16 +86,20 @@
                         <li>
                             <span class="label">Instructors:</span>
 
-                            <fieldset id="course_instructors">
-                                 <div id="instructors">[% FOREACH i IN instructors %]<div id="borrower_[% i.borrowernumber | html %]">[% i.surname | html %], [% i.firstname | html %] ( <a href="#" class="removeInstructor"> Remove </a> )
-                                             <input type='hidden' name='instructors' value='[% i.borrowernumber | html %]' /></div>[% END %]</div>
-                            </fieldset>
-
-                            <fieldset>
-                                <label for="find_instructor">Instructor search:</label>
-                                <input autocomplete="off" id="find_instructor" type="text" style="width:150px" class="noEnterSubmit"/>
+                            <div id="course_instructors">
+                                 <div id="instructors">
+                                    [% FOREACH i IN instructors %]
+                                        <div class="instructor_line" id="borrower_[% i.borrowernumber | html %]">[% i.surname | html %], [% i.firstname | html %] ( <a href="#" class="removeInstructor"><i class="fa fa-trash"></i> Remove </a> )
+                                             <input type='hidden' name='instructors' value='[% i.borrowernumber | html %]' />
+                                         </div>
+                                     [% END %]
+                                 </div>
+                                <p>
+                                    <label for="find_instructor">Instructor search:</label>
+                                    <input autocomplete="off" id="find_instructor" type="text" style="width:150px" class="noEnterSubmit"/>
+                                </p>
                                 <div id="find_instructor_container"></div>
-                            </fieldset>
+                            </div>
                         <li>
                             <label for="staff_note">Staff note:</label>
                             <textarea name="staff_note" id="staff_note">[% staff_note | html %]</textarea>
@@ -174,7 +186,7 @@
             });
 
             function AddInstructor( name, borrowernumber ) {
-                div = "<div id='borrower_" + borrowernumber + "'>" + name + " ( <a href='#' class='removeInstructor'> " + _("Remove")+ " </a> ) <input type='hidden' name='instructors' value='" + borrowernumber + "' /></div>";
+                div = "<div class='instructor_line' id='borrower_" + borrowernumber + "'>" + name + " ( <a href='#' class='removeInstructor'><i class='fa fa-trash'></i> " + _("Remove")+ " </a> ) <input type='hidden' name='instructors' value='" + borrowernumber + "' /></div>";
                 $('#instructors').append( div );
 
                 $('#find_instructor').val('').focus();
-- 
2.19.1