/* μlogger
*
* Copyright(C) 2019 Bartek Fabiszewski (www.fabiszewski.net)
*
* This is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see .
*/
import { config, lang } from './constants.js';
import uModal from './modal.js';
import uUtils from './utils.js';
export default class UserDialog {
/**
* @param {string} type: edit, add, pass
* @param {uUser=} user Update existing user if supplied
*/
constructor(type, user) {
this.type = type;
this.user = user;
this.dialog = new uModal(this.getHtml());
this.form = this.dialog.modal.querySelector('#userForm');
this.form.onsubmit = () => false;
}
/**
* @return {string}
*/
getHtml() {
let deleteButton = '';
let header = '';
let action;
let fields;
switch (this.type) {
case 'add':
action = 'add';
header = `
`;
fields = `
`;
break;
case 'edit':
action = 'update';
deleteButton = `