mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-07-23 11:16:10 +02:00
* Minor code cleanup + fixes, area change/list semi functional
This commit is contained in:
parent
aaac4e884b
commit
c9a24b7ec8
6 changed files with 56 additions and 47 deletions
|
@ -74,6 +74,7 @@ MCIViewFactory.prototype.getPredefinedViewLabel = function(code) {
|
|||
IP : this.client.address().address,
|
||||
}[code];
|
||||
} catch(e) {
|
||||
this.client.log.warn( { code : code, exception : e.message }, 'Exception caught attempting to construct predefined label');
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ var _ = require('lodash');
|
|||
var assert = require('assert');
|
||||
|
||||
exports.getAvailableMessageAreas = getAvailableMessageAreas;
|
||||
exports.changeCurrentArea = changeCurrentArea;
|
||||
|
||||
function getAvailableMessageAreas(cb) {
|
||||
var areas = []; // { areaId, name, groupIds[] }
|
||||
|
@ -58,4 +59,23 @@ function getAvailableMessageAreas(cb) {
|
|||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
function changeCurrentArea(client, areaId, cb) {
|
||||
async.series(
|
||||
[
|
||||
function validateAccess(callback) {
|
||||
// :TODO: validate user has access to areaId -- must belong to group(s) specified
|
||||
callback(null);
|
||||
},
|
||||
function changeArea(callback) {
|
||||
client.user.persistProperty('message_area_id', areaId, function persisted(err) {
|
||||
callback(err);
|
||||
});
|
||||
}
|
||||
],
|
||||
function complete(err) {
|
||||
cb(err);
|
||||
}
|
||||
);
|
||||
}
|
|
@ -267,6 +267,10 @@ function ViewController(options) {
|
|||
// * actionValue is a string: This represents a view with
|
||||
// "argName" set that must be present in formValue.
|
||||
//
|
||||
if(_.isUndefined(actionValue)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(_.isNumber(actionValue) || _.isString(actionValue)) {
|
||||
if(_.isUndefined(formValue[actionValue])) {
|
||||
return false;
|
||||
|
@ -440,7 +444,7 @@ ViewController.prototype.loadFromPromptConfig = function(options, cb) {
|
|||
function applyThemeCustomization(callback) {
|
||||
if(_.isObject(promptConfig)) {
|
||||
menuUtil.applyThemeCustomization({
|
||||
name : promptName,//self.client.currentMenuModule.menuConfig.prompt,
|
||||
name : promptName,
|
||||
type : "prompts",
|
||||
client : self.client,
|
||||
configMci : promptConfig.mci,
|
||||
|
@ -526,44 +530,6 @@ ViewController.prototype.loadFromMenuConfig = function(options, cb) {
|
|||
|
||||
// :TODO: honor options.withoutForm
|
||||
|
||||
// method for comparing submitted form data to configuration entries
|
||||
/*
|
||||
var actionBlockValueComparator = function(formValue, actionValue) {
|
||||
//
|
||||
// For a match to occur, one of the following must be true:
|
||||
//
|
||||
// * actionValue is a Object:
|
||||
// a) All key/values must exactly match
|
||||
// b) value is null; The key (view ID or "argName") must be present
|
||||
// in formValue. This is a wildcard/any match.
|
||||
// * actionValue is a Number: This represents a view ID that
|
||||
// must be present in formValue.
|
||||
// * actionValue is a string: This represents a view with
|
||||
// "argName" set that must be present in formValue.
|
||||
//
|
||||
if(_.isNumber(actionValue) || _.isString(actionValue)) {
|
||||
if(_.isUndefined(formValue[actionValue])) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
var actionValueKeys = Object.keys(actionValue);
|
||||
for(var i = 0; i < actionValueKeys.length; ++i) {
|
||||
var viewId = actionValueKeys[i];
|
||||
if(!_.has(formValue, viewId)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(null !== actionValue[viewId] && actionValue[viewId] !== formValue[viewId]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.client.log.trace( { formValue : formValue, actionValue : actionValue }, 'Action match');
|
||||
return true;
|
||||
};
|
||||
*/
|
||||
|
||||
async.waterfall(
|
||||
[
|
||||
function findMatchingFormConfig(callback) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue