2015-08-14 20:49:06 +00:00
|
|
|
/* jslint node: true */
|
|
|
|
'use strict';
|
|
|
|
|
2016-02-21 00:57:38 +00:00
|
|
|
let FullScreenEditorModule = require('../core/fse.js').FullScreenEditorModule;
|
|
|
|
//var Message = require('../core/message.js').Message;
|
|
|
|
let persistMessage = require('../core/message_area.js').persistMessage;
|
|
|
|
let user = require('../core/user.js');
|
2015-08-16 19:35:34 +00:00
|
|
|
|
2016-02-21 00:57:38 +00:00
|
|
|
let _ = require('lodash');
|
|
|
|
let async = require('async');
|
2015-08-14 20:49:06 +00:00
|
|
|
|
|
|
|
exports.getModule = AreaPostFSEModule;
|
|
|
|
|
|
|
|
exports.moduleInfo = {
|
|
|
|
name : 'Message Area Post',
|
2015-09-01 05:18:46 +00:00
|
|
|
desc : 'Module for posting a new message to an area',
|
2015-08-14 20:49:06 +00:00
|
|
|
author : 'NuSkooler',
|
|
|
|
};
|
|
|
|
|
|
|
|
function AreaPostFSEModule(options) {
|
|
|
|
FullScreenEditorModule.call(this, options);
|
|
|
|
|
2015-08-16 19:35:34 +00:00
|
|
|
var self = this;
|
|
|
|
|
2015-08-14 20:49:06 +00:00
|
|
|
// we're posting, so always start with 'edit' mode
|
|
|
|
this.editorMode = 'edit';
|
|
|
|
|
2015-08-16 19:35:34 +00:00
|
|
|
this.menuMethods.editModeMenuSave = function(formData, extraArgs) {
|
2015-08-20 04:10:18 +00:00
|
|
|
|
2015-09-21 01:10:09 +00:00
|
|
|
var msg;
|
2015-08-20 04:10:18 +00:00
|
|
|
async.series(
|
|
|
|
[
|
2015-09-21 01:10:09 +00:00
|
|
|
function getMessageObject(callback) {
|
|
|
|
self.getMessage(function gotMsg(err, msgObj) {
|
|
|
|
msg = msgObj;
|
|
|
|
callback(err);
|
|
|
|
});
|
2015-08-20 04:10:18 +00:00
|
|
|
},
|
|
|
|
function saveMessage(callback) {
|
2016-02-21 00:57:38 +00:00
|
|
|
persistMessage(msg, callback);
|
|
|
|
/*
|
2015-08-20 04:10:18 +00:00
|
|
|
msg.persist(function persisted(err) {
|
|
|
|
callback(err);
|
|
|
|
});
|
2016-02-21 00:57:38 +00:00
|
|
|
*/
|
2015-08-20 04:10:18 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
function complete(err) {
|
|
|
|
if(err) {
|
|
|
|
// :TODO:... sooooo now what?
|
|
|
|
} else {
|
2016-01-04 02:40:34 +00:00
|
|
|
console.log(msg); // :TODO: remove me -- probably log that one was saved, however.
|
2015-08-20 04:10:18 +00:00
|
|
|
}
|
|
|
|
|
2015-11-14 19:22:21 +00:00
|
|
|
self.nextMenu();
|
2015-08-20 04:10:18 +00:00
|
|
|
}
|
|
|
|
);
|
2015-08-16 19:35:34 +00:00
|
|
|
};
|
2015-08-14 20:49:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
require('util').inherits(AreaPostFSEModule, FullScreenEditorModule);
|
|
|
|
|
2016-02-03 04:35:59 +00:00
|
|
|
AreaPostFSEModule.prototype.enter = function() {
|
2015-08-18 03:45:11 +00:00
|
|
|
|
2016-02-03 04:35:59 +00:00
|
|
|
if(_.isString(this.client.user.properties.message_area_tag) && !_.isString(this.messageAreaTag)) {
|
|
|
|
this.messageAreaTag = this.client.user.properties.message_area_tag;
|
2015-08-20 23:00:35 +00:00
|
|
|
}
|
|
|
|
|
2016-02-03 04:35:59 +00:00
|
|
|
AreaPostFSEModule.super_.prototype.enter.call(this);
|
2015-08-20 04:10:18 +00:00
|
|
|
};
|