Updated to marionette 4

This commit is contained in:
Jamie Curnow 2018-08-13 21:11:21 +10:00
parent 065727fba2
commit 0bb65e4c3c
4 changed files with 19 additions and 40 deletions

View File

@ -9,15 +9,17 @@
"babel-minify-webpack-plugin": "^0.3.1",
"babel-preset-env": "^1.7.0",
"backbone": "^1.3.3",
"backbone.marionette": "^3.5.1",
"backbone.marionette": "^4.0.0",
"copy-webpack-plugin": "^4.5.1",
"css-loader": "^0.28.11",
"css-loader": "^1.0.0",
"ejs-loader": "^0.3.1",
"file-loader": "^1.1.11",
"imports-loader": "^0.8.0",
"jquery": "^3.3.1",
"jquery-mask-plugin": "^1.14.15",
"jquery-serializejson": "^2.8.1",
"marionette.approuter": "^1.0.0",
"marionette.templatecache": "^1.0.0",
"messageformat": "^2.0.2",
"messageformat-loader": "^0.7.0",
"mini-css-extract-plugin": "^0.4.0",
@ -25,7 +27,7 @@
"nodemon": "^1.17.5",
"numeral": "^2.0.6",
"sass-loader": "^7.0.3",
"style-loader": "^0.21.0",
"style-loader": "^0.22.1",
"tabler-ui": "git+https://github.com/tabler/tabler.git",
"underscore": "^1.8.3",
"webpack": "^4.12.0",
@ -38,7 +40,7 @@
"bcrypt": "^3.0.0",
"body-parser": "^1.18.3",
"compression": "^1.7.2",
"config": "^1.30.0",
"config": "^2.0.1",
"ejs": "^2.6.1",
"express": "^4.16.3",
"express-fileupload": "^0.4.0",
@ -46,7 +48,7 @@
"html-entities": "^1.2.1",
"json-schema-ref-parser": "^5.0.3",
"jsonwebtoken": "^8.3.0",
"knex": "^0.14.6",
"knex": "^0.15.2",
"liquidjs": "^5.1.1",
"lodash": "^4.17.10",
"moment": "^2.22.2",

View File

@ -73,25 +73,6 @@ const App = Mn.Application.extend({
}
},
Error: function (code, message, debug) {
let temp = Error.call(this, message);
temp.name = this.name = 'AppError';
this.stack = temp.stack;
this.message = temp.message;
this.code = code;
this.debug = debug;
},
showError: function () {
let ErrorView = Mn.View.extend({
tagName: 'section',
id: 'error',
template: _.template(i18n('main', 'unknown-error'))
});
this.getRegion().show(new ErrorView());
},
getParam: function (name) {
name = name.replace(/[\[\]]/g, '\\$&');
let url = window.location.href;

View File

@ -1,10 +1,11 @@
'use strict';
const Mn = require('../lib/marionette');
const AppRouter = require('marionette.approuter');
const Controller = require('./controller');
module.exports = Mn.AppRouter.extend({
appRoutes: {
module.exports = AppRouter.default.extend({
controller: Controller,
appRoutes: {
users: 'showUsers',
logout: 'logout',
'nginx/proxy': 'showNginxProxy',
@ -15,9 +16,5 @@ module.exports = Mn.AppRouter.extend({
'nginx/certificates': 'showNginxCertificates',
'audit-log': 'showAuditLog',
'*default': 'showDashboard'
},
initialize: function () {
this.controller = Controller;
}
});

View File

@ -1,18 +1,17 @@
'use strict';
const _ = require('underscore');
const Mn = require('backbone.marionette');
const i18n = require('../app/i18n');
const Helpers = require('./helpers');
const _ = require('underscore');
const Mn = require('backbone.marionette');
const i18n = require('../app/i18n');
const Helpers = require('./helpers');
const TemplateCache = require('marionette.templatecache');
let render = Mn.Renderer.render;
Mn.Renderer.render = function (template, data, view) {
Mn.setRenderer(function (template, data, view) {
data = _.clone(data);
data.i18n = i18n;
data.formatDbDate = Helpers.formatDbDate;
return render.call(this, template, data, view);
};
return TemplateCache.default.render.call(this, template, data, view);
});
module.exports = Mn;