Jacob Schmidt bdc1e36e63 Implement interactive garage UI with service-based client bridge
- replace placeholder garage interaction with real UI open flow
- add catalog/session/UI bridge services for hydrate, sync, store, and retrieve actions
- migrate garage web UI bundle to new app shell/runtime structure
- align org/store function naming with shared init and UI bridge patterns
2026-03-14 03:06:18 -05:00

88 lines
2.3 KiB
JavaScript

(function () {
const GarageApp = (window.GarageApp = window.GarageApp || {});
const store = GarageApp.store;
const bridge = window.ForgeWebUI.createBridge({
closeEvent: "garage::close",
globalName: "ForgeBridge",
readyEvent: "garage::ready",
});
function requestClose() {
return bridge.close({});
}
function requestRefresh() {
return bridge.send("garage::refresh", {});
}
function requestRetrieve(payload) {
return bridge.send("garage::vehicle::retrieve::request", payload);
}
function requestStore(payload) {
return bridge.send("garage::vehicle::store::request", payload);
}
function notifyReady() {
return bridge.ready({ loaded: true });
}
function hydrate(payloadData) {
GarageApp.data.applyHydratePayload(payloadData);
store.hydrateFromPayload(payloadData);
}
bridge.on("garage::hydrate", hydrate);
bridge.on("garage::sync", hydrate);
bridge.on("garage::retrieve::success", (payloadData) => {
store.finishAction();
if (GarageApp.actions) {
GarageApp.actions.showNotice(
"success",
payloadData.message || "Vehicle retrieved from the garage.",
);
}
});
bridge.on("garage::retrieve::failure", (payloadData) => {
store.finishAction();
if (GarageApp.actions) {
GarageApp.actions.showNotice(
"error",
payloadData.message || "Unable to retrieve vehicle.",
);
}
});
bridge.on("garage::store::success", (payloadData) => {
store.finishAction();
if (GarageApp.actions) {
GarageApp.actions.showNotice(
"success",
payloadData.message || "Vehicle stored in the garage.",
);
}
});
bridge.on("garage::store::failure", (payloadData) => {
store.finishAction();
if (GarageApp.actions) {
GarageApp.actions.showNotice(
"error",
payloadData.message || "Unable to store vehicle.",
);
}
});
GarageApp.bridge = {
notifyReady,
receive: bridge.receive,
requestClose,
requestRefresh,
requestRetrieve,
requestStore,
sendEvent: bridge.send,
};
})();