From dce7e68c6c2db2da90980640e4e619a537f7158e Mon Sep 17 00:00:00 2001 From: BenShelton Date: Tue, 15 Oct 2019 13:26:01 +0100 Subject: [PATCH 1/4] feat: add preferred school option to congregation members --- database/upload.ts | 1 + lambda/api.ts | 4 ++-- src/components/AssigneeSelect.vue | 4 +++- src/components/Schedule/ScheduleWeekView.vue | 4 ++++ src/views/Congregation.vue | 16 ++++++++++++++-- types/interfaces.d.ts | 1 + 6 files changed, 25 insertions(+), 5 deletions(-) diff --git a/database/upload.ts b/database/upload.ts index c5705e3..f76b8fc 100644 --- a/database/upload.ts +++ b/database/upload.ts @@ -119,6 +119,7 @@ const members: ICongregationMember[] = data.map(row => ({ gender: row.gender, languageGroup: row.languageGroup, show: !!row.show, + school: null, privileges: { chairman: !!row['privileges.chairman'], highlights: !!row['privileges.highlights'], diff --git a/lambda/api.ts b/lambda/api.ts index 60d9874..84b053a 100644 --- a/lambda/api.ts +++ b/lambda/api.ts @@ -81,8 +81,8 @@ function validateMember (member: Omit): string | nul } router.post('/congregation/addMember', (req, res) => { - const { name, appointment, gender, languageGroup, privileges, show } = req.body as APITypes.Congregation.AddMember.Data - const member = { name, appointment, gender, languageGroup, privileges, show } + const { name, appointment, gender, languageGroup, school, privileges, show } = req.body as APITypes.Congregation.AddMember.Data + const member = { name, appointment, gender, languageGroup, school, privileges, show } const validationError = validateMember(member) if (validationError) return res.status(400).json({ message: validationError }) congregation.addMember(member) diff --git a/src/components/AssigneeSelect.vue b/src/components/AssigneeSelect.vue index d591f26..8180522 100644 --- a/src/components/AssigneeSelect.vue +++ b/src/components/AssigneeSelect.vue @@ -48,6 +48,7 @@ export default Vue.extend({ value: { type: String, default: '' }, label: { type: String, required: true }, type: { type: String as PropType, default: '' as Privileges }, + school: { type: Number, required: true }, disabled: { type: Boolean, required: true } }, @@ -66,8 +67,9 @@ export default Vue.extend({ privilegedMembers (): ICongregationMember[] { const { inputDisabled, type, restrictLanguage } = this if (inputDisabled || !type) return [] - return congregationModule.activeMembers.filter(({ privileges, languageGroup }) => { + return congregationModule.activeMembers.filter(({ privileges, languageGroup, school }) => { if (restrictLanguage && languageGroup !== scheduleModule.language) return false + if (school && school !== this.school) return false return privileges[type] }) }, diff --git a/src/components/Schedule/ScheduleWeekView.vue b/src/components/Schedule/ScheduleWeekView.vue index dd23f5e..d1668a6 100644 --- a/src/components/Schedule/ScheduleWeekView.vue +++ b/src/components/Schedule/ScheduleWeekView.vue @@ -199,6 +199,7 @@ v-model="editAssignment.assignee" label="Assignee" :type="editAssignment.type" + :school="1" :disabled="!!(editAssignment.stream || editAssignment.inherit)" /> @@ -207,6 +208,7 @@ v-model="editAssignment.assistant" label="Assistant" :type="editAssignment.type + 'Assist'" + :school="1" :disabled="!!(editAssignment.stream || editAssignment.inherit)" /> @@ -216,6 +218,7 @@ v-model="editAssignment.assignee2" label="Assignee (2)" :type="editAssignment.type" + :school="2" :disabled="!!(editAssignment.stream || editAssignment.inherit)" /> @@ -224,6 +227,7 @@ v-model="editAssignment.assistant2" label="Assistant (2)" :type="editAssignment.type + 'Assist'" + :school="2" :disabled="!!(editAssignment.stream || editAssignment.inherit)" /> diff --git a/src/views/Congregation.vue b/src/views/Congregation.vue index be8bc9e..f1582f1 100644 --- a/src/views/Congregation.vue +++ b/src/views/Congregation.vue @@ -36,6 +36,9 @@ + + + @@ -147,7 +150,8 @@ import { APPOINTMENTS, SUPPORTED_LANGUAGES, USED_LANGUAGES, - PRIVILEGES + PRIVILEGES, + SECOND_SCHOOL } from '@/constants' import { ICongregationMember, Languages } from 'types' @@ -169,6 +173,7 @@ export default Vue.extend({ gender: GENDERS[0], appointment: APPOINTMENTS[0], languageGroup: USED_LANGUAGES[0].value, + school: null, show: true, privileges: {} } as unknown as ICongregationMember @@ -196,6 +201,11 @@ export default Vue.extend({ languageGroups (): { [key in Languages]: string } { return SUPPORTED_LANGUAGES.reduce((acc, { text, value }) => Object.assign(acc, { [value]: text }), {}) as { [key in Languages]: string } }, + preferredSchools (): { text: string, value: null | number }[] { + const items: { text: string, value: null | number }[] = [{ text: 'Any', value: null }] + if (SECOND_SCHOOL) items.push({ text: 'First Only', value: 1 }, { text: 'Second Only', value: 2 }) + return items + }, headers (): { text: string, value: string, align?: string, sortable?: boolean }[] { return [ { text: 'Name', value: 'name' }, @@ -230,6 +240,7 @@ export default Vue.extend({ gender: GENDERS[0], appointment: APPOINTMENTS[0], languageGroup: USED_LANGUAGES[0].value, + school: null, show: true, privileges: {} } @@ -239,12 +250,13 @@ export default Vue.extend({ }, onEdit (member: ICongregationMember): void { this.editID = member._id - const { name, gender, appointment, languageGroup, show, privileges } = member + const { name, gender, appointment, languageGroup, school, show, privileges } = member const updateProperties: Partial = { name, gender, appointment, languageGroup, + school, show, privileges: { ...privileges } } diff --git a/types/interfaces.d.ts b/types/interfaces.d.ts index 7df564c..9d0e274 100644 --- a/types/interfaces.d.ts +++ b/types/interfaces.d.ts @@ -59,6 +59,7 @@ export interface ICongregationMember { gender: Genders appointment: Appointments languageGroup: Languages + school: null | number show: boolean privileges: { [key in Privileges]?: boolean From 360901a2ba53530f567ebc3cecb4acafd58e2a71 Mon Sep 17 00:00:00 2001 From: BenShelton Date: Tue, 15 Oct 2019 14:07:38 +0100 Subject: [PATCH 2/4] feat(home): add changelog --- src/views/Home.vue | 116 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 114 insertions(+), 2 deletions(-) diff --git a/src/views/Home.vue b/src/views/Home.vue index 364bcbb..de5de57 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -4,14 +4,126 @@ Welcome to OCLM Planner

Getting Started

-

Click the navigation menu on the top left to login and navigate the site

+

+ Click the navigation menu on the top left to login and navigate the site +

+

Changelog

+ + + + + +
+

+
    +
  • +
+

+
+
+
+
From c2faf4331029892d80d23dac5ba695727bcd4194 Mon Sep 17 00:00:00 2001 From: BenShelton Date: Tue, 15 Oct 2019 14:26:41 +0100 Subject: [PATCH 3/4] feat: add bibleReading to the second school talk list --- .../Schedule/ScheduleAssignment.vue | 2 +- src/components/Schedule/ScheduleWeekView.vue | 2 +- src/plugins/pdfMake.ts | 21 +++++++++---------- src/views/Home.vue | 3 ++- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/components/Schedule/ScheduleAssignment.vue b/src/components/Schedule/ScheduleAssignment.vue index 509d645..c9a443a 100644 --- a/src/components/Schedule/ScheduleAssignment.vue +++ b/src/components/Schedule/ScheduleAssignment.vue @@ -83,7 +83,7 @@ export default Vue.extend({ hasSecondSchool (): boolean { const { details } = this.assignment if (!details) return false - return SECOND_SCHOOL && ['initialCall', 'returnVisit', 'bibleStudy', 'studentTalk'].includes(details.type) + return SECOND_SCHOOL && ['initialCall', 'returnVisit', 'bibleStudy', 'studentTalk', 'bibleReading'].includes(details.type) } }, diff --git a/src/components/Schedule/ScheduleWeekView.vue b/src/components/Schedule/ScheduleWeekView.vue index d1668a6..8434114 100644 --- a/src/components/Schedule/ScheduleWeekView.vue +++ b/src/components/Schedule/ScheduleWeekView.vue @@ -491,7 +491,7 @@ export default class ScheduleWeekView extends Vue { } get hasSecondSchool (): boolean { - return SECOND_SCHOOL && ['initialCall', 'returnVisit', 'bibleStudy', 'studentTalk'].includes(this.editAssignment.type) + return SECOND_SCHOOL && ['initialCall', 'returnVisit', 'bibleStudy', 'studentTalk', 'bibleReading'].includes(this.editAssignment.type) } // Methods diff --git a/src/plugins/pdfMake.ts b/src/plugins/pdfMake.ts index e2fbfb9..72587b4 100644 --- a/src/plugins/pdfMake.ts +++ b/src/plugins/pdfMake.ts @@ -13,7 +13,7 @@ import { ScheduleWeek } from 'types' -type ScheduleTableRow = [string | null, string, string | null, string | null, string | null, boolean?] | null +type ScheduleTableRow = [string | null, string, string | null, string | null, string | null, boolean?, boolean?] | null pdfMake.vfs = pdfFonts.pdfMake.vfs @@ -190,7 +190,7 @@ function getScheduleAssignees (assignment?: IScheduleAssignment): string { if (!assignment) return '' if (assignment.stream) return '(Video Stream)' const { type, assignee, assistant, assignee2, assistant2 } = assignment - if (SECOND_SCHOOL && ['initialCall', 'returnVisit', 'bibleStudy', 'studentTalk'].includes(type)) { + if (SECOND_SCHOOL && ['initialCall', 'returnVisit', 'bibleStudy', 'studentTalk', 'bibleReading'].includes(type)) { if (['initialCall', 'returnVisit', 'bibleStudy'].includes(type)) { return getAssigneeName(assignee, '-', true) + ' & ' + getAssigneeName(assistant, '-', true) + ' | ' + getAssigneeName(assignee2, '-', true) + ' & ' + getAssigneeName(assistant2, '-', true) } else { @@ -228,7 +228,7 @@ function createScheduleSeparator (pageStart = false): Content { } } -function createScheduleTable (markerColor: string, rows: ScheduleTableRow[], expandAssigneeName = false): Content { +function createScheduleTable (markerColor: string, rows: ScheduleTableRow[]): Content { const body = [] for (const row of rows) { const bodyRow: Content[] = [] @@ -237,18 +237,18 @@ function createScheduleTable (markerColor: string, rows: ScheduleTableRow[], exp bodyRow.push({ text: '', colSpan: 7 }) continue } - const [timeOn, title, assigneeTitle, assigneeName, timeOff] = row + const [timeOn, title, assigneeTitle, assigneeName, timeOff, , expandAssigneeName = false] = row bodyRow.push( { text: timeOn || '' }, { text: '•', fontSize: 24, color: markerColor, margin: [0, -8] }, { text: title, paddingLeft: 0, colSpan: expandAssigneeName ? 1 : 2 } ) if (SECOND_SCHOOL && expandAssigneeName) { - bodyRow.push({ text: assigneeName || '', colSpan: 3 }, { text: '' }, { text: '' }) + bodyRow.push({ text: assigneeName || '', colSpan: 3, alignment: 'right' }, { text: '' }, { text: '' }) } else { if (!expandAssigneeName) bodyRow.push({ text: '' }) bodyRow.push({ text: assigneeTitle || '', fontSize: 8, color: '#6F6F6F', alignment: 'right', margin: [0, 1, 0, 0] }) - bodyRow.push({ text: assigneeName || '', colSpan: expandAssigneeName ? 2 : 1 }) + bodyRow.push({ text: assigneeName || '', colSpan: expandAssigneeName ? 2 : 1, alignment: 'right' }) if (expandAssigneeName) bodyRow.push({ text: '' }) } bodyRow.push({ text: timeOff || '', alignment: 'right' }) @@ -390,7 +390,7 @@ export const generateSchedule: PDFGenerator = function (weeks, month) { stack.push(createScheduleTable(COLORS.TREASURES, [ [timer, getAssignmentTitle(highlights), null, getScheduleAssignees(highlights), addTime(highlights.time), highlights.inherit], [timer, translation.gems + ' (10 min.)', null, getScheduleAssignees(gems), addTime(gems.time), gems.inherit], - [timer, bibleReadingTitle, null, getScheduleAssignees(bibleReading), addTime(bibleReading.time), bibleReading.inherit] + [timer, bibleReadingTitle, null, getScheduleAssignees(bibleReading), addTime(bibleReading.time), bibleReading.inherit, true] ])) // MINISTRY Section @@ -406,9 +406,9 @@ export const generateSchedule: PDFGenerator = function (weeks, month) { let assigneeTitle = `${translation.student}/${translation.assistant}:` if (studentTalk.type === 'ministryVideo') assigneeTitle = '' if (studentTalk.type === 'studentTalk') assigneeTitle = translation.student + ':' - ministryTableRows.push([timer, getAssignmentTitle(studentTalk), assigneeTitle, getScheduleAssignees(studentTalk), addTime(studentTalk.time), studentTalk.inherit]) + ministryTableRows.push([timer, getAssignmentTitle(studentTalk), assigneeTitle, getScheduleAssignees(studentTalk), addTime(studentTalk.time), studentTalk.inherit, true]) } - stack.push(createScheduleTable(COLORS.MINISTRY, ministryTableRows, true)) + stack.push(createScheduleTable(COLORS.MINISTRY, ministryTableRows)) // LIVING Section stack.push(createScheduleSubheader(translation.living, COLORS.LIVING)) @@ -603,7 +603,6 @@ export const generateAssignmentSlips: PDFGenerator = function (weeks, month) { const slips = [] const VALID_TYPES = ['bibleReading', 'initialCall', 'returnVisit', 'bibleStudy', 'studentTalk'] - const SECOND_SCHOOL_TYPES = ['initialCall', 'returnVisit', 'bibleStudy', 'studentTalk'] const language = scheduleModule.language const translation = ASSIGNMENT_SLIP_TRANSLATIONS[language] if (!translation) throw new Error('Translations not created for the selected language') @@ -619,7 +618,7 @@ export const generateAssignmentSlips: PDFGenerator = function (weeks, month) { const talk: IScheduleAssignment | undefined = assignments[index] if (!talk || talk.inherit || !(VALID_TYPES.includes(talk.type))) continue slips.push(createSlip(translation, talk, false, date)) - if (SECOND_SCHOOL && SECOND_SCHOOL_TYPES.includes(talk.type)) slips.push(createSlip(translation, talk, true, date)) + if (SECOND_SCHOOL) slips.push(createSlip(translation, talk, true, date)) } } diff --git a/src/views/Home.vue b/src/views/Home.vue index de5de57..419e535 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -88,7 +88,8 @@ export default Vue.extend({ 'Simplifies user experience for changing languages and logging in', 'Date picker no longer closes immediately', 'Use correct color on printed schedule for Treasures bullet points', - 'Clears month data when leaving schedule page' + 'Clears month data when leaving schedule page', + 'Update layout of schedule printout to support second school' ] }, { From 8de60524372cb2cfa6cbf5a3f41489f38e909490 Mon Sep 17 00:00:00 2001 From: BenShelton Date: Tue, 15 Oct 2019 14:27:21 +0100 Subject: [PATCH 4/4] chore: bump minor version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 27d915e..d43f86e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "oclm-planner", - "version": "0.1.0", + "version": "1.1.0", "private": true, "scripts": { "serve": "npm-run-all --parallel serve:**",