Skip to content

Commit

Permalink
Merge pull request #48 from Assistants-Center/feature
Browse files Browse the repository at this point in the history
Added multiRow formType and improved types
  • Loading branch information
iMidnights authored Jan 27, 2023
2 parents b7f738b + 2117cc7 commit 74112cb
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 13 deletions.
26 changes: 13 additions & 13 deletions dbd-soft-ui.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,32 +339,32 @@ declare module "dbd-soft-ui" {
type: string,
themeOptions: Record<string, any>
}
emojiPicker: (disabled: any, themeOptions: Record<string, any>) => {
emojiPicker: (disabled: boolean, themeOptions: Record<string, any>) => {
type: string,
disabled: any,
disabled: boolean,
themeOptions: Record<string, any>
}
slider: (min: any, max: any, step: any, disabled: any, themeOptions: Record<string, any>) => {
slider: (min: number, max: number, step: number, disabled: boolean, themeOptions: Record<string, any>) => {
type: string,
min: any,
max: any,
step: any,
disabled: any,
min: number,
max: number,
step: number,
disabled: boolean,
themeOptions: Record<string, any>
},
date: (disabled: any, themeOptions: Record<string, any>) => {
date: (disabled: boolean, themeOptions: Record<string, any>) => {
type: string,
disabled: any,
disabled: boolean,
themeOptions: Record<string, any>
},
numberPicker: (disabled: any, themeOptions: Record<string, any>) => {
numberPicker: (min: number, max: number, disabled: boolean, themeOptions: Record<string, any>) => {
type: string,
disabled: any,
disabled: boolean,
themeOptions: Record<string, any>
},
tagInput: (disabled: any, themeOptions: Record<string, any>) => {
tagInput: (disabled: boolean, themeOptions: Record<string, any>) => {
type: string,
disabled: any,
disabled: boolean,
themeOptions: Record<string, any>
}
}
Expand Down
15 changes: 15 additions & 0 deletions utils/formtypes.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
module.exports = {
multiRow: (options) => {
// Validate Data
if (options && (!options.length || !options[0])) throw new Error("Options in the 'collapsable' form type should be an array.");

const hasType = (object) => object.hasOwnProperty('optionType') && object.optionType?.hasOwnProperty('type');

if (options && !options.every(hasType)) throw new Error("Invalid form type provided in the 'multiRow' form type.");

if (options && options.find(obj => obj.optionType.type == "multiRow")) throw new Error("You cannot use the form type 'multiRow' in the 'multiRow' form type.");

return {
type: "multiRow",
options
}
},
spacer: (themeOptions = {}) => {
return {
type: 'spacer',
Expand Down
19 changes: 19 additions & 0 deletions utils/functions/settingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,25 @@ module.exports = function (config, themeConfig) {
actual[s.categoryId] = {}
}
if (!actual[s.categoryId][c.optionId]) {
if (c.optionType.type === "multiRow") {
for (const item of c.optionType.options) {
actual[s.categoryId][item.optionId] = await item.getActualSet(
{
guild: {
id: req.params.id,
object: bot.guilds.cache.get(req.params.id)
},
user: {
id: req.session.user.id,
object: bot.guilds.cache
.get(req.params.id)
.members.cache.get(req.session.user.id)
}
}
)
}
continue
}
actual[s.categoryId][c.optionId] = await c.getActualSet(
{
guild: {
Expand Down
11 changes: 11 additions & 0 deletions views/components/formTypes/multiRow.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

<div class="formTypes">
<% option.optionType.options.forEach(opt => { %>
<% console.log({opt}) %>
<div class="formtype-item mt-3">
<h4 class="m-0"><%- opt?.optionName || ""%></h4>
<p><%- opt?.optionDescription || ""%></p>
<%- include(`./${opt.optionType.type}.ejs`, {option: opt, s, Allowed}) %>
</div>
<% }) %>
</div>

0 comments on commit 74112cb

Please sign in to comment.