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

(-)a/admin/floating-matrix-api.pl (+10 lines)
Lines 25-30 use JSON::XS; Link Here
25
use C4::Context;
25
use C4::Context;
26
use C4::Output;
26
use C4::Output;
27
use C4::Auth qw(check_cookie_auth);
27
use C4::Auth qw(check_cookie_auth);
28
use C4::Items;
28
29
29
use Koha::FloatingMatrix;
30
use Koha::FloatingMatrix;
30
31
Lines 52-57 if ($data) { Link Here
52
            $fm->deleteBranchRule($data->{fromBranch}, $data->{toBranch});
53
            $fm->deleteBranchRule($data->{fromBranch}, $data->{toBranch});
53
            $fm->store();
54
            $fm->store();
54
        }
55
        }
56
        elsif ($data->{test}) {
57
            my $item = C4::Items::GetItem(undef, $data->{barcode});
58
            if ($data->{barcode} && $item) {
59
                $data->{testResult} = $fm->checkFloating($item, $data->{fromBranch}, $data->{toBranch});
60
            }
61
            else {
62
                Koha::Exception::BadParameter->throw(error => "No Item found using barcode '".$data->{barcode}."'");
63
            }
64
        }
55
        ##If we are getting a POST-request, we UPSERT
65
        ##If we are getting a POST-request, we UPSERT
56
        else {
66
        else {
57
            $fm->upsertBranchRule($data);
67
            $fm->upsertBranchRule($data);
(-)a/koha-tmpl/intranet-tmpl/prog/en/css/admin/floating-matrix-loader.css (+78 lines)
Line 0 Link Here
1
.cssload-loader {
2
	position: relative;
3
	left: calc(50% - 8px);
4
	width: 16px;
5
	height: 16px;
6
	border-radius: 50%;
7
		-moz-border-radius: 50%;
8
	perspective: 200px;
9
    margin-top: 3px;
10
    visibility: hidden;
11
}
12
13
.cssload-inner {
14
	position: absolute;
15
	width: 100%;
16
	height: 100%;
17
	box-sizing: border-box;
18
		-moz-box-sizing: border-box;
19
	border-radius: 50%;
20
		-moz-border-radius: 50%;	
21
}
22
23
.cssload-inner.cssload-one {
24
	left: 0%;
25
	top: 0%;
26
	animation: cssload-rotate-one 1.3s linear infinite;
27
		-moz-animation: cssload-rotate-one 1.3s linear infinite;
28
	border-bottom: 2px solid rgb(0,0,0);
29
}
30
31
.cssload-inner.cssload-two {
32
	right: 0%;
33
	top: 0%;
34
	animation: cssload-rotate-two 1.3s linear infinite;
35
		-moz-animation: cssload-rotate-two 1.3s linear infinite;
36
	border-right: 2px solid rgb(0,0,0);
37
}
38
39
.cssload-inner.cssload-three {
40
	right: 0%;
41
	bottom: 0%;
42
	animation: cssload-rotate-three 1.3s linear infinite;
43
		-moz-animation: cssload-rotate-three 1.3s linear infinite;
44
	border-top: 2px solid rgba(0,0,0,0.99);
45
}
46
47
48
49
50
51
52
53
@keyframes cssload-rotate-one {
54
	0% {
55
		transform: rotateX(35deg) rotateY(-45deg) rotateZ(0deg);
56
	}
57
	100% {
58
		transform: rotateX(35deg) rotateY(-45deg) rotateZ(360deg);
59
	}
60
}
61
62
@keyframes cssload-rotate-two {
63
	0% {
64
		transform: rotateX(50deg) rotateY(10deg) rotateZ(0deg);
65
	}
66
	100% {
67
		transform: rotateX(50deg) rotateY(10deg) rotateZ(360deg);
68
	}
69
}
70
71
@keyframes cssload-rotate-three {
72
	0% {
73
		transform: rotateX(35deg) rotateY(55deg) rotateZ(0deg);
74
	}
75
	100% {
76
		transform: rotateX(35deg) rotateY(55deg) rotateZ(360deg);
77
	}
78
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/css/admin/floating-matrix.css (+8 lines)
Lines 1-6 Link Here
1
.disabled-transfer {
1
.disabled-transfer {
2
    background-color: #FF8888;
2
    background-color: #FF8888;
3
}
3
}
4
5
#testResulDisplay { width: 20px;
6
                    height: 22px;
7
                    background-color: #B9D8D9;
8
                    vertical-align: middle;
9
                    display: inline-block;
10
}
11
4
.branchRule select { width: 100%; }
12
.branchRule select { width: 100%; }
5
.branchRule select {padding: 0px; margin: 5px 0px;}
13
.branchRule select {padding: 0px; margin: 5px 0px;}
6
14
(-)a/koha-tmpl/intranet-tmpl/prog/en/js/admin/floating-matrix.js (+64 lines)
Lines 1-5 Link Here
1
////Create javascript namespace
1
////Create javascript namespace
2
var FloMax = FloMax || {};
2
var FloMax = FloMax || {};
3
FloMax.Tester = FloMax.Tester || {};
3
4
4
//// DOCUMENT READY INIT SCRIPTS
5
//// DOCUMENT READY INIT SCRIPTS
5
6
Lines 15-20 $(document).ready(function() { Link Here
15
        FloMax.changeBranchRuleColor(this);
16
        FloMax.changeBranchRuleColor(this);
16
    });
17
    });
17
18
19
    //Bind actions to the FloMax Tester
