49 lines
2.4 KiB
JavaScript
49 lines
2.4 KiB
JavaScript
// Rôle : rend les contrôles fréquents et l'ajout rapide du planificateur de tâches.
|
|
import { CategoryAutocompleteInput } from "../../../components/CategoryAutocompleteInput.jsx";
|
|
import { Icon } from "../../../components/Icon.jsx";
|
|
import {
|
|
TASK_TYPES,
|
|
getTaskTypeLabel
|
|
} from "./taskPlannerUtils.js";
|
|
|
|
export function TaskPlannerTopbar({
|
|
data,
|
|
editing,
|
|
categoryOptions,
|
|
taskDraft,
|
|
textContent,
|
|
onAddTask,
|
|
onHideCompletedToggle
|
|
}) {
|
|
return (
|
|
<div className="task-planner-topbar">
|
|
<div className="task-planner-global-controls">
|
|
<button
|
|
className={`tool-split-scroll-toggle task-planner-hide-completed-toggle nds-switch ${data.hideCompleted ? "active" : ""}`}
|
|
data-size="lg"
|
|
type="button"
|
|
onClick={onHideCompletedToggle}
|
|
aria-pressed={data.hideCompleted}
|
|
aria-label={textContent.hideCompletedTitle || "Masquer les tâches effectuées"}
|
|
title={textContent.hideCompletedTitle || "Masquer les tâches effectuées"}
|
|
>
|
|
<Icon name={data.hideCompleted ? "eye-closed" : "eye-open"} />
|
|
<i aria-hidden="true" />
|
|
</button>
|
|
</div>
|
|
{editing && (
|
|
<div className="task-planner-add-stack">
|
|
<form className="inline-form task-planner-add-form" onSubmit={onAddTask}>
|
|
<input {...taskDraft.getFieldProps("title", { className: "nds-input", "data-size": "sm", type: "text", placeholder: textContent.titlePlaceholder || "Nouvelle tâche" })} />
|
|
<CategoryAutocompleteInput {...taskDraft.getFieldProps("category", { className: "nds-input", "data-size": "sm", placeholder: textContent.categoryPlaceholder || "Nom de catégorie" })} options={categoryOptions} />
|
|
<select {...taskDraft.getFieldProps("type", { className: "nds-select", "data-size": "sm", "aria-label": textContent.typeLabel || "Type" })}>
|
|
{TASK_TYPES.map((taskType) => <option key={taskType} value={taskType}>{getTaskTypeLabel(taskType, textContent)}</option>)}
|
|
</select>
|
|
<input {...taskDraft.getFieldProps("qtyTarget", { className: "task-planner-quantity-target nds-input", "data-size": "sm", type: "number", min: 1, step: 1, "aria-label": textContent.quantityLabel, title: textContent.quantityLabel })} />
|
|
<button className="nds-button" data-size="sm" data-variant="primary">{textContent.addButton || "Ajouter"}</button>
|
|
</form>
|
|
</div>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|