-
Notifications
You must be signed in to change notification settings - Fork 2
Docs: Document how to include Sketches in Reports (FLCRM-20058) #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nehilor
wants to merge
6
commits into
v2
Choose a base branch
from
feature/FLCRM-20058-sketches-docs
base: v2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+463
−112
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4d0a89b
Docs: Add SKETCHURL and sketches examples to Report Builder
nehilor a95075b
Docs: Fix typo in sketches example
nehilor 4b22f05
Docs: Downgrade headings to H2 in sketches example per PR feedback
nehilor 1e4cc11
Docs: Clarify sketch ID usage in example per PR feedback
nehilor d098c61
FLCRM-20058: Enhanced documentation for including sketches in reports
nehilor f512658
FLCRM-20058: address PR #35 review feedback
nehilor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,271 @@ | ||
| --- | ||
| title: Sketches | ||
| excerpt: "Learn how to include sketches in custom reports" | ||
| deprecated: false | ||
| hidden: false | ||
| metadata: | ||
| title: "Include Sketches in Reports" | ||
| description: "Complete guide to including sketches in Fulcrum custom reports with examples" | ||
| robots: index | ||
| next: | ||
| description: "" | ||
| --- | ||
|
|
||
| ## Display Sketches in Reports | ||
|
|
||
| In the BODY section, search for `element.isSketchElement`. If it doesn't exist, you can add it to your `RENDERVALUES` loop. | ||
|
|
||
| ```html | ||
| <% } else if (element.isSketchElement) { %> | ||
| <div class="field"> | ||
| <h2 class="field-label"><%= element.label %></h2> | ||
| <div class="field-value"> | ||
| <% value && value.items.forEach((item, index) => { %> | ||
| <img class="sketch" src="<%= SKETCHURL(item.mediaID) %>" /> | ||
nehilor marked this conversation as resolved.
Show resolved
Hide resolved
nehilor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <% }); %> | ||
| </div> | ||
| </div> | ||
| <% } %> | ||
| ``` | ||
|
|
||
| ## Understanding Sketch Data Structure | ||
|
|
||
| Sketch fields contain an array of items. Each item has the following properties: | ||
|
|
||
| - `mediaID` - The unique identifier for the sketch | ||
| - `isEmpty` - Boolean indicating if the field has any sketches | ||
|
|
||
| ### Accessing Sketch Data | ||
|
|
||
| ```html | ||
| // Check if sketch field has values | ||
| <% if ($my_sketch_field && !$my_sketch_field.isEmpty) { %> | ||
| <% $my_sketch_field.items.forEach((item, index) => { %> | ||
| <!-- Display sketch --> | ||
| <% }); %> | ||
| <% } %> | ||
|
|
||
| // Access specific sketch properties | ||
| <% var firstSketch = $my_sketch_field && $my_sketch_field[0]; %> | ||
| <% var sketchId = firstSketch && firstSketch.mediaID; %> | ||
| ``` | ||
|
|
||
| ## SKETCHURL Function | ||
|
|
||
| The `SKETCHURL()` function generates a public URL for a sketch. It accepts two parameters: | ||
|
|
||
| ### Parameters | ||
|
|
||
| - `id` (String, required) - The sketch ID | ||
| - `options` (Object, optional) - Configuration options | ||
| - `version` - Image version: `'large'` (default), `'original'` | ||
| - `expires` - Expiration timestamp (default: `null`) | ||
|
|
||
| ### Examples | ||
|
|
||
| ```html | ||
| // Default large version | ||
| <img src="<%= SKETCHURL(item.mediaID) %>" /> | ||
|
|
||
| // Original full resolution | ||
| <img src="<%= SKETCHURL(item.mediaID, { version: 'original' }) %>" /> | ||
| ``` | ||
|
|
||
| ## Resize Sketches | ||
|
|
||
| You can control the size of sketches in the STYLES section by targeting the `.sketch` class. | ||
|
|
||
| ```css | ||
| .sketch { | ||
| max-width: 100%; | ||
| height: auto; | ||
| } | ||
|
|
||
| /* Fixed width */ | ||
| .sketch { | ||
| width: 500px; | ||
| height: auto; | ||
| } | ||
|
|
||
| /* Multiple sketches in a row */ | ||
| .sketch { | ||
| max-width: 48%; | ||
| height: auto; | ||
| display: inline-block; | ||
| margin: 1%; | ||
| } | ||
| ``` | ||
|
|
||
| ## Display Only First Sketch | ||
|
|
||
| If you have multiple sketches attached to a field and want to display only the first one: | ||
|
|
||
| ```html | ||
| <% } else if (element.isSketchElement) { %> | ||
| <div class="field"> | ||
| <h2 class="field-label"><%= element.label %></h2> | ||
| <div class="field-value"> | ||
| <% if (value && value.items.length > 0) { %> | ||
| <% let sketchItem = value.items[0]; %> | ||
| <img class="sketch" src="<%= SKETCHURL(sketchItem.mediaID) %>" /> | ||
| <% } %> | ||
| </div> | ||
| </div> | ||
| <% } %> | ||
| ``` | ||
|
|
||
| ## Accessing a Specific Sketch by Field Name | ||
|
|
||
| If you want to display sketches from a specific field outside the `RENDERVALUES` loop: | ||
|
|
||
| ```html | ||
| <div> | ||
| <% | ||
| // Using the data name of your sketch field | ||
| var sketchField = $my_sketch_field; | ||
| var sketchId = sketchField && sketchField[0] && sketchField[0].mediaID; | ||
| %> | ||
| <% if (sketchId) { %> | ||
| <div class="sketch-column"> | ||
| <img class="sketch" src="<%= SKETCHURL(sketchId) %>" /> | ||
| </div> | ||
| <% } %> | ||
| </div> | ||
|
|
||
| <!-- Display all sketches from a specific field --> | ||
| <div class="sketches-section"> | ||
| <h2>Site Sketches</h2> | ||
| <% if ($site_sketch && $site_sketch.items) { %> | ||
| <% $site_sketch.items.forEach((item, index) => { %> | ||
| <div class="sketch-item"> | ||
| <img src="<%= SKETCHURL(item.mediaID) %>" alt="Sketch <%= index + 1 %>" /> | ||
| </div> | ||
| <% }); %> | ||
| <% } %> | ||
| </div> | ||
| ``` | ||
|
|
||
| ## Add Metadata to Sketches | ||
|
|
||
| You can query the database to add metadata like creation date to each sketch: | ||
|
|
||
| ```html | ||
| <% } else if (element.isSketchElement) { %> | ||
| <div class="field"> | ||
| <h2 class="field-label"><%= element.label %></h2> | ||
| <div class="field-value"> | ||
| <% value && value.items.forEach((item, index) => { %> | ||
| <% | ||
| // Query sketch metadata | ||
| var sketchQuery = QUERY("SELECT created_at, updated_at FROM sketches WHERE sketch_id = '" + item.mediaID + "'"); | ||
| var sketchDate = sketchQuery.rows[0] && sketchQuery.rows[0].created_at.slice(0, 10); | ||
| %> | ||
| <div class="sketch-container"> | ||
| <img class="sketch" src="<%= SKETCHURL(item.mediaID) %>" /> | ||
| <% if (sketchDate) { %> | ||
| <p class="date">Created: <%= sketchDate %></p> | ||
| <% } %> | ||
| </div> | ||
| <% }); %> | ||
| </div> | ||
| </div> | ||
| <% } %> | ||
| ``` | ||
|
|
||
| ## Hide Sketch Label When Empty | ||
|
|
||
| Only display the sketch field label when there are sketches attached: | ||
|
|
||
| ```html | ||
| <% } else if (element.isSketchElement) { %> | ||
| <% if (value && !value.isEmpty && value.items.length > 0) { %> | ||
| <div class="field"> | ||
| <h2 class="field-label"><%= element.label %></h2> | ||
| <div class="field-value"> | ||
| <% value.items.forEach((item, index) => { %> | ||
| <img class="sketch" src="<%= SKETCHURL(item.mediaID) %>" /> | ||
| <% }); %> | ||
| </div> | ||
| </div> | ||
| <% } %> | ||
| <% } %> | ||
| ``` | ||
|
|
||
| ## Page Break Handling | ||
|
|
||
| To prevent sketches from breaking across pages: | ||
|
|
||
| ```html | ||
| <% } else if (element.isSketchElement) { %> | ||
| <div class="field" style="page-break-inside: avoid;"> | ||
| <h2 class="field-label"><%= element.label %></h2> | ||
| <div class="field-value"> | ||
| <% value && value.items.forEach((item, index) => { %> | ||
| <img class="sketch" src="<%= SKETCHURL(item.mediaID) %>" /> | ||
| <% }); %> | ||
| </div> | ||
| </div> | ||
| <% } %> | ||
| ``` | ||
|
|
||
| ## Numbering Sketches | ||
|
|
||
| Add numbers to sketches automatically: | ||
|
|
||
| ```html | ||
| <% } else if (element.isSketchElement) { %> | ||
| <div class="field"> | ||
| <h2 class="field-label"><%= element.label %></h2> | ||
| <div class="field-value"> | ||
| <% value && value.items.forEach((item, index) => { %> | ||
| <div class="sketch-item"> | ||
| <h3>Sketch <%= index + 1 %></h3> | ||
| <img class="sketch" src="<%= SKETCHURL(item.mediaID) %>" /> | ||
| </div> | ||
| <% }); %> | ||
| </div> | ||
| </div> | ||
| <% } %> | ||
| ``` | ||
|
|
||
| ## Grid Layout for Multiple Sketches | ||
|
|
||
| Display sketches in a responsive grid: | ||
|
|
||
| ```css | ||
| /* Add to STYLES section */ | ||
| .sketch-grid { | ||
| display: grid; | ||
| grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); | ||
| gap: 20px; | ||
| margin: 20px 0; | ||
| } | ||
|
|
||
| .sketch-grid-item { | ||
| text-align: center; | ||
| } | ||
|
|
||
| .sketch-grid-item img { | ||
| width: 100%; | ||
| height: auto; | ||
| border: 1px solid #ddd; | ||
| border-radius: 4px; | ||
| padding: 5px; | ||
| } | ||
| ``` | ||
|
|
||
| ```html | ||
| /* Add to BODY section */ | ||
| <% } else if (element.isSketchElement) { %> | ||
| <div class="field"> | ||
| <h2 class="field-label"><%= element.label %></h2> | ||
| <div class="sketch-grid"> | ||
| <% value && value.items.forEach((item, index) => { %> | ||
| <div class="sketch-grid-item"> | ||
| <img src="<%= SKETCHURL(item.mediaID) %>" /> | ||
| </div> | ||
| <% }); %> | ||
| </div> | ||
| </div> | ||
| <% } %> | ||
| ``` | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.