Skip to content

Commit 3c947f7

Browse files
committed
Merge remote-tracking branch 'origin/develop' into fb_jobUiImprovements
2 parents 3ce066a + 5195f22 commit 3c947f7

12 files changed

Lines changed: 677 additions & 419 deletions

File tree

modules/simpletest/resources/queries/lists/People.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ function stripPrefix(row)
2424
}
2525
}
2626

27+
// Disable managed columns from a script
28+
function managedColumns() {
29+
return false;
30+
}
31+
2732
function beforeInsert(row, errors)
2833
{
2934
// Test row map is case-insensitive
@@ -32,12 +37,9 @@ function beforeInsert(row, errors)
3237

3338
stripPrefix(row);
3439

35-
// var result = LABKEY.Query.deleteRows({
36-
// schemaName: "lists",
37-
// queryName: "People",
38-
// rowDataArray: [{Key: 100}]
39-
// });
40-
// console.log("Result of deleteRows: ", result);
40+
// Test disabling managed columns from a script by placing an invalid key/value on the row.
41+
// If this script managed columns, then this would fail.
42+
row.ImNotManagedInsert = "I'm not managed insert";
4143
}
4244

4345
function afterInsert(row, errors)
@@ -58,6 +60,10 @@ function beforeUpdate(row, oldRow, errors)
5860
throw new Error("beforeUpdate oldRow properties must be case-insensitive.");
5961

6062
stripPrefix(row);
63+
64+
// Test disabling managed columns from a script by placing an invalid key/value on the row.
65+
// If this script managed columns, then this would fail.
66+
row.ImNotManagedUpdate = "I'm not managed update";
6167
}
6268

6369
function afterUpdate(row, oldRow, errors)
Lines changed: 11 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,47 @@
1-
/*
2-
* Copyright (c) 2016-2017 LabKey Corporation
3-
*
4-
* Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
5-
*/
6-
var shared = require("TriggerTestModule/EmployeeLib");
1+
var shared = require("TriggerTestModule/SharedTriggerLib");
72
var console = require("console");
83

4+
function managedColumns() {
5+
return shared.managedColumns();
6+
}
7+
98
function init(event, errors) {
109
console.log("init got triggered with event: " + event);
11-
console.log(shared.sampleFunc("this is from the shared function"));
1210
}
1311

1412
function beforeInsert(row, errors) {
1513
console.log("exp.data: beforeInsert: row is: " + row);
16-
if(row.Comments) {
17-
if (row.Comments == "Individual Test") {
18-
row.Country = "Inserting Single";
19-
row.Comments = "BeforeDelete"; //set this for next test step
20-
}
21-
else if (row.Comments == "Import Test")
22-
row.Country = "Importing TSV";
23-
else if (row.Comments == "API Test")
24-
row.Country = "API BeforeInsert";
25-
} else {
26-
if (row.comments == "Individual Test") {
27-
row.country = "Inserting Single";
28-
row.comments = "BeforeDelete"; //set this for next test step
29-
}
30-
else if (row.comments == "Import Test")
31-
row.country = "Importing TSV";
32-
else if (row.comments == "API Test")
33-
row.country = "API BeforeInsert";
34-
}
35-
14+
shared.beforeInsert(row, errors);
3615
console.log("exp.data: edited row is: " + row);
37-
console.log(shared.sampleFunc("exp.data: this is from the shared function"));
3816
}
3917

4018
function beforeUpdate(row, oldRow, errors) {
4119
console.log("exp.data: beforeUpdate: row is: " + row);
42-
if(row.Comments == "BeforeUpdate")
43-
row.Country = "Before Update changed me";
44-
else if(row.comments == "BeforeUpdate")
45-
row.country = "Before Update changed me";
20+
shared.beforeUpdate(row, oldRow, errors);
4621
console.log("exp.data: old row is: " + oldRow);
47-
console.log(shared.sampleFunc("exp.data: this is from the shared function"));
4822
}
4923

5024
function beforeDelete(row, errors) {
5125
console.log("exp.data: beforeDelete: row is: " + row);
52-
if(row.Comments == "BeforeDelete" || row.comments == "BeforeDelete")
53-
errors[null] = "This is the Before Delete Error";
54-
55-
console.log(shared.sampleFunc("exp.data: this is from the shared function"));
26+
shared.beforeDelete(row, errors);
5627
}
5728

5829
function afterInsert(row, errors) {
5930
console.log("exp.data: afterInsert: row is: " + row);
60-
61-
if(row.Comments == "AfterInsert" || row.comments == "AfterInsert")
62-
errors[null] = "This is the After Insert Error";
63-
64-
console.log(shared.sampleFunc("exp.data: this is from the shared function"));
31+
shared.afterInsert(row, errors);
6532
}
6633

6734
function afterUpdate(row, oldRow, errors) {
6835
console.log("exp.data: afterUpdate: row is: " + row);
69-
70-
if(row.Comments == "AfterUpdate" || row.comments == "AfterUpdate")
71-
errors[null] = "This is the After Update Error";
72-
36+
shared.afterUpdate(row, oldRow, errors);
7337
console.log("exp.data: old row is: " +oldRow);
74-
console.log(shared.sampleFunc("exp.data: this is from the shared function"));
7538
}
7639

7740
function afterDelete(row, errors) {
7841
console.log("exp.data: afterDelete: row is: " + row);
79-
80-
if(row.Country == "Before Update changed me" || row.country == "Before Update changed me")
81-
errors[null] = "This is the After Delete Error";
82-
83-
console.log(shared.sampleFunc("exp.data: this is from the shared function"));
42+
shared.afterDelete(row, errors);
8443
}
8544

