-
-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ ct.res.groups and
group
field in rooms and templates.
- Loading branch information
1 parent
daed484
commit 8d6c1a3
Showing
5 changed files
with
40 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
export const flattenGroups = (project: IProject): Record<string, Record<string, string>> => { | ||
const out: Record<string, Record<string, string>> = {}; | ||
let thing: keyof typeof project.groups; | ||
for (thing in project.groups) { | ||
out[thing] = { | ||
'-1': 'ungrouped' | ||
}; | ||
for (const group of project.groups[thing]) { | ||
out[thing][group.uid] = group.name; | ||
} | ||
} | ||
return out; | ||
}; | ||
export const getGroups = (project: IProject): Record<string, Record<string, string[]>> => { | ||
const out: Record<string, Record<string, string[]>> = {}; | ||
let thing: keyof typeof project.groups; | ||
const flattened = flattenGroups(project); | ||
for (thing in project.groups) { | ||
out[thing] = {}; | ||
for (const groupId in flattened[thing]) { | ||
out[thing][flattened[thing][groupId]] = []; | ||
} | ||
for (const asset of project[thing]) { | ||
const groupName = asset.group ? flattened[thing][asset.group] : 'ungrouped'; | ||
out[thing][groupName].push(('name' in asset) ? asset.name : asset.typefaceName); | ||
} | ||
} | ||
return out; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters