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

(-)a/koha-tmpl/intranet-tmpl/prog/css/src/_header.scss (-10 / +1 lines)
Lines 271-294 a.navbar-toggle { Link Here
271
271
272
#lastborrower-window {
272
#lastborrower-window {
273
    display: none;
273
    display: none;
274
    background-color: $background-color-primary;
275
    box-shadow: 1px 1px 1px 0 #999;
276
    color: #FFFFFF;
277
    padding: .2em;
278
    border-radius: 5px 5px 5px 5px;
279
274
280
    > * {
275
    > * {
281
        padding: 0 .4em;
276
        padding: 0 .4em;
282
    }
277
    }
283
}
278
}
284
279
285
#lastborrower-remove {
286
    cursor: pointer;
287
    border-left: 1px solid #fff;
288
}
289
290
#lastborrowerlink {
280
#lastborrowerlink {
291
    color: #FFFFFF;
281
    color: #FFFFFF;
282
    background-color: $background-color-primary;
292
}
283
}
293
284
294
@media (max-width: 768px) {
285
@media (max-width: 768px) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/last-borrower.inc (-2 / +11 lines)
Lines 1-4 Link Here
1
<div id="lastborrower-window">
1
<div id="lastborrower-window">
2
    <div id="lastborrower-ref" class="lastborrower"><a id="lastborrowerlink" href="" title=""><i class="fa fa-arrow-right"></i> Last patron</a></div>
2
    <div class="btn-group">
3
    <div id="lastborrower-remove" class="lastborrower"><i class="fa fa-times"></i></div>
3
        <a class="btn btn-default navbar-btn lastborrower" id="lastborrowerlink" href="#" title=""><i class="fa fa-arrow-right"></i> Last patron</a>
4
        <button type="button" data-toggle="dropdown" class="btn btn-default navbar-btn dropdown-toggle" aria-haspopup="true" aria-expanded="false">
5
            <span class="caret"></span>
6
            <span class="sr-only">Toggle Dropdown</span>
7
        </button>
8
        <ul id="lastBorrowerList" class="dropdown-menu">
9
            <li role="separator" class="divider"></li>
10
            <li><a id="lastborrower-remove" class="lastborrower" href="#">Clear list</a></li>
11
        </ul>
12
    </div>
4
</div>
13
</div>
(-)a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js (-16 / +36 lines)
Lines 155-174 $(document).ready(function() { Link Here
155
        $("#catalog-search-dropdown a").toggleClass("catalog-search-dropdown-hover");
155
        $("#catalog-search-dropdown a").toggleClass("catalog-search-dropdown-hover");
156
    });
156
    });
157
157
158
    if ( localStorage.getItem("lastborrowernumber") ){
158
    console.log("HIDDEN BORROWER: " + $("#hiddenborrowernumber").val() );
159
        if( $("#hiddenborrowernumber").val() != localStorage.getItem("lastborrowernumber") ) {
159
    if ( localStorage.getItem("previousPatrons") || $("#hiddenborrowernumber").val() ){
160
        var previous_patrons = [];
161
        if ( localStorage.getItem("previousPatrons") ) {
162
            previous_patrons = JSON.parse(localStorage.getItem("previousPatrons"));
163
        }
164
165
        if ( $("#hiddenborrowernumber").val() ) {
166
            // Remove this patron from the list if they are already there
167
            previous_patrons = previous_patrons.filter(function (p) {
168
                return p["borrowernumber"] != $("#hiddenborrowernumber").val();
169
            });
170
171
            const previous_patron = {
172
                "borrowernumber": $("#hiddenborrowernumber").val(),
173
                "name": $("#hiddenborrowername").val(),
174
                "card": $("#hiddenborrowercard").val()
175
            };
176
177
            previous_patrons.unshift( previous_patron );
178
            // Limit to last 10 patrons
179
            if ( previous_patrons.length > 10 ) previous_patrons.pop();
180
            localStorage.setItem("previousPatrons", JSON.stringify(previous_patrons));
181
        }
182
183
        if ( previous_patrons.length ) {
184
            let p = previous_patrons[0];
160
            $("#lastborrowerlink").show();
185
            $("#lastborrowerlink").show();
161
            $("#lastborrowerlink").prop("title", localStorage.getItem("lastborrowername") + " (" + localStorage.getItem("lastborrowercard") + ")");
186
            $("#lastborrowerlink").prop("title", `${p["name"]} (${p["card"]})`);
162
            $("#lastborrowerlink").prop("href", "/cgi-bin/koha/circ/circulation.pl?borrowernumber=" + localStorage.getItem("lastborrowernumber"));
187
            $("#lastborrowerlink").prop("href", `/cgi-bin/koha/circ/circulation.pl?borrowernumber=${p["borrowernumber"]}`);
163
            $("#lastborrower-window").css("display", "inline-flex");
188
            $("#lastborrower-window").css("display", "inline-flex");
164
        }
165
    }
166
189
167
    if( !localStorage.getItem("lastborrowernumber") || ( $("#hiddenborrowernumber").val() != localStorage.getItem("lastborrowernumber") && localStorage.getItem("currentborrowernumber") != $("#hiddenborrowernumber").val())) {
190
            previous_patrons.reverse();
168
        if( $("#hiddenborrowernumber").val() ){
191
            for ( i in previous_patrons ) {
169
            localStorage.setItem("lastborrowernumber", $("#hiddenborrowernumber").val() );
192
                p = previous_patrons[i];
170
            localStorage.setItem("lastborrowername", $("#hiddenborrowername").val() );
193
                const el = `<li><a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=${p["borrowernumber"]}">${p["name"]} (${p["card"]})</a></li>`;
171
            localStorage.setItem("lastborrowercard", $("#hiddenborrowercard").val() );
194
                $("#lastBorrowerList").prepend(el);
195
            }
172
        }
196
        }
173
    }
197
    }
174
198
Lines 216-225 $(document).ready(function() { Link Here
216
});
240
});
217
241
218
function removeLastBorrower(){
242
function removeLastBorrower(){
219
    localStorage.removeItem("lastborrowernumber");
243
    localStorage.removeItem("previousPatrons");
220
    localStorage.removeItem("lastborrowername");
221
    localStorage.removeItem("lastborrowercard");
222
    localStorage.removeItem("currentborrowernumber");
223
}
244
}
224
245
225
// http://jennifermadden.com/javascript/stringEnterKeyDetector.html
246
// http://jennifermadden.com/javascript/stringEnterKeyDetector.html
226
- 

Return to bug 21246