FEAT: Rename 'Depth' to 'Draft' in Berth model and update related components for consistency
This commit is contained in:
parent
adf226a38a
commit
150f7f9aa9
|
|
@ -177,15 +177,15 @@
|
|||
<v-col cols="12" md="4">
|
||||
<v-text-field
|
||||
v-if="editMode"
|
||||
v-model="editedBerth.Depth"
|
||||
label="Depth (ft/m)"
|
||||
v-model="editedBerth.Draft"
|
||||
label="Draft (ft/m)"
|
||||
variant="outlined"
|
||||
density="compact"
|
||||
/>
|
||||
<div v-else class="field-display">
|
||||
<span class="field-label">Depth:</span>
|
||||
<span class="field-label">Draft:</span>
|
||||
<span class="field-value">
|
||||
{{ displayMeasurement(berth.Depth) }}
|
||||
{{ displayMeasurement(berth.Draft) }}
|
||||
</span>
|
||||
</div>
|
||||
</v-col>
|
||||
|
|
|
|||
|
|
@ -427,68 +427,82 @@ export const getInterestByFieldAsync = async (fieldName: string, value: any): Pr
|
|||
export const getBerths = async () => {
|
||||
console.log('[nocodb.getBerths] Fetching berths from NocoDB...');
|
||||
|
||||
const result = await $fetch<BerthsResponse>(createTableUrl(Table.Berth), {
|
||||
headers: {
|
||||
"xc-token": getNocoDbConfiguration().token,
|
||||
},
|
||||
params: {
|
||||
limit: 1000,
|
||||
// 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'
|
||||
},
|
||||
});
|
||||
try {
|
||||
// First try with basic query - no field expansion to avoid 404
|
||||
const result = await $fetch<BerthsResponse>(createTableUrl(Table.Berth), {
|
||||
headers: {
|
||||
"xc-token": getNocoDbConfiguration().token,
|
||||
},
|
||||
params: {
|
||||
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;
|
||||
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'] || '';
|
||||
|
||||
// First sort by letter zone
|
||||
const letterCompare = letterA.localeCompare(letterB);
|
||||
if (letterCompare !== 0) {
|
||||
return letterCompare;
|
||||
// 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);
|
||||
}
|
||||
|
||||
// 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);
|
||||
});
|
||||
|
||||
// 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] 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;
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
export const getBerthById = async (id: string) => {
|
||||
console.log('[nocodb.getBerthById] Fetching berth ID:', id);
|
||||
|
||||
const result = await $fetch<Berth>(`${createTableUrl(Table.Berth)}/${id}`, {
|
||||
headers: {
|
||||
"xc-token": getNocoDbConfiguration().token,
|
||||
},
|
||||
params: {
|
||||
// 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'
|
||||
}
|
||||
});
|
||||
|
||||
console.log('[nocodb.getBerthById] Successfully fetched berth:', result.Id);
|
||||
return result;
|
||||
try {
|
||||
// Use basic query first to avoid 404 field expansion errors
|
||||
const result = await $fetch<Berth>(`${createTableUrl(Table.Berth)}/${id}`, {
|
||||
headers: {
|
||||
"xc-token": getNocoDbConfiguration().token,
|
||||
},
|
||||
params: {
|
||||
// Start with basic fields only
|
||||
fields: '*'
|
||||
}
|
||||
});
|
||||
|
||||
console.log('[nocodb.getBerthById] Successfully fetched berth:', result.Id);
|
||||
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> => {
|
||||
|
|
@ -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
|
||||
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 = [
|
||||
"Mooring Number",
|
||||
"Area",
|
||||
|
|
@ -507,7 +521,7 @@ export const updateBerth = async (id: string, data: Partial<Berth>): Promise<Ber
|
|||
"Water Depth",
|
||||
"Length",
|
||||
"Width",
|
||||
"Depth",
|
||||
"Draft", // Changed from "Depth" to "Draft"
|
||||
"Side Pontoon",
|
||||
"Power Capacity",
|
||||
"Voltage",
|
||||
|
|
|
|||
|
|
@ -79,10 +79,15 @@ export interface Berth {
|
|||
Area: string; // Area enum values: A, B, C, D, E
|
||||
Status: string; // BerthStatus enum values
|
||||
"Nominal Boat Size": number; // in feet (imperial)
|
||||
"Nominal Boat Size (Metric)": number; // formula field - read only
|
||||
"Water Depth": number; // in feet
|
||||
"Water Depth (Metric)": number; // formula field - read only
|
||||
Length: number; // in feet
|
||||
"Length (Metric)": number; // formula field - read only
|
||||
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
|
||||
"Power Capacity": number;
|
||||
Voltage: number;
|
||||
|
|
@ -95,10 +100,6 @@ export interface Berth {
|
|||
Access: string; // Access enum values
|
||||
Price: number;
|
||||
"Interested Parties"?: InterestedParty[];
|
||||
"Map Data"?: {};
|
||||
"Water Depth Is Minimum"?: boolean;
|
||||
"Width Is Minimum"?: boolean;
|
||||
"Berth Approved"?: boolean;
|
||||
"Created At"?: string;
|
||||
"Updated At"?: string;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue