Fix jshint max-complexity issue by using extract method
This commit is contained in:
parent
b6c405bf68
commit
fb3afaa6ab
@ -184,7 +184,31 @@ MapController.prototype.create = function(req, res, prepareConfigFn, next) {
|
|||||||
},
|
},
|
||||||
function finish(err, layergroup) {
|
function finish(err, layergroup) {
|
||||||
if (err) {
|
if (err) {
|
||||||
if (Number.isFinite(err.layerIndex)) {
|
err = Number.isFinite(err.layerIndex) ? populateError(err, mapConfig) : err;
|
||||||
|
|
||||||
|
err.label = 'ANONYMOUS LAYERGROUP';
|
||||||
|
|
||||||
|
return next(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
var analysesResults = context.analysesResults || [];
|
||||||
|
self.addDataviewsAndWidgetsUrls(res.locals.user, layergroup, mapConfig.obj());
|
||||||
|
self.addAnalysesMetadata(res.locals.user, layergroup, analysesResults, true);
|
||||||
|
addContextMetadata(layergroup, mapConfig.obj(), context);
|
||||||
|
res.set('X-Layergroup-Id', layergroup.layergroupid);
|
||||||
|
|
||||||
|
res.status(200);
|
||||||
|
|
||||||
|
if (req.query && req.query.callback) {
|
||||||
|
res.jsonp(layergroup);
|
||||||
|
} else {
|
||||||
|
res.json(layergroup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
function populateError(err, mapConfig) {
|
||||||
var error = new Error(err.message);
|
var error = new Error(err.message);
|
||||||
error.http_status = err.http_status;
|
error.http_status = err.http_status;
|
||||||
|
|
||||||
@ -200,21 +224,8 @@ MapController.prototype.create = function(req, res, prepareConfigFn, next) {
|
|||||||
type: mapConfig.layerType(err.layerIndex)
|
type: mapConfig.layerType(err.layerIndex)
|
||||||
};
|
};
|
||||||
|
|
||||||
err = error;
|
return error;
|
||||||
}
|
}
|
||||||
err.label = 'ANONYMOUS LAYERGROUP';
|
|
||||||
next(err);
|
|
||||||
} else {
|
|
||||||
var analysesResults = context.analysesResults || [];
|
|
||||||
self.addDataviewsAndWidgetsUrls(res.locals.user, layergroup, mapConfig.obj());
|
|
||||||
self.addAnalysesMetadata(res.locals.user, layergroup, analysesResults, true);
|
|
||||||
addContextMetadata(layergroup, mapConfig.obj(), context);
|
|
||||||
res.set('X-Layergroup-Id', layergroup.layergroupid);
|
|
||||||
self.send(req, res, layergroup, 200);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
function addContextMetadata(layergroup, mapConfig, context) {
|
function addContextMetadata(layergroup, mapConfig, context) {
|
||||||
if (layergroup.metadata && Array.isArray(layergroup.metadata.layers) && Array.isArray(mapConfig.layers)) {
|
if (layergroup.metadata && Array.isArray(layergroup.metadata.layers) && Array.isArray(mapConfig.layers)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user