20
    $("#floatingRuleTester input[type='submit']").bind({
21
        click: function() {
22
            FloMax.Tester.testFloating();
23
        }
24
    });
25
18
    //Bind action listeners to the floating matrix
26
    //Bind action listeners to the floating matrix
19
    $(".branchRule").bind({
27
    $(".branchRule").bind({
20
        click: function() {
28
        click: function() {
Lines 183-186 FloMax.persistBranchRule = function (brJSON, branchRule) { Link Here
183
            alert("Saving floating rule "+brJSON.fromBranch+"-"+brJSON.toBranch+" failed, because of the following error:\n"+data.status+" "+data.statusText+"\n"+"More specific error: "+error.error);
191
            alert("Saving floating rule "+brJSON.fromBranch+"-"+brJSON.toBranch+" failed, because of the following error:\n"+data.status+" "+data.statusText+"\n"+"More specific error: "+error.error);
184
        });
192
        });
185
    }
193
    }
194
}
195
196
FloMax.Tester.defaultTestResultColor = "#B9D8D9";
197
198
FloMax.Tester.testFloating = function() {
199
    var testCase = FloMax.Tester.buildTestCaseFromHTML();
200
    $(".cssload-loader").css('visibility', 'visible');
201
202
    $.ajax('floating-matrix-api.pl',
203
           {method : 'POST',
204
            data : testCase,
205
            dataType : 'json',
206
    }).done(function(data, textStatus, jqXHR){
207
208
        FloMax.Tester.displayTestResult(data.testResult);
209
210
    }).fail(function (data, textStatus, jqXHR) {
211
        var error = $.parseJSON(data.responseText); //Pass the error as JSON so we don't trigger the default Koha error pages.
212
        alert("Testing floating rule "+testCase.fromBranch+"-"+testCase.toBranch+" failed, because of the following error:\n"+data.status+" "+data.statusText+"\n"+"More specific error: "+error.error);
213
        FloMax.Tester.displayTestResult("error");
214
    });
215
}
216
FloMax.Tester.buildTestCaseFromHTML = function () {
217
    var fromBranch = $("#floatingRuleTester #testerFromBranch").val();
218
    var toBranch   = $("#floatingRuleTester #testerToBranch").val();
219
    var barcode    = $("#floatingRuleTester #testerBarcode").val();
220
221
    var testCase = {
222
        'fromBranch' : fromBranch,
223
        'toBranch' : toBranch,
224
        'barcode' : barcode,
225
        'test': true,
226
    };
227
    return testCase;
228
}
229
FloMax.Tester.displayTestResult = function (testResult) {
230
    $(".cssload-loader").css('visibility', 'hidden');
231
    var color;
232
    if (testResult == null) {
233
        color = FloMax.branchRuleDisabledColor;
234
    }
235
    else if (testResult == 'ALWAYS') {
236
        color = FloMax.branchRuleAlwaysColor;
237
    }
238
    else if (testResult == 'POSSIBLE') {
239
        color = FloMax.branchRulePossibleColor;
240
    }
241
    else if (testResult == "error") {
242
        color = FloMax.Tester.defaultTestResultColor;
243
    }
244
    else {
245
        color = FloMax.Tester.defaultTestResultColor;
246
        alert("Couldn't display test result '"+testResult+"'. Value is unknown.");
247
    }
248
249
    $("#testResulDisplay").css('background-color', color);
186
}
250
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/floating-matrix.tt (-1 / +27 lines)
Lines 1-6 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Administration &rsaquo; Floating matrix</title>
2
<title>Koha &rsaquo; Administration &rsaquo; Floating matrix</title>
3
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/admin/floating-matrix.css" />
3
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/admin/floating-matrix.css" />
4
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/admin/floating-matrix-loader.css" />
4
[% INCLUDE 'doc-head-close.inc' %]
5
[% INCLUDE 'doc-head-close.inc' %]
5
6
6
</head>
7
</head>
Lines 38-43 Link Here
38
                </ul>
39
                </ul>
39
            </div>
40
            </div>
40
41
42
            <fieldset>
43
            <legend>Floating rule tester</legend>
44
            <div id="floatingRuleTester">
45
                <label for="testerFromBranch">Choose the origin library:</label>
46
                <select id="testerFromBranch">
47
                [% FOR branchcode IN branches.keys.sort; branch = branches.$branchcode %]
48
                    <option value="[% branch.branchcode %]">[% branch.branchcode %]</option>
49
                [% END %]
50
                </select>
51
                <label for="testerToBranch">Choose the destination library:</label>
52
                <select id="testerToBranch">
53
                [% FOR branchcode IN branches.keys.sort; branch = branches.$branchcode %]
54
                    <option value="[% branch.branchcode %]">[% branch.branchcode %]</option>
55
                [% END %]
56
                </select>
57
                <input id="testerBarcode" type="test" width="12"/>
58
                <input id="tester" type="submit" value="Test"/>
59
                <span id="testResulDisplay"/>
60
                <div class="cssload-loader">
61
                    <div class="cssload-inner cssload-one"></div>
62
                    <div class="cssload-inner cssload-two"></div>
63
                    <div class="cssload-inner cssload-three"></div>
64
                </div>
65
            </div>
66
            </fieldset>
67
41
            <table id="floatingMatrix">
68
            <table id="floatingMatrix">
42
                <tr id="fmHeaderRow">
69
                <tr id="fmHeaderRow">
43
                    <th>From \ To</th>
70
                    <th>From \ To</th>
44
- 

Return to bug 9525