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