fix(android): root field inventory at inspection Yacimiento
This commit is contained in:
@@ -1,68 +0,0 @@
|
|||||||
name: F6.1 Android Yacimiento root
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- 'hotfix/f6-1-inspection-planning-hierarchy'
|
|
||||||
paths:
|
|
||||||
- '.github/workflows/f6-1-android-yacimiento-root.yml'
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
apply:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
ref: hotfix/f6-1-inspection-planning-hierarchy
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Align Android field root with frozen Yacimiento scope
|
|
||||||
run: |
|
|
||||||
python - <<'PY'
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
dh = Path('android-app/app/src/main/java/com/korexlabs/dhinspeccion/data/DhMobile.kt')
|
|
||||||
text = dh.read_text()
|
|
||||||
before = '''data class VisitDetail(\n val id: String,\n val code: String,\n val objective: String? = null,\n val status: String,\n val operationalArea: AssetSummary? = null,'''
|
|
||||||
after = '''data class VisitDetail(\n val id: String,\n val code: String,\n val objective: String? = null,\n val status: String,\n val scopeAsset: AssetSummary? = null,\n val operationalArea: AssetSummary? = null,'''
|
|
||||||
if text.count(before) != 1:
|
|
||||||
raise SystemExit(f'VisitDetail insertion: {text.count(before)}')
|
|
||||||
dh.write_text(text.replace(before, after))
|
|
||||||
|
|
||||||
vm = Path('android-app/app/src/main/java/com/korexlabs/dhinspeccion/MainViewModel.kt')
|
|
||||||
text = vm.read_text()
|
|
||||||
replacements = {
|
|
||||||
'inventoryParentId = visit?.operationalArea?.id': 'inventoryParentId = visit?.scopeAsset?.id ?: visit?.operationalArea?.id',
|
|
||||||
'val effectiveParentId = parentId ?: inventoryParentId ?: currentVisit.operationalArea?.id': 'val effectiveParentId = parentId ?: inventoryParentId ?: currentVisit.scopeAsset?.id ?: currentVisit.operationalArea?.id',
|
|
||||||
'val effectiveParentId = parentId ?: currentVisit.operationalArea?.id': 'val effectiveParentId = parentId ?: currentVisit.scopeAsset?.id ?: currentVisit.operationalArea?.id',
|
|
||||||
'val effectiveParentId = inventoryParentId ?: visit?.operationalArea?.id': 'val effectiveParentId = inventoryParentId ?: visit?.scopeAsset?.id ?: visit?.operationalArea?.id',
|
|
||||||
}
|
|
||||||
for before, after in replacements.items():
|
|
||||||
count = text.count(before)
|
|
||||||
if count < 1:
|
|
||||||
raise SystemExit(f'MainViewModel root missing: {before}')
|
|
||||||
text = text.replace(before, after)
|
|
||||||
vm.write_text(text)
|
|
||||||
|
|
||||||
Path('.github/workflows/f6-1-android-yacimiento-root.yml').unlink()
|
|
||||||
PY
|
|
||||||
|
|
||||||
- name: Verify Android root contract
|
|
||||||
run: |
|
|
||||||
set -Eeuo pipefail
|
|
||||||
grep -Fq 'val scopeAsset: AssetSummary? = null' android-app/app/src/main/java/com/korexlabs/dhinspeccion/data/DhMobile.kt
|
|
||||||
grep -Fq 'currentVisit.scopeAsset?.id ?: currentVisit.operationalArea?.id' android-app/app/src/main/java/com/korexlabs/dhinspeccion/MainViewModel.kt
|
|
||||||
grep -Fq 'visit?.scopeAsset?.id ?: visit?.operationalArea?.id' android-app/app/src/main/java/com/korexlabs/dhinspeccion/MainViewModel.kt
|
|
||||||
|
|
||||||
- name: Commit Android scope fix
|
|
||||||
run: |
|
|
||||||
set -Eeuo pipefail
|
|
||||||
git config user.name 'github-actions[bot]'
|
|
||||||
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
|
|
||||||
git add android-app .github/workflows/f6-1-android-yacimiento-root.yml
|
|
||||||
git diff --cached --check
|
|
||||||
git commit -m 'fix(android): root field inventory at inspection Yacimiento'
|
|
||||||
git push origin HEAD:hotfix/f6-1-inspection-planning-hierarchy
|
|
||||||
@@ -115,7 +115,7 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
|||||||
fun openVisit(id: String) = launchBusy {
|
fun openVisit(id: String) = launchBusy {
|
||||||
visit = repository.visit(id)
|
visit = repository.visit(id)
|
||||||
inventory = emptyList()
|
inventory = emptyList()
|
||||||
inventoryParentId = visit?.operationalArea?.id
|
inventoryParentId = visit?.scopeAsset?.id ?: visit?.operationalArea?.id
|
||||||
fieldTypes = emptyList()
|
fieldTypes = emptyList()
|
||||||
selectedFieldAsset = null
|
selectedFieldAsset = null
|
||||||
clearFindingState()
|
clearFindingState()
|
||||||
@@ -137,7 +137,7 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
|||||||
val id = visit?.id ?: return
|
val id = visit?.id ?: return
|
||||||
launchBusy {
|
launchBusy {
|
||||||
visit = repository.startVisit(id)
|
visit = repository.startVisit(id)
|
||||||
inventoryParentId = visit?.operationalArea?.id
|
inventoryParentId = visit?.scopeAsset?.id ?: visit?.operationalArea?.id
|
||||||
notice = "Inspección iniciada."
|
notice = "Inspección iniciada."
|
||||||
loadActsInternal(id, selectDraft = true)
|
loadActsInternal(id, selectDraft = true)
|
||||||
loadVisitsInternal()
|
loadVisitsInternal()
|
||||||
@@ -197,7 +197,7 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
|||||||
fun searchInventory(search: String, parentId: String? = null) {
|
fun searchInventory(search: String, parentId: String? = null) {
|
||||||
val currentVisit = visit ?: return
|
val currentVisit = visit ?: return
|
||||||
launchBusy {
|
launchBusy {
|
||||||
val effectiveParentId = parentId ?: inventoryParentId ?: currentVisit.operationalArea?.id
|
val effectiveParentId = parentId ?: inventoryParentId ?: currentVisit.scopeAsset?.id ?: currentVisit.operationalArea?.id
|
||||||
inventory = repository.fieldInventory(currentVisit.id, search, effectiveParentId).data
|
inventory = repository.fieldInventory(currentVisit.id, search, effectiveParentId).data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -205,7 +205,7 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
|||||||
fun loadFieldTypes(parentId: String? = null) {
|
fun loadFieldTypes(parentId: String? = null) {
|
||||||
val currentVisit = visit ?: return
|
val currentVisit = visit ?: return
|
||||||
launchBusy {
|
launchBusy {
|
||||||
val effectiveParentId = parentId ?: currentVisit.operationalArea?.id
|
val effectiveParentId = parentId ?: currentVisit.scopeAsset?.id ?: currentVisit.operationalArea?.id
|
||||||
inventoryParentId = effectiveParentId
|
inventoryParentId = effectiveParentId
|
||||||
fieldTypes = repository.fieldTypes(currentVisit.id, parentId).data
|
fieldTypes = repository.fieldTypes(currentVisit.id, parentId).data
|
||||||
inventory = repository.fieldInventory(currentVisit.id, null, effectiveParentId).data
|
inventory = repository.fieldInventory(currentVisit.id, null, effectiveParentId).data
|
||||||
@@ -213,7 +213,7 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun reloadCurrentInventory(visitId: String) {
|
private suspend fun reloadCurrentInventory(visitId: String) {
|
||||||
val effectiveParentId = inventoryParentId ?: visit?.operationalArea?.id
|
val effectiveParentId = inventoryParentId ?: visit?.scopeAsset?.id ?: visit?.operationalArea?.id
|
||||||
inventory = repository.fieldInventory(visitId, null, effectiveParentId).data
|
inventory = repository.fieldInventory(visitId, null, effectiveParentId).data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -154,6 +154,7 @@ data class VisitDetail(
|
|||||||
val code: String,
|
val code: String,
|
||||||
val objective: String? = null,
|
val objective: String? = null,
|
||||||
val status: String,
|
val status: String,
|
||||||
|
val scopeAsset: AssetSummary? = null,
|
||||||
val operationalArea: AssetSummary? = null,
|
val operationalArea: AssetSummary? = null,
|
||||||
val operatorCompany: AssetSummary? = null,
|
val operatorCompany: AssetSummary? = null,
|
||||||
val leadInspector: PersonSummary? = null,
|
val leadInspector: PersonSummary? = null,
|
||||||
|
|||||||
Reference in New Issue
Block a user