Skip to content
This repository has been archived by the owner on May 4, 2019. It is now read-only.

Commit

Permalink
Merge pull request #273 from osu-cass/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
tnoelcke committed Nov 27, 2018
2 parents abb8c74 + d7faf21 commit a52e9c9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
19 changes: 18 additions & 1 deletion src/Accessibility/AccessibilityModels.ts
Expand Up @@ -127,13 +127,30 @@ export function mergeAccessibilityGroups(
ar.disabled =
newGroups[groupIndex].accessibilityResources[resourceIndex].disabled;

return ar;
return mergeSelections(
newGroups[groupIndex].accessibilityResources[resourceIndex],
ar
);
});
});

return mergedGroups;
}

function mergeSelections(
newModel: AccessibilityResourceModel,
current: AccessibilityResourceModel
): AccessibilityResourceModel {
const newSelection: AccessibilityResourceModel = current;
newSelection.selections.map((s, index) => {
s.disabled = newModel.selections[index].disabled;

return s;
});

return current;
}

export function resetAccessibilityGroups(
accGroups: AccResourceGroupModel[]
): AccResourceGroupModel[] {
Expand Down
16 changes: 15 additions & 1 deletion src/ItemPage/ItemPageModels.ts
Expand Up @@ -45,14 +45,28 @@ export function toiSAAP(
for (const group of accResourceGroups) {
for (const res of group.accessibilityResources) {
if (res.currentSelectionCode && !res.disabled) {
isaapCodes += `${res.currentSelectionCode};`;
isaapCodes += `${findSelection(res)};`;
}
}
}

return encodeURIComponent(isaapCodes);
}

function findSelection(resource: AccessibilityResourceModel) {
let selectionCode: String;
const currentSelection = resource.selections.filter(
s => s.selectionCode === resource.currentSelectionCode
);
if (currentSelection[0] && currentSelection[0].disabled) {
selectionCode = resource.defaultSelection;
} else {
selectionCode = resource.currentSelectionCode;
}

return selectionCode;
}

export function resetResource(
model: AccessibilityResourceModel
): AccessibilityResourceModel {
Expand Down

0 comments on commit a52e9c9

Please sign in to comment.