mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Cleanup views system
This commit is contained in:
parent
c0f494c758
commit
3e494f6519
12 changed files with 26 additions and 40 deletions
|
|
@ -2,7 +2,7 @@ import ko from 'ko';
|
|||
|
||||
import { addObservablesTo, addComputablesTo, addSubscribablesTo } from 'External/ko';
|
||||
import { keyScope, SettingsGet, leftPanelDisabled } from 'Common/Globals';
|
||||
import { ViewType, showScreenPopup } from 'Knoin/Knoin';
|
||||
import { ViewTypePopup, showScreenPopup } from 'Knoin/Knoin';
|
||||
|
||||
import { SaveSettingsStep } from 'Common/Enums';
|
||||
|
||||
|
|
@ -10,8 +10,7 @@ class AbstractView {
|
|||
constructor(templateID, type)
|
||||
{
|
||||
// Object.defineProperty(this, 'viewModelTemplateID', { value: templateID });
|
||||
// this.viewModelTemplateID = this.constructor.name;
|
||||
this.viewModelTemplateID = templateID;
|
||||
this.viewModelTemplateID = templateID || this.constructor.name.replace('UserView', '');
|
||||
this.viewType = type;
|
||||
this.viewModelDom = null;
|
||||
|
||||
|
|
@ -57,7 +56,7 @@ export class AbstractViewPopup extends AbstractView
|
|||
{
|
||||
constructor(name)
|
||||
{
|
||||
super('Popups' + name, ViewType.Popup);
|
||||
super('Popups' + name, ViewTypePopup);
|
||||
this.keyScope.scope = name;
|
||||
this.modalVisible = ko.observable(false).extend({ rateLimit: 0 });
|
||||
shortcuts.add('escape,close', '', name, () => {
|
||||
|
|
@ -92,19 +91,11 @@ AbstractViewPopup.hidden = function() {
|
|||
return !this.__vm || !this.__vm.modalVisible();
|
||||
}
|
||||
|
||||
export class AbstractViewCenter extends AbstractView
|
||||
{
|
||||
constructor(templateID)
|
||||
{
|
||||
super(templateID, ViewType.Content);
|
||||
}
|
||||
}
|
||||
|
||||
export class AbstractViewLeft extends AbstractView
|
||||
{
|
||||
constructor(templateID)
|
||||
{
|
||||
super(templateID, ViewType.Left);
|
||||
super(templateID, 'Left');
|
||||
this.leftPanelDisabled = leftPanelDisabled;
|
||||
}
|
||||
}
|
||||
|
|
@ -113,7 +104,7 @@ export class AbstractViewRight extends AbstractView
|
|||
{
|
||||
constructor(templateID)
|
||||
{
|
||||
super(templateID, ViewType.Right);
|
||||
super(templateID, 'Right');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -158,9 +149,9 @@ export class AbstractViewSettings
|
|||
}
|
||||
}
|
||||
|
||||
export class AbstractViewLogin extends AbstractViewCenter {
|
||||
export class AbstractViewLogin extends AbstractView {
|
||||
constructor(templateID) {
|
||||
super(templateID);
|
||||
super(templateID, 'Content');
|
||||
this.hideSubmitButton = SettingsGet('hideSubmitButton');
|
||||
this.formError = ko.observable(false).extend({ falseTimeout: 500 });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ const
|
|||
vm = new ViewModelClass(vmScreen),
|
||||
id = vm.viewModelTemplateID,
|
||||
position = vm.viewType || '',
|
||||
dialog = ViewType.Popup === position,
|
||||
dialog = ViewTypePopup === position,
|
||||
vmPlace = position ? doc.getElementById('rl-' + position.toLowerCase()) : null;
|
||||
|
||||
ViewModelClass.__builded = true;
|
||||
|
|
@ -49,7 +49,7 @@ const
|
|||
vm.viewModelDom = vmDom;
|
||||
ViewModelClass.__dom = vmDom;
|
||||
|
||||
if (ViewType.Popup === position) {
|
||||
if (ViewTypePopup === position) {
|
||||
vm.close = () => hideScreenPopup(ViewModelClass);
|
||||
|
||||
// Firefox / Safari HTMLDialogElement not defined
|
||||
|
|
@ -133,7 +133,7 @@ const
|
|||
if (
|
||||
ViewModelClass.__vm &&
|
||||
ViewModelClass.__dom &&
|
||||
ViewType.Popup !== ViewModelClass.__vm.viewType
|
||||
ViewTypePopup !== ViewModelClass.__vm.viewType
|
||||
) {
|
||||
fn(ViewModelClass.__vm, ViewModelClass.__dom);
|
||||
}
|
||||
|
|
@ -230,12 +230,7 @@ const
|
|||
|
||||
|
||||
export const
|
||||
ViewType = {
|
||||
Popup: 'Popups',
|
||||
Left: 'Left',
|
||||
Right: 'Right',
|
||||
Content: 'Content'
|
||||
},
|
||||
ViewTypePopup = 'Popups',
|
||||
|
||||
/**
|
||||
* @param {Function} ViewModelClassToShow
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import { AbstractScreen } from 'Knoin/AbstractScreen';
|
||||
|
||||
import { LoginAdminView } from 'View/Admin/Login';
|
||||
import { AdminLoginView } from 'View/Admin/Login';
|
||||
|
||||
export class LoginAdminScreen extends AbstractScreen {
|
||||
constructor() {
|
||||
super('login', [LoginAdminView]);
|
||||
super('login', [AdminLoginView]);
|
||||
}
|
||||
|
||||
onShow() {
|
||||
|
|
|
|||
|
|
@ -18,12 +18,12 @@ import { UserSettingsFolders } from 'Settings/User/Folders';
|
|||
import { UserSettingsThemes } from 'Settings/User/Themes';
|
||||
|
||||
import { SystemDropDownUserView } from 'View/User/SystemDropDown';
|
||||
import { MenuSettingsUserView } from 'View/User/Settings/Menu';
|
||||
import { PaneSettingsUserView } from 'View/User/Settings/Pane';
|
||||
import { SettingsMenuUserView } from 'View/User/Settings/Menu';
|
||||
import { SettingsPaneUserView } from 'View/User/Settings/Pane';
|
||||
|
||||
export class SettingsUserScreen extends AbstractSettingsScreen {
|
||||
constructor() {
|
||||
super([SystemDropDownUserView, MenuSettingsUserView, PaneSettingsUserView]);
|
||||
super([SystemDropDownUserView, SettingsMenuUserView, SettingsPaneUserView]);
|
||||
|
||||
const views = [
|
||||
UserSettingsGeneral
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import Remote from 'Remote/Admin/Fetch';
|
|||
import { decorateKoCommands } from 'Knoin/Knoin';
|
||||
import { AbstractViewLogin } from 'Knoin/AbstractViews';
|
||||
|
||||
export class LoginAdminView extends AbstractViewLogin {
|
||||
export class AdminLoginView extends AbstractViewLogin {
|
||||
constructor() {
|
||||
super('AdminLogin');
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ const SignMeOff = 0,
|
|||
|
||||
export class LoginUserView extends AbstractViewLogin {
|
||||
constructor() {
|
||||
super('Login');
|
||||
super();
|
||||
|
||||
this.addObservables({
|
||||
loadingDesc: SettingsGet('LoadingDescription'),
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import { setExpandedFolder } from 'Model/FolderCollection';
|
|||
|
||||
export class MailFolderList extends AbstractViewLeft {
|
||||
constructor() {
|
||||
super('MailFolderList');
|
||||
super();
|
||||
|
||||
this.oContentScrollable = null;
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ const
|
|||
|
||||
export class MailMessageList extends AbstractViewRight {
|
||||
constructor() {
|
||||
super('MailMessageList');
|
||||
super();
|
||||
|
||||
this.bPrefetch = false;
|
||||
this.emptySubjectValue = '';
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ const
|
|||
|
||||
export class MailMessageView extends AbstractViewRight {
|
||||
constructor() {
|
||||
super('MailMessageView');
|
||||
super();
|
||||
|
||||
const
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@ import { getFolderInboxName } from 'Common/Cache';
|
|||
|
||||
import { AbstractViewLeft } from 'Knoin/AbstractViews';
|
||||
|
||||
export class MenuSettingsUserView extends AbstractViewLeft {
|
||||
export class SettingsMenuUserView extends AbstractViewLeft {
|
||||
/**
|
||||
* @param {Object} screen
|
||||
*/
|
||||
constructor(screen) {
|
||||
super('SettingsMenu');
|
||||
super();
|
||||
|
||||
this.menu = screen.menu;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@ import { ThemeStore } from 'Stores/Theme';
|
|||
|
||||
import { AbstractViewRight } from 'Knoin/AbstractViews';
|
||||
|
||||
export class PaneSettingsUserView extends AbstractViewRight {
|
||||
export class SettingsPaneUserView extends AbstractViewRight {
|
||||
constructor() {
|
||||
super('SettingsPane');
|
||||
super();
|
||||
|
||||
this.isMobile = ThemeStore.isMobile;
|
||||
this.leftPanelDisabled = leftPanelDisabled;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import { getNotification } from 'Common/Translator';
|
|||
|
||||
export class SystemDropDownUserView extends AbstractViewRight {
|
||||
constructor() {
|
||||
super('SystemDropDown');
|
||||
super();
|
||||
|
||||
this.allowAccounts = SettingsCapa('AdditionalAccounts');
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue