aboutsummaryrefslogtreecommitdiff
path: root/client/js/controllers/pool_create_controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'client/js/controllers/pool_create_controller.js')
-rw-r--r--client/js/controllers/pool_create_controller.js75
1 files changed, 41 insertions, 34 deletions
diff --git a/client/js/controllers/pool_create_controller.js b/client/js/controllers/pool_create_controller.js
index 2b8e7e6..7140aac 100644
--- a/client/js/controllers/pool_create_controller.js
+++ b/client/js/controllers/pool_create_controller.js
@@ -1,58 +1,65 @@
-'use strict';
+"use strict";
-const router = require('../router.js');
-const api = require('../api.js');
-const misc = require('../util/misc.js');
-const uri = require('../util/uri.js');
-const PoolCategoryList = require('../models/pool_category_list.js');
-const PoolCreateView = require('../views/pool_create_view.js');
-const EmptyView = require('../views/empty_view.js');
+const router = require("../router.js");
+const api = require("../api.js");
+const misc = require("../util/misc.js");
+const uri = require("../util/uri.js");
+const PoolCategoryList = require("../models/pool_category_list.js");
+const PoolCreateView = require("../views/pool_create_view.js");
+const EmptyView = require("../views/empty_view.js");
class PoolCreateController {
constructor(ctx) {
- if (!api.hasPrivilege('pools:create')) {
+ if (!api.hasPrivilege("pools:create")) {
this._view = new EmptyView();
- this._view.showError('You don\'t have privileges to create pools.');
+ this._view.showError("You don't have privileges to create pools.");
return;
}
- PoolCategoryList.get().then(poolCategoriesResponse => {
- const categories = {};
- for (let category of poolCategoriesResponse.results) {
- categories[category.name] = category.name;
- }
+ PoolCategoryList.get().then(
+ (poolCategoriesResponse) => {
+ const categories = {};
+ for (let category of poolCategoriesResponse.results) {
+ categories[category.name] = category.name;
+ }
- this._view = new PoolCreateView({
- canCreate: api.hasPrivilege('pools:create'),
- categories: categories,
- escapeColons: uri.escapeColons,
- });
+ this._view = new PoolCreateView({
+ canCreate: api.hasPrivilege("pools:create"),
+ categories: categories,
+ escapeColons: uri.escapeColons,
+ });
- this._view.addEventListener('submit', e => this._evtCreate(e));
- }, error => {
- this._view = new EmptyView();
- this._view.showError(error.message);
- });
+ this._view.addEventListener("submit", (e) =>
+ this._evtCreate(e)
+ );
+ },
+ (error) => {
+ this._view = new EmptyView();
+ this._view.showError(error.message);
+ }
+ );
}
_evtCreate(e) {
this._view.clearMessages();
this._view.disableForm();
- api.post(uri.formatApiLink('pool'), e.detail)
- .then(() => {
+ api.post(uri.formatApiLink("pool"), e.detail).then(
+ () => {
this._view.clearMessages();
misc.disableExitConfirmation();
- const ctx = router.show(uri.formatClientLink('pools'));
- ctx.controller.showSuccess('Pool created.');
- }, error => {
+ const ctx = router.show(uri.formatClientLink("pools"));
+ ctx.controller.showSuccess("Pool created.");
+ },
+ (error) => {
this._view.showError(error.message);
this._view.enableForm();
- });
+ }
+ );
}
}
-module.exports = router => {
- router.enter(['pool', 'create'], (ctx, next) => {
- ctx.controller = new PoolCreateController(ctx, 'create');
+module.exports = (router) => {
+ router.enter(["pool", "create"], (ctx, next) => {
+ ctx.controller = new PoolCreateController(ctx, "create");
});
};

© 2015 - 2026 Jakob L. Kreuze