Remove unused blade settings pages not linked from UI Convert remaining frontend pages to SPA actions Convert settings user_settings and general to SPA actions Convert settings profile pages to SPA actions Convert contacts and projects add/edit pages to SPA actions Convert clients add/edit page to SPA action with loading pattern Refactor component scoped IDs from $id to $sid Fix jqhtml comment syntax and implement universal error component system Update all application code to use new unified error system Remove all backwards compatibility - unified error system complete Phase 5: Remove old response classes Phase 3-4: Ajax response handler sends new format, old helpers deprecated Phase 2: Add client-side unified error foundation Phase 1: Add server-side unified error foundation Add unified Ajax error response system with constants 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
47 lines
2.0 KiB
JavaScript
47 lines
2.0 KiB
JavaScript
// JQHTML v2 Template Integration
|
|
// Connects compiled templates to Component class
|
|
/// <reference path="./types.d.ts" />
|
|
import { process_instructions, html, register_template } from './runtime.js';
|
|
// Mixin to add template support to any component
|
|
export function with_template(ComponentClass, template_name) {
|
|
const original_on_render = ComponentClass.prototype.on_render;
|
|
ComponentClass.prototype.on_render = async function () {
|
|
// Get compiled template from registry
|
|
const global_obj = typeof window !== 'undefined' ? window : global;
|
|
const template_map = global_obj.jqhtml_components;
|
|
if (!template_map || !template_map.has(template_name)) {
|
|
throw new Error(`Template not found: ${template_name}`);
|
|
}
|
|
const template_info = template_map.get(template_name);
|
|
const render_fn = template_info.render;
|
|
// Call render function with component context
|
|
const [instructions] = render_fn.call(this, this.constructor, this.data, this.args, {});
|
|
// Process instructions into DOM
|
|
const rendered = process_instructions(instructions, this);
|
|
// Clear and append to component element
|
|
this.$.empty().append(rendered);
|
|
// Call original on_render if it exists
|
|
if (original_on_render) {
|
|
await original_on_render.call(this);
|
|
}
|
|
};
|
|
return ComponentClass;
|
|
}
|
|
// Register templates from compiled module
|
|
export function register_compiled_templates(template_map) {
|
|
// Store on global object for now (MVP approach)
|
|
const global_obj = typeof window !== 'undefined' ? window : global;
|
|
global_obj.jqhtml_components = template_map;
|
|
// Also register each template
|
|
for (const [name, info] of template_map) {
|
|
register_template(name, info.render);
|
|
}
|
|
}
|
|
// Make html function available globally for templates
|
|
if (typeof window !== 'undefined') {
|
|
window.html = html;
|
|
}
|
|
else if (typeof global !== 'undefined') {
|
|
global.html = html;
|
|
}
|
|
//# sourceMappingURL=integration.js.map
|