refactor: rename note controller to note view controller
This commit is contained in:
@@ -30,8 +30,8 @@ import { AccountSwitcher } from './views/account_switcher/account_switcher';
|
||||
import {
|
||||
ApplicationGroupView,
|
||||
ApplicationView,
|
||||
EditorGroupView,
|
||||
EditorView,
|
||||
NoteGroupViewDirective,
|
||||
NoteViewDirective,
|
||||
TagsView,
|
||||
FooterView,
|
||||
ChallengeModal,
|
||||
@@ -141,8 +141,8 @@ const startApplication: StartApplication = async function startApplication(
|
||||
.module('app')
|
||||
.directive('applicationGroupView', () => new ApplicationGroupView())
|
||||
.directive('applicationView', () => new ApplicationView())
|
||||
.directive('editorGroupView', () => new EditorGroupView())
|
||||
.directive('editorView', () => new EditorView())
|
||||
.directive('noteGroupView', () => new NoteGroupViewDirective())
|
||||
.directive('noteView', () => new NoteViewDirective())
|
||||
.directive('tagsView', () => new TagsView())
|
||||
.directive('footerView', () => new FooterView());
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Bridge } from '@/services/bridge';
|
||||
import { storage, StorageKey } from '@/services/localStorage';
|
||||
import { WebApplication } from '@/ui_models/application';
|
||||
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 {
|
||||
ApplicationEvent,
|
||||
@@ -236,7 +236,7 @@ export class AppState {
|
||||
: this.selectedTag.uuid
|
||||
: undefined;
|
||||
|
||||
await this.application.noteControllerGroup.createNoteController(
|
||||
await this.application.noteControllerGroup.createNoteView(
|
||||
undefined,
|
||||
title,
|
||||
activeTagUuid
|
||||
@@ -251,16 +251,16 @@ export class AppState {
|
||||
return this.application.noteControllerGroup.noteControllers;
|
||||
}
|
||||
|
||||
closeNoteController(controller: NoteController) {
|
||||
this.application.noteControllerGroup.closeController(controller);
|
||||
closeNoteController(controller: NoteViewController) {
|
||||
this.application.noteControllerGroup.closeNoteView(controller);
|
||||
}
|
||||
|
||||
closeActiveNoteController() {
|
||||
this.application.noteControllerGroup.closeActiveController();
|
||||
this.application.noteControllerGroup.closeActiveNoteView();
|
||||
}
|
||||
|
||||
closeAllNoteControllers() {
|
||||
this.application.noteControllerGroup.closeAllControllers();
|
||||
this.application.noteControllerGroup.closeAllNoteViews();
|
||||
}
|
||||
|
||||
noteControllerForNote(note: SNNote) {
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
runInAction,
|
||||
} from 'mobx';
|
||||
import { WebApplication } from '../application';
|
||||
import { NoteController } from '../note_controller';
|
||||
import { NoteViewController } from '@/views/note_view/note_view_controller';
|
||||
import { AppState } from './app_state';
|
||||
|
||||
export class NotesState {
|
||||
@@ -68,7 +68,7 @@ export class NotesState {
|
||||
);
|
||||
}
|
||||
|
||||
get activeNoteController(): NoteController | undefined {
|
||||
get activeNoteController(): NoteViewController | undefined {
|
||||
return this.application.noteControllerGroup.noteControllers[0];
|
||||
}
|
||||
|
||||
@@ -168,10 +168,10 @@ export class NotesState {
|
||||
}
|
||||
|
||||
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();
|
||||
await this.onActiveEditorChanged();
|
||||
|
||||
@@ -10,7 +10,7 @@ import { StatusManager } from '@/services/statusManager';
|
||||
import { ThemeManager } from '@/services/themeManager';
|
||||
import { PasswordWizardScope, PasswordWizardType } from '@/types';
|
||||
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 { WebDeviceInterface } from '@/web_device_interface';
|
||||
import {
|
||||
@@ -36,7 +36,7 @@ export class WebApplication extends SNApplication {
|
||||
private scope?: angular.IScope;
|
||||
private webServices!: WebServices;
|
||||
private currentAuthenticationElement?: angular.IRootElementService;
|
||||
public noteControllerGroup: NoteControllerGroup;
|
||||
public noteControllerGroup: NoteGroupController;
|
||||
|
||||
/* @ngInject */
|
||||
constructor(
|
||||
@@ -66,7 +66,7 @@ export class WebApplication extends SNApplication {
|
||||
this.$compile = $compile;
|
||||
this.scope = scope;
|
||||
deviceInterface.setApplication(this);
|
||||
this.noteControllerGroup = new NoteControllerGroup(this);
|
||||
this.noteControllerGroup = new NoteGroupController(this);
|
||||
this.presentPermissionsDialog = this.presentPermissionsDialog.bind(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
application='self.application'
|
||||
app-state='self.appState'
|
||||
)
|
||||
editor-group-view.flex-grow(application='self.application')
|
||||
note-group-view.flex-grow(application='self.application')
|
||||
|
||||
footer-view(
|
||||
ng-if='!self.state.needsUnlock && self.state.launched'
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
export { PureViewCtrl } from './abstract/pure_view_ctrl';
|
||||
export { ApplicationGroupView } from './application_group/application_group_view';
|
||||
export { ApplicationView } from './application/application_view';
|
||||
export { EditorGroupView } from './editor_group/editor_group_view';
|
||||
export { EditorView } from './editor/editor_view';
|
||||
export { NoteGroupViewDirective } from './note_group_view/note_group_view';
|
||||
export { NoteViewDirective } from './note_view/note_view';
|
||||
export { FooterView } from './footer/footer_view';
|
||||
export { TagsView } from './tags/tags_view';
|
||||
export { ChallengeModal } from './challenge_modal/challenge_modal';
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
ng-if='!self.state.showMultipleSelectedNotes'
|
||||
ng-repeat='controller in self.controllers'
|
||||
)
|
||||
editor-view(
|
||||
note-view(
|
||||
application='self.application'
|
||||
controller='controller'
|
||||
)
|
||||
@@ -1,11 +1,11 @@
|
||||
import { removeFromArray, UuidString } from '@standardnotes/snjs';
|
||||
import { NoteController } from './note_controller';
|
||||
import { WebApplication } from './application';
|
||||
import { NoteViewController } from '@/views/note_view/note_view_controller';
|
||||
import { WebApplication } from '@/ui_models/application';
|
||||
|
||||
type NoteControllerGroupChangeCallback = () => void;
|
||||
|
||||
export class NoteControllerGroup {
|
||||
public noteControllers: NoteController[] = [];
|
||||
export class NoteGroupController {
|
||||
public noteControllers: NoteViewController[] = [];
|
||||
private application: WebApplication;
|
||||
changeObservers: NoteControllerGroupChangeCallback[] = [];
|
||||
|
||||
@@ -16,16 +16,16 @@ export class NoteControllerGroup {
|
||||
public deinit() {
|
||||
(this.application as unknown) = undefined;
|
||||
for (const controller of this.noteControllers) {
|
||||
this.deleteController(controller);
|
||||
this.deleteNoteView(controller);
|
||||
}
|
||||
}
|
||||
|
||||
async createNoteController(
|
||||
async createNoteView(
|
||||
noteUuid?: string,
|
||||
noteTitle?: string,
|
||||
noteTag?: UuidString
|
||||
) {
|
||||
const controller = new NoteController(
|
||||
const controller = new NoteViewController(
|
||||
this.application,
|
||||
noteUuid,
|
||||
noteTitle,
|
||||
@@ -36,30 +36,30 @@ export class NoteControllerGroup {
|
||||
this.notifyObservers();
|
||||
}
|
||||
|
||||
deleteController(controller: NoteController) {
|
||||
deleteNoteView(controller: NoteViewController) {
|
||||
controller.deinit();
|
||||
removeFromArray(this.noteControllers, controller);
|
||||
}
|
||||
|
||||
closeController(controller: NoteController) {
|
||||
this.deleteController(controller);
|
||||
closeNoteView(controller: NoteViewController) {
|
||||
this.deleteNoteView(controller);
|
||||
this.notifyObservers();
|
||||
}
|
||||
|
||||
closeActiveController() {
|
||||
const activeController = this.activeNoteController;
|
||||
closeActiveNoteView() {
|
||||
const activeController = this.activeNoteViewController;
|
||||
if (activeController) {
|
||||
this.deleteController(activeController);
|
||||
this.deleteNoteView(activeController);
|
||||
}
|
||||
}
|
||||
|
||||
closeAllControllers() {
|
||||
closeAllNoteViews() {
|
||||
for (const controller of this.noteControllers) {
|
||||
this.deleteController(controller);
|
||||
this.deleteNoteView(controller);
|
||||
}
|
||||
}
|
||||
|
||||
get activeNoteController() {
|
||||
get activeNoteViewController() {
|
||||
return this.noteControllers[0];
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ export class NoteControllerGroup {
|
||||
*/
|
||||
public addChangeObserver(callback: NoteControllerGroupChangeCallback) {
|
||||
this.changeObservers.push(callback);
|
||||
if (this.activeNoteController) {
|
||||
if (this.activeNoteViewController) {
|
||||
callback();
|
||||
}
|
||||
return () => {
|
||||
@@ -1,15 +1,15 @@
|
||||
import { WebDirective } from './../../types';
|
||||
import template from './editor-group-view.pug';
|
||||
import { NoteController } from '@/ui_models/note_controller';
|
||||
import template from './note-group-view.pug';
|
||||
import { NoteViewController } from '@/views/note_view/note_view_controller';
|
||||
import { PureViewCtrl } from '../abstract/pure_view_ctrl';
|
||||
|
||||
class EditorGroupViewCtrl extends PureViewCtrl<
|
||||
class NoteGroupView extends PureViewCtrl<
|
||||
unknown,
|
||||
{
|
||||
showMultipleSelectedNotes: boolean;
|
||||
}
|
||||
> {
|
||||
public controllers: NoteController[] = [];
|
||||
public controllers: NoteViewController[] = [];
|
||||
|
||||
/* @ngInject */
|
||||
constructor($timeout: ng.ITimeoutService) {
|
||||
@@ -31,11 +31,11 @@ class EditorGroupViewCtrl extends PureViewCtrl<
|
||||
}
|
||||
}
|
||||
|
||||
export class EditorGroupView extends WebDirective {
|
||||
export class NoteGroupViewDirective extends WebDirective {
|
||||
constructor() {
|
||||
super();
|
||||
this.template = template;
|
||||
this.controller = EditorGroupViewCtrl;
|
||||
this.controller = NoteGroupView;
|
||||
this.controllerAs = 'self';
|
||||
this.bindToController = true;
|
||||
this.scope = {
|
||||
@@ -2,19 +2,19 @@
|
||||
* @jest-environment jsdom
|
||||
*/
|
||||
|
||||
import { EditorViewCtrl } from '@Views/editor/editor_view';
|
||||
import { NoteView } from '@Views/note_view/note_view';
|
||||
import {
|
||||
ApplicationEvent,
|
||||
ProposedSecondsToDeferUILevelSessionExpirationDuringActiveInteraction,
|
||||
} from '@standardnotes/snjs/';
|
||||
|
||||
describe('editor-view', () => {
|
||||
let ctrl: EditorViewCtrl;
|
||||
let ctrl: NoteView;
|
||||
let setShowProtectedWarningSpy: jest.SpyInstance;
|
||||
|
||||
beforeEach(() => {
|
||||
const $timeout = {} as jest.Mocked<ng.ITimeoutService>;
|
||||
ctrl = new EditorViewCtrl($timeout);
|
||||
ctrl = new NoteView($timeout);
|
||||
|
||||
setShowProtectedWarningSpy = jest.spyOn(ctrl, 'setShowProtectedOverlay');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
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 { PanelPuppet, WebDirective } from '@/types';
|
||||
import angular from 'angular';
|
||||
@@ -23,7 +23,7 @@ import {
|
||||
} from '@standardnotes/snjs';
|
||||
import { debounce, isDesktopApplication } from '@/utils';
|
||||
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 { EventSource } from '@/ui_models/app_state';
|
||||
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 */
|
||||
readonly application!: WebApplication;
|
||||
readonly controller!: NoteController;
|
||||
readonly controller!: NoteViewController;
|
||||
|
||||
private leftPanelPuppet?: 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() {
|
||||
super();
|
||||
this.restrict = 'E';
|
||||
@@ -1049,7 +1049,7 @@ export class EditorView extends WebDirective {
|
||||
};
|
||||
this.template = template;
|
||||
this.replace = true;
|
||||
this.controller = EditorViewCtrl;
|
||||
this.controller = NoteView;
|
||||
this.controllerAs = 'self';
|
||||
this.bindToController = true;
|
||||
}
|
||||
@@ -5,9 +5,9 @@ import {
|
||||
UuidString,
|
||||
SNTag,
|
||||
} from '@standardnotes/snjs';
|
||||
import { WebApplication } from './application';
|
||||
import { WebApplication } from '@/ui_models/application';
|
||||
|
||||
export class NoteController {
|
||||
export class NoteViewController {
|
||||
public note!: SNNote;
|
||||
private application: WebApplication;
|
||||
private onNoteValueChange?: (note: SNNote, source: PayloadSource) => void;
|
||||
Reference in New Issue
Block a user