refactor: rename note controller to note view controller

This commit is contained in:
Mo
2021-12-27 22:56:21 -06:00
parent 15aea42d4f
commit 0eeb9b7da1
13 changed files with 55 additions and 55 deletions

View File

@@ -30,8 +30,8 @@ import { AccountSwitcher } from './views/account_switcher/account_switcher';
import { import {
ApplicationGroupView, ApplicationGroupView,
ApplicationView, ApplicationView,
EditorGroupView, NoteGroupViewDirective,
EditorView, NoteViewDirective,
TagsView, TagsView,
FooterView, FooterView,
ChallengeModal, ChallengeModal,
@@ -141,8 +141,8 @@ const startApplication: StartApplication = async function startApplication(
.module('app') .module('app')
.directive('applicationGroupView', () => new ApplicationGroupView()) .directive('applicationGroupView', () => new ApplicationGroupView())
.directive('applicationView', () => new ApplicationView()) .directive('applicationView', () => new ApplicationView())
.directive('editorGroupView', () => new EditorGroupView()) .directive('noteGroupView', () => new NoteGroupViewDirective())
.directive('editorView', () => new EditorView()) .directive('noteView', () => new NoteViewDirective())
.directive('tagsView', () => new TagsView()) .directive('tagsView', () => new TagsView())
.directive('footerView', () => new FooterView()); .directive('footerView', () => new FooterView());

View File

@@ -2,7 +2,7 @@ import { Bridge } from '@/services/bridge';
import { storage, StorageKey } from '@/services/localStorage'; import { storage, StorageKey } from '@/services/localStorage';
import { WebApplication } from '@/ui_models/application'; import { WebApplication } from '@/ui_models/application';
import { AccountMenuState } from '@/ui_models/app_state/account_menu_state'; import { AccountMenuState } from '@/ui_models/app_state/account_menu_state';
import { NoteController } from '@/ui_models/note_controller'; import { NoteViewController } from '@/views/note_view/note_view_controller';
import { isDesktopApplication } from '@/utils'; import { isDesktopApplication } from '@/utils';
import { import {
ApplicationEvent, ApplicationEvent,
@@ -236,7 +236,7 @@ export class AppState {
: this.selectedTag.uuid : this.selectedTag.uuid
: undefined; : undefined;
await this.application.noteControllerGroup.createNoteController( await this.application.noteControllerGroup.createNoteView(
undefined, undefined,
title, title,
activeTagUuid activeTagUuid
@@ -251,16 +251,16 @@ export class AppState {
return this.application.noteControllerGroup.noteControllers; return this.application.noteControllerGroup.noteControllers;
} }
closeNoteController(controller: NoteController) { closeNoteController(controller: NoteViewController) {
this.application.noteControllerGroup.closeController(controller); this.application.noteControllerGroup.closeNoteView(controller);
} }
closeActiveNoteController() { closeActiveNoteController() {
this.application.noteControllerGroup.closeActiveController(); this.application.noteControllerGroup.closeActiveNoteView();
} }
closeAllNoteControllers() { closeAllNoteControllers() {
this.application.noteControllerGroup.closeAllControllers(); this.application.noteControllerGroup.closeAllNoteViews();
} }
noteControllerForNote(note: SNNote) { noteControllerForNote(note: SNNote) {

View File

@@ -17,7 +17,7 @@ import {
runInAction, runInAction,
} from 'mobx'; } from 'mobx';
import { WebApplication } from '../application'; import { WebApplication } from '../application';
import { NoteController } from '../note_controller'; import { NoteViewController } from '@/views/note_view/note_view_controller';
import { AppState } from './app_state'; import { AppState } from './app_state';
export class NotesState { export class NotesState {
@@ -68,7 +68,7 @@ export class NotesState {
); );
} }
get activeNoteController(): NoteController | undefined { get activeNoteController(): NoteViewController | undefined {
return this.application.noteControllerGroup.noteControllers[0]; return this.application.noteControllerGroup.noteControllers[0];
} }
@@ -168,10 +168,10 @@ export class NotesState {
} }
if (this.activeNoteController) { if (this.activeNoteController) {
this.application.noteControllerGroup.closeActiveController(); this.application.noteControllerGroup.closeActiveNoteView();
} }
await this.application.noteControllerGroup.createNoteController(noteUuid); await this.application.noteControllerGroup.createNoteView(noteUuid);
this.appState.noteTags.reloadTags(); this.appState.noteTags.reloadTags();
await this.onActiveEditorChanged(); await this.onActiveEditorChanged();

View File

@@ -10,7 +10,7 @@ import { StatusManager } from '@/services/statusManager';
import { ThemeManager } from '@/services/themeManager'; import { ThemeManager } from '@/services/themeManager';
import { PasswordWizardScope, PasswordWizardType } from '@/types'; import { PasswordWizardScope, PasswordWizardType } from '@/types';
import { AppState } from '@/ui_models/app_state'; import { AppState } from '@/ui_models/app_state';
import { NoteControllerGroup } from '@/ui_models/note_controller_group'; import { NoteGroupController } from '@/views/note_group_view/note_group_controller';
import { AppVersion } from '@/version'; import { AppVersion } from '@/version';
import { WebDeviceInterface } from '@/web_device_interface'; import { WebDeviceInterface } from '@/web_device_interface';
import { import {
@@ -36,7 +36,7 @@ export class WebApplication extends SNApplication {
private scope?: angular.IScope; private scope?: angular.IScope;
private webServices!: WebServices; private webServices!: WebServices;
private currentAuthenticationElement?: angular.IRootElementService; private currentAuthenticationElement?: angular.IRootElementService;
public noteControllerGroup: NoteControllerGroup; public noteControllerGroup: NoteGroupController;
/* @ngInject */ /* @ngInject */
constructor( constructor(
@@ -66,7 +66,7 @@ export class WebApplication extends SNApplication {
this.$compile = $compile; this.$compile = $compile;
this.scope = scope; this.scope = scope;
deviceInterface.setApplication(this); deviceInterface.setApplication(this);
this.noteControllerGroup = new NoteControllerGroup(this); this.noteControllerGroup = new NoteGroupController(this);
this.presentPermissionsDialog = this.presentPermissionsDialog.bind(this); this.presentPermissionsDialog = this.presentPermissionsDialog.bind(this);
} }

View File

@@ -10,7 +10,7 @@
application='self.application' application='self.application'
app-state='self.appState' app-state='self.appState'
) )
editor-group-view.flex-grow(application='self.application') note-group-view.flex-grow(application='self.application')
footer-view( footer-view(
ng-if='!self.state.needsUnlock && self.state.launched' ng-if='!self.state.needsUnlock && self.state.launched'

View File

@@ -1,8 +1,8 @@
export { PureViewCtrl } from './abstract/pure_view_ctrl'; export { PureViewCtrl } from './abstract/pure_view_ctrl';
export { ApplicationGroupView } from './application_group/application_group_view'; export { ApplicationGroupView } from './application_group/application_group_view';
export { ApplicationView } from './application/application_view'; export { ApplicationView } from './application/application_view';
export { EditorGroupView } from './editor_group/editor_group_view'; export { NoteGroupViewDirective } from './note_group_view/note_group_view';
export { EditorView } from './editor/editor_view'; export { NoteViewDirective } from './note_view/note_view';
export { FooterView } from './footer/footer_view'; export { FooterView } from './footer/footer_view';
export { TagsView } from './tags/tags_view'; export { TagsView } from './tags/tags_view';
export { ChallengeModal } from './challenge_modal/challenge_modal'; export { ChallengeModal } from './challenge_modal/challenge_modal';

View File

@@ -8,7 +8,7 @@
ng-if='!self.state.showMultipleSelectedNotes' ng-if='!self.state.showMultipleSelectedNotes'
ng-repeat='controller in self.controllers' ng-repeat='controller in self.controllers'
) )
editor-view( note-view(
application='self.application' application='self.application'
controller='controller' controller='controller'
) )

View File

@@ -1,11 +1,11 @@
import { removeFromArray, UuidString } from '@standardnotes/snjs'; import { removeFromArray, UuidString } from '@standardnotes/snjs';
import { NoteController } from './note_controller'; import { NoteViewController } from '@/views/note_view/note_view_controller';
import { WebApplication } from './application'; import { WebApplication } from '@/ui_models/application';
type NoteControllerGroupChangeCallback = () => void; type NoteControllerGroupChangeCallback = () => void;
export class NoteControllerGroup { export class NoteGroupController {
public noteControllers: NoteController[] = []; public noteControllers: NoteViewController[] = [];
private application: WebApplication; private application: WebApplication;
changeObservers: NoteControllerGroupChangeCallback[] = []; changeObservers: NoteControllerGroupChangeCallback[] = [];
@@ -16,16 +16,16 @@ export class NoteControllerGroup {
public deinit() { public deinit() {
(this.application as unknown) = undefined; (this.application as unknown) = undefined;
for (const controller of this.noteControllers) { for (const controller of this.noteControllers) {
this.deleteController(controller); this.deleteNoteView(controller);
} }
} }
async createNoteController( async createNoteView(
noteUuid?: string, noteUuid?: string,
noteTitle?: string, noteTitle?: string,
noteTag?: UuidString noteTag?: UuidString
) { ) {
const controller = new NoteController( const controller = new NoteViewController(
this.application, this.application,
noteUuid, noteUuid,
noteTitle, noteTitle,
@@ -36,30 +36,30 @@ export class NoteControllerGroup {
this.notifyObservers(); this.notifyObservers();
} }
deleteController(controller: NoteController) { deleteNoteView(controller: NoteViewController) {
controller.deinit(); controller.deinit();
removeFromArray(this.noteControllers, controller); removeFromArray(this.noteControllers, controller);
} }
closeController(controller: NoteController) { closeNoteView(controller: NoteViewController) {
this.deleteController(controller); this.deleteNoteView(controller);
this.notifyObservers(); this.notifyObservers();
} }
closeActiveController() { closeActiveNoteView() {
const activeController = this.activeNoteController; const activeController = this.activeNoteViewController;
if (activeController) { if (activeController) {
this.deleteController(activeController); this.deleteNoteView(activeController);
} }
} }
closeAllControllers() { closeAllNoteViews() {
for (const controller of this.noteControllers) { for (const controller of this.noteControllers) {
this.deleteController(controller); this.deleteNoteView(controller);
} }
} }
get activeNoteController() { get activeNoteViewController() {
return this.noteControllers[0]; return this.noteControllers[0];
} }
@@ -68,7 +68,7 @@ export class NoteControllerGroup {
*/ */
public addChangeObserver(callback: NoteControllerGroupChangeCallback) { public addChangeObserver(callback: NoteControllerGroupChangeCallback) {
this.changeObservers.push(callback); this.changeObservers.push(callback);
if (this.activeNoteController) { if (this.activeNoteViewController) {
callback(); callback();
} }
return () => { return () => {

View File

@@ -1,15 +1,15 @@
import { WebDirective } from './../../types'; import { WebDirective } from './../../types';
import template from './editor-group-view.pug'; import template from './note-group-view.pug';
import { NoteController } from '@/ui_models/note_controller'; import { NoteViewController } from '@/views/note_view/note_view_controller';
import { PureViewCtrl } from '../abstract/pure_view_ctrl'; import { PureViewCtrl } from '../abstract/pure_view_ctrl';
class EditorGroupViewCtrl extends PureViewCtrl< class NoteGroupView extends PureViewCtrl<
unknown, unknown,
{ {
showMultipleSelectedNotes: boolean; showMultipleSelectedNotes: boolean;
} }
> { > {
public controllers: NoteController[] = []; public controllers: NoteViewController[] = [];
/* @ngInject */ /* @ngInject */
constructor($timeout: ng.ITimeoutService) { constructor($timeout: ng.ITimeoutService) {
@@ -31,11 +31,11 @@ class EditorGroupViewCtrl extends PureViewCtrl<
} }
} }
export class EditorGroupView extends WebDirective { export class NoteGroupViewDirective extends WebDirective {
constructor() { constructor() {
super(); super();
this.template = template; this.template = template;
this.controller = EditorGroupViewCtrl; this.controller = NoteGroupView;
this.controllerAs = 'self'; this.controllerAs = 'self';
this.bindToController = true; this.bindToController = true;
this.scope = { this.scope = {

View File

@@ -2,19 +2,19 @@
* @jest-environment jsdom * @jest-environment jsdom
*/ */
import { EditorViewCtrl } from '@Views/editor/editor_view'; import { NoteView } from '@Views/note_view/note_view';
import { import {
ApplicationEvent, ApplicationEvent,
ProposedSecondsToDeferUILevelSessionExpirationDuringActiveInteraction, ProposedSecondsToDeferUILevelSessionExpirationDuringActiveInteraction,
} from '@standardnotes/snjs/'; } from '@standardnotes/snjs/';
describe('editor-view', () => { describe('editor-view', () => {
let ctrl: EditorViewCtrl; let ctrl: NoteView;
let setShowProtectedWarningSpy: jest.SpyInstance; let setShowProtectedWarningSpy: jest.SpyInstance;
beforeEach(() => { beforeEach(() => {
const $timeout = {} as jest.Mocked<ng.ITimeoutService>; const $timeout = {} as jest.Mocked<ng.ITimeoutService>;
ctrl = new EditorViewCtrl($timeout); ctrl = new NoteView($timeout);
setShowProtectedWarningSpy = jest.spyOn(ctrl, 'setShowProtectedOverlay'); setShowProtectedWarningSpy = jest.spyOn(ctrl, 'setShowProtectedOverlay');

View File

@@ -1,5 +1,5 @@
import { STRING_SAVING_WHILE_DOCUMENT_HIDDEN } from './../../strings'; import { STRING_SAVING_WHILE_DOCUMENT_HIDDEN } from './../../strings';
import { NoteController } from '@/ui_models/note_controller'; import { NoteViewController } from '@/views/note_view/note_view_controller';
import { WebApplication } from '@/ui_models/application'; import { WebApplication } from '@/ui_models/application';
import { PanelPuppet, WebDirective } from '@/types'; import { PanelPuppet, WebDirective } from '@/types';
import angular from 'angular'; import angular from 'angular';
@@ -23,7 +23,7 @@ import {
} from '@standardnotes/snjs'; } from '@standardnotes/snjs';
import { debounce, isDesktopApplication } from '@/utils'; import { debounce, isDesktopApplication } from '@/utils';
import { KeyboardModifier, KeyboardKey } from '@/services/ioService'; import { KeyboardModifier, KeyboardKey } from '@/services/ioService';
import template from './editor-view.pug'; import template from './note-view.pug';
import { PureViewCtrl } from '@Views/abstract/pure_view_ctrl'; import { PureViewCtrl } from '@Views/abstract/pure_view_ctrl';
import { EventSource } from '@/ui_models/app_state'; import { EventSource } from '@/ui_models/app_state';
import { import {
@@ -90,10 +90,10 @@ function sortAlphabetically(array: SNComponent[]): SNComponent[] {
); );
} }
export class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> { export class NoteView extends PureViewCtrl<unknown, EditorState> {
/** Passed through template */ /** Passed through template */
readonly application!: WebApplication; readonly application!: WebApplication;
readonly controller!: NoteController; readonly controller!: NoteViewController;
private leftPanelPuppet?: PanelPuppet; private leftPanelPuppet?: PanelPuppet;
private rightPanelPuppet?: PanelPuppet; private rightPanelPuppet?: PanelPuppet;
@@ -1039,7 +1039,7 @@ export class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
} }
} }
export class EditorView extends WebDirective { export class NoteViewDirective extends WebDirective {
constructor() { constructor() {
super(); super();
this.restrict = 'E'; this.restrict = 'E';
@@ -1049,7 +1049,7 @@ export class EditorView extends WebDirective {
}; };
this.template = template; this.template = template;
this.replace = true; this.replace = true;
this.controller = EditorViewCtrl; this.controller = NoteView;
this.controllerAs = 'self'; this.controllerAs = 'self';
this.bindToController = true; this.bindToController = true;
} }

View File

@@ -5,9 +5,9 @@ import {
UuidString, UuidString,
SNTag, SNTag,
} from '@standardnotes/snjs'; } from '@standardnotes/snjs';
import { WebApplication } from './application'; import { WebApplication } from '@/ui_models/application';
export class NoteController { export class NoteViewController {
public note!: SNNote; public note!: SNNote;
private application: WebApplication; private application: WebApplication;
private onNoteValueChange?: (note: SNNote, source: PayloadSource) => void; private onNoteValueChange?: (note: SNNote, source: PayloadSource) => void;