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-minify-webpack-plugin": "^0.3.1",
"babel-preset-env": "^1.7.0", "babel-preset-env": "^1.7.0",
"backbone": "^1.3.3", "backbone": "^1.3.3",
"backbone.marionette": "^3.5.1", "backbone.marionette": "^4.0.0",
"copy-webpack-plugin": "^4.5.1", "copy-webpack-plugin": "^4.5.1",
"css-loader": "^0.28.11", "css-loader": "^1.0.0",
"ejs-loader": "^0.3.1", "ejs-loader": "^0.3.1",
"file-loader": "^1.1.11", "file-loader": "^1.1.11",
"imports-loader": "^0.8.0", "imports-loader": "^0.8.0",
"jquery": "^3.3.1", "jquery": "^3.3.1",
"jquery-mask-plugin": "^1.14.15", "jquery-mask-plugin": "^1.14.15",
"jquery-serializejson": "^2.8.1", "jquery-serializejson": "^2.8.1",
"marionette.approuter": "^1.0.0",
"marionette.templatecache": "^1.0.0",
"messageformat": "^2.0.2", "messageformat": "^2.0.2",
"messageformat-loader": "^0.7.0", "messageformat-loader": "^0.7.0",
"mini-css-extract-plugin": "^0.4.0", "mini-css-extract-plugin": "^0.4.0",
@ -25,7 +27,7 @@
"nodemon": "^1.17.5", "nodemon": "^1.17.5",
"numeral": "^2.0.6", "numeral": "^2.0.6",
"sass-loader": "^7.0.3", "sass-loader": "^7.0.3",
"style-loader": "^0.21.0", "style-loader": "^0.22.1",
"tabler-ui": "git+https://github.com/tabler/tabler.git", "tabler-ui": "git+https://github.com/tabler/tabler.git",
"underscore": "^1.8.3", "underscore": "^1.8.3",
"webpack": "^4.12.0", "webpack": "^4.12.0",
@ -38,7 +40,7 @@
"bcrypt": "^3.0.0", "bcrypt": "^3.0.0",
"body-parser": "^1.18.3", "body-parser": "^1.18.3",
"compression": "^1.7.2", "compression": "^1.7.2",
"config": "^1.30.0", "config": "^2.0.1",
"ejs": "^2.6.1", "ejs": "^2.6.1",
"express": "^4.16.3", "express": "^4.16.3",
"express-fileupload": "^0.4.0", "express-fileupload": "^0.4.0",
@ -46,7 +48,7 @@
"html-entities": "^1.2.1", "html-entities": "^1.2.1",
"json-schema-ref-parser": "^5.0.3", "json-schema-ref-parser": "^5.0.3",
"jsonwebtoken": "^8.3.0", "jsonwebtoken": "^8.3.0",
"knex": "^0.14.6", "knex": "^0.15.2",
"liquidjs": "^5.1.1", "liquidjs": "^5.1.1",
"lodash": "^4.17.10", "lodash": "^4.17.10",
"moment": "^2.22.2", "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) { getParam: function (name) {
name = name.replace(/[\[\]]/g, '\\$&'); name = name.replace(/[\[\]]/g, '\\$&');
let url = window.location.href; let url = window.location.href;

View File

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

View File

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