Skip to main content

FasReporting Subsystem Documentation - Addendum B

Version: 1.2

Date: October 26, 2023

Change: Implementation of UI Components for Template Grid Editing


1. Overview of Changes

This addendum documents the creation of a suite of Vue 2 components designed to enable in-place editing of report template lines within a web interface. The primary goal is to provide a user-friendly way for administrators to modify templates directly in the browser, reducing reliance on the Excel re-import process for minor changes. The architecture consists of:
  1. A new backend API endpoint to handle granular, cell-level updates.
  2. Three specialized, reusable Vue components for different data types: InlineTextEditor, StyleSelector, and FormulaEditorDialog.
  3. A parent view component, TemplateEditor.vue, which demonstrates how to integrate these editor components into a data table structure.

2. Backend API Endpoint for Cell Updates

A new API endpoint is introduced to persist changes made in the UI. It is designed to update a single field of a specific line within a report template’s embedded lines array.

2.1. API Route

File: routes/api.php

2.2. API Controller

File: app/Http/Controllers/Api/ReportTemplateLineController.php

3. Frontend Vue 2 Components

These components are designed to be placed within the slots of a data table. Each one manages its own editing state and emits a standardized @update event with the new value.

3.1. Prerequisite: vue-multiselect

The StyleSelector component depends on the vue-multiselect library. Installation:
Global CSS Import (e.g., in main.js):

3.2. Component: InlineTextEditor.vue

Purpose: Provides a simple click-to-edit functionality for text-based fields. File: resources/js/components/editors/InlineTextEditor.vue

3.3. Component: StyleSelector.vue

Purpose: Provides a tags-style multi-select input for choosing and creating CSS class names. File: resources/js/components/editors/StyleSelector.vue

3.4. Component: FormulaEditorDialog.vue

Purpose: Provides a button that opens a modal with helpers for building complex formula strings. File: resources/js/components/editors/FormulaEditorDialog.vue

4. Parent View: TemplateEditor.vue

This view acts as a container and orchestrator. It fetches the template data and integrates the editor components into a table, handling the @update events to make API calls. File: resources/js/views/TemplateEditor.vue