languages/config improvements & bug fixes
This commit is contained in:
@@ -15,6 +15,42 @@ export const loadAllOptions = async () => {
|
||||
openticket.options.add(loadRoleOption(option))
|
||||
}
|
||||
})
|
||||
|
||||
//update options on config reload
|
||||
optionConfig.onReload(async () => {
|
||||
//clear previous options
|
||||
openticket.options.forEach((data,id) => {openticket.options.remove(id)})
|
||||
|
||||
//add new options
|
||||
optionConfig.data.forEach((option) => {
|
||||
if (option.type == "ticket"){
|
||||
const loadedOption = loadTicketOption(option)
|
||||
openticket.options.add(loadedOption)
|
||||
openticket.options.suffix.add(loadTicketOptionSuffix(loadedOption))
|
||||
}else if (option.type == "website"){
|
||||
openticket.options.add(loadWebsiteOption(option))
|
||||
}else if (option.type == "role"){
|
||||
openticket.options.add(loadRoleOption(option))
|
||||
}
|
||||
})
|
||||
|
||||
//update options in tickets
|
||||
openticket.tickets.forEach((ticket) => {
|
||||
const optionId = ticket.option.id
|
||||
const option = openticket.options.get(optionId)
|
||||
if (option && option instanceof api.ODTicketOption) ticket.option = option
|
||||
else{
|
||||
openticket.log("Unable to move ticket to unexisting option due to config reload!","warning",[
|
||||
{key:"channelid",value:ticket.id.value},
|
||||
{key:"option",value:optionId.value}
|
||||
])
|
||||
}
|
||||
})
|
||||
|
||||
//update roles on config reload
|
||||
openticket.roles.forEach((data,id) => {openticket.roles.remove(id)})
|
||||
await (await import("./roleLoader.js")).loadAllRoles()
|
||||
})
|
||||
}
|
||||
|
||||
export const loadTicketOption = (option:api.ODJsonConfig_DefaultOptionTicketType): api.ODTicketOption => {
|
||||
|
||||
@@ -8,6 +8,17 @@ export const loadAllPanels = async () => {
|
||||
panelConfig.data.forEach((panel) => {
|
||||
openticket.panels.add(loadPanel(panel))
|
||||
})
|
||||
|
||||
//update panels on config reload
|
||||
panelConfig.onReload(async () => {
|
||||
//clear previous panels
|
||||
openticket.panels.forEach((data,id) => {openticket.panels.remove(id)})
|
||||
|
||||
//add new panels
|
||||
panelConfig.data.forEach((panel) => {
|
||||
openticket.panels.add(loadPanel(panel))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const loadPanel = (panel:api.ODJsonConfig_DefaultPanelType) => {
|
||||
|
||||
@@ -11,6 +11,21 @@ export const loadAllQuestions = async () => {
|
||||
openticket.questions.add(loadParagraphQuestion(question))
|
||||
}
|
||||
})
|
||||
|
||||
//update questions on config reload
|
||||
questionConfig.onReload(() => {
|
||||
//clear previous questions
|
||||
openticket.questions.forEach((data,id) => {openticket.questions.remove(id)})
|
||||
|
||||
//add new questions
|
||||
questionConfig.data.forEach((question) => {
|
||||
if (question.type == "short"){
|
||||
openticket.questions.add(loadShortQuestion(question))
|
||||
}else if (question.type == "paragraph"){
|
||||
openticket.questions.add(loadParagraphQuestion(question))
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const loadShortQuestion = (option:api.ODJsonConfig_DefaultShortQuestionType) => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {openticket, api, utilities} from "../../index"
|
||||
|
||||
export const loadAllRoles = async () => {
|
||||
openticket.options.getAll().forEach((opt) => {
|
||||
openticket.options.forEach((opt) => {
|
||||
if (opt instanceof api.ODRoleOption){
|
||||
openticket.roles.add(loadRole(opt))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user