mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-06-11 07:04:32 +02:00
ENiGMA 1/2 WILL USE SPACES FROM THIS POINT ON VS TABS
* Really just to make GitHub formatting happy. Arg.
This commit is contained in:
parent
5ddf04c882
commit
e9787cee3e
135 changed files with 27397 additions and 27397 deletions
|
@ -4,9 +4,9 @@
|
|||
// ENiGMA½
|
||||
const MenuModule = require('./menu_module.js').MenuModule;
|
||||
const {
|
||||
getSortedAvailMessageConferences,
|
||||
getAvailableMessageAreasByConfTag,
|
||||
getSortedAvailMessageAreasByConfTag,
|
||||
getSortedAvailMessageConferences,
|
||||
getAvailableMessageAreasByConfTag,
|
||||
getSortedAvailMessageAreasByConfTag,
|
||||
} = require('./message_area.js');
|
||||
const Errors = require('./enig_error.js').Errors;
|
||||
const Message = require('./message.js');
|
||||
|
@ -15,134 +15,134 @@ const Message = require('./message.js');
|
|||
const _ = require('lodash');
|
||||
|
||||
exports.moduleInfo = {
|
||||
name : 'Message Base Search',
|
||||
desc : 'Module for quickly searching the message base',
|
||||
author : 'NuSkooler',
|
||||
name : 'Message Base Search',
|
||||
desc : 'Module for quickly searching the message base',
|
||||
author : 'NuSkooler',
|
||||
};
|
||||
|
||||
const MciViewIds = {
|
||||
search : {
|
||||
searchTerms : 1,
|
||||
search : 2,
|
||||
conf : 3,
|
||||
area : 4,
|
||||
to : 5,
|
||||
from : 6,
|
||||
advSearch : 7,
|
||||
}
|
||||
search : {
|
||||
searchTerms : 1,
|
||||
search : 2,
|
||||
conf : 3,
|
||||
area : 4,
|
||||
to : 5,
|
||||
from : 6,
|
||||
advSearch : 7,
|
||||
}
|
||||
};
|
||||
|
||||
exports.getModule = class MessageBaseSearch extends MenuModule {
|
||||
constructor(options) {
|
||||
super(options);
|
||||
constructor(options) {
|
||||
super(options);
|
||||
|
||||
this.menuMethods = {
|
||||
search : (formData, extraArgs, cb) => {
|
||||
return this.searchNow(formData, cb);
|
||||
}
|
||||
};
|
||||
}
|
||||
this.menuMethods = {
|
||||
search : (formData, extraArgs, cb) => {
|
||||
return this.searchNow(formData, cb);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
mciReady(mciData, cb) {
|
||||
super.mciReady(mciData, err => {
|
||||
if(err) {
|
||||
return cb(err);
|
||||
}
|
||||
mciReady(mciData, cb) {
|
||||
super.mciReady(mciData, err => {
|
||||
if(err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
this.prepViewController('search', 0, mciData.menu, (err, vc) => {
|
||||
if(err) {
|
||||
return cb(err);
|
||||
}
|
||||
this.prepViewController('search', 0, mciData.menu, (err, vc) => {
|
||||
if(err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
const confView = vc.getView(MciViewIds.search.conf);
|
||||
const areaView = vc.getView(MciViewIds.search.area);
|
||||
const confView = vc.getView(MciViewIds.search.conf);
|
||||
const areaView = vc.getView(MciViewIds.search.area);
|
||||
|
||||
if(!confView || !areaView) {
|
||||
return cb(Errors.DoesNotExist('Missing one or more required views'));
|
||||
}
|
||||
if(!confView || !areaView) {
|
||||
return cb(Errors.DoesNotExist('Missing one or more required views'));
|
||||
}
|
||||
|
||||
const availConfs = [ { text : '-ALL-', data : '' } ].concat(
|
||||
getSortedAvailMessageConferences(this.client).map(conf => Object.assign(conf, { text : conf.conf.name, data : conf.confTag } )) || []
|
||||
);
|
||||
const availConfs = [ { text : '-ALL-', data : '' } ].concat(
|
||||
getSortedAvailMessageConferences(this.client).map(conf => Object.assign(conf, { text : conf.conf.name, data : conf.confTag } )) || []
|
||||
);
|
||||
|
||||
let availAreas = [ { text : '-ALL-', data : '' } ]; // note: will populate if conf changes from ALL
|
||||
let availAreas = [ { text : '-ALL-', data : '' } ]; // note: will populate if conf changes from ALL
|
||||
|
||||
confView.setItems(availConfs);
|
||||
areaView.setItems(availAreas);
|
||||
confView.setItems(availConfs);
|
||||
areaView.setItems(availAreas);
|
||||
|
||||
confView.setFocusItemIndex(0);
|
||||
areaView.setFocusItemIndex(0);
|
||||
confView.setFocusItemIndex(0);
|
||||
areaView.setFocusItemIndex(0);
|
||||
|
||||
confView.on('index update', idx => {
|
||||
availAreas = [ { text : '-ALL-', data : '' } ].concat(
|
||||
getSortedAvailMessageAreasByConfTag(availConfs[idx].confTag, { client : this.client }).map(
|
||||
area => Object.assign(area, { text : area.area.name, data : area.areaTag } )
|
||||
)
|
||||
);
|
||||
areaView.setItems(availAreas);
|
||||
areaView.setFocusItemIndex(0);
|
||||
});
|
||||
confView.on('index update', idx => {
|
||||
availAreas = [ { text : '-ALL-', data : '' } ].concat(
|
||||
getSortedAvailMessageAreasByConfTag(availConfs[idx].confTag, { client : this.client }).map(
|
||||
area => Object.assign(area, { text : area.area.name, data : area.areaTag } )
|
||||
)
|
||||
);
|
||||
areaView.setItems(availAreas);
|
||||
areaView.setFocusItemIndex(0);
|
||||
});
|
||||
|
||||
vc.switchFocus(MciViewIds.search.searchTerms);
|
||||
return cb(null);
|
||||
});
|
||||
});
|
||||
}
|
||||
vc.switchFocus(MciViewIds.search.searchTerms);
|
||||
return cb(null);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
searchNow(formData, cb) {
|
||||
const isAdvanced = formData.submitId === MciViewIds.search.advSearch;
|
||||
const value = formData.value;
|
||||
searchNow(formData, cb) {
|
||||
const isAdvanced = formData.submitId === MciViewIds.search.advSearch;
|
||||
const value = formData.value;
|
||||
|
||||
const filter = {
|
||||
resultType : 'messageList',
|
||||
sort : 'modTimestamp',
|
||||
terms : value.searchTerms,
|
||||
//extraFields : [ 'area_tag', 'message_uuid', 'reply_to_message_id', 'to_user_name', 'from_user_name', 'subject', 'modified_timestamp' ],
|
||||
limit : 2048, // :TODO: best way to handle this? we should probably let the user know if some results are returned
|
||||
};
|
||||
const filter = {
|
||||
resultType : 'messageList',
|
||||
sort : 'modTimestamp',
|
||||
terms : value.searchTerms,
|
||||
//extraFields : [ 'area_tag', 'message_uuid', 'reply_to_message_id', 'to_user_name', 'from_user_name', 'subject', 'modified_timestamp' ],
|
||||
limit : 2048, // :TODO: best way to handle this? we should probably let the user know if some results are returned
|
||||
};
|
||||
|
||||
if(isAdvanced) {
|
||||
filter.toUserName = value.toUserName;
|
||||
filter.fromUserName = value.fromUserName;
|
||||
if(isAdvanced) {
|
||||
filter.toUserName = value.toUserName;
|
||||
filter.fromUserName = value.fromUserName;
|
||||
|
||||
if(value.confTag && !value.areaTag) {
|
||||
// areaTag may be a string or array of strings
|
||||
// getAvailableMessageAreasByConfTag() returns a obj - we only need tags
|
||||
filter.areaTag = _.map(
|
||||
getAvailableMessageAreasByConfTag(value.confTag, { client : this.client } ),
|
||||
(area, areaTag) => areaTag
|
||||
);
|
||||
} else if(value.areaTag) {
|
||||
filter.areaTag = value.areaTag; // specific conf + area
|
||||
}
|
||||
}
|
||||
if(value.confTag && !value.areaTag) {
|
||||
// areaTag may be a string or array of strings
|
||||
// getAvailableMessageAreasByConfTag() returns a obj - we only need tags
|
||||
filter.areaTag = _.map(
|
||||
getAvailableMessageAreasByConfTag(value.confTag, { client : this.client } ),
|
||||
(area, areaTag) => areaTag
|
||||
);
|
||||
} else if(value.areaTag) {
|
||||
filter.areaTag = value.areaTag; // specific conf + area
|
||||
}
|
||||
}
|
||||
|
||||
Message.findMessages(filter, (err, messageList) => {
|
||||
if(err) {
|
||||
return cb(err);
|
||||
}
|
||||
Message.findMessages(filter, (err, messageList) => {
|
||||
if(err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
if(0 === messageList.length) {
|
||||
return this.gotoMenu(
|
||||
this.menuConfig.config.noResultsMenu || 'messageSearchNoResults',
|
||||
{ menuFlags : [ 'popParent' ] },
|
||||
cb
|
||||
);
|
||||
}
|
||||
if(0 === messageList.length) {
|
||||
return this.gotoMenu(
|
||||
this.menuConfig.config.noResultsMenu || 'messageSearchNoResults',
|
||||
{ menuFlags : [ 'popParent' ] },
|
||||
cb
|
||||
);
|
||||
}
|
||||
|
||||
const menuOpts = {
|
||||
extraArgs : {
|
||||
messageList,
|
||||
noUpdateLastReadId : true
|
||||
},
|
||||
menuFlags : [ 'popParent' ],
|
||||
};
|
||||
const menuOpts = {
|
||||
extraArgs : {
|
||||
messageList,
|
||||
noUpdateLastReadId : true
|
||||
},
|
||||
menuFlags : [ 'popParent' ],
|
||||
};
|
||||
|
||||
return this.gotoMenu(
|
||||
this.menuConfig.config.messageListMenu || 'messageAreaMessageList',
|
||||
menuOpts,
|
||||
cb
|
||||
);
|
||||
});
|
||||
}
|
||||
return this.gotoMenu(
|
||||
this.menuConfig.config.messageListMenu || 'messageAreaMessageList',
|
||||
menuOpts,
|
||||
cb
|
||||
);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue