Skip to content

Commit 1421339

Browse files
Christian Nassif-HaynesChristian Nassif-Haynes
Christian Nassif-Haynes
authored and
Christian Nassif-Haynes
committed
Init
1 parent b6b44cc commit 1421339

25 files changed

+11713
-3
lines changed

LICENSE

+3-3
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,8 @@ to attach them to the start of each source file to most effectively
631631
state the exclusion of warranty; and each file should have at least
632632
the "copyright" line and a pointer to where the full notice is found.
633633

634-
<one line to give the program's name and a brief idea of what it does.>
635-
Copyright (C) <year> <name of author>
634+
{one line to give the program's name and a brief idea of what it does.}
635+
Copyright (C) {year} {name of author}
636636

637637
This program is free software: you can redistribute it and/or modify
638638
it under the terms of the GNU General Public License as published by
@@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
652652
If the program does terminal interaction, make it output a short
653653
notice like this when it starts in an interactive mode:
654654

655-
<program> Copyright (C) <year> <name of author>
655+
{project} Copyright (C) {year} {fullname}
656656
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657657
This is free software, and you are welcome to redistribute it
658658
under certain conditions; type `show c' for details.

logic/context-dates.bsh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/******************************* CONTEXT DATES ********************************/
2+
addOnEvent("Context/General/Add_Date_Closed", "click", "setContextDateClosed()");
3+
4+
setTimestamp(String path) {
5+
setFieldValue(path, new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss z").format(new Date()));
6+
}
7+
8+
// Linked using @POSTPROC
9+
setContextDateOpened() {
10+
String ref = "Context/General/Date_Opened";
11+
setTimestamp(ref);
12+
}
13+
14+
setContextDateClosed() {
15+
String ref = "Context/General/Date_Closed";
16+
setTimestamp(ref);
17+
}

logic/dynamic-ui-context.bsh

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/************************ DYNAMIC UI - OPEN/CLOSE SITE ************************/
2+
/* There are two cases to handle: */
3+
/* (a) When a record is newly created. */
4+
/* (b) When a record has been loaded. */
5+
/* */
6+
/* Case (a) is handled by events which trigger a UI update. */
7+
/* */
8+
/* Case (b) is handled by a callback to `showTabGroup`. This is implemented */
9+
/* by overwriting the auto-generated record loading function using @POSTPROC. */
10+
/******************************************************************************/
11+
addOnEvent("Context", "show", "openContextTabs()");
12+
addOnEvent("Context/General/Fill_in_Context_Type_Details", "click", "openContextTabs()");
13+
14+
openContextTabs() {
15+
openContextTabs(false);
16+
}
17+
18+
openContextTabs(Boolean showGeneralInformationTab){
19+
fetchOne("SELECT vocabName FROM vocabulary WHERE vocabid = '"+getFieldValue("Context/General/Context_Type")+"';",
20+
new FetchCallback() {
21+
onFetch(name) {
22+
if (!isNull(name)){
23+
String vocab = name.get(0);
24+
if ((vocab.equals("{Deposit}"))){
25+
cancelTab("Context/Cut", false);
26+
cancelTab("Context/Structure", false);
27+
cancelTab("Context/Skeleton", false);
28+
showTab("Context/Deposit");
29+
} else if (vocab.equals("{Negative_Element}")){
30+
cancelTab("Context/Deposit", false);
31+
cancelTab("Context/Structure", false);
32+
cancelTab("Context/Skeleton", false);
33+
showTab("Context/Cut");
34+
} else if (vocab.equals("{Structure}")){
35+
cancelTab("Context/Deposit", false);
36+
cancelTab("Context/Cut", false);
37+
cancelTab("Context/Skeleton", false);
38+
showTab("Context/Structure");
39+
} else if (vocab.equals("{Skeleton}")){
40+
cancelTab("Context/Deposit", false);
41+
cancelTab("Context/Cut", false);
42+
cancelTab("Context/Structure", false);
43+
showTab("Context/Skeleton");
44+
} else {
45+
cancelTab("Context/Cut", false);
46+
cancelTab("Context/Deposit", false);
47+
cancelTab("Context/Structure", false);
48+
cancelTab("Context/Skeleton", false);
49+
}
50+
} else {
51+
cancelTab("Context/Cut", false);
52+
cancelTab("Context/Deposit", false);
53+
cancelTab("Context/Structure", false);
54+
cancelTab("Context/Skeleton", false);
55+
}
56+
if(showGeneralInformationTab) {
57+
showTab("Context/General");
58+
}
59+
}
60+
});
61+
}
62+
63+
loadContextFrom(String uuid) {
64+
String tabgroup = "Context";
65+
setUuid(tabgroup, uuid);
66+
if (isNull(uuid)) return;
67+
68+
FetchCallback cb = new FetchCallback() {
69+
onFetch(result) {
70+
openContextTabs(true);
71+
}
72+
};
73+
showTabGroup(tabgroup, uuid, cb);
74+
}

logic/field-inheritance.bsh

+153
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
/***************************** FIELD INHERITANCE ******************************/
2+
String moduleYear = new java.text.SimpleDateFormat("yy").format(new Date());
3+
String moduleSiteCode = "BK" + moduleYear;
4+
5+
copyFieldValue(src, dst) {
6+
val = getFieldValue(src);
7+
setFieldValue(dst, val);
8+
}
9+
10+
inheritContextFields() {
11+
copyFieldValue(
12+
"Control/Contexts/Team_Members",
13+
"Context/General/Excavators"
14+
);
15+
16+
copyFieldValue(
17+
"User/User_List/AreaCode",
18+
"Context/General/AreaCode"
19+
);
20+
21+
copyFieldValue(
22+
"User/User_List/Device_Code",
23+
"Context/Vars/Device_Code"
24+
);
25+
26+
setFieldValue(
27+
"Context/Vars/Site_Code",
28+
moduleSiteCode
29+
);
30+
}
31+
32+
inheritContextGroupFields() {
33+
copyFieldValue(
34+
"User/User_List/AreaCode",
35+
"Context_Group/Gen/AreaCode"
36+
);
37+
38+
copyFieldValue(
39+
"User/User_List/Device_Code",
40+
"Context_Group/Vars/Device_Code"
41+
);
42+
43+
setFieldValue(
44+
"Context_Group/Vars/Site_Code",
45+
moduleSiteCode
46+
);
47+
}
48+
49+
inheritMatrixFields() {
50+
copyFieldValue(
51+
"User/User_List/AreaCode",
52+
"Matrix/Vars/AreaCode"
53+
);
54+
55+
copyFieldValue(
56+
"Context/General/Context_ID",
57+
"Matrix/Vars/Context_ID"
58+
);
59+
}
60+
61+
inheritHeightFields() {
62+
copyFieldValue(
63+
"User/User_List/AreaCode",
64+
"Height/Vars/AreaCode"
65+
);
66+
67+
copyFieldValue(
68+
"Context/General/Context_ID",
69+
"Height/Vars/Context_ID"
70+
);
71+
}
72+
73+
inheritSampleFields() {
74+
copyFieldValue(
75+
"User/User_List/AreaCode",
76+
"Sample/Vars/AreaCode"
77+
);
78+
79+
copyFieldValue(
80+
"Context/General/Context_ID",
81+
"Sample/Deposit_Samples/Context_ID"
82+
);
83+
84+
copyFieldValue(
85+
"User/User_List/Device_Code",
86+
"Sample/Vars/Device_Code"
87+
);
88+
89+
setFieldValue(
90+
"Sample/Vars/Site_Code",
91+
moduleSiteCode
92+
);
93+
}
94+
95+
inheritSpecialFindFields() {
96+
copyFieldValue(
97+
"Context/General/Context_ID",
98+
"Special_Find/Special_Find/Context_ID"
99+
);
100+
101+
copyFieldValue(
102+
"User/User_List/AreaCode",
103+
"Special_Find/Vars/AreaCode"
104+
);
105+
106+
copyFieldValue(
107+
"User/User_List/Device_Code",
108+
"Special_Find/Vars/Device_Code"
109+
);
110+
111+
setFieldValue(
112+
"Special_Find/Vars/Site_Code",
113+
moduleSiteCode
114+
);
115+
}
116+
117+
inheritPhotographLogFields() {
118+
//BEWARE! Weird formatting!
119+
if (parentTabgroup__.equals("Context"))
120+
copyFieldValue(
121+
"Context/General/Context_ID",
122+
"Photograph_Log/Photograph_Log/Photo_Context_ID"
123+
);
124+
125+
//BEWARE! Weird formatting!
126+
if (parentTabgroup__.equals("Context_Group"))
127+
copyFieldValue(
128+
"Context_Group/Gen/Context_Group_ID",
129+
"Photograph_Log/Photograph_Log/Photo_Context_Group_ID"
130+
);
131+
132+
copyFieldValue(
133+
"User/User_List/AreaCode",
134+
"Photograph_Log/Vars/AreaCode"
135+
);
136+
137+
copyFieldValue(
138+
"User/User_List/Device_Code",
139+
"Photograph_Log/Vars/Device_Code"
140+
);
141+
142+
setFieldValue(
143+
"Photograph_Log/Vars/Site_Code",
144+
moduleSiteCode
145+
);
146+
}
147+
148+
inheritDiaryFields() {
149+
copyFieldValue(
150+
"User/User_List/AreaCode",
151+
"Diary/Diary/AreaCode"
152+
);
153+
}

logic/local-settings-access.bsh

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*************************** LOCAL SETTINGS ACCESS ****************************/
2+
/* Loading and saving things in localSettings. */
3+
/******************************************************************************/
4+
addOnEvent("User/User_List/AreaCode", "click", "saveAreaCode()");
5+
addOnEvent("User/User_List/AreaCode", "show", "loadAreaCode()");
6+
addOnEvent("User/User_List/Device_Code", "click", "saveDeviceCode()");
7+
addOnEvent("User/User_List/Device_Code", "show", "loadDeviceCode()");
8+
onFocus ("Control/Contexts/Team_Members", "", "saveTeamMembers()");
9+
addOnEvent("Control/Contexts/Team_Members", "show", "loadTeamMembers()");
10+
11+
insertFieldValueIntoLocalSettings(String ref) {
12+
String val = getFieldValue(ref);
13+
insertIntoLocalSettings(ref, val);
14+
}
15+
16+
saveAreaCode () {
17+
String ref = "User/User_List/AreaCode";
18+
insertFieldValueIntoLocalSettings(ref);
19+
}
20+
21+
loadAreaCode () {
22+
String ref ="User/User_List/AreaCode";
23+
setFieldValueFromLocalSettings(ref, ref);
24+
}
25+
26+
saveDeviceCode() {
27+
String ref = "User/User_List/Device_Code";
28+
insertFieldValueIntoLocalSettings(ref);
29+
}
30+
31+
loadDeviceCode() {
32+
String ref = "User/User_List/Device_Code";
33+
setFieldValueFromLocalSettings(ref, ref);
34+
}
35+
36+
saveTeamMembers() {
37+
String ref = "Control/Contexts/Team_Members";
38+
insertFieldValueIntoLocalSettings(ref);
39+
}
40+
41+
loadTeamMembers() {
42+
String ref = "Control/Contexts/Team_Members";
43+
setFieldValueFromLocalSettings(ref, ref);
44+
}

0 commit comments

Comments
 (0)