Better 'config new' and fix a couple menu refs

This commit is contained in:
Bryan Ashby 2020-07-06 21:02:18 -06:00
parent f4ccc998f5
commit 60a1f14f6e
No known key found for this signature in database
GPG Key ID: B49EB437951D2542
6 changed files with 29 additions and 28 deletions

View File

@ -60,8 +60,8 @@ exports.getModule = class MessageListModule extends MessageAreaConfTempSwitcher(
this.menuMethods = {
selectMessage : (formData, extraArgs, cb) => {
if(MciViewIds.allViews.msgList === formData.submitId) {
this.initialFocusIndex = formData.value.messageIndex ||
formData.value.message; // older deprecated arg name
// 'messageIndex' or older deprecated 'message' member
this.initialFocusIndex = _.get(formData, 'value.messageIndex', formData.value.message);
const modOpts = {
extraArgs : {
@ -108,8 +108,9 @@ exports.getModule = class MessageListModule extends MessageAreaConfTempSwitcher(
if(MciViewIds.allViews.msgList != formData.submitId) {
return cb(null);
}
const messageIndex = formData.value.messageIndex ||
formData.value.message; // older, deprecated arg name
// newer 'messageIndex' or older deprecated value
const messageIndex = _.get(formData, 'value.messageIndex', formData.value.message);
return this.promptDeleteMessageConfirm(messageIndex, cb);
},
deleteMessageYes : (formData, extraArgs, cb) => {

View File

@ -231,11 +231,8 @@ function buildNewConfig() {
.replace(/[^a-z0-9_-]/ig, '_')
.replace(/_+/g, '_')
.toLowerCase();
const menuFile = `menus/${boardName}-main.hjson`;
const mainTemplate = hjson.rt.parse(fs.readFileSync(paths.join(__dirname, '../../misc/menu_templates/main.in.hjson'), 'utf8'));
const includeFiles = [
const includeFilesIn = [
'message_base.in.hjson',
'private_mail.in.hjson',
'login.in.hjson',
@ -244,8 +241,11 @@ function buildNewConfig() {
'file_base.in.hjson',
];
includeFiles.forEach(incFile => {
let includeFiles = [];
includeFilesIn.forEach(incFile => {
const outName = `${boardName}-${incFile.replace('.in', '')}`;
includeFiles.push(outName);
copyFileSyncSilent(
paths.join(__dirname, '../../misc/menu_templates', incFile),
paths.join(__dirname, '../../config/menus', outName),
@ -253,24 +253,24 @@ function buildNewConfig() {
);
});
mainTemplate.includes = includeFiles.map(incFile => {
return `${boardName}-${incFile.replace('.in', '')}`;
});
// We really only need includes to be replaced
const mainTemplate = fs.readFileSync(paths.join(__dirname, '../../misc/menu_templates/main.in.hjson'), 'utf8')
.replace(/%INCLUDE_FILES%/g, includeFiles.join('\n\t\t')); // cheesy, but works!
if (writeConfig(
const menuFile = `${boardName}-main.hjson`;
fs.writeFileSync(
paths.join(__dirname, '../../config/menus', menuFile),
mainTemplate,
paths.join(__dirname, '../../config/menus', `${boardName}-main.hjson`)))
{
config.general.menuFile = menuFile;
'utf8'
);
config.general.menuFile = paths.join(__dirname, '../../config/menus/', menuFile);
if(writeConfig(config, configPath)) {
console.info('Configuration generated');
} else {
console.error('Failed writing configuration');
}
} else {
console.error('Failed writing configuration');
}
});
}

View File

@ -364,7 +364,7 @@
module: msg_list
art: NEWMSGS
config: {
menuViewPost: messageBaseViewPost
menuViewPost: messageAreaViewPost
}
form: {
0: {
@ -379,7 +379,7 @@
submit: {
*: [
{
value: { message: null }
value: { messageIndex: null }
action: @method:selectMessage
}
]

View File

@ -51,7 +51,7 @@
// You may include as many additional fragments as you like here.
includes: [
XXXXXXXX
%INCLUDE_FILES%
]
// This section creates common fragments to use as @reference

View File

@ -381,7 +381,7 @@
submit: {
*: [
{
value: { message: null }
value: { messageIndex: null }
action: @method:selectMessage
}
]
@ -427,7 +427,7 @@
submit: {
*: [
{
value: { message: null }
value: { messageIndex: null }
action: @method:selectMessage
}
]

View File

@ -145,7 +145,7 @@
module: msg_list
art: PRVMSGLIST
config: {
menuViewPost: messageBaseViewPost
menuViewPost: messageAreaViewPost
messageAreaTag: private_mail
}
form: {
@ -160,7 +160,7 @@
submit: {
*: [
{
value: { message: null }
value: { messageIndex: null }
action: @method:selectMessage
}
]