feat(board): warn when column already exists

This commit is contained in:
Elian Doran 2025-11-15 11:34:01 +02:00
parent f820c6f23b
commit df8da0fd4f
No known key found for this signature in database
4 changed files with 15 additions and 8 deletions

View File

@ -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

View File

@ -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",

View File

@ -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) {

View File

@ -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"}