no-mistakes(review): Extend legacy self-heal rename; clear stale Mould & Damp priority default
This commit is contained in:
+11
-1
@@ -20,7 +20,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def ensure_legacy_schema(conn) -> None:
|
||||
"""Add columns from alembic migrations that legacy create_all databases lack."""
|
||||
"""Add columns/data changes from alembic migrations that legacy create_all databases lack."""
|
||||
result = await conn.execute(text("PRAGMA table_info(categories)"))
|
||||
columns = {row[1] for row in result}
|
||||
if "show_in_form" not in columns:
|
||||
@@ -28,6 +28,16 @@ async def ensure_legacy_schema(conn) -> None:
|
||||
text("ALTER TABLE categories ADD COLUMN show_in_form BOOLEAN NOT NULL DEFAULT 1")
|
||||
)
|
||||
logger.info("Added missing categories.show_in_form column (legacy database)")
|
||||
result = await conn.execute(
|
||||
text(
|
||||
"UPDATE categories SET name = 'Missing Item' "
|
||||
"WHERE type = 'cs' AND name = 'Lost Property' AND parent_id IS NULL "
|
||||
"AND NOT EXISTS (SELECT 1 FROM categories c2 "
|
||||
"WHERE c2.type = 'cs' AND c2.name = 'Missing Item' AND c2.parent_id IS NULL)"
|
||||
)
|
||||
)
|
||||
if result.rowcount:
|
||||
logger.info("Renamed legacy 'Lost Property' category to 'Missing Item'")
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
|
||||
@@ -111,19 +111,19 @@
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">Priority</label>
|
||||
<div class="grid grid-cols-2 md:grid-cols-4 gap-2">
|
||||
<label class="flex items-center p-3 border rounded-lg cursor-pointer hover:bg-gray-50" :class="form.priority === 'urgent' ? 'border-red-500 bg-red-50' : 'border-gray-200'">
|
||||
<input type="radio" name="priority" value="urgent" x-model="form.priority" class="sr-only">
|
||||
<input type="radio" name="priority" value="urgent" x-model="form.priority" @change="priorityAuto = false" class="sr-only">
|
||||
<span class="text-sm">🔴 Urgent</span>
|
||||
</label>
|
||||
<label class="flex items-center p-3 border rounded-lg cursor-pointer hover:bg-gray-50" :class="form.priority === 'high' ? 'border-orange-500 bg-orange-50' : 'border-gray-200'">
|
||||
<input type="radio" name="priority" value="high" x-model="form.priority" class="sr-only">
|
||||
<input type="radio" name="priority" value="high" x-model="form.priority" @change="priorityAuto = false" class="sr-only">
|
||||
<span class="text-sm">🟠 High</span>
|
||||
</label>
|
||||
<label class="flex items-center p-3 border rounded-lg cursor-pointer hover:bg-gray-50" :class="form.priority === 'medium' ? 'border-yellow-500 bg-yellow-50' : 'border-gray-200'">
|
||||
<input type="radio" name="priority" value="medium" x-model="form.priority" class="sr-only">
|
||||
<input type="radio" name="priority" value="medium" x-model="form.priority" @change="priorityAuto = false" class="sr-only">
|
||||
<span class="text-sm">🟡 Medium</span>
|
||||
</label>
|
||||
<label class="flex items-center p-3 border rounded-lg cursor-pointer hover:bg-gray-50" :class="form.priority === 'low' ? 'border-green-500 bg-green-50' : 'border-gray-200'">
|
||||
<input type="radio" name="priority" value="low" x-model="form.priority" class="sr-only">
|
||||
<input type="radio" name="priority" value="low" x-model="form.priority" @change="priorityAuto = false" class="sr-only">
|
||||
<span class="text-sm">🟢 Low</span>
|
||||
</label>
|
||||
</div>
|
||||
@@ -207,6 +207,7 @@
|
||||
reporter: '',
|
||||
reported_via: ''
|
||||
},
|
||||
priorityAuto: false,
|
||||
categories: [],
|
||||
subCategories: [],
|
||||
unitGroups: {},
|
||||
@@ -237,6 +238,7 @@
|
||||
} else {
|
||||
this.form.priority = '';
|
||||
}
|
||||
this.priorityAuto = false;
|
||||
this.loadCategories();
|
||||
},
|
||||
|
||||
@@ -319,8 +321,16 @@
|
||||
'Aluminum/Glass': 'Windows, doors, sliding/fixed panels, glass and mirror replacement.'
|
||||
};
|
||||
if (parent?.name && hints[parent.name]) this.selectedCategoryHint = hints[parent.name];
|
||||
// Mould & Damp defaults to Medium priority
|
||||
if (parent?.name === 'Mould & Damp' && !this.form.priority) this.form.priority = 'medium';
|
||||
// Mould & Damp defaults to Medium priority; clear the auto-default
|
||||
// when switching away so a non-Mould ticket doesn't keep it silently
|
||||
if (parent?.name !== 'Mould & Damp' && this.priorityAuto) {
|
||||
this.form.priority = '';
|
||||
this.priorityAuto = false;
|
||||
}
|
||||
if (parent?.name === 'Mould & Damp' && !this.form.priority) {
|
||||
this.form.priority = 'medium';
|
||||
this.priorityAuto = true;
|
||||
}
|
||||
},
|
||||
|
||||
handlePhotos(e) {
|
||||
|
||||
Reference in New Issue
Block a user