Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions src/renderer/src/__tests__/getSheet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,49 @@ test('one section and one passage with step gives output', () => {
]);
});

test('passage assignee from organizationSchemeStep', () => {
const s1WithScheme = {
...s1,
relationships: {
...s1.relationships,
organizationScheme: {
data: { type: 'organizationscheme', id: 'scheme1' },
},
},
} as SectionD;
const schemeStep = {
type: 'organizationschemestep',
id: 'oss1',
attributes: {
dateCreated: '2021-09-14',
dateUpdated: '2021-09-15',
lastModifiedBy: 1,
},
relationships: {
organizationscheme: {
data: { type: 'organizationscheme', id: 'scheme1' },
},
orgWorkflowStep: { data: { type: 'orgworkflowstep', id: 'owf1' } },
user: { data: { type: 'user', id: 'u2' } },
group: {},
lastModifiedByUser: { data: { type: 'user', id: 'u0' } },
},
};
const sheet = getSheet({
...gsDefaults,
plan: 'pl1',
sections: [s1WithScheme],
passages: [pa1],
orgWorkflowSteps: owf,
organizationSchemeSteps: [schemeStep],
} as any);
expect(sheet[1].assign).toEqual({ type: 'user', id: 'u2' });
expect(sheet[0].scheme).toEqual({
type: 'organizationscheme',
id: 'scheme1',
});
});

test('two flat sections with steps gives output', () => {
const stepStatus =
'{"completed": [{"name": "Internalize", "stepid": "1", "complete": true}, {"name": "Record", "stepid": "2", "complete": true}, {"name": "TeamCheck", "stepid": "3", "complete": true}]}';
Expand Down
12 changes: 8 additions & 4 deletions src/renderer/src/components/Sheet/ScriptureTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1439,12 +1439,18 @@ export function ScriptureTable(props: IProps) {

const refreshSheet = useCallback(() => {
if (!plan) return;
const freshSections = memory.cache.query((q) =>
q.findRecords('section')
) as SectionD[];
const freshSchemeSteps = memory.cache.query((q) =>
q.findRecords('organizationschemestep')
) as OrganizationSchemeStepD[];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we can't rely on useOrbitData we're in trouble. sections is in the callback refresh list. Why do we need to get from memory????? This feels like extra code that we shouldn't need.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when I removed this code and just relied on what was there (a dependency which includes sections and and organizationshemestepss, the sheet isn't updated like it should be. :-(

setSheet(
getSheet({
plan,
sections,
sections: freshSections,
passages,
organizationSchemeSteps,
organizationSchemeSteps: freshSchemeSteps,
flat,
projectShared: shared,
memory,
Expand All @@ -1467,9 +1473,7 @@ export function ScriptureTable(props: IProps) {
);
}, [
plan,
sections,
passages,
organizationSchemeSteps,
flat,
shared,
memory,
Expand Down
Loading