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();
|
$(`#toast-${id}`).remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
function showMessage(message: string, delay = 2000) {
|
function showMessage(message: string, delay = 2000, icon = "check") {
|
||||||
console.debug(utils.now(), "message:", message);
|
console.debug(utils.now(), "message:", message);
|
||||||
|
|
||||||
toast({
|
toast({
|
||||||
icon: "check",
|
icon,
|
||||||
message: message,
|
message: message,
|
||||||
autohide: true,
|
autohide: true,
|
||||||
delay
|
delay
|
||||||
|
|||||||
@ -2035,7 +2035,8 @@
|
|||||||
"add-column": "Add Column",
|
"add-column": "Add Column",
|
||||||
"add-column-placeholder": "Enter column name...",
|
"add-column-placeholder": "Enter column name...",
|
||||||
"edit-note-title": "Click to edit note title",
|
"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": {
|
"presentation_view": {
|
||||||
"edit-slide": "Edit this slide",
|
"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
|
// Add the new column to persisted data if it doesn't exist
|
||||||
const existingColumn = this.viewConfig.columns.find(col => col.value === columnName);
|
const existingColumn = this.viewConfig.columns.find(col => col.value === columnName);
|
||||||
if (!existingColumn) {
|
if (existingColumn) return false;
|
||||||
this.viewConfig.columns.push({ value: columnName });
|
this.viewConfig.columns.push({ value: columnName });
|
||||||
this.saveConfig(this.viewConfig);
|
this.saveConfig(this.viewConfig);
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
async removeColumn(column: string) {
|
async removeColumn(column: string) {
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import BoardApi from "./api";
|
|||||||
import FormTextArea from "../../react/FormTextArea";
|
import FormTextArea from "../../react/FormTextArea";
|
||||||
import FNote from "../../../entities/fnote";
|
import FNote from "../../../entities/fnote";
|
||||||
import NoteAutocomplete from "../../react/NoteAutocomplete";
|
import NoteAutocomplete from "../../react/NoteAutocomplete";
|
||||||
|
import toast from "../../../services/toast";
|
||||||
|
|
||||||
export interface BoardViewData {
|
export interface BoardViewData {
|
||||||
columns?: BoardColumnData[];
|
columns?: BoardColumnData[];
|
||||||
@ -213,7 +214,12 @@ function AddNewColumn({ api, isInRelationMode }: { api: BoardApi, isInRelationMo
|
|||||||
: (
|
: (
|
||||||
<TitleEditor
|
<TitleEditor
|
||||||
placeholder={t("board_view.add-column-placeholder")}
|
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)}
|
dismiss={() => setIsCreatingNewColumn(false)}
|
||||||
isNewItem
|
isNewItem
|
||||||
mode={isInRelationMode ? "relation" : "normal"}
|
mode={isInRelationMode ? "relation" : "normal"}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user