[open-ils-commits] [GIT] Evergreen ILS branch master updated. 88bdd77b97a85bd6c41b174faa2e828c34d3a948
Evergreen Git
git at git.evergreen-ils.org
Tue Mar 20 14:25:14 EDT 2018
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".
The branch, master has been updated
via 88bdd77b97a85bd6c41b174faa2e828c34d3a948 (commit)
via 5944342aefa557f6a2b3bc677085bfa19222447d (commit)
from af288445a609cae947e3346d25bd28bbca513b91 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 88bdd77b97a85bd6c41b174faa2e828c34d3a948
Author: Galen Charlton <gmc at equinoxinitiative.org>
Date: Tue Mar 6 18:00:23 2018 -0500
LP#1721807: fix webstaff report templates that have might_have and has_many joins
This patch fixes a bug where using a virtual field in the web staff
report template editor to join another table would result in a syntax
error in the generated SQL.
To test
-------
[1] Apply the patch and verify that the regression test in the previous
commit passes.
[2] Create new report template in the web staff client that include
virtual fields and joins and verify that they work. One example
would be a report that uses ILS User as the base source and joins
in the patron notes virtual field.
[3] If available, clone a report template originally created in the web
staff client that had previously failed, then save it. The new
report should work.
Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>
Signed-off-by: Chris Sharp <csharp at georgialibraries.org>
Signed-off-by: Kathy Lussier <klussier at masslnc.org>
diff --git a/Open-ILS/web/js/ui/default/staff/reporter/template/app.js b/Open-ILS/web/js/ui/default/staff/reporter/template/app.js
index 9ea625e..b50dabc 100644
--- a/Open-ILS/web/js/ui/default/staff/reporter/template/app.js
+++ b/Open-ILS/web/js/ui/default/staff/reporter/template/app.js
@@ -119,7 +119,14 @@ function($scope , $q , $routeParams , $location , $timeout , $window, egCore ,
if (i) { // not at the top of the tree
if (i == 1) join_path = join_path.split('-')[0];
- var uplink = p.uplink.name;
+ // SQLBuilder relies on the first dash-separated component
+ // of the join key to specify the column of left-hand relation
+ // to join on; for has_many and might_have link types, we have to grab the
+ // primary key of the left-hand table; otherwise, we can
+ // just use the field/column name found in p.uplink.name.
+ var uplink = (p.uplink.reltype == 'has_many' || p.uplink.reltype == 'might_have') ?
+ egCore.idl.classes[p.from.split('.').slice(-1)[0]].pkey + '-' + p.uplink.name :
+ p.uplink.name;
join_path += '-' + uplink;
alias = hex_md5(join_path);
commit 5944342aefa557f6a2b3bc677085bfa19222447d
Author: Galen Charlton <gmc at equinoxinitiative.org>
Date: Wed Mar 7 14:27:44 2018 -0500
LP#1721807: regression test
This adds an automated regression test as well as some additional
unit tests for the web staff reporter app and template service. This
patch could be applied by itself to verify that the regression
test (run using 'npm run test' for master or 'grunt test' for rel_3_0)
fails.
Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>
Signed-off-by: Chris Sharp <csharp at georgialibraries.org>
Signed-off-by: Kathy Lussier <klussier at masslnc.org>
diff --git a/Open-ILS/web/js/ui/default/staff/reporter/template/app.js b/Open-ILS/web/js/ui/default/staff/reporter/template/app.js
index 69c433f..9ea625e 100644
--- a/Open-ILS/web/js/ui/default/staff/reporter/template/app.js
+++ b/Open-ILS/web/js/ui/default/staff/reporter/template/app.js
@@ -155,7 +155,9 @@ function($scope , $q , $routeParams , $location , $timeout , $window, egCore ,
});
return tree;
- }
+ };
+ // expose for testing
+ $scope._mergePaths = mergePaths;
$scope.constructTemplate = function () {
var param_counter = 0;
diff --git a/Open-ILS/web/js/ui/default/staff/test/karma.conf.js b/Open-ILS/web/js/ui/default/staff/test/karma.conf.js
index 531ac85..987d216 100644
--- a/Open-ILS/web/js/ui/default/staff/test/karma.conf.js
+++ b/Open-ILS/web/js/ui/default/staff/test/karma.conf.js
@@ -31,6 +31,7 @@ module.exports = function(config){
'app.js',
'circ/**/*.js',
'cat/**/*.js',
+ 'reporter/**/*.js',
'admin/**/*.js',
'test/unit/egIDL.js', // order matters for some of these
'test/unit/egOrg.js',
diff --git a/Open-ILS/web/js/ui/default/staff/test/unit/egReporter.js b/Open-ILS/web/js/ui/default/staff/test/unit/egReporter.js
new file mode 100644
index 0000000..743483e
--- /dev/null
+++ b/Open-ILS/web/js/ui/default/staff/test/unit/egReporter.js
@@ -0,0 +1,185 @@
+'use strict';
+
+describe('egReporterTest', function() {
+ beforeEach(module('egCoreMod'));
+ beforeEach(module('egReportMod'));
+ beforeEach(module('egReporter'));
+
+ var reportEditCtrl, reportEditScope;
+ beforeEach(inject(function ($rootScope, $controller, $location, egIDL) {
+ egIDL.parseIDL();
+ reportEditScope = $rootScope.$new();
+ reportEditCtrl = $controller('ReporterTemplateEdit', {$scope: reportEditScope});
+ }));
+
+ /** egReportTemplateSvc tests **/
+ describe('egReportTemplateSvcTests', function() {
+
+ it('egReportTemplateSvc should start with empty lists', inject(function(egReportTemplateSvc) {
+ expect(egReportTemplateSvc.display_fields.length).toEqual(0);
+ expect(egReportTemplateSvc.filter_fields.length).toEqual(0);
+ }));
+
+ });
+
+ // test template
+ var display_fields = [{
+ "name": "family_name",
+ "label": "Last Name",
+ "datatype": "text",
+ "index": 0,
+ "path": [
+ {
+ "label": "ILS User",
+ "id": "au",
+ "jtype": "inner",
+ "classname": "au",
+ "struct": {
+ "name": "au",
+ "label": "ILS User",
+ "table": "actor.usr",
+ "core": true,
+ "pkey": "id",
+ "pkey_sequence": "actor.usr_id_seq",
+ "core_label": "Core sources",
+ "classname": "au"
+ },
+ "table": "actor.usr"
+ }
+ ],
+ "path_label": "ILS User",
+ "transform": {
+ "transform": "Bare",
+ "label": "Raw Data",
+ "aggregate": false
+ },
+ "doc_text": ""
+ }, {
+ "name": "first_given_name",
+ "label": "First Name",
+ "datatype": "text",
+ "index": 1,
+ "path": [
+ {
+ "label": "ILS User",
+ "id": "au",
+ "jtype": "inner",
+ "classname": "au",
+ "struct": {
+ "name": "au",
+ "label": "ILS User",
+ "table": "actor.usr",
+ "core": true,
+ "pkey": "id",
+ "pkey_sequence": "actor.usr_id_seq",
+ "core_label": "Core sources",
+ "classname": "au"
+ },
+ "table": "actor.usr"
+ }
+ ],
+ "path_label": "ILS User",
+ "transform": {
+ "transform": "Bare",
+ "label": "Raw Data",
+ "aggregate": false
+ },
+ "doc_text": ""
+ }, {
+ "name": "value",
+ "label": "Note Content",
+ "datatype": "text",
+ "index": 2,
+ "path": [
+ {
+ "label": "ILS User",
+ "id": "au",
+ "jtype": "inner",
+ "classname": "au",
+ "struct": {
+ "name": "au",
+ "label": "ILS User",
+ "table": "actor.usr",
+ "core": true,
+ "pkey": "id",
+ "pkey_sequence": "actor.usr_id_seq",
+ "core_label": "Core sources",
+ "classname": "au"
+ },
+ "table": "actor.usr"
+ },
+ {
+ "label": "User Notes",
+ "from": "au",
+ "link": {
+ "name": "notes",
+ "label": "User Notes",
+ "virtual": true,
+ "type": "link",
+ "key": "usr",
+ "class": "aun",
+ "reltype": "has_many",
+ "datatype": "link"
+ },
+ "id": "au.aun",
+ "jtype": "left",
+ "uplink": {
+ "name": "notes",
+ "label": "User Notes",
+ "virtual": true,
+ "type": "link",
+ "key": "usr",
+ "class": "aun",
+ "reltype": "has_many",
+ "datatype": "link"
+ },
+ "classname": "aun",
+ "struct": {
+ "name": "aun",
+ "label": "User Note",
+ "table": "actor.usr_note",
+ "pkey": "id",
+ "pkey_sequence": "actor.usr_note_id_seq",
+ "core_label": "Non-core sources",
+ "classname": "aun"
+ },
+ "table": "actor.usr_note"
+ }
+ ],
+ "path_label": "ILS User -> User Notes (left)",
+ "transform": {
+ "transform": "Bare",
+ "label": "Raw Data",
+ "aggregate": false
+ },
+ "doc_text": ""
+ }];
+
+ describe('egReporterTemplateEditTests', function() {
+ it('initialize and set core source for ReporterTemplateEdit', inject(function(egIDL, egCore) {
+ egIDL.parseIDL();
+
+ // initialize
+ expect(reportEditScope.class_tree.length).toEqual(0);
+ expect(reportEditScope.coreSourceChosen).toEqual(false);
+
+ // set core source
+ reportEditScope.changeCoreSource('au');
+ expect(reportEditScope.coreSourceChosen).toEqual(true);
+ expect(reportEditScope.class_tree.length).toEqual(1);
+
+ }));
+
+ it('LP#1721807: construct join key correctly when using virtual field', function() {
+ var tmpl = reportEditScope._mergePaths(display_fields);
+ expect(tmpl).toBeDefined();
+ expect(Object.keys(tmpl)).toContain('join');
+ expect(Object.keys(tmpl.join).length).toEqual(1);
+ var join_key = Object.keys(tmpl.join)[0];
+ var lcol = join_key.split(/-/)[0];
+ expect(lcol).toEqual('id');
+ });
+
+ });
+
+});
-----------------------------------------------------------------------
Summary of changes:
.../js/ui/default/staff/reporter/template/app.js | 13 ++-
.../web/js/ui/default/staff/test/karma.conf.js | 1 +
.../js/ui/default/staff/test/unit/egReporter.js | 185 ++++++++++++++++++++
3 files changed, 197 insertions(+), 2 deletions(-)
create mode 100644 Open-ILS/web/js/ui/default/staff/test/unit/egReporter.js
hooks/post-receive
--
Evergreen ILS
More information about the open-ils-commits
mailing list