add serchOrCreate for chats
This commit is contained in:
@@ -67,7 +67,7 @@ export function TaskPage(
|
|||||||
on:enter={taskPageViewModel.createBoard}
|
on:enter={taskPageViewModel.createBoard}
|
||||||
placeholder={
|
placeholder={
|
||||||
coreViewModel.translations.general
|
coreViewModel.translations.general
|
||||||
.filterOrCreateLabel
|
.filterOrCreateLabel(coreViewModel.translations.chatPage.task.typeBoard)
|
||||||
}
|
}
|
||||||
></input>
|
></input>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import ChatViewModel from "../../ViewModel/Chat/chatViewModel";
|
|||||||
export function ChatEntry(chatViewModel: ChatViewModel) {
|
export function ChatEntry(chatViewModel: ChatViewModel) {
|
||||||
const view = (
|
const view = (
|
||||||
<button
|
<button
|
||||||
class="tile colored-tile chat-entry animate-highlight"
|
class="tile colored-tile chat-entry animate-highlight slide-up"
|
||||||
set:color={chatViewModel.settingsPageViewModel.color}
|
set:color={chatViewModel.settingsPageViewModel.color}
|
||||||
style="height: 8rem"
|
style="height: 8rem"
|
||||||
on:click={chatViewModel.open}
|
on:click={chatViewModel.open}
|
||||||
|
|||||||
@@ -29,15 +29,19 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: start;
|
justify-content: start;
|
||||||
|
|
||||||
gap: var(--gap-between-tiles);
|
|
||||||
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
min-width: 100%;
|
min-width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#home-page #chat-grid {
|
#home-page #overview-section {
|
||||||
margin-top: var(--content-padding);
|
gap: var(--gap-between-tiles);
|
||||||
|
}
|
||||||
|
|
||||||
|
#home-page #chat-section > button {
|
||||||
|
margin-bottom: var(--gap-between-tiles);
|
||||||
|
}
|
||||||
|
|
||||||
|
#home-page #chat-grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
gap: var(--gap-between-tiles);
|
gap: var(--gap-between-tiles);
|
||||||
|
|
||||||
|
|||||||
+7
-16
@@ -9,6 +9,7 @@ import FileTransferViewModel from "../ViewModel/Global/fileTransferViewModel";
|
|||||||
import CoreViewModel from "../ViewModel/Global/coreViewModel";
|
import CoreViewModel from "../ViewModel/Global/coreViewModel";
|
||||||
import ConnectionViewModel from "../ViewModel/Global/connectionViewModel";
|
import ConnectionViewModel from "../ViewModel/Global/connectionViewModel";
|
||||||
import ChatListViewModel from "../ViewModel/Chat/chatListViewModel";
|
import ChatListViewModel from "../ViewModel/Chat/chatListViewModel";
|
||||||
|
import {NewItemEntry} from "./Components/newItemEntry";
|
||||||
|
|
||||||
export function HomePage(
|
export function HomePage(
|
||||||
coreViewModel: CoreViewModel,
|
coreViewModel: CoreViewModel,
|
||||||
@@ -126,32 +127,22 @@ export function HomePage(
|
|||||||
<div class="flex-row width-input">
|
<div class="flex-row width-input">
|
||||||
<input
|
<input
|
||||||
placeholder={
|
placeholder={
|
||||||
coreViewModel.translations.homePage.addChatPlaceholder
|
coreViewModel.translations.general
|
||||||
|
.filterOrCreateLabel(coreViewModel.translations.homePage.typeChat)
|
||||||
}
|
}
|
||||||
aria-label={
|
bind:value={chatListViewModel.chatQuery}
|
||||||
coreViewModel.translations.homePage.addChatAudioLabel
|
|
||||||
}
|
|
||||||
bind:value={chatListViewModel.newChatPrimaryChannel}
|
|
||||||
on:enter={chatListViewModel.createChat}
|
on:enter={chatListViewModel.createChat}
|
||||||
></input>
|
></input>
|
||||||
<button
|
|
||||||
class="primary"
|
|
||||||
aria-label={
|
|
||||||
coreViewModel.translations.homePage.addChatButton
|
|
||||||
}
|
|
||||||
on:click={chatListViewModel.createChat}
|
|
||||||
toggle:disabled={chatListViewModel.cannotCreateChat}
|
|
||||||
>
|
|
||||||
<span class="icon">add</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<hr></hr>
|
<hr></hr>
|
||||||
|
|
||||||
|
{NewItemEntry(coreViewModel, chatListViewModel.chatQuery, chatListViewModel.createChat)}
|
||||||
|
|
||||||
<div
|
<div
|
||||||
id="chat-grid"
|
id="chat-grid"
|
||||||
children:append={[
|
children:append={[
|
||||||
chatListViewModel.chatViewModels,
|
chatListViewModel.chatMatches,
|
||||||
ChatViewModelToChatEntry,
|
ChatViewModelToChatEntry,
|
||||||
]}
|
]}
|
||||||
></div>
|
></div>
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ const englishTranslations = {
|
|||||||
saveButton: "Save",
|
saveButton: "Save",
|
||||||
setButton: "Set",
|
setButton: "Set",
|
||||||
|
|
||||||
filterOrCreateLabel: "Search or create",
|
filterOrCreateLabel: (type: string) => `Search or create ${type}`,
|
||||||
createLabel: (query: string) => `Create "${query}"`,
|
createLabel: (query: string) => `Create "${query}"`,
|
||||||
|
|
||||||
reloadAppButton: "Reload App",
|
reloadAppButton: "Reload App",
|
||||||
@@ -72,7 +72,8 @@ const englishTranslations = {
|
|||||||
|
|
||||||
///
|
///
|
||||||
|
|
||||||
addChatAudioLabel: "name of new chat",
|
typeChat: "chat",
|
||||||
|
|
||||||
addChatPlaceholder: "Add chat",
|
addChatPlaceholder: "Add chat",
|
||||||
addChatButton: "Add chat",
|
addChatButton: "Add chat",
|
||||||
},
|
},
|
||||||
@@ -292,6 +293,8 @@ const englishTranslations = {
|
|||||||
noBoardSelected: "No board selected",
|
noBoardSelected: "No board selected",
|
||||||
boardNotFound: "Board not found",
|
boardNotFound: "Board not found",
|
||||||
|
|
||||||
|
typeBoard: "board",
|
||||||
|
|
||||||
///
|
///
|
||||||
|
|
||||||
closeBoardButtonAudioLabel: "close board",
|
closeBoardButtonAudioLabel: "close board",
|
||||||
@@ -400,7 +403,7 @@ export const allTranslations: {
|
|||||||
saveButton: "Speichern",
|
saveButton: "Speichern",
|
||||||
setButton: "OK",
|
setButton: "OK",
|
||||||
|
|
||||||
filterOrCreateLabel: "Suchen oder erstellen",
|
filterOrCreateLabel: (type: string) => `${type} suchen oder erstellen`,
|
||||||
createLabel: (query: string) => `"${query}" erstellen`,
|
createLabel: (query: string) => `"${query}" erstellen`,
|
||||||
|
|
||||||
reloadAppButton: "Neu laden",
|
reloadAppButton: "Neu laden",
|
||||||
@@ -446,7 +449,8 @@ export const allTranslations: {
|
|||||||
|
|
||||||
updateButton: (version: string) => `Aktualisieren: ${version}`,
|
updateButton: (version: string) => `Aktualisieren: ${version}`,
|
||||||
|
|
||||||
addChatAudioLabel: "Name des neuen Chats",
|
typeChat: "Chat",
|
||||||
|
|
||||||
addChatPlaceholder: "Chat hinzufügen",
|
addChatPlaceholder: "Chat hinzufügen",
|
||||||
addChatButton: "Chat hinzufügen",
|
addChatButton: "Chat hinzufügen",
|
||||||
},
|
},
|
||||||
@@ -655,6 +659,8 @@ export const allTranslations: {
|
|||||||
noBoardSelected: "Kein Board ausgewählt",
|
noBoardSelected: "Kein Board ausgewählt",
|
||||||
boardNotFound: "Board nicht gefunden",
|
boardNotFound: "Board nicht gefunden",
|
||||||
|
|
||||||
|
typeBoard: "Board",
|
||||||
|
|
||||||
closeBoardButtonAudioLabel: "board schließen",
|
closeBoardButtonAudioLabel: "board schließen",
|
||||||
toggleBoardButtonAudioLabel: "board-liste ein/ausblenden",
|
toggleBoardButtonAudioLabel: "board-liste ein/ausblenden",
|
||||||
showBoardSettingsButtonAudioLabel:
|
showBoardSettingsButtonAudioLabel:
|
||||||
@@ -742,7 +748,7 @@ export const allTranslations: {
|
|||||||
saveButton: "Guardar",
|
saveButton: "Guardar",
|
||||||
setButton: "OK",
|
setButton: "OK",
|
||||||
|
|
||||||
filterOrCreateLabel: "Buscar o crear",
|
filterOrCreateLabel: (type: string) => `Buscar o crear ${type}`,
|
||||||
createLabel: (query: string) => `Crear "${query}"`,
|
createLabel: (query: string) => `Crear "${query}"`,
|
||||||
|
|
||||||
reloadAppButton: "Recargar app",
|
reloadAppButton: "Recargar app",
|
||||||
@@ -788,7 +794,8 @@ export const allTranslations: {
|
|||||||
|
|
||||||
updateButton: (version: string) => `Actualizar a ${version}`,
|
updateButton: (version: string) => `Actualizar a ${version}`,
|
||||||
|
|
||||||
addChatAudioLabel: "nombre del nuevo chat",
|
typeChat: "chat",
|
||||||
|
|
||||||
addChatPlaceholder: "Añadir chat",
|
addChatPlaceholder: "Añadir chat",
|
||||||
addChatButton: "Añadir chat",
|
addChatButton: "Añadir chat",
|
||||||
},
|
},
|
||||||
@@ -998,6 +1005,8 @@ export const allTranslations: {
|
|||||||
noBoardSelected: "Ningún tablero seleccionado",
|
noBoardSelected: "Ningún tablero seleccionado",
|
||||||
boardNotFound: "Tablero no encontrado",
|
boardNotFound: "Tablero no encontrado",
|
||||||
|
|
||||||
|
typeBoard: "board",
|
||||||
|
|
||||||
closeBoardButtonAudioLabel: "cerrar tablero",
|
closeBoardButtonAudioLabel: "cerrar tablero",
|
||||||
toggleBoardButtonAudioLabel:
|
toggleBoardButtonAudioLabel:
|
||||||
"mostrar o ocultar lista de tableros",
|
"mostrar o ocultar lista de tableros",
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import CoreViewModel from "../Global/coreViewModel";
|
|||||||
import ContactListViewModel from "../Global/contactViewModel";
|
import ContactListViewModel from "../Global/contactViewModel";
|
||||||
import ConnectionViewModel from "../Global/connectionViewModel";
|
import ConnectionViewModel from "../Global/connectionViewModel";
|
||||||
import * as React from "../../react";
|
import * as React from "../../react";
|
||||||
import { IndexManager } from "../../Model/Utility/utility";
|
import implementFilter, { IndexManager } from "../../Model/Utility/utility";
|
||||||
import ChatModel from "../../Model/Chat/chatModel";
|
import ChatModel from "../../Model/Chat/chatModel";
|
||||||
|
|
||||||
export default class ChatListViewModel {
|
export default class ChatListViewModel {
|
||||||
@@ -18,8 +18,9 @@ export default class ChatListViewModel {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// state
|
// state
|
||||||
newChatPrimaryChannel: React.State<string> = new React.State("");
|
chatQuery: React.State<string> = new React.State("");
|
||||||
chatViewModels: React.ListState<ChatViewModel> = new React.ListState();
|
chatViewModels: React.ListState<ChatViewModel> = new React.ListState();
|
||||||
|
chatMatches: React.ListState<ChatViewModel> = new React.ListState();
|
||||||
|
|
||||||
selectedChat: React.State<ChatViewModel | undefined> = new React.State<any>(
|
selectedChat: React.State<ChatViewModel | undefined> = new React.State<any>(
|
||||||
undefined,
|
undefined,
|
||||||
@@ -27,17 +28,17 @@ export default class ChatListViewModel {
|
|||||||
|
|
||||||
// guards
|
// guards
|
||||||
cannotCreateChat = React.createProxyState(
|
cannotCreateChat = React.createProxyState(
|
||||||
[this.newChatPrimaryChannel],
|
[this.chatQuery],
|
||||||
() => this.newChatPrimaryChannel.value == "",
|
() => this.chatQuery.value == "",
|
||||||
);
|
);
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
createChat = (): void => {
|
createChat = (): void => {
|
||||||
const chatModel: ChatModel =
|
const chatModel: ChatModel =
|
||||||
this.coreViewModel.chatListModel.createChat(
|
this.coreViewModel.chatListModel.createChat(
|
||||||
this.newChatPrimaryChannel.value,
|
this.chatQuery.value,
|
||||||
);
|
);
|
||||||
this.newChatPrimaryChannel.value = "";
|
this.chatQuery.value = "";
|
||||||
|
|
||||||
const chatViewModel: ChatViewModel =
|
const chatViewModel: ChatViewModel =
|
||||||
this.createChatViewModel(chatModel);
|
this.createChatViewModel(chatModel);
|
||||||
@@ -107,6 +108,8 @@ export default class ChatListViewModel {
|
|||||||
);
|
);
|
||||||
|
|
||||||
this.loadChats();
|
this.loadChats();
|
||||||
|
|
||||||
|
implementFilter(this.chatViewModels, this.chatMatches, this.chatQuery, chat => chat.chatModel.info.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// utility
|
// utility
|
||||||
|
|||||||
Reference in New Issue
Block a user