add CoreViewModel for drag&drop
This commit is contained in:
@@ -3,7 +3,7 @@ import * as React from "bloatless-react";
|
||||
import ChatListModel from "../../Model/Chat/chatListModel";
|
||||
import ChatModel from "../../Model/Chat/chatModel";
|
||||
import ChatViewModel from "./chatViewModel";
|
||||
import FileModel from "../../Model/Files/fileModel";
|
||||
import CoreViewModel from "../Global/coreViewModel";
|
||||
import { IndexManager } from "../../Model/Utility/utility";
|
||||
import SettingsViewModel from "../Global/settingsViewModel";
|
||||
import StorageModel from "../../Model/Global/storageModel";
|
||||
@@ -56,6 +56,7 @@ export default class ChatListViewModel {
|
||||
|
||||
createChatViewModel = (chatModel: ChatModel): ChatViewModel => {
|
||||
return new ChatViewModel(
|
||||
this.coreViewModel,
|
||||
this.storageModel,
|
||||
chatModel,
|
||||
this.settingsViewModel,
|
||||
@@ -91,6 +92,7 @@ export default class ChatListViewModel {
|
||||
|
||||
// init
|
||||
constructor(
|
||||
public coreViewModel: CoreViewModel,
|
||||
storageModel: StorageModel,
|
||||
chatListModel: ChatListModel,
|
||||
settingsViewModel: SettingsViewModel
|
||||
|
||||
@@ -2,6 +2,7 @@ import * as React from "bloatless-react";
|
||||
|
||||
import { ChatMessage, ChatMessageStatus } from "../../Model/Chat/chatModel";
|
||||
|
||||
import CoreViewModel from "../Global/coreViewModel";
|
||||
import MessagePageViewModel from "../Pages/messagePageViewModel";
|
||||
|
||||
export default class ChatMessageViewModel {
|
||||
@@ -52,6 +53,7 @@ export default class ChatMessageViewModel {
|
||||
|
||||
// init
|
||||
constructor(
|
||||
public coreViewModel: CoreViewModel,
|
||||
messagePageViewModel: MessagePageViewModel,
|
||||
chatMessage: ChatMessage,
|
||||
sentByUser: boolean
|
||||
|
||||
@@ -5,6 +5,7 @@ import StorageModel, { filePaths } from "../../Model/Global/storageModel";
|
||||
|
||||
import ChatListViewModel from "./chatListViewModel";
|
||||
import { Color } from "../../colors";
|
||||
import CoreViewModel from "../Global/coreViewModel";
|
||||
import MessagePageViewModel from "../Pages/messagePageViewModel";
|
||||
import SettingsPageViewModel from "../Pages/settingsPageViewModel";
|
||||
import SettingsViewModel from "../Global/settingsViewModel";
|
||||
@@ -77,6 +78,7 @@ export default class ChatViewModel {
|
||||
|
||||
// init
|
||||
constructor(
|
||||
public coreViewModel: CoreViewModel,
|
||||
storageModel: StorageModel,
|
||||
chatModel: ChatModel,
|
||||
settingsViewModel: SettingsViewModel,
|
||||
@@ -90,12 +92,19 @@ export default class ChatViewModel {
|
||||
|
||||
// page viewModels
|
||||
this.taskPageViewModel = new TaskPageViewModel(
|
||||
this.coreViewModel,
|
||||
this.storageModel,
|
||||
this.chatModel.fileModel.boardsAndTasksModel,
|
||||
this
|
||||
);
|
||||
this.messagePageViewModel = new MessagePageViewModel(this);
|
||||
this.settingsPageViewModel = new SettingsPageViewModel(this);
|
||||
this.messagePageViewModel = new MessagePageViewModel(
|
||||
this.coreViewModel,
|
||||
this
|
||||
);
|
||||
this.settingsPageViewModel = new SettingsPageViewModel(
|
||||
this.coreViewModel,
|
||||
this
|
||||
);
|
||||
|
||||
// handlers
|
||||
chatModel.chatMessageHandlerManager.addHandler(
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import * as React from "bloatless-react";
|
||||
|
||||
import ConnectionModel from "../../Model/Global/connectionModel";
|
||||
import CoreViewModel from "./coreViewModel";
|
||||
|
||||
export default class ConnectionViewModel {
|
||||
connectionModel: ConnectionModel;
|
||||
@@ -77,7 +78,10 @@ export default class ConnectionViewModel {
|
||||
};
|
||||
|
||||
// init
|
||||
constructor(connectionModel: ConnectionModel) {
|
||||
constructor(
|
||||
public coreViewModel: CoreViewModel,
|
||||
connectionModel: ConnectionModel
|
||||
) {
|
||||
this.connectionModel = connectionModel;
|
||||
this.updatePreviousAddresses();
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import * as React from "bloatless-react";
|
||||
|
||||
export default class CoreViewModel {
|
||||
draggedFile: React.State<File | undefined> = new React.State<
|
||||
File | undefined
|
||||
>(undefined);
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import * as React from "bloatless-react";
|
||||
|
||||
import CoreViewModel from "./coreViewModel";
|
||||
import SettingsModel from "../../Model/Global/settingsModel";
|
||||
|
||||
export default class SettingsViewModel {
|
||||
@@ -30,7 +31,10 @@ export default class SettingsViewModel {
|
||||
};
|
||||
|
||||
// init
|
||||
constructor(settingsModel: SettingsModel) {
|
||||
constructor(
|
||||
public coreViewModel: CoreViewModel,
|
||||
settingsModel: SettingsModel
|
||||
) {
|
||||
this.settingsModel = settingsModel;
|
||||
|
||||
this.username.value = settingsModel.username;
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import * as React from "bloatless-react";
|
||||
|
||||
import StorageModel, { PATH_COMPONENT_SEPARATOR } from "../../Model/Global/storageModel";
|
||||
import StorageModel, {
|
||||
PATH_COMPONENT_SEPARATOR,
|
||||
} from "../../Model/Global/storageModel";
|
||||
|
||||
import CoreViewModel from "./coreViewModel";
|
||||
import { translations } from "../../View/translations";
|
||||
|
||||
export default class StorageViewModel {
|
||||
@@ -49,7 +52,7 @@ export default class StorageViewModel {
|
||||
};
|
||||
|
||||
// init
|
||||
constructor(storageModel: StorageModel) {
|
||||
constructor(public coreViewModel: CoreViewModel, storageModel: StorageModel) {
|
||||
this.storageModel = storageModel;
|
||||
|
||||
this.selectedFileName = React.createProxyState([this.selectedPath], () =>
|
||||
|
||||
@@ -6,6 +6,7 @@ import BoardsAndTasksModel, {
|
||||
} from "../../Model/Files/boardsAndTasksModel";
|
||||
|
||||
import { Color } from "../../colors";
|
||||
import CoreViewModel from "../Global/coreViewModel";
|
||||
import { IndexManager } from "../../Model/Utility/utility";
|
||||
import StorageModel from "../../Model/Global/storageModel";
|
||||
import TaskPageViewModel from "./taskPageViewModel";
|
||||
@@ -79,6 +80,7 @@ export default class BoardViewModel {
|
||||
this.boardInfo.fileId
|
||||
);
|
||||
const taskViewModel: TaskViewModel = new TaskViewModel(
|
||||
this.coreViewModel,
|
||||
this.boardModel,
|
||||
this,
|
||||
taskFileContent
|
||||
@@ -110,6 +112,7 @@ export default class BoardViewModel {
|
||||
// view
|
||||
showTaskInList = (taskFileContent: TaskFileContent): void => {
|
||||
const taskViewModel: TaskViewModel = new TaskViewModel(
|
||||
this.coreViewModel,
|
||||
this.boardModel,
|
||||
this,
|
||||
taskFileContent
|
||||
@@ -195,6 +198,7 @@ export default class BoardViewModel {
|
||||
if (taskFileContent == null) continue;
|
||||
|
||||
const taskViewModel: TaskViewModel = new TaskViewModel(
|
||||
this.coreViewModel,
|
||||
this.boardModel,
|
||||
this,
|
||||
taskFileContent
|
||||
@@ -212,6 +216,7 @@ export default class BoardViewModel {
|
||||
|
||||
// init
|
||||
constructor(
|
||||
public coreViewModel: CoreViewModel,
|
||||
storageModel: StorageModel,
|
||||
boardModel: BoardsAndTasksModel,
|
||||
taskPageViewModel: TaskPageViewModel,
|
||||
|
||||
@@ -3,6 +3,7 @@ import * as React from "bloatless-react";
|
||||
import { ChatMessage } from "../../Model/Chat/chatModel";
|
||||
import ChatMessageViewModel from "../Chat/chatMessageViewModel";
|
||||
import ChatViewModel from "../Chat/chatViewModel";
|
||||
import CoreViewModel from "../Global/coreViewModel";
|
||||
|
||||
export default class MessagePageViewModel {
|
||||
chatViewModel: ChatViewModel;
|
||||
@@ -39,6 +40,7 @@ export default class MessagePageViewModel {
|
||||
// view
|
||||
showChatMessage = (chatMessage: ChatMessage): void => {
|
||||
const chatMessageModel = new ChatMessageViewModel(
|
||||
this.coreViewModel,
|
||||
this,
|
||||
chatMessage,
|
||||
chatMessage.sender == this.chatViewModel.settingsViewModel.username.value
|
||||
@@ -62,7 +64,10 @@ export default class MessagePageViewModel {
|
||||
};
|
||||
|
||||
// init
|
||||
constructor(chatViewModel: ChatViewModel) {
|
||||
constructor(
|
||||
public coreViewModel: CoreViewModel,
|
||||
chatViewModel: ChatViewModel
|
||||
) {
|
||||
this.chatViewModel = chatViewModel;
|
||||
|
||||
this.cannotSendMessage = React.createProxyState(
|
||||
|
||||
@@ -2,6 +2,7 @@ import * as React from "bloatless-react";
|
||||
|
||||
import ChatViewModel from "../Chat/chatViewModel";
|
||||
import { Color } from "../../colors";
|
||||
import CoreViewModel from "../Global/coreViewModel";
|
||||
|
||||
export default class SettingsPageViewModel {
|
||||
chatViewModel: ChatViewModel;
|
||||
@@ -110,7 +111,10 @@ export default class SettingsPageViewModel {
|
||||
};
|
||||
|
||||
// init
|
||||
constructor(chatViewModel: ChatViewModel) {
|
||||
constructor(
|
||||
public coreViewModel: CoreViewModel,
|
||||
chatViewModel: ChatViewModel
|
||||
) {
|
||||
this.chatViewModel = chatViewModel;
|
||||
this.loadListRelevantData();
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import BoardsAndTasksModel, { BoardInfoFileContent } from "../../Model/Files/boa
|
||||
|
||||
import BoardViewModel from "./boardViewModel";
|
||||
import ChatViewModel from "../Chat/chatViewModel";
|
||||
import CoreViewModel from "../Global/coreViewModel";
|
||||
import { IndexManager } from "../../Model/Utility/utility";
|
||||
import StorageModel from "../../Model/Global/storageModel";
|
||||
|
||||
@@ -73,6 +74,7 @@ export default class TaskPageViewModel {
|
||||
// view
|
||||
showBoardInList = (boardInfo: BoardInfoFileContent): void => {
|
||||
const boardViewModel: BoardViewModel = new BoardViewModel(
|
||||
this.coreViewModel,
|
||||
this.storageModel,
|
||||
this.boardModel,
|
||||
this,
|
||||
@@ -140,6 +142,7 @@ export default class TaskPageViewModel {
|
||||
|
||||
// init
|
||||
constructor(
|
||||
public coreViewModel: CoreViewModel,
|
||||
storageModel: StorageModel,
|
||||
boardModel: BoardsAndTasksModel,
|
||||
chatViewModel: ChatViewModel
|
||||
|
||||
@@ -4,6 +4,7 @@ import BoardsAndTasksModel, { TaskFileContent } from "../../Model/Files/boardsAn
|
||||
import { localeCompare, padZero } from "../../Model/Utility/utility";
|
||||
|
||||
import BoardViewModel from "./boardViewModel";
|
||||
import CoreViewModel from "../Global/coreViewModel";
|
||||
|
||||
export default class TaskViewModel {
|
||||
boardModel: BoardsAndTasksModel;
|
||||
@@ -138,6 +139,7 @@ export default class TaskViewModel {
|
||||
|
||||
// init
|
||||
constructor(
|
||||
public coreViewModel: CoreViewModel,
|
||||
boardModel: BoardsAndTasksModel,
|
||||
boardViewModel: BoardViewModel,
|
||||
taskFileContent: TaskFileContent
|
||||
|
||||
+10
-3
@@ -10,6 +10,7 @@ import { ChatPageWrapper } from "./View/chatPageWrapper";
|
||||
import { ConnectionModal } from "./View/Modals/connectionModal";
|
||||
import ConnectionModel from "./Model/Global/connectionModel";
|
||||
import ConnectionViewModel from "./ViewModel/Global/connectionViewModel";
|
||||
import CoreViewModel from "./ViewModel/Global/coreViewModel";
|
||||
import { HomePage } from "./View/homePage";
|
||||
import SettingsModel from "./Model/Global/settingsModel";
|
||||
import SettingsViewModel from "./ViewModel/Global/settingsViewModel";
|
||||
@@ -28,10 +29,16 @@ const chatListModel = new ChatListModel(
|
||||
);
|
||||
|
||||
// viewModels
|
||||
const storageViewModel = new StorageViewModel(storageModel);
|
||||
const settingsViewModel = new SettingsViewModel(settingsModel);
|
||||
const connectionViewModel = new ConnectionViewModel(connectionModel);
|
||||
const coreVieWModel = new CoreViewModel();
|
||||
|
||||
const storageViewModel = new StorageViewModel(coreVieWModel, storageModel);
|
||||
const settingsViewModel = new SettingsViewModel(coreVieWModel, settingsModel);
|
||||
const connectionViewModel = new ConnectionViewModel(
|
||||
coreVieWModel,
|
||||
connectionModel
|
||||
);
|
||||
const chatListViewModel = new ChatListViewModel(
|
||||
coreVieWModel,
|
||||
storageModel,
|
||||
chatListModel,
|
||||
settingsViewModel
|
||||
|
||||
Reference in New Issue
Block a user