diff --git a/TEMPLATE_DOCUMENTATION.md b/TEMPLATE_DOCUMENTATION.md new file mode 100644 index 00000000..646c0bdf --- /dev/null +++ b/TEMPLATE_DOCUMENTATION.md @@ -0,0 +1,282 @@ +# Template Documentation - Dynamic Lists Widget + +## Overview +The Dynamic Lists widget uses Handlebars templating system to render both the configuration interface and the runtime display. Templates are organized by purpose and layout type. + +## Template Categories + +### 1. Interface Templates (`templates/interface/`) +Used for the widget configuration interface in Fliplet Studio. + +#### `layouts.interface.hbs` +Renders the layout selection grid showing available layout options. + +**Context Variables:** +- `id`: Layout identifier +- `name`: Display name +- `description`: Layout description +- `warning`: Optional warning message +- `gif`: Animated preview image URL +- `image`: Static preview image URL + +#### `filter-panels.interface.hbs` +Creates filter configuration panels in the interface. + +#### `sort-panels.interface.hbs` +Creates sort configuration panels in the interface. + +#### `summary-view-panels.interface.hbs` +Configures which data fields appear in the summary/list view. + +#### `detail-view-panels.interface.hbs` +Configures which data fields appear in the detail view. + +#### `field-token.interface.hbs` +Renders individual field tokens for drag-and-drop configuration. + +### 2. Build Templates (`templates/build/`) +Used for runtime rendering of the widget content. + +#### Base Templates (`[layout]-base.build.hbs`) +Main structure template for each layout containing: +- Container wrapper +- Search interface +- Filter controls +- Sort controls +- Loading states +- Error states +- Detail view overlay +- Social interaction panels + +**Example Structure (simple-list-base.build.hbs):** +```handlebars +
+ + {{#if searchEnabled}} + + {{/if}} + + +
+ +
+ + +
+ +
+
+``` + +#### Loop Templates (`[layout]-loop.build.hbs`) +Defines how individual data items are rendered in the list. + +**Example Structure (simple-list-loop.build.hbs):** +```handlebars +{{#each this}} +
+ {{#if [Image]}} +
+ {{/if}} + +
+ {{#if [Title]}} +
{{[Title]}}
+ {{/if}} + + {{#if [Description]}} +
{{plaintext [Description]}}
+ {{/if}} + + +
+ {{#if likesEnabled}} +
+ +
+ {{/if}} +
+
+
+{{/each}} +``` + +#### Detail Templates (`[layout]-detail.build.hbs`) +Renders the expanded detail view for individual items. + +#### Filter Templates (`[layout]-filters.build.hbs`) +Renders filter controls specific to each layout. + +#### Additional Templates +- `[layout]-comment.build.hbs`: Comment display template +- `[layout]-single-comment.build.hbs`: Individual comment template +- `[layout]-temp-comment.build.hbs`: Temporary comment template during submission + +### 3. Specialized Templates + +#### Agenda Layout Templates +- `agenda-cards-*.build.hbs`: Card-based agenda items +- `agenda-dates-loop.build.hbs`: Date grouping for agenda +- `agenda-filters.build.hbs`: Date-based filtering + +#### News Feed Templates +- `news-feed-*.build.hbs`: Social media style feed layout +- Supports comments, likes, and social interactions + +#### Directory Templates +- `small-card-*.build.hbs`: Directory-style people listings +- `small-card-profile-icon.build.hbs`: Profile icon display +- `small-card-user-profile.build.hbs`: User profile card + +## Template Variables + +### Common Context Variables +All templates receive these standard variables: + +#### Widget Configuration +- `id`: Widget instance ID +- `layout`: Selected layout type +- `searchEnabled`: Boolean for search functionality +- `filtersEnabled`: Boolean for filtering +- `sortEnabled`: Boolean for sorting +- `likesEnabled`: Boolean for likes feature +- `bookmarksEnabled`: Boolean for bookmarks +- `commentsEnabled`: Boolean for comments + +#### Data Entry Variables +- `[Title]`: Entry title field +- `[Description]`: Entry description field +- `[Image]`: Entry image field +- `[Category]`: Entry category field +- `[Date]`: Entry date field +- `[flClasses]`: CSS classes for filtering/sorting +- `id`: Entry unique identifier + +#### UI State Variables +- `filtersInOverlay`: Boolean for filter overlay display +- `searchIconsEnabled`: Boolean for search icon display +- `showAddEntry`: Boolean for add entry button +- `previousScreen`: Boolean for navigation state +- `enabledLimitEntries`: Boolean for entry limiting +- `limitEntries`: Number of entries to limit + +### Template Helpers + +#### Built-in Helpers +- `{{#if condition}}`: Conditional rendering +- `{{#unless condition}}`: Negative conditional +- `{{#each array}}`: Loop over arrays +- `{{#ifCond a '==' b}}`: Conditional comparison + +#### Custom Helpers +- `{{auth url}}`: Authentication-aware URL handling +- `{{plaintext text}}`: Strip HTML from text +- `{{T "key"}}`: Translation/internationalization +- `{{[fieldName]}}`: Dynamic field access + +## Template Compilation + +Templates are pre-compiled into JavaScript files: +- `js/build.templates.js`: Runtime templates +- `js/interface.templates.js`: Interface templates + +Access compiled templates via: +```javascript +Fliplet.Widget.Templates['templates.build.template-name'] +Fliplet.Widget.Templates['templates.interface.template-name'] +``` + +## Customization Guidelines + +### Adding New Templates +1. Create `.hbs` file in appropriate directory +2. Follow naming convention: `[layout]-[purpose].build.hbs` +3. Recompile templates after changes +4. Update template references in JavaScript + +### Template Best Practices +1. **Accessibility**: Include proper ARIA labels and roles +2. **Responsive Design**: Use appropriate CSS classes +3. **Performance**: Minimize template complexity +4. **Localization**: Use `{{T "key"}}` for all user-facing text +5. **Data Binding**: Use `{{[fieldName]}}` for dynamic fields + +### Common Patterns + +#### Conditional Rendering +```handlebars +{{#if fieldName}} +
{{fieldName}}
+{{/if}} +``` + +#### Loop with Fallback +```handlebars +{{#each items}} +
{{this}}
+{{else}} +
No items found
+{{/each}} +``` + +#### Dynamic Field Access +```handlebars +{{#if [customField]}} +
{{[customField]}}
+{{/if}} +``` + +#### Social Features +```handlebars +{{#if likesEnabled}} +
+ +
+{{/if}} +``` + +## Layout-Specific Features + +### Simple List +- Minimal design +- Focus on content readability +- Basic social interactions + +### News Feed +- Rich media support +- Full comment system +- Social interaction emphasis + +### Directory (Small Card) +- Profile image prominence +- Contact information display +- People-focused layout + +### Agenda +- Date-based organization +- Time-sensitive display +- Calendar-style navigation + +### Featured List (Small H-Card) +- Horizontal card layout +- Featured content emphasis +- Image and text balance + +## Debugging Templates + +### Common Issues +1. **Missing Variables**: Check data source configuration +2. **Render Errors**: Validate Handlebars syntax +3. **Style Issues**: Verify CSS class names +4. **JavaScript Errors**: Check template compilation + +### Debug Tools +- Browser developer tools for DOM inspection +- Fliplet Studio preview for real-time testing +- Template compilation logs for syntax errors +- Network tab for asset loading issues + +This documentation provides comprehensive guidance for understanding and customizing the Dynamic Lists widget templates. \ No newline at end of file diff --git a/agents.md b/agents.md new file mode 100644 index 00000000..6dd40c64 --- /dev/null +++ b/agents.md @@ -0,0 +1,285 @@ +# Fliplet Dynamic Lists Widget - AI Agent Documentation + +## Overview +This is a comprehensive Fliplet widget that generates dynamic lists from data sources. The widget provides multiple layout options and extensive customization capabilities for displaying data in various formats. + +**Package**: com.fliplet.dynamic-lists +**Version**: 1.4.0 +**Category**: List component + +## Component Architecture + +### Core Files Structure + +``` +fliplet-widget-dynamic-lists/ +├── widget.json # Widget configuration and dependencies +├── package.json # NPM package configuration +├── interface.html # Widget configuration interface +├── build.html # Widget runtime HTML structure +├── js/ +│ ├── build.js # Main widget runtime initialization +│ ├── build-lists.js # Core DynamicLists class (minimal constructor) +│ ├── interface.js # Widget configuration interface logic +│ ├── interface-lists.js # Interface list management +│ ├── utils.js # Utility functions and helpers +│ ├── query-parser.js # Data query parsing functionality +│ ├── build.templates.js # Compiled Handlebars templates for runtime +│ ├── interface.templates.js # Compiled Handlebars templates for interface +│ ├── layout-mapping/ +│ │ ├── list-layouts.js # Available layout definitions +│ │ └── layout-mapping.js # Layout configuration mapping +│ ├── layout-javascript/ # Layout-specific JavaScript files +│ │ ├── small-card-code.js +│ │ ├── news-feed-code.js +│ │ ├── agenda-code.js +│ │ ├── small-h-card-code.js +│ │ └── simple-list-code.js +│ └── default-configs/ # Default configuration files +│ └── layouts-config.js +├── css/ +│ ├── build.css # Main widget styles +│ ├── interface.css # Configuration interface styles +│ └── layout-css/ # Layout-specific CSS files +│ ├── small-card-style.upload.css +│ ├── news-feed-style.upload.css +│ ├── agenda-style.upload.css +│ ├── small-h-card-style.upload.css +│ └── simple-list-style.upload.css +├── templates/ +│ ├── build/ # Runtime Handlebars templates +│ │ ├── [layout]-base.build.hbs +│ │ ├── [layout]-loop.build.hbs +│ │ ├── [layout]-detail.build.hbs +│ │ └── [layout]-filters.build.hbs +│ └── interface/ # Interface Handlebars templates +│ ├── layouts.interface.hbs +│ ├── filter-panels.interface.hbs +│ ├── sort-panels.interface.hbs +│ ├── summary-view-panels.interface.hbs +│ └── detail-view-panels.interface.hbs +├── img/ # Layout preview images and icons +└── vendor/ # Third-party dependencies +``` + +## Available Layouts + +The widget supports 5 predefined layouts: + +1. **Small Card (Directory)** - `small-card` + - Suitable for directories of people + - Displays compact card-style entries + +2. **News Feed** - `news-feed` + - Suitable for news feeds and social-style content + - Supports comments and social interactions + +3. **Agenda** - `agenda` + - Create agenda/calendar-style displays + - Requires full screen layout + - Date-based organization + +4. **Small H-Card (Featured List)** - `small-h-card` + - Suitable for featured items + - Horizontal card layout + +5. **Simple List** - `simple-list` + - Suitable for simple data lists + - Minimalist list display + +## Core Functionality + +### Data Source Integration +- Connects to Fliplet data sources for dynamic content +- Supports multiple data source types (main data, user data, likes, bookmarks, comments) +- Handles data source views and filtering + +### Key Features +- **Search**: Full-text search across data entries +- **Filtering**: Multiple filter options with custom configurations +- **Sorting**: Configurable sort options +- **Social Features**: Likes, bookmarks, comments integration +- **Detail Views**: Expandable detail views for entries +- **Responsive Design**: Mobile-optimized layouts +- **Real-time Updates**: Live data synchronization + +### Dependencies + +#### Interface Dependencies +- fliplet-core: Core Fliplet functionality +- fliplet-datasources: Data source integration +- fliplet-studio-ui: Studio interface components +- jquery-ui: UI components and interactions +- bootstrap: CSS framework +- handlebars: Template engine +- codemirror: Code editor for custom templates + +#### Runtime Dependencies +- fliplet-core: Core runtime functionality +- fliplet-session: Session management +- fliplet-datasources: Data source access +- fliplet-media: Media handling +- bootstrap: UI framework +- moment: Date/time manipulation +- lodash: Utility functions +- handlebars: Template rendering +- hammer.js: Touch gesture support + +## Configuration Options + +### Data Source Configuration +- Primary data source selection +- User data source for authentication +- Social data sources (likes, bookmarks, comments) +- Data source views and filtering rules + +### Layout Customization +- Layout selection from predefined options +- Custom HTML templates via Handlebars +- Custom CSS styling +- Custom JavaScript behavior + +### Display Options +- Summary view field configuration +- Detail view field configuration +- Filter panel configuration +- Sort panel configuration +- Social interaction settings + +### Advanced Settings +- Custom query parsing +- Data transformation options +- Performance optimization settings +- Security and access control + +## Template System + +### Handlebars Templates +The widget uses Handlebars for templating with the following template types: + +- **Base Templates**: Main layout structure +- **Loop Templates**: Individual item rendering +- **Detail Templates**: Expanded item views +- **Filter Templates**: Filter interface components +- **Search Result Templates**: Search result formatting + +### Template Compilation +Templates are pre-compiled into JavaScript files: +- `build.templates.js`: Runtime templates +- `interface.templates.js`: Configuration interface templates + +## JavaScript Architecture + +### Main Classes + +#### DynamicLists (build-lists.js) +```javascript +var DynamicLists = function(data, container) { + this.data = data; + this.$container = $(container); + return this; +}; +``` +- Minimal constructor for widget instances +- Handles data and container initialization + +#### Interface DynamicLists (interface.js) +- Complex configuration interface logic +- Data source provider management +- Template editor integration +- Layout selection and configuration + +### Key Functions + +#### Widget Initialization (build.js) +```javascript +Fliplet.Widget.instance('dynamic-lists', function(data) { + var container = this; + var id = data.id; + + if (!data.layout) { + dynamicLists[id] = new DynamicLists(data, container); + } +}); +``` + +#### Layout Event Handling +```javascript +Fliplet.Studio.onEvent(function(event) { + var eventDetail = event.detail; + + if (eventDetail.type === 'dynamicListLayout') { + $('.fl-widget-instance[data-id="' + eventDetail.data.id + '"]') + .attr('data-settings-layout', eventDetail.data.layout); + } +}); +``` + +## Data References + +The widget maintains references to various Fliplet resources: +- Data sources (main, user, likes, bookmarks, comments) +- Pages (add entry, edit entry, summary links) +- Media folders (file uploads) +- App and organization folders +- Data source views + +## Development Guidelines + +### Adding New Layouts +1. Create layout definition in `js/layout-mapping/list-layouts.js` +2. Add layout mapping in `js/layout-mapping/layout-mapping.js` +3. Create CSS file in `css/layout-css/[layout]-style.upload.css` +4. Create JavaScript file in `js/layout-javascript/[layout]-code.js` +5. Create Handlebars templates in `templates/build/[layout]-*.hbs` +6. Update default configurations in `js/default-configs/` + +### Customization Points +- Templates: Modify Handlebars templates for custom rendering +- Styles: Override CSS for visual customization +- Behavior: Extend JavaScript for custom interactions +- Data: Configure data source connections and transformations + +### Testing Considerations +- Test all layout variations +- Verify data source connections +- Test responsive behavior +- Validate social features +- Check performance with large datasets + +## AI Agent Guidance + +When working with this widget: + +1. **Layout Selection**: Always consider the appropriate layout for the use case +2. **Data Source Integration**: Ensure proper data source configuration +3. **Template Modifications**: Use Handlebars syntax for template customization +4. **Performance**: Consider data loading and rendering performance +5. **Mobile Optimization**: Ensure responsive design considerations +6. **Social Features**: Configure social interactions appropriately +7. **Security**: Implement proper access controls and data validation + +## Common Use Cases + +1. **Employee Directory**: Use small-card layout with user photos and contact info +2. **News Feed**: Use news-feed layout with comments and social features +3. **Event Agenda**: Use agenda layout with date-based organization +4. **Product Catalog**: Use small-h-card layout for featured products +5. **Simple Lists**: Use simple-list layout for basic data display + +## Troubleshooting + +### Common Issues +1. **Data Not Loading**: Check data source configuration and permissions +2. **Layout Not Rendering**: Verify template compilation and CSS loading +3. **Search Not Working**: Check search configuration and data indexing +4. **Social Features Failing**: Verify social data source configurations +5. **Performance Issues**: Review data query optimization and caching + +### Debug Information +- Widget ID and configuration data available in browser console +- Template compilation errors logged to console +- Data source connection status available via Fliplet APIs +- Network requests visible in browser developer tools + +This documentation provides a comprehensive overview for AI agents working with the Fliplet Dynamic Lists widget, covering architecture, functionality, and development guidelines. \ No newline at end of file diff --git a/css/build.css b/css/build.css index 2ed02bc5..103afd6e 100644 --- a/css/build.css +++ b/css/build.css @@ -1,3 +1,24 @@ +/** + * Dynamic Lists Widget - Main Build CSS + * + * This file contains the core styling for all dynamic list layouts including: + * - Common component styles (buttons, controls, placeholders) + * - Responsive design utilities + * - Animation and transition effects + * - Social interaction styling (likes, bookmarks, comments) + * - Search and filter interface styling + * - Detail view overlay styling + * - Mobile-optimized touch interactions + * - Accessibility enhancements (focus states, screen reader support) + * + * Layout-specific styles are in separate CSS files in the layout-css/ directory. + * This file provides the foundation that all layouts build upon. + */ + +/* ========================================================================== + Common Component Styles + ========================================================================== */ + .btn.disabled { pointer-events: none; } diff --git a/css/layout-css/simple-list-style.upload.css b/css/layout-css/simple-list-style.upload.css index bb428613..aee33b97 100644 --- a/css/layout-css/simple-list-style.upload.css +++ b/css/layout-css/simple-list-style.upload.css @@ -1,3 +1,29 @@ +/** + * Simple List Layout CSS + * + * Specific styling for the Simple List layout of the Dynamic Lists widget. + * This layout focuses on clean, minimalist design with emphasis on content readability. + * + * Key Features: + * - Clean list-style item display + * - Overlay-based filter and search interfaces + * - Responsive design for all screen sizes + * - Smooth animations and transitions + * - Accessibility-compliant interactions + * - Touch-optimized mobile experience + * + * Layout Structure: + * - .simple-list-container: Main container + * - .simple-list-item: Individual list items + * - .simple-list-detail-overlay: Detail view overlay + * - .simple-list-search-filter-overlay: Filter overlay + * - .simple-list-social-holder: Social interaction buttons + */ + +/* ========================================================================== + Studio/Edit Mode Styles + ========================================================================== */ + .mode-interact .simple-list-container { pointer-events: none; } @@ -6,7 +32,10 @@ overflow: hidden !important; } -/* SEARCH FILTER OVERLAY */ +/* ========================================================================== + Search Filter Overlay + ========================================================================== */ + .simple-list-search-filter-overlay { position: fixed; top: 0; diff --git a/js/build-lists.js b/js/build-lists.js index 44795ac4..64d2af8f 100644 --- a/js/build-lists.js +++ b/js/build-lists.js @@ -1,7 +1,27 @@ +/** + * DynamicLists Constructor + * Initializes a dynamic list widget instance with data and container + * This is the main class that handles runtime behavior of dynamic lists + * + * @param {Object} data - Widget configuration data including: + * - id: Unique widget instance ID + * - layout: Selected layout type (small-card, news-feed, agenda, etc.) + * - dataSourceId: Connected data source ID + * - filterOptions: Array of filter configurations + * - sortOptions: Array of sort configurations + * - social: Social features configuration + * - advancedSettings: Advanced widget settings + * @param {Element} container - DOM element that contains the widget + * @constructor + */ // eslint-disable-next-line no-unused-vars var DynamicLists = function(data, container) { + // Store widget configuration data this.data = data; + + // Store jQuery wrapped container element this.$container = $(container); + // Return the instance for method chaining return this; }; diff --git a/js/build.js b/js/build.js index e824b70e..dfeb34ff 100644 --- a/js/build.js +++ b/js/build.js @@ -1,18 +1,31 @@ +// Global container for all dynamic list instances var dynamicLists = dynamicLists || {}; +/** + * Main widget initialization function + * Creates a new DynamicLists instance for each widget on the page + * @param {Object} data - Widget configuration data including id, layout, and other settings + */ Fliplet.Widget.instance('dynamic-lists', function(data) { - var container = this; - var id = data.id; + var container = this; // Widget container element + var id = data.id; // Unique widget instance ID + // Only initialize if no specific layout is set (normal runtime mode) if (!data.layout) { dynamicLists[id] = new DynamicLists(data, container); } }); +/** + * Listen for studio events to handle layout changes + * Updates widget attributes when layout is changed in the studio + */ Fliplet.Studio.onEvent(function(event) { var eventDetail = event.detail; + // Handle dynamic list layout change events if (eventDetail.type === 'dynamicListLayout') { + // Update the widget instance's layout attribute $('.fl-widget-instance[data-id="' + eventDetail.data.id + '"]').attr('data-settings-layout', eventDetail.data.layout); } }); diff --git a/js/default-configs/layouts-config.js b/js/default-configs/layouts-config.js index 2e62da1d..487ac0ed 100644 --- a/js/default-configs/layouts-config.js +++ b/js/default-configs/layouts-config.js @@ -1,3 +1,18 @@ +/** + * Default Layout Configurations + * + * Defines the default settings for each layout type in the dynamic lists widget. + * Each layout includes configuration for: + * - Filter settings and default filter fields + * - Search configuration and searchable fields + * - Sort options with column mappings + * - Summary and detail view field configurations + * - Social features (comments, likes, bookmarks) + * - Layout-specific styling options + * + * These configurations are used when creating new widgets or resetting to defaults. + * They provide sensible defaults based on the intended use case for each layout. + */ window.flListLayoutConfig = { 'small-card': { 'filtersEnabled': true, diff --git a/js/interface-lists.js b/js/interface-lists.js index b72bd6a1..7f2dbf2a 100644 --- a/js/interface-lists.js +++ b/js/interface-lists.js @@ -1,17 +1,37 @@ -var widgetId = Fliplet.Widget.getDefaultId(); -var widgetData = Fliplet.Widget.getData(widgetId) || {}; -var page = Fliplet.Widget.getPage(); -var dynamicLists; -var dataSourceProvider; - -var omitPages = page ? [page.id] : []; -var addEntryLinkAction; -var editEntryLinkAction; -var linkAddEntryProvider; -var linkEditEntryProvider; -var filePickerPromises = []; -var withError = false; -var selectedFieldId = []; +/** + * Interface Lists Module + * + * Handles the widget configuration interface for dynamic lists, including: + * - Link action configuration for add/edit entry buttons + * - File picker integration for media fields + * - Widget data management and validation + * - Page navigation setup + * - Interface state management + * + * This module is loaded in the Fliplet Studio interface and manages the + * configuration UI for dynamic list widgets. + */ + +// Core widget configuration variables +var widgetId = Fliplet.Widget.getDefaultId(); // Current widget instance ID +var widgetData = Fliplet.Widget.getData(widgetId) || {}; // Widget configuration data +var page = Fliplet.Widget.getPage(); // Current page context +var dynamicLists; // Dynamic lists instance +var dataSourceProvider; // Data source provider instance + +// Navigation configuration +var omitPages = page ? [page.id] : []; // Pages to exclude from navigation options + +// Link action providers and configurations +var addEntryLinkAction; // Provider for add entry link action +var editEntryLinkAction; // Provider for edit entry link action +var linkAddEntryProvider; // Link provider for adding entries +var linkEditEntryProvider; // Link provider for editing entries + +// File and interface state management +var filePickerPromises = []; // Array to track file picker promises +var withError = false; // Flag to track validation errors +var selectedFieldId = []; // Array of selected field IDs for configuration var addEntryLinkData = $.extend(true, { action: 'screen', diff --git a/js/interface.js b/js/interface.js index 0d14fab8..94977e6a 100644 --- a/js/interface.js +++ b/js/interface.js @@ -1,3 +1,37 @@ +/** + * Dynamic Lists Widget Configuration Interface + * + * This module provides the complete configuration interface for dynamic list widgets + * in Fliplet Studio. It handles all aspects of widget setup including: + * + * Core Features: + * - Layout selection and preview + * - Data source integration and field mapping + * - Search and filter configuration + * - Sort options setup + * - Social features configuration (likes, bookmarks, comments) + * - Field display customization (summary and detail views) + * - Template editing with CodeMirror integration + * - CSS and JavaScript customization + * - Real-time preview and validation + * + * Interface Components: + * - Layout selection grid with animated previews + * - Data source provider integration + * - Drag-and-drop field configuration + * - Filter and sort panel builders + * - Template editors with syntax highlighting + * - Style customization panels + * - Advanced settings configuration + * + * Dependencies: + * - CodeMirror for template editing + * - jQuery UI for drag-and-drop functionality + * - Bootstrap for UI components + * - Handlebars for template compilation + * - Fliplet core APIs for data source integration + */ + /* global CodeMirror */ // eslint-disable-next-line no-unused-vars var DynamicLists = (function() { @@ -60,10 +94,33 @@ var DynamicLists = (function() { var defaultColumns = window.flListLayoutTableColumnConfig; var defaultEntries = window.flListLayoutTableConfig; - // Constructor + /** + * DynamicLists Interface Constructor + * + * Initializes the widget configuration interface in Fliplet Studio. + * This constructor sets up the configuration UI including: + * - Data source provider integration + * - Layout selection interface + * - Field mapping and configuration + * - Filter and sort option setup + * - Social features configuration + * - Template editor initialization + * + * @param {Object} configuration - Widget configuration object including: + * - id: Widget instance ID + * - layout: Selected layout type + * - dataSourceId: Connected data source ID + * - sortOptions: Array of sort configurations + * - filterOptions: Array of filter configurations + * - detailViewOptions: Array of detail view field configurations + * - social: Social features configuration + * - advancedSettings: Advanced widget settings + * @constructor + */ function DynamicLists(configuration) { _this = this; + // Merge configuration with defaults _this.config = $.extend(true, { sortOptions: [], filterOptions: [], @@ -75,9 +132,11 @@ var DynamicLists = (function() { _this.widgetId = configuration.id; _this.isLoaded = false; + // Initialize interface _this.attachListeners(); _this.init(); + // Register data source provider for external access Fliplet.Registry.set('datasource-provider', function() { return dataSourceProvider; }); diff --git a/js/layout-javascript/news-feed-code.js b/js/layout-javascript/news-feed-code.js index 7b26ef48..61b82541 100644 --- a/js/layout-javascript/news-feed-code.js +++ b/js/layout-javascript/news-feed-code.js @@ -1,17 +1,52 @@ -// Constructor +/** + * News Feed Layout - Dynamic List Implementation + * + * This file contains the specific implementation for the News Feed layout. + * It extends the base Dynamic List functionality with social media features: + * + * - Social media-style feed design + * - Rich media support (images, videos) + * - Full commenting system with replies + * - Like and bookmark functionality + * - User mentions and notifications + * - Real-time updates and interactions + * - Card-based layout with content emphasis + * + * The News Feed layout is ideal for social applications, news feeds, + * content sharing platforms, and community-driven content. + */ + +/** + * DynamicList Constructor for News Feed Layout + * + * @param {string} id - Unique widget instance identifier + * @param {Object} data - Widget configuration data including: + * - layout: Layout type ('news-feed') + * - social: Enhanced social features configuration + * - commentsEnabled: Boolean for comments functionality + * - likesEnabled: Boolean for likes functionality + * - bookmarksEnabled: Boolean for bookmarks functionality + * - summary-fields: Array of fields to display in feed view + * - detailViewOptions: Array of fields to display in detail view + * - userDataSourceId: User data source for social features + * @constructor + */ function DynamicList(id, data) { var _this = this; + // Reference to global layout configurations this.flListLayoutConfig = window.flListLayoutConfig; + + // Template mapping specific to news-feed layout this.layoutMapping = { 'news-feed': { - 'base': 'templates.build.news-feed-base', - 'loop': 'templates.build.news-feed-loop', - 'detail': 'templates.build.news-feed-detail', - 'filter': 'templates.build.news-feed-filters', - 'comments': 'templates.build.news-feed-comment', - 'single-comment': 'templates.build.news-feed-single-comment', - 'temp-comment': 'templates.build.news-feed-temp-comment' + 'base': 'templates.build.news-feed-base', // Main feed structure template + 'loop': 'templates.build.news-feed-loop', // Individual feed item template + 'detail': 'templates.build.news-feed-detail', // Detail view template + 'filter': 'templates.build.news-feed-filters', // Filter controls template + 'comments': 'templates.build.news-feed-comment', // Comments display template + 'single-comment': 'templates.build.news-feed-single-comment', // Individual comment template + 'temp-comment': 'templates.build.news-feed-temp-comment' // Temporary comment template } }; diff --git a/js/layout-javascript/simple-list-code.js b/js/layout-javascript/simple-list-code.js index 3beb6680..c3bf4189 100644 --- a/js/layout-javascript/simple-list-code.js +++ b/js/layout-javascript/simple-list-code.js @@ -1,33 +1,69 @@ -// Constructor +/** + * Simple List Layout - Dynamic List Implementation + * + * This file contains the specific implementation for the Simple List layout. + * It extends the base Dynamic List functionality with layout-specific features: + * + * - Minimalist design focused on content readability + * - Basic social interactions (likes, bookmarks, comments) + * - Clean list-style display of data entries + * - Responsive design optimized for mobile and desktop + * - Search, filter, and sort capabilities + * - Detail view overlay for expanded content + * + * The Simple List layout is ideal for basic data display scenarios where + * content clarity and simplicity are prioritized over visual complexity. + */ + +/** + * DynamicList Constructor for Simple List Layout + * + * @param {string} id - Unique widget instance identifier + * @param {Object} data - Widget configuration data including: + * - layout: Layout type ('simple-list') + * - summary-fields: Array of fields to display in list view + * - detailViewOptions: Array of fields to display in detail view + * - filterOptions: Array of filter configurations + * - sortOptions: Array of sort configurations + * - social: Social features configuration + * - searchEnabled: Boolean for search functionality + * - filtersEnabled: Boolean for filter functionality + * - dataSourceId: Connected data source ID + * @constructor + */ function DynamicList(id, data) { var _this = this; + // Reference to global layout configurations this.flListLayoutConfig = window.flListLayoutConfig; + + // Template mapping specific to simple-list layout this.layoutMapping = { 'simple-list': { - 'base': 'templates.build.simple-list-base', - 'loop': 'templates.build.simple-list-loop', - 'detail': 'templates.build.simple-list-detail', - 'filter': 'templates.build.simple-list-filters', - 'comments': 'templates.build.simple-list-comment', - 'single-comment': 'templates.build.simple-list-single-comment', - 'temp-comment': 'templates.build.simple-list-temp-comment' + 'base': 'templates.build.simple-list-base', // Main structure template + 'loop': 'templates.build.simple-list-loop', // Individual item template + 'detail': 'templates.build.simple-list-detail', // Detail view template + 'filter': 'templates.build.simple-list-filters', // Filter controls template + 'comments': 'templates.build.simple-list-comment', // Comments display template + 'single-comment': 'templates.build.simple-list-single-comment', // Individual comment template + 'temp-comment': 'templates.build.simple-list-temp-comment' // Temporary comment template } }; - // Makes data and the component container available to Public functions + // Store widget configuration data and apply defaults this.data = data; this.data['summary-fields'] = this.data['summary-fields'] || this.flListLayoutConfig[this.data.layout]['summary-fields']; this.data.computedFields = this.data.computedFields || {}; this.data.forceRenderList = false; this.data.apiFiltersAvailable = true; + + // Get the widget container element this.$container = $('[data-dynamic-lists-id="' + id + '"]'); - // Other variables - // Global variables - this.allowClick = true; - this.allUsers; - this.usersToMention; + // Initialize component state variables + this.allowClick = true; // Flag to control click interactions + this.allUsers; // Cache for all users data + this.usersToMention; // Cache for users available for mentions this.commentsLoadingHTML = '
' + T('widgets.list.dynamic.loading') + '
'; this.entryClicked = undefined; this.isFiltering; diff --git a/js/layout-mapping/layout-mapping.js b/js/layout-mapping/layout-mapping.js index 02322ef0..80b71e16 100644 --- a/js/layout-mapping/layout-mapping.js +++ b/js/layout-mapping/layout-mapping.js @@ -1,3 +1,29 @@ +/** + * Layout Mapping Configuration + * + * Maps layout IDs to their corresponding template, CSS, and JavaScript files. + * This configuration defines how each layout is assembled from its components: + * + * - name: Display name for the layout + * - base: Base template that provides the main structure + * - loop: Template for rendering individual items in the list + * - detail: Template for detailed view of individual items + * - filter: Template for filter controls (if applicable) + * - css: CSS file identifier for layout-specific styling + * - js: JavaScript file identifier for layout-specific behavior + * + * Additional templates may be defined for specific layouts: + * - profile-icon: User profile icon template + * - user-profile: User profile template + * - comment: Comment display template + * - single-comment: Individual comment template + * - temp-comment: Temporary comment template + * - search-results: Search results template + * - dates-loop: Date grouping template (agenda layout) + * - cards-loop: Card grouping template (agenda layout) + * - cards-detail: Card detail template (agenda layout) + * - cards-search-results: Card search results template (agenda layout) + */ window.flLayoutMapping = { 'small-card': { 'name': 'Small expandable cards', diff --git a/js/layout-mapping/list-layouts.js b/js/layout-mapping/list-layouts.js index 62639377..5ea33387 100644 --- a/js/layout-mapping/list-layouts.js +++ b/js/layout-mapping/list-layouts.js @@ -1,5 +1,23 @@ +/** + * Layout Definitions for Dynamic Lists Widget + * Defines all available layout options with their metadata and preview assets + */ + +// Get the widget ID for asset URL construction var widgetId = Fliplet.Widget.getDefaultId(); +/** + * Array of available layout configurations + * Each layout includes: + * - id: Unique identifier used in code + * - name: Display name shown in interface + * - description: Brief description of use case + * - gif: Animated preview image URL + * - image: Static preview image URL + * - warning: Optional warning message for layout requirements + * + * @type {Array} + */ window.flWidgetLayout = [ { 'id': 'small-card', diff --git a/js/query-parser.js b/js/query-parser.js index 2dec2b6c..5668e381 100644 --- a/js/query-parser.js +++ b/js/query-parser.js @@ -1,10 +1,40 @@ /** - * This gets data out of the URL as an INPUT, - * parses it, and as an OUTPUT sets all the required variables used by LFD - * for prepopulating, prefiltering and opening an entry + * Dynamic List Query Parser + * + * This module gets data out of the URL as an INPUT, parses it, and as an OUTPUT + * sets all the required variables used by LFD (List from Data source) for: + * - Prepopulating form fields + * - Prefiltering list content + * - Opening specific entries + * - Handling navigation state * + * URL Query Parameters Supported: + * - dynamicListPreviousScreen: Boolean flag for previous screen navigation + * - dynamicListEnableButton: Boolean flag for enabling go-back button + * - dynamicListHijackBack: Boolean flag for hijacking back navigation + * - dynamicListOpenEntry: Entry ID to open automatically + * - dynamicListPrefilter: JSON object with filter conditions + * - dynamicListQuery: Search query string + * - dynamicListUserId: User ID for filtering + * - dynamicListUserColumn: Column name for user filtering + * - dynamicListAppendFilters: JSON object with additional filters + * - dynamicListIgnoreFilters: JSON object with filters to ignore + * - dynamicListLimitData: Number to limit data entries + * - dynamicListView: Data source view ID + * - dynamicListOpenBookmarks: Boolean flag to show only bookmarked items + * - dynamicListSort: JSON object with sort configuration + * - dynamicListPrepopulate: JSON object with prepopulation data + * - dynamicListSourceId: Override data source ID + * - dynamicListCommentsDataSourceId: Override comments data source ID + * - dynamicListLikesDataSourceId: Override likes data source ID + * - dynamicListBookmarksDataSourceId: Override bookmarks data source ID + * - dynamicListPassthrough: JSON object with additional data + * * Note: Boolean flags are treated as strings as Fliplet.Navigate.query * does not parse the values into boolean values. + * + * Security: XSS prevention is implemented by limiting which query parameters + * are processed and avoiding direct execution of user-provided data. */ Fliplet.Registry.set('dynamicListQueryParser', function() { var _this = this; diff --git a/js/utils.js b/js/utils.js index f22ee933..9d7e058b 100644 --- a/js/utils.js +++ b/js/utils.js @@ -1,20 +1,37 @@ +/** + * Dynamic List Utilities + * Provides common utility functions for dynamic list widgets including: + * - Data parsing and validation + * - String manipulation and formatting + * - Date and number handling + * - Image URL validation + * - File handling + * - Search and filtering helpers + * + * Registered in Fliplet.Registry as 'dynamicListUtils' + */ Fliplet.Registry.set('dynamicListUtils', (function() { + // Flag to track if ISO date warning has been issued var isoDateWarningIssued = false; + + // Cache for file data to improve performance var cachedFiles = {}; + + // Static configuration and regular expressions var Static = { RegExp: { - httpUrl: /^https?:\/\//i, - base64Image: /^data:image\/[^;]+;base64,/i, - dataSourcesPath: /^datasources\//i, - number: /^\d+$/i, - linebreak: /(\r\n|\n|\r)/gm, - email: /(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/gm, - phone: /[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,8}/gm, - url: /(?:^|[^@\.\w-])([a-z0-9]+:\/\/)?(\w(?!ailto:)\w+:\w+@)?([\w.-]+\.[a-z]{2,32})(:[0-9]+)?(\/.*)?(?=$|[^@\.\w-])/ig, - mention: /\B@[a-z0-9_-]+/ig, - date: /^[0-9]{4}-([0]?[1-9]|[1][0-2])-([0]?[1-9]|[1|2][0-9]|[3][0|1])$/ + httpUrl: /^https?:\/\//i, // HTTP/HTTPS URLs + base64Image: /^data:image\/[^;]+;base64,/i, // Base64 encoded images + dataSourcesPath: /^datasources\//i, // Fliplet datasources path + number: /^\d+$/i, // Pure numeric strings + linebreak: /(\r\n|\n|\r)/gm, // Line breaks (cross-platform) + email: /(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/gm, // Email addresses + phone: /[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,8}/gm, // Phone numbers + url: /(?:^|[^@\.\w-])([a-z0-9]+:\/\/)?(\w(?!ailto:)\w+:\w+@)?([\w.-]+\.[a-z]{2,32})(:[0-9]+)?(\/.*)?(?=$|[^@\.\w-])/ig, // URLs + mention: /\B@[a-z0-9_-]+/ig, // Social media mentions + date: /^[0-9]{4}-([0]?[1-9]|[1][0-2])-([0]?[1-9]|[1|2][0-9]|[3][0|1])$/ // ISO date format }, - refArraySeparator: '.$.' + refArraySeparator: '.$.' // Separator for array references in data paths }; var computedFieldClashes = []; var searchValueMap = {};