T024: add function_type and group start/end dates to function groups UI
This commit is contained in:
@@ -0,0 +1,42 @@
|
|||||||
|
"""add_function_type_and_group_dates
|
||||||
|
|
||||||
|
Revision ID: cfe638817921
|
||||||
|
Revises: f5772dd5cd55
|
||||||
|
Create Date: 2026-05-31 21:17:13.064051
|
||||||
|
|
||||||
|
"""
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = 'cfe638817921'
|
||||||
|
down_revision: Union[str, None] = 'f5772dd5cd55'
|
||||||
|
branch_labels: Union[str, Sequence[str], None] = None
|
||||||
|
depends_on: Union[str, Sequence[str], None] = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
with op.batch_alter_table('project_function_groups', schema=None) as batch_op:
|
||||||
|
batch_op.add_column(sa.Column('start_date', sa.DateTime(timezone=True), nullable=True))
|
||||||
|
batch_op.add_column(sa.Column('end_date', sa.DateTime(timezone=True), nullable=True))
|
||||||
|
|
||||||
|
with op.batch_alter_table('project_functions', schema=None) as batch_op:
|
||||||
|
batch_op.add_column(sa.Column('function_type', sa.String(length=50), nullable=False))
|
||||||
|
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
with op.batch_alter_table('project_functions', schema=None) as batch_op:
|
||||||
|
batch_op.drop_column('function_type')
|
||||||
|
|
||||||
|
with op.batch_alter_table('project_function_groups', schema=None) as batch_op:
|
||||||
|
batch_op.drop_column('end_date')
|
||||||
|
batch_op.drop_column('start_date')
|
||||||
|
|
||||||
|
# ### end Alembic commands ###
|
||||||
@@ -108,6 +108,8 @@ class ProjectFunctionGroup(Base):
|
|||||||
String(36), ForeignKey("projects.id", ondelete="CASCADE"), nullable=False
|
String(36), ForeignKey("projects.id", ondelete="CASCADE"), nullable=False
|
||||||
)
|
)
|
||||||
sort_order: Mapped[int] = mapped_column(Integer, nullable=False, default=0)
|
sort_order: Mapped[int] = mapped_column(Integer, nullable=False, default=0)
|
||||||
|
start_date: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
|
||||||
|
end_date: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
|
||||||
|
|
||||||
# Relationships
|
# Relationships
|
||||||
project: Mapped["Project"] = relationship(
|
project: Mapped["Project"] = relationship(
|
||||||
@@ -135,6 +137,7 @@ class ProjectFunction(Base):
|
|||||||
ForeignKey("project_function_groups.id", ondelete="CASCADE"),
|
ForeignKey("project_function_groups.id", ondelete="CASCADE"),
|
||||||
nullable=False,
|
nullable=False,
|
||||||
)
|
)
|
||||||
|
function_type: Mapped[str] = mapped_column(String(50), nullable=False, default='crew')
|
||||||
quantity: Mapped[float] = mapped_column(Float, nullable=False, default=1.0)
|
quantity: Mapped[float] = mapped_column(Float, nullable=False, default=1.0)
|
||||||
daily_costs: Mapped[float] = mapped_column(Float, nullable=False, default=0.0)
|
daily_costs: Mapped[float] = mapped_column(Float, nullable=False, default=0.0)
|
||||||
total_costs: Mapped[float] = mapped_column(Float, nullable=False, default=0.0)
|
total_costs: Mapped[float] = mapped_column(Float, nullable=False, default=0.0)
|
||||||
|
|||||||
@@ -103,12 +103,16 @@ class ProjectFunctionGroupCreateRequest(BaseModel):
|
|||||||
"""Request body for creating a function group."""
|
"""Request body for creating a function group."""
|
||||||
name: str = Field(..., max_length=255)
|
name: str = Field(..., max_length=255)
|
||||||
sort_order: int = 0
|
sort_order: int = 0
|
||||||
|
start_date: datetime | None = None
|
||||||
|
end_date: datetime | None = None
|
||||||
|
|
||||||
|
|
||||||
class ProjectFunctionGroupUpdateRequest(BaseModel):
|
class ProjectFunctionGroupUpdateRequest(BaseModel):
|
||||||
"""Request body for updating a function group."""
|
"""Request body for updating a function group."""
|
||||||
name: str | None = Field(None, max_length=255)
|
name: str | None = Field(None, max_length=255)
|
||||||
sort_order: int | None = None
|
sort_order: int | None = None
|
||||||
|
start_date: datetime | None = None
|
||||||
|
end_date: datetime | None = None
|
||||||
|
|
||||||
|
|
||||||
class ProjectFunctionGroupResponse(BaseModel):
|
class ProjectFunctionGroupResponse(BaseModel):
|
||||||
@@ -117,6 +121,8 @@ class ProjectFunctionGroupResponse(BaseModel):
|
|||||||
name: str
|
name: str
|
||||||
project_id: str
|
project_id: str
|
||||||
sort_order: int = 0
|
sort_order: int = 0
|
||||||
|
start_date: datetime | None = None
|
||||||
|
end_date: datetime | None = None
|
||||||
|
|
||||||
model_config = {"from_attributes": True}
|
model_config = {"from_attributes": True}
|
||||||
|
|
||||||
@@ -134,6 +140,7 @@ class ProjectFunctionGroupListResponse(BaseModel):
|
|||||||
class ProjectFunctionCreateRequest(BaseModel):
|
class ProjectFunctionCreateRequest(BaseModel):
|
||||||
"""Request body for creating a project function."""
|
"""Request body for creating a project function."""
|
||||||
name: str = Field(..., max_length=255)
|
name: str = Field(..., max_length=255)
|
||||||
|
function_type: str = "crew"
|
||||||
quantity: float = 1.0
|
quantity: float = 1.0
|
||||||
daily_costs: float = 0.0
|
daily_costs: float = 0.0
|
||||||
total_costs: float = 0.0
|
total_costs: float = 0.0
|
||||||
@@ -143,6 +150,7 @@ class ProjectFunctionCreateRequest(BaseModel):
|
|||||||
class ProjectFunctionUpdateRequest(BaseModel):
|
class ProjectFunctionUpdateRequest(BaseModel):
|
||||||
"""Request body for updating a project function."""
|
"""Request body for updating a project function."""
|
||||||
name: str | None = Field(None, max_length=255)
|
name: str | None = Field(None, max_length=255)
|
||||||
|
function_type: str | None = None
|
||||||
quantity: float | None = None
|
quantity: float | None = None
|
||||||
daily_costs: float | None = None
|
daily_costs: float | None = None
|
||||||
total_costs: float | None = None
|
total_costs: float | None = None
|
||||||
@@ -154,6 +162,7 @@ class ProjectFunctionResponse(BaseModel):
|
|||||||
id: str
|
id: str
|
||||||
name: str
|
name: str
|
||||||
function_group_id: str
|
function_group_id: str
|
||||||
|
function_type: str = "crew"
|
||||||
quantity: float = 1.0
|
quantity: float = 1.0
|
||||||
daily_costs: float = 0.0
|
daily_costs: float = 0.0
|
||||||
total_costs: float = 0.0
|
total_costs: float = 0.0
|
||||||
|
|||||||
@@ -17,12 +17,15 @@ interface FunctionGroupItem {
|
|||||||
name: string;
|
name: string;
|
||||||
project_id: string;
|
project_id: string;
|
||||||
sort_order: number;
|
sort_order: number;
|
||||||
|
start_date: string | null;
|
||||||
|
end_date: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface FunctionItem {
|
interface FunctionItem {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
function_group_id: string;
|
function_group_id: string;
|
||||||
|
function_type: string;
|
||||||
quantity: number;
|
quantity: number;
|
||||||
daily_costs: number;
|
daily_costs: number;
|
||||||
total_costs: number;
|
total_costs: number;
|
||||||
@@ -49,18 +52,24 @@ export default function FunctionGroupEditor({
|
|||||||
const [expandedGroups, setExpandedGroups] = useState<Set<string>>(new Set());
|
const [expandedGroups, setExpandedGroups] = useState<Set<string>>(new Set());
|
||||||
const [editingGroupId, setEditingGroupId] = useState<string | null>(null);
|
const [editingGroupId, setEditingGroupId] = useState<string | null>(null);
|
||||||
const [editingGroupName, setEditingGroupName] = useState('');
|
const [editingGroupName, setEditingGroupName] = useState('');
|
||||||
|
const [editingGroupStartDate, setEditingGroupStartDate] = useState('');
|
||||||
|
const [editingGroupEndDate, setEditingGroupEndDate] = useState('');
|
||||||
const [editingFuncId, setEditingFuncId] = useState<string | null>(null);
|
const [editingFuncId, setEditingFuncId] = useState<string | null>(null);
|
||||||
const [editingFuncData, setEditingFuncData] = useState<{
|
const [editingFuncData, setEditingFuncData] = useState<{
|
||||||
name: string;
|
name: string;
|
||||||
|
function_type: string;
|
||||||
quantity: number;
|
quantity: number;
|
||||||
daily_costs: number;
|
daily_costs: number;
|
||||||
total_costs: number;
|
total_costs: number;
|
||||||
} | null>(null);
|
} | null>(null);
|
||||||
const [newGroupName, setNewGroupName] = useState('');
|
const [newGroupName, setNewGroupName] = useState('');
|
||||||
|
const [newGroupStartDate, setNewGroupStartDate] = useState('');
|
||||||
|
const [newGroupEndDate, setNewGroupEndDate] = useState('');
|
||||||
const [showNewGroup, setShowNewGroup] = useState(false);
|
const [showNewGroup, setShowNewGroup] = useState(false);
|
||||||
const [newFuncMap, setNewFuncMap] = useState<Record<string, boolean>>({});
|
const [newFuncMap, setNewFuncMap] = useState<Record<string, boolean>>({});
|
||||||
const [newFuncData, setNewFuncData] = useState<Record<string, {
|
const [newFuncData, setNewFuncData] = useState<Record<string, {
|
||||||
name: string;
|
name: string;
|
||||||
|
function_type: string;
|
||||||
quantity: number;
|
quantity: number;
|
||||||
daily_costs: number;
|
daily_costs: number;
|
||||||
total_costs: number;
|
total_costs: number;
|
||||||
@@ -82,11 +91,15 @@ export default function FunctionGroupEditor({
|
|||||||
const startEditGroup = (fg: FunctionGroupItem) => {
|
const startEditGroup = (fg: FunctionGroupItem) => {
|
||||||
setEditingGroupId(fg.id);
|
setEditingGroupId(fg.id);
|
||||||
setEditingGroupName(fg.name);
|
setEditingGroupName(fg.name);
|
||||||
|
setEditingGroupStartDate(fg.start_date ? fg.start_date.split('T')[0] : '');
|
||||||
|
setEditingGroupEndDate(fg.end_date ? fg.end_date.split('T')[0] : '');
|
||||||
};
|
};
|
||||||
|
|
||||||
const cancelEditGroup = () => {
|
const cancelEditGroup = () => {
|
||||||
setEditingGroupId(null);
|
setEditingGroupId(null);
|
||||||
setEditingGroupName('');
|
setEditingGroupName('');
|
||||||
|
setEditingGroupStartDate('');
|
||||||
|
setEditingGroupEndDate('');
|
||||||
};
|
};
|
||||||
|
|
||||||
const saveGroup = async (fgId: string) => {
|
const saveGroup = async (fgId: string) => {
|
||||||
@@ -95,6 +108,8 @@ export default function FunctionGroupEditor({
|
|||||||
try {
|
try {
|
||||||
await api.put(`/projects/${projectId}/function-groups/${fgId}`, {
|
await api.put(`/projects/${projectId}/function-groups/${fgId}`, {
|
||||||
name: editingGroupName.trim(),
|
name: editingGroupName.trim(),
|
||||||
|
start_date: editingGroupStartDate || null,
|
||||||
|
end_date: editingGroupEndDate || null,
|
||||||
});
|
});
|
||||||
setEditingGroupId(null);
|
setEditingGroupId(null);
|
||||||
onReload();
|
onReload();
|
||||||
@@ -128,6 +143,7 @@ export default function FunctionGroupEditor({
|
|||||||
setEditingFuncId(fn.id);
|
setEditingFuncId(fn.id);
|
||||||
setEditingFuncData({
|
setEditingFuncData({
|
||||||
name: fn.name,
|
name: fn.name,
|
||||||
|
function_type: fn.function_type || 'crew',
|
||||||
quantity: fn.quantity,
|
quantity: fn.quantity,
|
||||||
daily_costs: fn.daily_costs,
|
daily_costs: fn.daily_costs,
|
||||||
total_costs: fn.total_costs,
|
total_costs: fn.total_costs,
|
||||||
@@ -145,6 +161,7 @@ export default function FunctionGroupEditor({
|
|||||||
try {
|
try {
|
||||||
await api.put(`/projects/${projectId}/function-groups/${fgId}/functions/${funcId}`, {
|
await api.put(`/projects/${projectId}/function-groups/${fgId}/functions/${funcId}`, {
|
||||||
name: editingFuncData.name.trim(),
|
name: editingFuncData.name.trim(),
|
||||||
|
function_type: editingFuncData.function_type,
|
||||||
quantity: editingFuncData.quantity,
|
quantity: editingFuncData.quantity,
|
||||||
daily_costs: editingFuncData.daily_costs,
|
daily_costs: editingFuncData.daily_costs,
|
||||||
total_costs: editingFuncData.total_costs,
|
total_costs: editingFuncData.total_costs,
|
||||||
@@ -179,8 +196,12 @@ export default function FunctionGroupEditor({
|
|||||||
await api.post(`/projects/${projectId}/function-groups`, {
|
await api.post(`/projects/${projectId}/function-groups`, {
|
||||||
name: newGroupName.trim(),
|
name: newGroupName.trim(),
|
||||||
sort_order: functionGroups.length,
|
sort_order: functionGroups.length,
|
||||||
|
start_date: newGroupStartDate || null,
|
||||||
|
end_date: newGroupEndDate || null,
|
||||||
});
|
});
|
||||||
setNewGroupName('');
|
setNewGroupName('');
|
||||||
|
setNewGroupStartDate('');
|
||||||
|
setNewGroupEndDate('');
|
||||||
setShowNewGroup(false);
|
setShowNewGroup(false);
|
||||||
onReload();
|
onReload();
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
@@ -194,7 +215,7 @@ export default function FunctionGroupEditor({
|
|||||||
setNewFuncMap(prev => ({ ...prev, [fgId]: true }));
|
setNewFuncMap(prev => ({ ...prev, [fgId]: true }));
|
||||||
setNewFuncData(prev => ({
|
setNewFuncData(prev => ({
|
||||||
...prev,
|
...prev,
|
||||||
[fgId]: { name: '', quantity: 1, daily_costs: 0, total_costs: 0 },
|
[fgId]: { name: '', function_type: 'crew', quantity: 1, daily_costs: 0, total_costs: 0 },
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -218,6 +239,7 @@ export default function FunctionGroupEditor({
|
|||||||
try {
|
try {
|
||||||
await api.post(`/projects/${projectId}/function-groups/${fgId}/functions`, {
|
await api.post(`/projects/${projectId}/function-groups/${fgId}/functions`, {
|
||||||
name: data.name.trim(),
|
name: data.name.trim(),
|
||||||
|
function_type: data.function_type,
|
||||||
quantity: data.quantity,
|
quantity: data.quantity,
|
||||||
daily_costs: data.daily_costs,
|
daily_costs: data.daily_costs,
|
||||||
total_costs: data.total_costs,
|
total_costs: data.total_costs,
|
||||||
@@ -241,40 +263,58 @@ export default function FunctionGroupEditor({
|
|||||||
{canWrite && (
|
{canWrite && (
|
||||||
<div className="flex justify-end">
|
<div className="flex justify-end">
|
||||||
{showNewGroup ? (
|
{showNewGroup ? (
|
||||||
<div className="flex items-center gap-2 w-full">
|
<div className="flex flex-col gap-2 w-full">
|
||||||
<input
|
<div className="flex items-center gap-2">
|
||||||
type="text"
|
<input
|
||||||
value={newGroupName}
|
type="text"
|
||||||
onChange={e => setNewGroupName(e.target.value)}
|
value={newGroupName}
|
||||||
placeholder="New function group name..."
|
onChange={e => setNewGroupName(e.target.value)}
|
||||||
className={inputClass}
|
placeholder="New function group name..."
|
||||||
autoFocus
|
className={inputClass}
|
||||||
onKeyDown={e => {
|
autoFocus
|
||||||
if (e.key === 'Enter') addNewGroup();
|
onKeyDown={e => {
|
||||||
if (e.key === 'Escape') {
|
if (e.key === 'Enter') addNewGroup();
|
||||||
|
if (e.key === 'Escape') {
|
||||||
|
setShowNewGroup(false);
|
||||||
|
setNewGroupName('');
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
type="date"
|
||||||
|
value={newGroupStartDate}
|
||||||
|
onChange={e => setNewGroupStartDate(e.target.value)}
|
||||||
|
className={inputClass + ' w-auto'}
|
||||||
|
title="Start date"
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
type="date"
|
||||||
|
value={newGroupEndDate}
|
||||||
|
onChange={e => setNewGroupEndDate(e.target.value)}
|
||||||
|
className={inputClass + ' w-auto'}
|
||||||
|
title="End date"
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
onClick={addNewGroup}
|
||||||
|
disabled={saving || !newGroupName.trim()}
|
||||||
|
className="flex items-center gap-1 px-3 py-1.5 bg-primary text-white rounded-lg hover:bg-primary-dark transition-colors text-xs disabled:opacity-50"
|
||||||
|
>
|
||||||
|
<Save size={14} />
|
||||||
|
Save
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={() => {
|
||||||
setShowNewGroup(false);
|
setShowNewGroup(false);
|
||||||
setNewGroupName('');
|
setNewGroupName('');
|
||||||
}
|
setNewGroupStartDate('');
|
||||||
}}
|
setNewGroupEndDate('');
|
||||||
/>
|
}}
|
||||||
<button
|
className="flex items-center gap-1 px-3 py-1.5 bg-surface border border-border rounded-lg hover:bg-gray-50 text-xs"
|
||||||
onClick={addNewGroup}
|
>
|
||||||
disabled={saving || !newGroupName.trim()}
|
<X size={14} />
|
||||||
className="flex items-center gap-1 px-3 py-1.5 bg-primary text-white rounded-lg hover:bg-primary-dark transition-colors text-xs disabled:opacity-50"
|
Cancel
|
||||||
>
|
</button>
|
||||||
<Save size={14} />
|
</div>
|
||||||
Save
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onClick={() => {
|
|
||||||
setShowNewGroup(false);
|
|
||||||
setNewGroupName('');
|
|
||||||
}}
|
|
||||||
className="flex items-center gap-1 px-3 py-1.5 bg-surface border border-border rounded-lg hover:bg-gray-50 text-xs"
|
|
||||||
>
|
|
||||||
<X size={14} />
|
|
||||||
Cancel
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<button
|
<button
|
||||||
@@ -311,7 +351,7 @@ export default function FunctionGroupEditor({
|
|||||||
<FolderOpen size={18} className="text-primary flex-shrink-0" />
|
<FolderOpen size={18} className="text-primary flex-shrink-0" />
|
||||||
|
|
||||||
{isEditingGroup ? (
|
{isEditingGroup ? (
|
||||||
<div className="flex items-center gap-2 flex-1">
|
<div className="flex items-center gap-2 flex-1 flex-wrap">
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
value={editingGroupName}
|
value={editingGroupName}
|
||||||
@@ -323,6 +363,20 @@ export default function FunctionGroupEditor({
|
|||||||
if (e.key === 'Escape') cancelEditGroup();
|
if (e.key === 'Escape') cancelEditGroup();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
<input
|
||||||
|
type="date"
|
||||||
|
value={editingGroupStartDate}
|
||||||
|
onChange={e => setEditingGroupStartDate(e.target.value)}
|
||||||
|
className={inputClass + ' w-auto'}
|
||||||
|
title="Start date"
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
type="date"
|
||||||
|
value={editingGroupEndDate}
|
||||||
|
onChange={e => setEditingGroupEndDate(e.target.value)}
|
||||||
|
className={inputClass + ' w-auto'}
|
||||||
|
title="End date"
|
||||||
|
/>
|
||||||
<button
|
<button
|
||||||
onClick={() => saveGroup(fg.id)}
|
onClick={() => saveGroup(fg.id)}
|
||||||
disabled={saving || !editingGroupName.trim()}
|
disabled={saving || !editingGroupName.trim()}
|
||||||
@@ -338,7 +392,16 @@ export default function FunctionGroupEditor({
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<span className="font-medium text-text-primary text-sm flex-1">{fg.name}</span>
|
<>
|
||||||
|
<span className="font-medium text-text-primary text-sm flex-1">{fg.name}</span>
|
||||||
|
{(fg.start_date || fg.end_date) && (
|
||||||
|
<span className="text-xs text-text-secondary ml-2">
|
||||||
|
{fg.start_date && new Date(fg.start_date).toLocaleDateString('de-DE', {day:'2-digit', month:'2-digit', year:'numeric'})}
|
||||||
|
{fg.start_date && fg.end_date && ' – '}
|
||||||
|
{fg.end_date && new Date(fg.end_date).toLocaleDateString('de-DE', {day:'2-digit', month:'2-digit', year:'numeric'})}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<span className="text-xs text-text-secondary">Sort: {fg.sort_order}</span>
|
<span className="text-xs text-text-secondary">Sort: {fg.sort_order}</span>
|
||||||
@@ -384,7 +447,7 @@ export default function FunctionGroupEditor({
|
|||||||
className="px-4 py-3 flex items-center justify-between hover:bg-gray-50"
|
className="px-4 py-3 flex items-center justify-between hover:bg-gray-50"
|
||||||
>
|
>
|
||||||
{isEditingFunc && editingFuncData ? (
|
{isEditingFunc && editingFuncData ? (
|
||||||
<div className="flex-1 grid grid-cols-4 gap-2 items-end">
|
<div className="flex-1 grid grid-cols-5 gap-2 items-end">
|
||||||
<div>
|
<div>
|
||||||
<label className={labelClass}>Name</label>
|
<label className={labelClass}>Name</label>
|
||||||
<input
|
<input
|
||||||
@@ -403,6 +466,22 @@ export default function FunctionGroupEditor({
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<label className={labelClass}>Type</label>
|
||||||
|
<select
|
||||||
|
value={editingFuncData.function_type}
|
||||||
|
onChange={e =>
|
||||||
|
setEditingFuncData(prev =>
|
||||||
|
prev ? { ...prev, function_type: e.target.value } : prev
|
||||||
|
)
|
||||||
|
}
|
||||||
|
className={inputClass}
|
||||||
|
>
|
||||||
|
<option value="crew">Crew</option>
|
||||||
|
<option value="equipment">Equipment</option>
|
||||||
|
<option value="transport">Transport</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label className={labelClass}>Qty</label>
|
<label className={labelClass}>Qty</label>
|
||||||
<input
|
<input
|
||||||
@@ -457,7 +536,7 @@ export default function FunctionGroupEditor({
|
|||||||
className={inputClass}
|
className={inputClass}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="col-span-4 flex items-center gap-2 mt-1">
|
<div className="col-span-5 flex items-center gap-2 mt-1">
|
||||||
<button
|
<button
|
||||||
onClick={() => saveFunc(fg.id, fn.id)}
|
onClick={() => saveFunc(fg.id, fn.id)}
|
||||||
disabled={saving || !editingFuncData.name.trim()}
|
disabled={saving || !editingFuncData.name.trim()}
|
||||||
@@ -479,10 +558,15 @@ export default function FunctionGroupEditor({
|
|||||||
<>
|
<>
|
||||||
<div className="flex items-center gap-3 flex-1">
|
<div className="flex items-center gap-3 flex-1">
|
||||||
<ListChecks size={16} className="text-text-secondary flex-shrink-0" />
|
<ListChecks size={16} className="text-text-secondary flex-shrink-0" />
|
||||||
<div className="grid grid-cols-4 gap-4 flex-1">
|
<div className="grid grid-cols-5 gap-4 flex-1">
|
||||||
<div>
|
<div>
|
||||||
<p className="text-sm text-text-primary">{fn.name}</p>
|
<p className="text-sm text-text-primary">{fn.name}</p>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<span className="inline-block px-2 py-0.5 text-xs rounded-full bg-blue-100 text-blue-800">
|
||||||
|
{fn.function_type}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p className="text-xs text-text-secondary">
|
<p className="text-xs text-text-secondary">
|
||||||
Qty: {fn.quantity}
|
Qty: {fn.quantity}
|
||||||
@@ -538,7 +622,7 @@ export default function FunctionGroupEditor({
|
|||||||
{/* Add new function form */}
|
{/* Add new function form */}
|
||||||
{isAddingFunc && (
|
{isAddingFunc && (
|
||||||
<div className="px-4 py-3 border-t border-border bg-gray-50">
|
<div className="px-4 py-3 border-t border-border bg-gray-50">
|
||||||
<div className="grid grid-cols-4 gap-2 items-end mb-2">
|
<div className="grid grid-cols-5 gap-2 items-end mb-2">
|
||||||
<div>
|
<div>
|
||||||
<label className={labelClass}>Name</label>
|
<label className={labelClass}>Name</label>
|
||||||
<input
|
<input
|
||||||
@@ -558,6 +642,26 @@ export default function FunctionGroupEditor({
|
|||||||
autoFocus
|
autoFocus
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<label className={labelClass}>Type</label>
|
||||||
|
<select
|
||||||
|
value={newFuncData[fg.id]?.function_type || 'crew'}
|
||||||
|
onChange={e =>
|
||||||
|
setNewFuncData(prev => ({
|
||||||
|
...prev,
|
||||||
|
[fg.id]: {
|
||||||
|
...prev[fg.id],
|
||||||
|
function_type: e.target.value,
|
||||||
|
},
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
className={inputClass}
|
||||||
|
>
|
||||||
|
<option value="crew">Crew</option>
|
||||||
|
<option value="equipment">Equipment</option>
|
||||||
|
<option value="transport">Transport</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label className={labelClass}>Qty</label>
|
<label className={labelClass}>Qty</label>
|
||||||
<input
|
<input
|
||||||
|
|||||||
@@ -33,12 +33,15 @@ interface FunctionGroupItem {
|
|||||||
name: string;
|
name: string;
|
||||||
project_id: string;
|
project_id: string;
|
||||||
sort_order: number;
|
sort_order: number;
|
||||||
|
start_date: string | null;
|
||||||
|
end_date: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface FunctionItem {
|
interface FunctionItem {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
function_group_id: string;
|
function_group_id: string;
|
||||||
|
function_type: string;
|
||||||
quantity: number;
|
quantity: number;
|
||||||
daily_costs: number;
|
daily_costs: number;
|
||||||
total_costs: number;
|
total_costs: number;
|
||||||
|
|||||||
Reference in New Issue
Block a user