2015-10-12 05:26:27 +00:00
|
|
|
/* jslint node: true */
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var MenuModule = require('./menu_module.js').MenuModule;
|
|
|
|
var ViewController = require('./view_controller.js').ViewController;
|
|
|
|
|
|
|
|
var async = require('async');
|
|
|
|
var assert = require('assert');
|
|
|
|
var _ = require('lodash');
|
2015-10-13 06:35:37 +00:00
|
|
|
var moment = require('moment');
|
2015-10-12 05:26:27 +00:00
|
|
|
|
|
|
|
exports.getModule = UserConfigModule;
|
|
|
|
|
|
|
|
exports.moduleInfo = {
|
|
|
|
name : 'User Configuration',
|
|
|
|
desc : 'Module for user configuration',
|
|
|
|
author : 'NuSkooler',
|
|
|
|
};
|
|
|
|
|
2015-10-13 06:35:37 +00:00
|
|
|
var MciCodeIds = {
|
|
|
|
Email : 1,
|
|
|
|
Loc : 2,
|
|
|
|
Web : 3,
|
|
|
|
Affils : 4,
|
|
|
|
|
|
|
|
BirthDate : 5,
|
|
|
|
Sex : 6,
|
|
|
|
|
|
|
|
Theme : 10,
|
|
|
|
ScreenSize : 11,
|
|
|
|
};
|
|
|
|
|
2015-10-12 05:26:27 +00:00
|
|
|
function UserConfigModule(options) {
|
|
|
|
MenuModule.call(this, options);
|
|
|
|
|
|
|
|
var self = this;
|
|
|
|
|
2015-10-13 06:35:37 +00:00
|
|
|
self.setViewText = function(viewId, text) {
|
|
|
|
var v = self.viewControllers.menu.getView(viewId);
|
|
|
|
if(v) {
|
|
|
|
v.setText(text);
|
|
|
|
}
|
|
|
|
};
|
2015-10-12 05:26:27 +00:00
|
|
|
|
2015-10-18 02:03:51 +00:00
|
|
|
this.menuMethods = {
|
|
|
|
exitKeyPressed : function(formData, extraArgs) {
|
|
|
|
// :TODO: save/etc.
|
2015-11-04 06:25:35 +00:00
|
|
|
self.prevMenu();
|
2015-10-18 02:03:51 +00:00
|
|
|
}
|
|
|
|
};
|
2015-10-12 05:26:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
require('util').inherits(UserConfigModule, MenuModule);
|
|
|
|
|
|
|
|
UserConfigModule.prototype.mciReady = function(mciData, cb) {
|
|
|
|
var self = this;
|
2015-10-13 06:35:37 +00:00
|
|
|
var vc = self.viewControllers.menu = new ViewController( { client : self.client} );
|
2015-10-12 05:26:27 +00:00
|
|
|
|
|
|
|
async.series(
|
|
|
|
[
|
|
|
|
function callParentMciReady(callback) {
|
|
|
|
UserConfigModule.super_.prototype.mciReady.call(self, mciData, callback);
|
2015-10-13 06:35:37 +00:00
|
|
|
},
|
|
|
|
function loadFromConfig(callback) {
|
|
|
|
vc.loadFromMenuConfig( { callingMenu : self, mciMap : mciData.menu }, callback);
|
|
|
|
},
|
|
|
|
function populateViews(callback) {
|
|
|
|
var user = self.client.user;
|
|
|
|
|
|
|
|
self.setViewText(MciCodeIds.Email, user.properties.email_address);
|
|
|
|
self.setViewText(MciCodeIds.Loc, user.properties.location);
|
|
|
|
self.setViewText(MciCodeIds.Web, user.properties.web_address);
|
|
|
|
self.setViewText(MciCodeIds.Affils, user.properties.affiliation);
|
|
|
|
self.setViewText(MciCodeIds.BirthDate, moment(user.properties.birthdate).format('YYYYMMDD'));
|
|
|
|
self.setViewText(MciCodeIds.Sex, user.properties.sex);
|
|
|
|
|
2015-10-12 05:26:27 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
);
|
|
|
|
};
|