Skip to content

Commit

Permalink
Merge branch 'main' into bug-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
iMidnights authored Feb 8, 2023
2 parents 3f8a7ac + 7d3d70f commit c2f457e
Show file tree
Hide file tree
Showing 19 changed files with 138 additions and 51 deletions.
37 changes: 37 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Contributions are welcome! Please read the following guidelines before contributing.

## How to contribute

1. Fork the project
2. Create a new branch
3. Commit your changes
4. Ensure features are tested and documented
5. Create a new Pull Request

## How to update the documentation

1. Head to the [Documentation Repo](https://github.com/Assistants-Center/Soft-UI-Docs)
2. Fork the project
3. Create a new branch
4. Preview docs with `yarn docs:dev`
5. Make changes to the docs
6. Commit your changes
7. Create a new Pull Request

## Submitting a bug report

1. Join the [Discord Server](https://discord.gg/CHbfcSbEgd)
2. Create a new post in the #report-bug channel
3. Describe the bug
4. Provide a codepen and steps to reproduce the bug
5. Provide screenshots if possible and any console errors

## Submitting a feature request

1. Join the [Discord Server](https://discord.gg/CHbfcSbEgd)
2. Create a new post in the #suggestions channel
3. Describe the feature
4. Provide screenshots if possible

### Thank you for your contributions!
#### Assistants Center
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
11 changes: 0 additions & 11 deletions pages/admin/feed.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const { icons, otherIcons } = require('../../icons')
module.exports = {
page: '/feed',
execute: async (req, res, app, config, themeConfig, info) => {
console.log(`Feed request, action: ${req.query.action}`)
if (req.query.action === 'delete') {
const deleteFeed = req.query.feed
if (!deleteFeed) return res.redirect('/admin?error=invalidFeed')
Expand All @@ -13,7 +12,6 @@ module.exports = {
if (deleteFeed !== '1' && deleteFeed !== '2' && deleteFeed !== '3')
return res.redirect('/admin?error=invalidFeed')
if (deleteFeed === '1') {
console.log('1')
if (!db.get('feeds.one'))
return res.redirect('/admin?error=invalidFeed')
if (db.get('feeds.two')) {
Expand All @@ -40,7 +38,6 @@ module.exports = {
await db.delete('feeds.three')
}
} else if (deleteFeed === '2') {
console.log('2')
if (!db.get('feeds.two'))
return res.redirect('/admin?error=invalidFeed')
if (db.get('feeds.one')) {
Expand All @@ -52,20 +49,14 @@ module.exports = {
icon: f.icon,
diff: f.diff
})
console.log('Set feed 1 to 2')
await db.delete('feeds.one')
console.log('Deleted feed 1')
} else {
await db.delete('feeds.two')
console.log('Deleted feed 2')
}
} else if (deleteFeed === '3') {
console.log('3')
if (!db.get('feeds.three'))
return res.redirect('/admin?error=invalidFeed')
await db.delete('feeds.three')
console.log(db.get('feeds.three'))
console.log('Deleted feed 3')
if (db.get('feeds.two')) {
const f = await db.get('feeds.two')
await db.set('feeds.three', {
Expand All @@ -75,7 +66,6 @@ module.exports = {
icon: f.icon,
diff: f.diff
})
console.log('Set feed 2 to 3')
}
if (db.get('feeds.one')) {
const f = await db.get('feeds.one')
Expand All @@ -86,7 +76,6 @@ module.exports = {
icon: f.icon,
diff: f.diff
})
console.log('Set feed 1 to 2')
}
}
return res.redirect('/admin')
Expand Down
19 changes: 18 additions & 1 deletion 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 Expand Up @@ -29,9 +44,11 @@ module.exports = {
themeOptions
}
},
numberPicker: (disabled, themeOptions = {}) => {
numberPicker: (min, max, disabled, themeOptions = {}) => {
return {
type: 'numberPicker',
min,
max,
disabled,
themeOptions
}
Expand Down
20 changes: 20 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 Expand Up @@ -294,6 +313,7 @@ module.exports = function (config, themeConfig) {
canUseList,
bot: config.bot,
guild,
userid: req.session.user.id,
gIcon,
req: req,
guildid: req.params.id,
Expand Down
2 changes: 1 addition & 1 deletion views/components/formTypes/channelsMultiSelect.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
>
<% if (actual[s.categoryId][option.optionId]) {
let ioooooo = 0;
let functiona = option.optionType.function(bot, guildid);
let functiona = option.optionType.function(bot, guildid, userid);
functiona.values.forEach(value=>{ %>
<option value="<%= value %>"
<% if(actual[s.categoryId][option.optionId].includes(value)){ %>selected
Expand Down
2 changes: 1 addition & 1 deletion views/components/formTypes/channelsSelect.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
style="<% if(!Allowed.allowed){ %>border-color: red;<% } %> ">
<%
let ioooooo = 0;
let functiona = option.optionType.function(bot, guildid);
let functiona = option.optionType.function(bot, guildid, userid);
functiona.values.forEach(value=>{ %>
<option value="<%= value %>"
<% if(actual[s.categoryId][option.optionId] == value){ %>selected
Expand Down
2 changes: 0 additions & 2 deletions views/components/formTypes/emojiPicker.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@
<br>
<% } %>

<% console.log(actual[s.categoryId][option.optionId]) %>

<input defaultValue="<%= actual[s.categoryId][option.optionId] || "" %>" class="d-none" type="text" id="<%= option.optionId %>" formType="emojiPicker" type="text" onchange="optionEdited(this)">

<div class="dropdown">
Expand Down
10 changes: 10 additions & 0 deletions views/components/formTypes/multiRow.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

<div class="formTypes">
<% option.optionType.options.forEach(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>
8 changes: 8 additions & 0 deletions views/components/formTypes/numberPicker.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
type="number"
id="<%= option.optionId %>"
formType="numberPicker"
<% if (option.optionType.min) { %>
min="<%= option.optionType.min %>"
onkeyup="if(this.value < <%= option.optionType.min %>) this.value = <%= option.optionType.min %>"
<% } %>
<% if (option.optionType.max) { %>
max="<%= option.optionType.max %>"
onkeyup="if(this.value > <%= option.optionType.max %>) this.value = <%= option.optionType.max %>"
<% } %>
<% if(!Allowed.allowed ){ %>
style="border-color: red !important"
disabled
Expand Down
2 changes: 1 addition & 1 deletion views/components/formTypes/rolesMultiSelect.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
>
<% if (actual[s.categoryId][option.optionId]) {
let ioooooo = 0;
let functiona = option.optionType.function(bot, guildid);
let functiona = option.optionType.function(bot, guildid, userid);
functiona.values.forEach(value=>{ %>
<option value="<%= value %>"
<% if(actual[s.categoryId][option.optionId].includes(value)){ %>selected
Expand Down
5 changes: 3 additions & 2 deletions views/components/formTypes/rolesSelect.ejs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<% if(!Allowed.allowed){ %><span style="color: red;"><%- Allowed.errorMessage %></span><br><% } %>
<select <% if(option.optionType.disabled){ %>disabled
<select class="form-control"
<% if(option.optionType.disabled){ %>disabled
<% } %>
id="<%= option.optionId %>" class="col-md-12"
formType="rolesSelect"
Expand All @@ -8,7 +9,7 @@
>
<%
let iooooooo = 0;
let functiona = option.optionType.function(bot, guildid);
let functiona = option.optionType.function(bot, guildid, userid);
functiona.values.forEach(value=>{ %>
<option value="<%= value %>"
<% if(actual[s.categoryId][option.optionId] == value){ %>selected
Expand Down
2 changes: 1 addition & 1 deletion views/components/formTypes/textarea.ejs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<% if(!Allowed.allowed){ %><span style="color: red;"><%- Allowed.errorMessage %></span><br><% } %>
<textarea id="<%= option.optionId %>"<%if(option.optionType.required){%>required<% } %><% if(option.optionType.disabled || !Allowed.allowed ){ %>disabled<% } %><% if(option.optionType.min){ %>minlength="<%= option.optionType.min %>"<% } %><% if(option.optionType.max){ %>maxlength="<%= option.optionType.max %>"<% } %>rows="4" class="col-md-12 form-control" defaultValue="<% if(actual[s.categoryId][option.optionId]){ %><%= actual[s.categoryId][option.optionId] %><% }else{ %><%= option.optionType.data %><% } %>" formType="textarea"><% if(actual[s.categoryId][option.optionId]){ %><%= actual[s.categoryId][option.optionId] %><% }else{ %><%= option.optionType.data %><% } %></textarea>
<textarea id="<%= option.optionId %>"<%if(option.optionType.required){%>required<% } %><% if(option.optionType.disabled || !Allowed.allowed ){ %>disabled <% } %><% if(option.optionType.min){ %>minlength="<%= option.optionType.min %>"<% } %><% if(option.optionType.max){ %>maxlength="<%= option.optionType.max %>"<% } %>rows="4" class="col-md-12 form-control" defaultValue="<% if(actual[s.categoryId][option.optionId]){ %><%= actual[s.categoryId][option.optionId] %><% }else{ %><%= option.optionType.data %><% } %>" formType="textarea"><% if(actual[s.categoryId][option.optionId]){ %><%= actual[s.categoryId][option.optionId] %><% }else{ %><%= option.optionType.data %><% } %></textarea>
8 changes: 4 additions & 4 deletions views/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@
<h5 class="font-weight-bolder"><%- req?.locales?.index?.card?.title %></h5>
<p><%- req?.locales?.index?.card?.description %></p>
<p class="mb-5"><%= req?.locales?.index?.card?.footer %></p>
<% if(themeConfig.index.card.link.enabled) { %>
<% if(themeConfig.index?.card?.link?.enabled) { %>
<a class="text-body text-sm font-weight-bold mb-0 icon-move-right mt-auto"
href="<%- themeConfig.index.card.link.url %>">
<%- req?.locales?.index?.card?.link.text %>
<%- req?.locales?.index?.card?.link?.text %>
<i class="fas fa-arrow-right text-sm ms-1" aria-hidden="true"></i>
</a>
<% } %>
Expand All @@ -117,7 +117,7 @@
<div class="col-lg-7 mb-lg-0 mb-4">
<div class="card z-index-2">
<div class="card-body p-3">
<h5 class="font-weight-bolder"><%- req?.locales?.index?.feedsTitle || "Feeds" %></h5>
<h5 class="font-weight-bolder"><%- req?.locales?.index?.feeds.title || "Feeds" %></h5>
<%- include('partials/feeds.ejs', {require, admin:false}) %>
</div>
</div>
Expand All @@ -126,7 +126,7 @@
<% if(themeConfig.index.graph.enabled) { %>
<div class="card z-index-2">
<div class="card-body p-3">
<h5 class="font-weight-bolder"><%- req?.locales?.index?.graph.title %></h5>
<h5 class="font-weight-bolder"><%- req?.locales?.index?.graph?.title %></h5>
<% if(themeConfig.index.graph.lineGraph) { %>
<div class="bg-gradient-dark border-radius-lg py-3 pe-1 mb-3">
<% } %>
Expand Down
2 changes: 1 addition & 1 deletion views/partials/scripts.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
}
<% } %>
function sweetalert(icons, text, timer) {
var is_mobile = !!navigator.userAgent.match(/iphone|android|blackberry/ig) || false;
var is_mobile = !!navigator.userAgent.match(/iphone|android|blackberry/ig);
let pos = 'top-end';
if (is_mobile) pos = 'bottom-end';
const Toast = Swal.mixin({
Expand Down
24 changes: 15 additions & 9 deletions views/settings.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,12 @@
<li class="nav-item categories" id="<%- s.categoryId %>">
<a class="nav-link <% if (req.params.category == s.categoryId) { %>active<% } %>"
id="<%- s.categoryId %>">
<div
class="icon icon-shape icon-sm shadow border-radius-md bg-white text-center me-2 d-flex align-items-center justify-content-center">
<img width="20px" src="<%= s.categoryImageURL %>">
</div>
<% if(s.categoryImageURL) { %>
<div
class="icon icon-shape icon-sm shadow border-radius-md bg-white text-center me-2 d-flex align-items-center justify-content-center">
<img width="20px" src="<%= s.categoryImageURL %>">
</div>
<% } %>
<span class="nav-link-text ms-1">
<%- s.categoryName %>
</span>
Expand Down Expand Up @@ -212,12 +214,14 @@
</div>
<div class="card card-body blur shadow-blur mx-4 mt-n6 overflow-hidden">
<div class="row gx-4">
<div class="col-auto">
<div class="avatar avatar-xl position-relative">
<img id="img" src="<%= gIcon %>" alt="profile_image"
class="w-100 border-radius-lg shadow-sm">
<% if(gIcon) { %>
<div class="col-auto">
<div class="avatar avatar-xl position-relative">
<img id="img" src="<%= gIcon %>" alt="profile_image"
class="w-100 border-radius-lg shadow-sm">
</div>
</div>
</div>
<% } %>
<div class="col-auto my-auto">
<div class="h-100">
<h5 id="title" class="mb-1">
Expand Down Expand Up @@ -330,7 +334,9 @@
document.addEventListener("DOMContentLoaded", function () {
$(`#title`).html(`<%- s.categoryName %>`)
$(`#desc`).html(`<%- s.categoryDescription %>`)
<% if(s.categoryImageURL) { %>
$("#img").attr("src", `<%- s.categoryImageURL %>`);
<% } %>
});
</script>
<div class="container-fluid settings mb-4" id="<%= s.categoryId %>div">
Expand Down
2 changes: 1 addition & 1 deletion views/src/css/soft-design-system.min.css
Original file line number Diff line number Diff line change
Expand Up @@ -2663,7 +2663,7 @@ progress {
.form-control {
display: block;
width: 100%;
padding: 0.5rem 0.75rem;
padding: 0rem 1rem 0rem 0.75rem;
font-size: 0.875rem;
font-weight: 400;
line-height: 1.4rem;
Expand Down
Loading

0 comments on commit c2f457e

Please sign in to comment.