mirror of
https://github.com/zadam/trilium.git
synced 2025-11-16 13:34:30 +01:00
feat(board): warn when column already exists
This commit is contained in:
parent
f820c6f23b
commit
df8da0fd4f
@ -77,11 +77,11 @@ function closePersistent(id: string) {
|
||||
$(`#toast-${id}`).remove();
|
||||
}
|
||||
|
||||
function showMessage(message: string, delay = 2000) {
|
||||
function showMessage(message: string, delay = 2000, icon = "check") {
|
||||
console.debug(utils.now(), "message:", message);
|
||||
|
||||
toast({
|
||||
icon: "check",
|
||||
icon,
|
||||
message: message,
|
||||
autohide: true,
|
||||
delay
|
||||
|
||||
@ -2035,7 +2035,8 @@
|
||||
"add-column": "Add Column",
|
||||
"add-column-placeholder": "Enter column name...",
|
||||
"edit-note-title": "Click to edit note title",
|
||||
"edit-column-title": "Click to edit column title"
|
||||
"edit-column-title": "Click to edit column title",
|
||||
"column-already-exists": "This column already exists on the board."
|
||||
},
|
||||
"presentation_view": {
|
||||
"edit-slide": "Edit this slide",
|
||||
|
||||
@ -75,10 +75,10 @@ export default class BoardApi {
|
||||
|
||||
// Add the new column to persisted data if it doesn't exist
|
||||
const existingColumn = this.viewConfig.columns.find(col => col.value === columnName);
|
||||
if (!existingColumn) {
|
||||
if (existingColumn) return false;
|
||||
this.viewConfig.columns.push({ value: columnName });
|
||||
this.saveConfig(this.viewConfig);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
async removeColumn(column: string) {
|
||||
|
||||
@ -14,6 +14,7 @@ import BoardApi from "./api";
|
||||
import FormTextArea from "../../react/FormTextArea";
|
||||
import FNote from "../../../entities/fnote";
|
||||
import NoteAutocomplete from "../../react/NoteAutocomplete";
|
||||
import toast from "../../../services/toast";
|
||||
|
||||
export interface BoardViewData {
|
||||
columns?: BoardColumnData[];
|
||||
@ -213,7 +214,12 @@ function AddNewColumn({ api, isInRelationMode }: { api: BoardApi, isInRelationMo
|
||||
: (
|
||||
<TitleEditor
|
||||
placeholder={t("board_view.add-column-placeholder")}
|
||||
save={(columnName) => api.addNewColumn(columnName)}
|
||||
save={async (columnName) => {
|
||||
const created = await api.addNewColumn(columnName);
|
||||
if (!created) {
|
||||
toast.showMessage(t("board_view.column-already-exists"), undefined, "bx bx-duplicate");
|
||||
}
|
||||
}}
|
||||
dismiss={() => setIsCreatingNewColumn(false)}
|
||||
isNewItem
|
||||
mode={isInRelationMode ? "relation" : "normal"}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user