cyc-type-def 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,3 +1,548 @@
1
+ // src/constants/method.constant.ts
2
+ var METHOD = {
3
+ SKY: "S",
4
+ GROUND: "G",
5
+ TOTAL: "T"
6
+ };
7
+
8
+ // src/constants/status.constant.ts
9
+ var LIST_STATUS = ["OM", "NB", "AC", "NF", "RNF"];
10
+
11
+ // src/classes/attendance/SessionAttendance.ts
12
+ var SessionAttendance = class {
13
+ constructor(session) {
14
+ this.arrSheep = [];
15
+ if (session) {
16
+ this.code = session.code;
17
+ this.type = session.type;
18
+ this.desc = session.desc;
19
+ this.seq = session.seq;
20
+ this.needAbsReason = session.needAbsReason;
21
+ }
22
+ }
23
+ sortedArrAttSheep() {
24
+ let arrStatusCopy = LIST_STATUS;
25
+ return this.arrSheep.sort((a, b) => {
26
+ if (a.attended && b.attended || !a.attended && !b.attended) {
27
+ let indexA = arrStatusCopy.indexOf(a.status);
28
+ let indexB = arrStatusCopy.indexOf(b.status);
29
+ if (indexA < 0) {
30
+ return 1;
31
+ } else if (indexB < 0) {
32
+ return -1;
33
+ } else {
34
+ if (indexA < indexB) {
35
+ return -1;
36
+ } else if (indexA > indexB) {
37
+ return 1;
38
+ } else {
39
+ return a.name.localeCompare(b.name);
40
+ }
41
+ }
42
+ } else if (a.attended) {
43
+ return -1;
44
+ } else if (b.attended) {
45
+ return 1;
46
+ } else {
47
+ return -1;
48
+ }
49
+ });
50
+ }
51
+ get arrFilteredSheep() {
52
+ return this.input ? this.arrSheep.filter(
53
+ (sheep) => sheep.name.toLowerCase().includes(this.input.toLowerCase())
54
+ ) : this.arrSheep.slice();
55
+ }
56
+ getCnt(status, attType) {
57
+ if (!this.arrSheep) return 0;
58
+ else {
59
+ let cnt = 0;
60
+ for (let s of this.arrSheep) {
61
+ if (attType == METHOD.GROUND || attType == METHOD.SKY) {
62
+ if (attType == s.method && s.status == status && s.attended) cnt++;
63
+ } else if (attType == METHOD.TOTAL) {
64
+ if (s.status == status && s.attended) cnt++;
65
+ }
66
+ }
67
+ return cnt;
68
+ }
69
+ }
70
+ getAbsCnt() {
71
+ if (!this.arrSheep) return 0;
72
+ else {
73
+ let cnt = 0;
74
+ for (let s of this.arrSheep) {
75
+ if (s.status == "OM" && !s.attended) cnt++;
76
+ }
77
+ return cnt;
78
+ }
79
+ }
80
+ getDesc(status, attType) {
81
+ if (!this.arrSheep) return "";
82
+ else {
83
+ let desc = "";
84
+ for (let s of this.arrSheep) {
85
+ if (attType == METHOD.GROUND || attType == METHOD.SKY) {
86
+ if (attType == s.method && s.status == status && s.attended)
87
+ desc += s.name + ", ";
88
+ } else if (attType == METHOD.TOTAL) {
89
+ if (s.status == status && s.attended) desc += s.name + ", ";
90
+ }
91
+ }
92
+ desc = desc.slice(0, desc.length - 2);
93
+ return desc;
94
+ }
95
+ }
96
+ getAbsDesc() {
97
+ if (!this.arrSheep) return "";
98
+ else {
99
+ let desc = "";
100
+ for (let s of this.arrSheep) {
101
+ if (s.status == "OM" && !s.attended)
102
+ desc += s.name + " - " + s.absReason + ", ";
103
+ }
104
+ desc = desc.slice(0, desc.length - 2);
105
+ return desc;
106
+ }
107
+ }
108
+ calc() {
109
+ this.ground = new DisplayAttendance();
110
+ this.sky = new DisplayAttendance();
111
+ this.total = new DisplayAttendance();
112
+ this.calcFigure();
113
+ this.calcDesc();
114
+ }
115
+ /** generate count of OM, NB, AC, NF, RNF */
116
+ calcFigure() {
117
+ for (let status of LIST_STATUS) {
118
+ this.ground["cnt" + status] = this.getCnt(status, METHOD.GROUND);
119
+ this.ground.calcTotal();
120
+ }
121
+ for (let status of LIST_STATUS) {
122
+ this.sky["cnt" + status] = this.getCnt(status, METHOD.SKY);
123
+ this.sky.calcTotal();
124
+ }
125
+ for (let status of LIST_STATUS) {
126
+ this.total["cnt" + status] = this.getCnt(status, METHOD.TOTAL);
127
+ this.total.calcTotal();
128
+ }
129
+ this.cntAbs = this.getAbsCnt();
130
+ }
131
+ /** generate description of OM, NB, AC, NF, RNF */
132
+ calcDesc() {
133
+ for (let status of LIST_STATUS) {
134
+ this.ground["des" + status] = this.getDesc(status, METHOD.GROUND);
135
+ }
136
+ for (let status of LIST_STATUS) {
137
+ this.sky["des" + status] = this.getDesc(status, METHOD.SKY);
138
+ }
139
+ for (let status of LIST_STATUS) {
140
+ this.total["des" + status] = this.getDesc(status, METHOD.TOTAL);
141
+ }
142
+ this.desAbs = this.getAbsDesc();
143
+ }
144
+ /**
145
+ * reset all display attendance figure to zero
146
+ */
147
+ resetDisplayAttendance() {
148
+ this.ground = new DisplayAttendance();
149
+ this.sky = new DisplayAttendance();
150
+ this.total = new DisplayAttendance();
151
+ for (let status of LIST_STATUS) {
152
+ this.ground["cnt" + status] = 0;
153
+ this.sky["cnt" + status] = 0;
154
+ this.total["cnt" + status] = 0;
155
+ }
156
+ this.ground.total = 0;
157
+ this.sky.total = 0;
158
+ this.total.total = 0;
159
+ this.cntAbs = 0;
160
+ }
161
+ /**
162
+ * Sums CG's sessionAttendance into total sessionAttendance.
163
+ * @param sessionAttendance
164
+ */
165
+ sum(sessionAttendance) {
166
+ for (let status of LIST_STATUS) {
167
+ this.ground["cnt" + status] += sessionAttendance.ground["cnt" + status];
168
+ this.sky["cnt" + status] += sessionAttendance.sky["cnt" + status];
169
+ this.total["cnt" + status] += sessionAttendance.total["cnt" + status];
170
+ }
171
+ this.ground.total += sessionAttendance.ground.total;
172
+ this.sky.total += sessionAttendance.sky.total;
173
+ this.total.total += sessionAttendance.total.total;
174
+ this.cntAbs += sessionAttendance.cntAbs;
175
+ }
176
+ };
177
+ var AttSheep = class {
178
+ /**
179
+ * initialize AttSheep object from Sheep object
180
+ * @param sheep
181
+ */
182
+ constructor(sheep) {
183
+ this.idSheep = sheep.id;
184
+ this.name = sheep.name;
185
+ this.status = sheep.status;
186
+ this.attended = false;
187
+ this.absReason = "";
188
+ this.method = METHOD.GROUND;
189
+ }
190
+ copyAtt(attSheep) {
191
+ this.attended = attSheep.attended;
192
+ this.absReason = attSheep.absReason;
193
+ this.method = attSheep.method;
194
+ }
195
+ };
196
+ var DisplayAttendance = class {
197
+ calcTotal() {
198
+ this.total = this.cntOM + this.cntNB + this.cntAC + this.cntNF + this.cntRNF;
199
+ }
200
+ };
201
+
202
+ // src/classes/attendance/Attendance.ts
203
+ var Attendance = class {
204
+ constructor(attendance) {
205
+ if (attendance) {
206
+ Object.assign(this, attendance);
207
+ }
208
+ }
209
+ getSessionAttendance(session) {
210
+ }
211
+ setSessionAttendance(arrSession) {
212
+ if (this.arrSessionAttendance) {
213
+ let oriArr = this.deepCopySessionAttendance(this.arrSessionAttendance);
214
+ this.arrSessionAttendance = [];
215
+ for (let s of arrSession) {
216
+ this.arrSessionAttendance.push(new SessionAttendance(s));
217
+ }
218
+ for (let oriSession of oriArr) {
219
+ for (let newSession of this.arrSessionAttendance) {
220
+ if (oriSession.code == newSession.code) {
221
+ if (oriSession.arrSheep) {
222
+ newSession.arrSheep = [...oriSession.arrSheep];
223
+ }
224
+ }
225
+ }
226
+ }
227
+ } else {
228
+ this.arrSessionAttendance = [];
229
+ for (let s of arrSession) {
230
+ this.arrSessionAttendance.push(new SessionAttendance(s));
231
+ }
232
+ }
233
+ }
234
+ deepCopySessionAttendance(arrSessionAttendance) {
235
+ let arrRtn = [];
236
+ for (let s of arrSessionAttendance) {
237
+ let sessionAtt = new SessionAttendance();
238
+ sessionAtt.code = s.code;
239
+ sessionAtt.desc = s.desc;
240
+ sessionAtt.type = s.type;
241
+ sessionAtt.seq = s.seq;
242
+ sessionAtt.needAbsReason = s.needAbsReason;
243
+ sessionAtt.arrSheep = [];
244
+ for (let sheep of s.arrSheep) {
245
+ sessionAtt.arrSheep.push(sheep);
246
+ }
247
+ arrRtn.push(sessionAtt);
248
+ }
249
+ return arrRtn;
250
+ }
251
+ clearArrAttSheep(idCG, arrSheepForRef) {
252
+ if (this.arrSessionAttendance) {
253
+ for (let sessionAtt of this.arrSessionAttendance) {
254
+ sessionAtt.arrSheep = sessionAtt.arrSheep.filter((s) => {
255
+ return arrSheepForRef[s.idSheep] ? arrSheepForRef[s.idSheep].cg == idCG : false;
256
+ });
257
+ }
258
+ }
259
+ }
260
+ setArrAttSheep(arrSheep) {
261
+ for (let sessionAtt of this.arrSessionAttendance) {
262
+ for (let sheep of arrSheep) {
263
+ let found = false;
264
+ for (let attSheep of sessionAtt.arrSheep) {
265
+ if (attSheep.idSheep == sheep.id) {
266
+ found = true;
267
+ }
268
+ }
269
+ if (!found) sessionAtt.arrSheep.push(new AttSheep(sheep));
270
+ }
271
+ sessionAtt.arrSheep = sessionAtt.sortedArrAttSheep();
272
+ }
273
+ }
274
+ addSheep(sheep) {
275
+ for (let sessionAtt of this.arrSessionAttendance) {
276
+ sessionAtt.arrSheep.push(new AttSheep(sheep));
277
+ sessionAtt.arrSheep = sessionAtt.sortedArrAttSheep();
278
+ }
279
+ }
280
+ setCG(cg) {
281
+ this.idCg = cg.id;
282
+ this.idSt = cg.st;
283
+ this.idCluster = cg.cluster;
284
+ }
285
+ /**
286
+ * remove sheep where attended=false from arrSheep to submit attendance,
287
+ * won't remove OM
288
+ */
289
+ removeNotAttendForSubmission() {
290
+ for (let sessionAtt of this.arrSessionAttendance) {
291
+ sessionAtt.arrSheep = sessionAtt.arrSheep.filter(
292
+ (sheep) => sheep.attended || sheep.status == "OM"
293
+ );
294
+ }
295
+ }
296
+ /** calculate session attendance's figure & description */
297
+ calc() {
298
+ for (let sessionAtt of this.arrSessionAttendance) {
299
+ sessionAtt.calc();
300
+ }
301
+ }
302
+ /** Reset all display attendance figure to zero. */
303
+ resetDisplayAttendance() {
304
+ for (let session of this.arrSessionAttendance) {
305
+ session.resetDisplayAttendance();
306
+ }
307
+ }
308
+ getSessionAttendanceByCode(code) {
309
+ for (let session of this.arrSessionAttendance) {
310
+ if (session.code == code) {
311
+ return session;
312
+ }
313
+ }
314
+ return new SessionAttendance();
315
+ }
316
+ /**
317
+ * copy attendance to the writing panel
318
+ * @param attendance
319
+ */
320
+ copy(attendance) {
321
+ for (let sessionAtt of this.arrSessionAttendance) {
322
+ for (let prevSessionAtt of attendance.arrSessionAttendance) {
323
+ if (sessionAtt.code == prevSessionAtt.code) {
324
+ for (let attSheep of sessionAtt.arrSheep) {
325
+ let found = false;
326
+ for (let prevAttSheep of prevSessionAtt.arrSheep) {
327
+ if (attSheep.idSheep == prevAttSheep.idSheep) {
328
+ attSheep.copyAtt(prevAttSheep);
329
+ found = true;
330
+ }
331
+ }
332
+ if (!found) attSheep.attended = false;
333
+ }
334
+ }
335
+ }
336
+ }
337
+ }
338
+ };
339
+
340
+ // src/classes/attendance/BackupAttendance.ts
341
+ var BackupAttendance = class {
342
+ };
343
+
344
+ // src/classes/attendance/Session.ts
345
+ var Session = class {
346
+ constructor() {
347
+ }
348
+ };
349
+
350
+ // src/classes/attendance/Title.ts
351
+ var Title = class {
352
+ getKey() {
353
+ return "dddd";
354
+ }
355
+ };
356
+
357
+ // src/classes/pastoral-team/Sheep.ts
358
+ var Sheep = class {
359
+ constructor(id, name, status, cg, st, cluster, deleted, show, attCnt) {
360
+ this.id = id;
361
+ this.name = name;
362
+ this.status = status;
363
+ this.cg = cg;
364
+ this.st = st;
365
+ this.cluster = cluster;
366
+ this.deleted = deleted;
367
+ this.show = show;
368
+ this.attCnt = attCnt;
369
+ }
370
+ };
371
+
372
+ // src/classes/attendance-report/ReportSheep.ts
373
+ var ReportSheep = class extends Sheep {
374
+ constructor(sheep) {
375
+ super(
376
+ sheep.id,
377
+ sheep.name,
378
+ sheep.status,
379
+ sheep.cg,
380
+ sheep.st,
381
+ sheep.cluster,
382
+ sheep.deleted,
383
+ sheep.show,
384
+ sheep.attCnt
385
+ );
386
+ this.attMap = {};
387
+ }
388
+ };
389
+
390
+ // src/classes/attendance-report/TitleAttendance.ts
391
+ var TitleAttendance = class {
392
+ constructor(cgAtt, serviceAtt, title) {
393
+ this.cgAtt = cgAtt;
394
+ this.serviceAtt = serviceAtt;
395
+ this.title = title;
396
+ }
397
+ };
398
+
399
+ // src/classes/flw-up/FollowUpStatus.ts
400
+ var FollowUpStatus = class {
401
+ constructor() {
402
+ this.id = "";
403
+ this.method = "";
404
+ this.cluster = "";
405
+ this.st = "";
406
+ this.cg = "";
407
+ this.sheep = "";
408
+ this.in_list = true;
409
+ this.status = "";
410
+ this.timeStamp = "";
411
+ this.date = "";
412
+ this.discipler = "";
413
+ }
414
+ };
415
+
416
+ // src/classes/pastoral-team/CG.ts
417
+ var CG = class {
418
+ constructor(id, name, st, cluster, deleted) {
419
+ this.id = id;
420
+ this.name = name;
421
+ this.st = st;
422
+ this.cluster = cluster;
423
+ this.deleted = deleted;
424
+ }
425
+ };
426
+
427
+ // src/classes/pastoral-team/Cluster.ts
428
+ var Cluster = class {
429
+ constructor(id, name, deleted) {
430
+ this.id = id;
431
+ this.name = name;
432
+ this.deleted = deleted;
433
+ }
434
+ };
435
+
436
+ // src/classes/pastoral-team/SmallTeam.ts
437
+ var SmallTeam = class {
438
+ constructor(id, name, cluster, deleted) {
439
+ this.id = id;
440
+ this.name = name;
441
+ this.cluster = cluster;
442
+ this.deleted = deleted;
443
+ }
444
+ };
445
+
446
+ // src/classes/AppUser.ts
447
+ var AppUser = class {
448
+ constructor(id, name, phoneNum, permission) {
449
+ this.id = id;
450
+ this.name = name;
451
+ this.phoneNum = phoneNum;
452
+ this.permission = permission;
453
+ }
454
+ };
455
+
456
+ // src/classes/Click.ts
457
+ var Click = class {
458
+ };
459
+
460
+ // src/constants/click.constant.ts
461
+ var ClickAction = /* @__PURE__ */ ((ClickAction2) => {
462
+ ClickAction2[ClickAction2["P_WeeklyAttendance"] = 0] = "P_WeeklyAttendance";
463
+ ClickAction2[ClickAction2["P_AttendanceReport"] = 1] = "P_AttendanceReport";
464
+ ClickAction2[ClickAction2["P_CGNameList"] = 2] = "P_CGNameList";
465
+ ClickAction2[ClickAction2["F_CopyAttendance"] = 3] = "F_CopyAttendance";
466
+ ClickAction2[ClickAction2["F_CheckAttendanceHistory"] = 4] = "F_CheckAttendanceHistory";
467
+ ClickAction2[ClickAction2["F_AttendanceReminder"] = 5] = "F_AttendanceReminder";
468
+ ClickAction2[ClickAction2["F_ExportWeekAttendance"] = 6] = "F_ExportWeekAttendance";
469
+ ClickAction2[ClickAction2["F_ClickEditSheep"] = 7] = "F_ClickEditSheep";
470
+ ClickAction2[ClickAction2["F_EditSheep"] = 8] = "F_EditSheep";
471
+ ClickAction2[ClickAction2["F_VerticalViewAttendance"] = 9] = "F_VerticalViewAttendance";
472
+ return ClickAction2;
473
+ })(ClickAction || {});
474
+
475
+ // src/constants/permission.constant.ts
476
+ var PERMISSION = {
477
+ SUPER_USER: "Super user",
478
+ TL: "TL",
479
+ SCGL: "SCGL",
480
+ CGL: "CGL",
481
+ FL: "FL",
482
+ WM: "WM",
483
+ NOT_VERIFIED: "Not verified",
484
+ PASTORAL_ADMIN: "Pastoral Admin",
485
+ ST_ADMIN: "Small Team Admin"
486
+ };
487
+ var PERMISSION_TYPE = {
488
+ USER_MANAGEMENT: [PERMISSION.SUPER_USER],
489
+ WEEKLY_ATT: [
490
+ PERMISSION.SUPER_USER,
491
+ PERMISSION.TL,
492
+ PERMISSION.SCGL,
493
+ PERMISSION.PASTORAL_ADMIN
494
+ ],
495
+ ATT_RPT: [
496
+ PERMISSION.SUPER_USER,
497
+ PERMISSION.TL,
498
+ PERMISSION.SCGL,
499
+ PERMISSION.CGL,
500
+ PERMISSION.PASTORAL_ADMIN
501
+ ],
502
+ TITLE: [PERMISSION.SUPER_USER],
503
+ CLICKS: [PERMISSION.SUPER_USER],
504
+ // SHEEP_LIST: [PERMISSION.TL],
505
+ // view specific permissions
506
+ monthlyReport: [
507
+ PERMISSION.SUPER_USER,
508
+ PERMISSION.PASTORAL_ADMIN,
509
+ PERMISSION.TL
510
+ ],
511
+ read: [
512
+ PERMISSION.SUPER_USER,
513
+ PERMISSION.PASTORAL_ADMIN,
514
+ PERMISSION.TL,
515
+ PERMISSION.SCGL,
516
+ PERMISSION.CGL
517
+ ],
518
+ msjStudentRecord: [PERMISSION.SUPER_USER, PERMISSION.PASTORAL_ADMIN],
519
+ msjProgress: [
520
+ PERMISSION.SUPER_USER,
521
+ PERMISSION.TL,
522
+ PERMISSION.SCGL,
523
+ PERMISSION.CGL,
524
+ PERMISSION.PASTORAL_ADMIN
525
+ ],
526
+ msjToAttend: [
527
+ PERMISSION.SUPER_USER,
528
+ PERMISSION.TL,
529
+ PERMISSION.SCGL,
530
+ PERMISSION.CGL,
531
+ PERMISSION.PASTORAL_ADMIN
532
+ ],
533
+ addSheep: [
534
+ PERMISSION.SUPER_USER,
535
+ PERMISSION.PASTORAL_ADMIN,
536
+ PERMISSION.ST_ADMIN,
537
+ PERMISSION.TL,
538
+ PERMISSION.SCGL,
539
+ PERMISSION.CGL
540
+ ],
541
+ addCG: [PERMISSION.SUPER_USER, PERMISSION.PASTORAL_ADMIN],
542
+ // action specific permission
543
+ oprAddSheep: [PERMISSION.SUPER_USER, PERMISSION.PASTORAL_ADMIN]
544
+ };
545
+
1
546
  // src/utils.ts
2
547
  function greet(name) {
3
548
  return `Hello, ${name}!`;
@@ -6,6 +551,27 @@ function sum(a, b) {
6
551
  return a + b;
7
552
  }
8
553
  export {
554
+ AppUser,
555
+ AttSheep,
556
+ Attendance,
557
+ BackupAttendance,
558
+ CG,
559
+ Click,
560
+ ClickAction,
561
+ Cluster,
562
+ DisplayAttendance,
563
+ FollowUpStatus,
564
+ LIST_STATUS,
565
+ METHOD,
566
+ PERMISSION,
567
+ PERMISSION_TYPE,
568
+ ReportSheep,
569
+ Session,
570
+ SessionAttendance,
571
+ Sheep,
572
+ SmallTeam,
573
+ Title,
574
+ TitleAttendance,
9
575
  greet,
10
576
  sum
11
577
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cyc-type-def",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [