Migration of userpasswordpage and userprofilespage to ES6 modules

This commit is contained in:
Cameron 2020-07-09 13:47:58 +01:00
parent 84a47081be
commit ee54d4efdb
3 changed files with 36 additions and 18 deletions

View File

@ -136,6 +136,8 @@
"src/controllers/dashboard/users/userlibraryaccess.js",
"src/controllers/dashboard/users/usernew.js",
"src/controllers/dashboard/users/userparentalcontrol.js",
"src/controllers/dashboard/users/userpasswordpage.js",
"src/controllers/dashboard/users/userprofilespage.js",
"src/plugins/bookPlayer/plugin.js",
"src/plugins/bookPlayer/tableOfContents.js",
"src/plugins/photoPlayer/plugin.js",

View File

@ -1,5 +1,10 @@
define(['loading', 'libraryMenu', 'globalize', 'emby-button'], function (loading, libraryMenu, globalize) {
'use strict';
import loading from 'loading';
import libraryMenu from 'libraryMenu';
import globalize from 'globalize';
import 'emby-button';
/* eslint-disable indent */
function loadUser(page, params) {
var userid = params.userId;
@ -48,7 +53,7 @@ define(['loading', 'libraryMenu', 'globalize', 'emby-button'], function (loading
page.querySelector('.chkEnableLocalEasyPassword').checked = user.Configuration.EnableLocalPassword;
require(['autoFocuser'], function (autoFocuser) {
import('autoFocuser').then(({default: autoFocuser}) => {
autoFocuser.autoFocus(page);
});
});
@ -58,7 +63,7 @@ define(['loading', 'libraryMenu', 'globalize', 'emby-button'], function (loading
page.querySelector('#txtNewPasswordConfirm').value = '';
}
return function (view, params) {
export default function (view, params) {
function saveEasyPassword() {
var userId = params.userId;
var easyPassword = view.querySelector('#txtEasyPassword').value;
@ -78,7 +83,7 @@ define(['loading', 'libraryMenu', 'globalize', 'emby-button'], function (loading
ApiClient.updateUserConfiguration(user.Id, user.Configuration).then(function () {
loading.hide();
require(['toast'], function (toast) {
import('toast').then(({default: toast}) => {
toast(globalize.translate('MessageSettingsSaved'));
});
@ -101,7 +106,7 @@ define(['loading', 'libraryMenu', 'globalize', 'emby-button'], function (loading
ApiClient.updateUserPassword(userId, currentPassword, newPassword).then(function () {
loading.hide();
require(['toast'], function (toast) {
import('toast').then(({default: toast}) => {
toast(globalize.translate('PasswordSaved'));
});
@ -119,7 +124,7 @@ define(['loading', 'libraryMenu', 'globalize', 'emby-button'], function (loading
var form = this;
if (form.querySelector('#txtNewPassword').value != form.querySelector('#txtNewPasswordConfirm').value) {
require(['toast'], function (toast) {
import('toast').then(({default: toast}) => {
toast(globalize.translate('PasswordMatchError'));
});
} else {
@ -140,8 +145,7 @@ define(['loading', 'libraryMenu', 'globalize', 'emby-button'], function (loading
function resetPassword() {
var msg = globalize.translate('PasswordResetConfirmation');
require(['confirm'], function (confirm) {
import('confirm').then(({default: confirm}) => {
confirm(msg, globalize.translate('PasswordResetHeader')).then(function () {
var userId = params.userId;
loading.show();
@ -160,7 +164,7 @@ define(['loading', 'libraryMenu', 'globalize', 'emby-button'], function (loading
function resetEasyPassword() {
var msg = globalize.translate('PinCodeResetConfirmation');
require(['confirm'], function (confirm) {
import('confirm').then(({default: confirm}) => {
confirm(msg, globalize.translate('HeaderPinCodeReset')).then(function () {
var userId = params.userId;
loading.show();
@ -184,4 +188,5 @@ define(['loading', 'libraryMenu', 'globalize', 'emby-button'], function (loading
loadUser(view, params);
});
};
});
/* eslint-enable indent */

View File

@ -1,10 +1,20 @@
define(['loading', 'dom', 'globalize', 'date-fns', 'dfnshelper', 'paper-icon-button-light', 'cardStyle', 'emby-button', 'indicators', 'flexStyles'], function (loading, dom, globalize, datefns, dfnshelper) {
'use strict';
import loading from 'loading';
import dom from 'dom';
import globalize from 'globalize';
import * as datefns from 'date-fns';
import dfnshelper from 'dfnshelper';
import 'paper-icon-button-light';
import 'cardStyle';
import 'emby-button';
import 'indicators';
import 'flexStyles';
/* eslint-disable indent */
function deleteUser(page, id) {
var msg = globalize.translate('DeleteUserConfirmation');
require(['confirm'], function (confirm) {
import('confirm').then(({default: confirm}) => {
confirm({
title: globalize.translate('DeleteUser'),
text: msg,
@ -45,7 +55,7 @@ define(['loading', 'dom', 'globalize', 'date-fns', 'dfnshelper', 'paper-icon-but
icon: 'delete'
});
require(['actionsheet'], function (actionsheet) {
import('actionsheet').then(({default: actionsheet}) => {
actionsheet.show({
items: menuItems,
positionTo: card,
@ -153,7 +163,7 @@ define(['loading', 'dom', 'globalize', 'date-fns', 'dfnshelper', 'paper-icon-but
icon: 'delete'
});
require(['actionsheet'], function (actionsheet) {
import('actionsheet').then(({default: actionsheet}) => {
var card = dom.parentWithClass(elem, 'card');
var page = dom.parentWithClass(card, 'page');
var id = card.getAttribute('data-id');
@ -236,7 +246,7 @@ define(['loading', 'dom', 'globalize', 'date-fns', 'dfnshelper', 'paper-icon-but
}
function showInvitePopup(page) {
require(['components/guestinviter/guestinviter'], function (guestinviter) {
import('components/guestinviter/guestinviter').then(({default: guestinviter}) => {
guestinviter.show().then(function () {
loadData(page);
});
@ -266,4 +276,5 @@ define(['loading', 'dom', 'globalize', 'date-fns', 'dfnshelper', 'paper-icon-but
pageIdOn('pagebeforeshow', 'userProfilesPage', function () {
loadData(this);
});
});
/* eslint-enable indent */