FEAT: Rename 'Depth' to 'Draft' in Berth model and update related components for consistency

This commit is contained in:
Matt 2025-06-17 16:18:29 +02:00
parent adf226a38a
commit 150f7f9aa9
3 changed files with 76 additions and 61 deletions

View File

@ -177,15 +177,15 @@
<v-col cols="12" md="4"> <v-col cols="12" md="4">
<v-text-field <v-text-field
v-if="editMode" v-if="editMode"
v-model="editedBerth.Depth" v-model="editedBerth.Draft"
label="Depth (ft/m)" label="Draft (ft/m)"
variant="outlined" variant="outlined"
density="compact" density="compact"
/> />
<div v-else class="field-display"> <div v-else class="field-display">
<span class="field-label">Depth:</span> <span class="field-label">Draft:</span>
<span class="field-value"> <span class="field-value">
{{ displayMeasurement(berth.Depth) }} {{ displayMeasurement(berth.Draft) }}
</span> </span>
</div> </div>
</v-col> </v-col>

View File

@ -427,68 +427,82 @@ export const getInterestByFieldAsync = async (fieldName: string, value: any): Pr
export const getBerths = async () => { export const getBerths = async () => {
console.log('[nocodb.getBerths] Fetching berths from NocoDB...'); console.log('[nocodb.getBerths] Fetching berths from NocoDB...');
const result = await $fetch<BerthsResponse>(createTableUrl(Table.Berth), { try {
headers: { // First try with basic query - no field expansion to avoid 404
"xc-token": getNocoDbConfiguration().token, const result = await $fetch<BerthsResponse>(createTableUrl(Table.Berth), {
}, headers: {
params: { "xc-token": getNocoDbConfiguration().token,
limit: 1000, },
// Include interested parties (expand the linked field) params: {
fields: '*,Interested Parties.Id,Interested Parties.Full Name,Interested Parties.Sales Process Level,Interested Parties.EOI Status,Interested Parties.Contract Status' limit: 1000,
}, // Start with basic fields only
}); fields: '*'
},
console.log('[nocodb.getBerths] Successfully fetched berths, count:', result.list?.length || 0);
// Sort berths by letter zone and then by number using Mooring Number
if (result.list && Array.isArray(result.list)) {
result.list.sort((a, b) => {
const berthA = a['Mooring Number'] || '';
const berthB = b['Mooring Number'] || '';
// Extract letter and number parts
const matchA = berthA.match(/^([A-Za-z]+)(\d+)$/);
const matchB = berthB.match(/^([A-Za-z]+)(\d+)$/);
if (matchA && matchB) {
const [, letterA, numberA] = matchA;
const [, letterB, numberB] = matchB;
// First sort by letter zone
const letterCompare = letterA.localeCompare(letterB);
if (letterCompare !== 0) {
return letterCompare;
}
// Then sort by number within the same letter zone
return parseInt(numberA) - parseInt(numberB);
}
// Fallback to string comparison if pattern doesn't match
return berthA.localeCompare(berthB);
}); });
console.log('[nocodb.getBerths] Berths sorted by zone and number'); console.log('[nocodb.getBerths] Successfully fetched berths, count:', result.list?.length || 0);
}
return result; // Sort berths by letter zone and then by number using Mooring Number
if (result.list && Array.isArray(result.list)) {
result.list.sort((a, b) => {
const berthA = a['Mooring Number'] || '';
const berthB = b['Mooring Number'] || '';
// Extract letter and number parts
const matchA = berthA.match(/^([A-Za-z]+)(\d+)$/);
const matchB = berthB.match(/^([A-Za-z]+)(\d+)$/);
if (matchA && matchB) {
const [, letterA, numberA] = matchA;
const [, letterB, numberB] = matchB;
// First sort by letter zone
const letterCompare = letterA.localeCompare(letterB);
if (letterCompare !== 0) {
return letterCompare;
}
// Then sort by number within the same letter zone
return parseInt(numberA) - parseInt(numberB);
}
// Fallback to string comparison if pattern doesn't match
return berthA.localeCompare(berthB);
});
console.log('[nocodb.getBerths] Berths sorted by zone and number');
}
return result;
} catch (error: any) {
console.error('[nocodb.getBerths] Error fetching berths:', error);
console.error('[nocodb.getBerths] Error details:', error instanceof Error ? error.message : 'Unknown error');
throw error;
}
}; };
export const getBerthById = async (id: string) => { export const getBerthById = async (id: string) => {
console.log('[nocodb.getBerthById] Fetching berth ID:', id); console.log('[nocodb.getBerthById] Fetching berth ID:', id);
const result = await $fetch<Berth>(`${createTableUrl(Table.Berth)}/${id}`, { try {
headers: { // Use basic query first to avoid 404 field expansion errors
"xc-token": getNocoDbConfiguration().token, const result = await $fetch<Berth>(`${createTableUrl(Table.Berth)}/${id}`, {
}, headers: {
params: { "xc-token": getNocoDbConfiguration().token,
// Include interested parties (expand the linked field) },
fields: '*,Interested Parties.Id,Interested Parties.Full Name,Interested Parties.Sales Process Level,Interested Parties.EOI Status,Interested Parties.Contract Status' params: {
} // Start with basic fields only
}); fields: '*'
}
});
console.log('[nocodb.getBerthById] Successfully fetched berth:', result.Id); console.log('[nocodb.getBerthById] Successfully fetched berth:', result.Id);
return result; return result;
} catch (error: any) {
console.error('[nocodb.getBerthById] Error fetching berth:', error);
console.error('[nocodb.getBerthById] Error details:', error instanceof Error ? error.message : 'Unknown error');
throw error;
}
}; };
export const updateBerth = async (id: string, data: Partial<Berth>): Promise<Berth> => { export const updateBerth = async (id: string, data: Partial<Berth>): Promise<Berth> => {
@ -498,7 +512,7 @@ export const updateBerth = async (id: string, data: Partial<Berth>): Promise<Ber
// Create a clean data object that matches the Berth schema // Create a clean data object that matches the Berth schema
const cleanData: Record<string, any> = {}; const cleanData: Record<string, any> = {};
// Only include fields that are part of the Berth schema // Only include fields that are part of the Berth schema (excluding formula fields)
const allowedFields = [ const allowedFields = [
"Mooring Number", "Mooring Number",
"Area", "Area",
@ -507,7 +521,7 @@ export const updateBerth = async (id: string, data: Partial<Berth>): Promise<Ber
"Water Depth", "Water Depth",
"Length", "Length",
"Width", "Width",
"Depth", "Draft", // Changed from "Depth" to "Draft"
"Side Pontoon", "Side Pontoon",
"Power Capacity", "Power Capacity",
"Voltage", "Voltage",

View File

@ -79,10 +79,15 @@ export interface Berth {
Area: string; // Area enum values: A, B, C, D, E Area: string; // Area enum values: A, B, C, D, E
Status: string; // BerthStatus enum values Status: string; // BerthStatus enum values
"Nominal Boat Size": number; // in feet (imperial) "Nominal Boat Size": number; // in feet (imperial)
"Nominal Boat Size (Metric)": number; // formula field - read only
"Water Depth": number; // in feet "Water Depth": number; // in feet
"Water Depth (Metric)": number; // formula field - read only
Length: number; // in feet Length: number; // in feet
"Length (Metric)": number; // formula field - read only
Width: number; // in feet Width: number; // in feet
Depth: number; // in feet "Width (Metric)": number; // formula field - read only
Draft: number; // in feet (was previously "Depth")
"Draft (Metric)": number; // formula field - read only
"Side Pontoon": string; // SidePontoon enum values "Side Pontoon": string; // SidePontoon enum values
"Power Capacity": number; "Power Capacity": number;
Voltage: number; Voltage: number;
@ -95,10 +100,6 @@ export interface Berth {
Access: string; // Access enum values Access: string; // Access enum values
Price: number; Price: number;
"Interested Parties"?: InterestedParty[]; "Interested Parties"?: InterestedParty[];
"Map Data"?: {};
"Water Depth Is Minimum"?: boolean;
"Width Is Minimum"?: boolean;
"Berth Approved"?: boolean;
"Created At"?: string; "Created At"?: string;
"Updated At"?: string; "Updated At"?: string;
} }