8645
function complete(event, errors) {
8746
console.log("exp.data: complete got triggered with event: " + event);
88-
console.log(shared.sampleFunc("exp.data: this is from the shared function"));
8947
}
Lines changed: 61 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,108 @@
1-
/*
2-
* Copyright (c) 2016-2018 LabKey Corporation
3-
*
4-
* Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
5-
*/
6-
var shared = require("TriggerTestModule/EmployeeLib");
71
var console = require("console");
8-
2+
3+
function managedColumns() {
4+
return {
5+
insert: ["boomerang", "employeeId"],
6+
update: ["boomerang", "company", "employeeId"],
7+
ignored: ["notes"],
8+
};
9+
}
10+
911
function init(event, errors) {
1012
console.log("init got triggered with event: " + event);
11-
console.log(shared.sampleFunc("this is from the shared function"));
1213
}
1314

1415
function beforeInsert(row, errors) {
1516
console.log("list: beforeInsert: row is: " + row);
16-
if(row.name == "Emp 2")
17+
if (row.name === "Emp 2")
1718
row.company = "Inserting Single";
18-
else if(row.name == "Emp 5")
19+
else if (row.name === "Emp 5")
1920
row.company = "Importing TSV";
20-
else if(row.name == "Emp 6")
21+
else if (row.name === "Emp 6")
2122
row.company = "API BeforeInsert";
23+
else if (row.name === "Managed Insert")
24+
row.employeeId = "EMP-INS";
25+
else if (row.name === "Managed Struct") {
26+
row.employeeId = "EMP-STRUCT";
27+
row.undeclaredCol = "bad";
28+
}
29+
else if (row.name === "Managed Struct Remove") {
30+
row.employeeId = "EMP-STRUCT-REM";
31+
delete row.SSN;
32+
}
33+
34+
if (!row.employeeId) {
35+
row.employeeId = "EMP-INS1";
36+
}
37+
38+
row.notes = "This is a note";
39+
40+
if (row.SSN !== "-123") {
41+
row.boomeRANG = "Back at ya!";
42+
}
2243
console.log("list: edited row is: " + row);
23-
console.log(shared.sampleFunc("list: this is from the shared function"));
2444
}
2545

2646
function beforeUpdate(row, oldRow, errors) {
2747
console.log("list: beforeUpdate: row is: " + row);
28-
if(row.name == "Emp 3" || row.name == "Emp 8" )
48+
if (row.company === "Company Up")
2949
row.company = "Before Update changed me";
50+
else if (row.name === "Managed Update") {
51+
row.company = "Managed Co";
52+
row.employeeId = "EMP-UPD";
53+
}
54+
else if (row.name === "Managed Struct") {
55+
row.company = "Struct Co";
56+
row.employeeId = "EMP-STRUCT";
57+
row.undeclaredCol = "bad";
58+
}
59+
else if (row.name === "Managed Struct Remove") {
60+
row.company = "Struct Remove Co";
61+
row.employeeId = "EMP-STRUCT-REM";
62+
delete row.SSN;
63+
}
64+
65+
if (!row.employeeId) {
66+
row.employeeId = "EMP-UPD1";
67+
}
68+
69+
row.notes = "This is a note";
70+
71+
if (row.SSN !== "-123") {
72+
row.boomeRANG = "Back at me!";
73+
}
3074
console.log("list: old row is: " + oldRow);
31-
console.log(shared.sampleFunc("list: this is from the shared function"));
3275
}
3376

3477
function beforeDelete(row, errors) {
3578
console.log("list: beforeDelete: row is: " + row);
36-
if(row.company == "Inserting Single" || row.company == "DeleteMe")
79+
if (row.company === "Inserting Single" || row.company === "DeleteMe")
3780
errors[null] = "This is the Before Delete Error";
38-
39-
console.log(shared.sampleFunc("list: this is from the shared function"));
4081
}
4182

4283
function afterInsert(row, errors) {
4384
console.log("list: afterInsert: row is: " + row);
4485

45-
if(row.name == "Emp 1")
86+
if (row.name === "Emp 1")
4687
errors[null] = "This is the After Insert Error";
47-
48-
console.log(shared.sampleFunc("list: this is from the shared function"));
4988
}
5089

5190
function afterUpdate(row, oldRow, errors) {
5291
console.log("list: afterUpdate: row is: " + row);
5392

54-
if(row.name == "Emp 2" || row.name == "Emp 6" )
93+
if (row.company === "Company After Update Error")
5594
errors[null] = "This is the After Update Error";
56-
//throw new Error("This is the After Update Error");
5795

5896
console.log("list: old row is: " +oldRow);
59-
console.log(shared.sampleFunc("list: this is from the shared function"));
6097
}
6198

6299
function afterDelete(row, errors) {
63100
console.log("list: afterDelete: row is: " + row);
64101

65-
if(row.company == "Before Update changed me")
102+
if (row.company === "Before Update changed me")
66103
errors[null] = "This is the After Delete Error";
67-
68-
console.log(shared.sampleFunc("list: this is from the shared function"));
69104
}
70105

71106
function complete(event, errors) {
72107
console.log("list: complete got triggered with event: " + event);
73-
console.log(shared.sampleFunc("list: this is from the shared function"));
74108
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
var console = require("console");
2+
3+
function managedColumns() {
4+
return false;
5+
}
6+
7+
function beforeInsert(row, errors) {
8+
console.log("list: beforeInsert: row is: " + row);
9+
10+
// Flower is not marked as a managed column, but managed columns are disabled
11+
if (row.type === 'A') {
12+
row.flower = 'Rose';
13+
}
14+
}
15+
16+
function beforeUpdate(row, oldRow, errors) {
17+
console.log("list: beforeUpdate: row is: " + row);
18+
19+
if (row.type === 'A') {
20+
row.hemisphere = 'Northern';
21+
}
22+
}

0 commit comments

Comments
 (0)