Skip to content
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

Jsonforms for form component #181

Merged
merged 113 commits into from
Apr 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
c7e6576
introduction of a forms component
reusr1 Aug 12, 2020
eec8db3
Added success page and failure message dialog options
qial Aug 13, 2020
e3cb545
Added more options to Form's model
qial Aug 17, 2020
f0b255b
Updated form component with test submit code
qial Aug 17, 2020
289a91e
Updated form to use javascript function correctly and fixed dialog is…
qial Aug 19, 2020
d4dc94d
Fixed failure message coming through
qial Aug 19, 2020
cbfe6d7
Updated submitfunction workings
qial Aug 19, 2020
2bb5e16
Updated submitfunction to correctly handle all forms of functions and…
qial Aug 20, 2020
74bb4e7
Fixed functions inside of objects, but doesn't fail well when the obj…
qial Aug 20, 2020
07ce128
Fixed functions inside nested objects in the submitfunction dialog
qial Aug 20, 2020
77057b8
Changed defaultSubmit to onSubmit, changed function not found alert t…
qial Aug 20, 2020
fd9728f
Fixed some styling issues, cleaned up form dialog with hints
qial Aug 20, 2020
5152f32
Updated onSubmit closure to better format so 'this' is carried over
qial Aug 20, 2020
88ca794
Cleaned up useless cases in the submit function loop
qial Aug 20, 2020
75dcf2f
Updated error messages for bad json in the form field model
qial Aug 20, 2020
0196f01
Added _blank target to form model docs link, and removed inline editi…
qial Aug 20, 2020
9c83f7b
poc style implementation of a data list component and a save/load han…
reusr1 Aug 20, 2020
35849d3
Merge branch 'issues/136' of https://github.com/headwirecom/themeclea…
reusr1 Aug 20, 2020
ce28f34
Updated form samples and added sample-all with all supported inputs
qial Aug 21, 2020
99450b8
Updated sample content to fix jcr import error
qial Aug 21, 2020
4184cc1
#136 added styles to error messages and submit btn
smcgrath0 Aug 24, 2020
ba6e404
Fixed Submit button text and other issues with formatting
qial Aug 24, 2020
77c84f1
#136 added transition for error message
smcgrath0 Aug 24, 2020
6ae0a1c
#136 added submit button in all example schemas and removed in markup
smcgrath0 Aug 24, 2020
b44317b
Merge branch 'issues/136' of https://github.com/headwirecom/themeclea…
smcgrath0 Aug 24, 2020
f247851
#136 added styles for all inputs
smcgrath0 Aug 24, 2020
9c24c09
#136 added button alignment and size dialog/styling
smcgrath0 Aug 24, 2020
3862af1
#136 fixed class string/fixed font on textarea/select
smcgrath0 Aug 25, 2020
e7da0a8
updated inline settings for failure messages
qial Aug 25, 2020
5dac11f
Added groups to the input type sample form
qial Aug 25, 2020
3fb9e95
#136 fixed form alignment issue/group styling/checkbox alignment
smcgrath0 Aug 25, 2020
2e29646
#136 dialog button size: sm,lg -> small, large
smcgrath0 Aug 25, 2020
797f0f0
Merge branch 'issues/136' of https://github.com/headwirecom/themeclea…
smcgrath0 Aug 25, 2020
c0b1a49
#156 initial markup
smcgrath0 Aug 25, 2020
c9eceb6
#156 added sortable styles
smcgrath0 Aug 26, 2020
68970ee
#156 built out datalist dialog options
qial Aug 26, 2020
eef1767
#156 fixed table configuration dialog headers
qial Aug 26, 2020
f86a1bb
#156 reordered dialog option for datalist
qial Aug 26, 2020
71cb5e1
#156 updating datalist to load data from localStorage according to di…
qial Aug 27, 2020
79f72a4
#156 styles to dialog
smcgrath0 Aug 27, 2020
b1861da
Merge branch 'issues/156' of https://github.com/headwirecom/themeclea…
smcgrath0 Aug 27, 2020
09f9ab5
#156 added pagination and reformatted hatch
smcgrath0 Aug 27, 2020
b258694
#156 updated endpointurl so datalist can easily load backing data jso…
qial Aug 27, 2020
725c805
#156 added mobile table, removed sorting, fixed header/strip colors
smcgrath0 Aug 28, 2020
874abdb
#156 added text to show when datalist is not configured
smcgrath0 Aug 28, 2020
39a908d
#156 updated loadfunction code and fixed dialog names and error logging
qial Aug 31, 2020
2d8341a
#156 added selected actions
smcgrath0 Aug 31, 2020
c907cd4
Merge branch 'issues/156' of https://github.com/headwirecom/themeclea…
smcgrath0 Aug 31, 2020
0f8b2f3
#156 fixed string error in mounted
smcgrath0 Aug 31, 2020
8d7a1f4
#156 removed pagination
smcgrath0 Aug 31, 2020
9ebf951
#156 Added a start to the forms documentation. Still needs more infor…
qial Aug 31, 2020
1750217
#156 start of datalist docs
smcgrath0 Sep 1, 2020
b614b41
#156 added deletebutton event
smcgrath0 Sep 1, 2020
12f4b29
#156 added hover style to action buttons
smcgrath0 Sep 1, 2020
88413f6
#156 Updated datalist docs, added deletefuntion config and started re…
qial Sep 1, 2020
b8bcf2f
#156 updated documentation with quickstart instructions
qial Sep 2, 2020
1bbea53
#156 squashing bugs in the delete functionality, cleaned up data load…
qial Sep 2, 2020
79a37da
#156 fixed always checked when no elements in table
smcgrath0 Sep 2, 2020
f8b02c4
#156 put selectable action in its own column
smcgrath0 Sep 2, 2020
7b1bef0
#156 hid empty rows and fixed json stringify
qial Sep 2, 2020
6fe91ec
#156 added text alignment for individual columns
smcgrath0 Sep 3, 2020
5cbca32
#156 text align defaults to left if not set
smcgrath0 Sep 3, 2020
c681126
#156 added row alignment
smcgrath0 Sep 3, 2020
366508d
#156 added mobile actions
smcgrath0 Sep 3, 2020
6234679
#156 updated docs and delete function on formsapp
qial Sep 4, 2020
fa60012
#156 added default mobile table style
smcgrath0 Sep 4, 2020
3ced731
Merge branch 'issues/156' of https://github.com/headwirecom/themeclea…
smcgrath0 Sep 4, 2020
51c8a9c
#136 removed form error transition
smcgrath0 Sep 4, 2020
448ee96
#156 fixed datalist deleting and loading
qial Sep 4, 2020
66f1353
#156 updated form submitfunction loop to be simpler, fixed formatting…
qial Sep 4, 2020
f3f372f
Bringing in changes so that failure text no longer times out
qial Sep 4, 2020
fe2c405
Merge remote-tracking branch 'upstream/issues/136' into issues/136
qial Sep 4, 2020
056aa96
#136 removing a final setTimeout on the error message
qial Sep 4, 2020
e6508b9
\#156 Merging in form changes from issues/136 branch
qial Sep 4, 2020
d9f11fd
Merge branch 'develop' of https://github.com/headwirecom/themeclean-f…
smcgrath0 Sep 4, 2020
733a4a3
#156 fixed desktop table when gets too large
smcgrath0 Sep 8, 2020
c4438fd
#156 fixed if no success page is configured
smcgrath0 Sep 8, 2020
72e6bb9
#156 fixed successpage not working on javascript functions
smcgrath0 Sep 8, 2020
1efc1a5
Merge remote-tracking branch 'origin/develop-sling12' into issues/156
Mar 4, 2021
bad28b6
commit current state
Mar 24, 2021
548b5c0
moved the scripts into renderer.html ...
Mar 25, 2021
441cc5c
remove debugging code
Mar 25, 2021
3e9d6c6
remove vfg samples
Mar 25, 2021
9993aad
remove jsonforms-vue2-vanilla.css
Mar 25, 2021
ce6b14a
optimized. styling
Mar 25, 2021
da4e55b
adjust styling
Mar 25, 2021
b5be26c
code-styling
Mar 26, 2021
7d86ddc
remove debounce
Mar 26, 2021
82a5239
add: rerender workaround...
Mar 26, 2021
b18264a
code-style
Mar 26, 2021
81aeef7
update form template
Mar 26, 2021
66af2de
remove new-lines from sample.json
Mar 26, 2021
5aec12a
fixed form default content to contain sample.json
Mar 29, 2021
11bf266
update jsonforms-core.js
Mar 29, 2021
6302994
fix: vertical/horizontal styling ...
Mar 29, 2021
683087c
fix: textarea classes ...
Mar 29, 2021
5c4633d
re-add sample-contact.json
Mar 29, 2021
45a6c89
add sample-all.json ...
Mar 29, 2021
624030d
update form samples
Mar 29, 2021
5910c01
add btn class to arrayList buttons
Mar 29, 2021
bfcc246
add some jsonforms vanilla styling
Mar 29, 2021
772d464
add button workaround ...
Mar 29, 2021
2789868
Merge branch 'develop-sling12' into jsonforms-for-form-component
reusr1 Apr 8, 2021
34abb23
Merge branch 'develop-sling12' into jsonforms-for-form-component
reusr1 Apr 10, 2021
5a827f9
Merge branch 'develop-sling12' into jsonforms-for-form-component
Apr 16, 2021
713f7b9
remove: dependencies
Apr 16, 2021
226b2fd
remove vue version from themecleanflex
reusr1 Apr 16, 2021
21aecf3
Merge branch 'jsonforms-for-form-component' of https://github.com/hea…
reusr1 Apr 16, 2021
eedda22
Merge remote-tracking branch 'origin/jsonforms-for-form-component' in…
Apr 16, 2021
f0dda4a
change: dependencies (not working yet)
Apr 16, 2021
4cf9bbb
add: temp. solution for dep. order loading
Apr 19, 2021
7d0286d
fix: dependencies
Apr 20, 2021
1b2bbf4
minor changes to add a dialog group and make sure the component is no…
reusr1 Apr 24, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
879 changes: 879 additions & 0 deletions core/src/main/java/com/themecleanflex/models/DatalistModel.java

Large diffs are not rendered by default.

727 changes: 727 additions & 0 deletions core/src/main/java/com/themecleanflex/models/FormModel.java

Large diffs are not rendered by default.

108 changes: 108 additions & 0 deletions docs/datalist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Datalist Implementation

### Quickstart
The easiest way to get started with the Datalist is to use the <code>$formsapp</code> javascript connected to a form. This will store data into your local browser storage that will then be displayed in the datalist.

Create a new page and add a Form component. Edit the form to use the following form model:

{
"fields": [
{
"type": "input",
"inputType": "text",
"label": "First Name",
"model": "firstName",
"id": "first_name",
"placeholder": "Your name",
"featured": true,
"required": true
},{
"type": "input",
"inputType": "text",
"label": "Last Name",
"model": "lastName",
"id": "last_name",
"placeholder": "Your name",
"featured": true,
"required": true
}
]}

- Endpoint URL: <code>list</code>
- Submit Function: <code>$formsapp.save</code>

Add a Datalist component. You can leave the *endpoint URL*, *load function*, and *delete function* blank. Add two columns
in the *Table Configuration* with the following values:
- Header: **First Name**
- Data Value: **firstName**
- Header: **Last Name**
- Data Value: **lastName**

Now, if you submit a first and last name through the form and refresh the page, your values should show up in the table.
If you edit the Datalist component and turn on *Selectable Table* you will get the option to delete rows from the table.

### Datalist Javascript Events

#### datalist-storage-update
The datalist component has an event listener for the <code>datalist-storage-update</code> event. If this event is fired, it will trigger a reload of the backing data. You can use this event in other javascript functions to force a reload when data has been changed.

See the **themecleanflex/pages/js/formsapp.js** <code>save()</code> function for an example of this in action.

### Datalist Component Configuration

#### Datalist Data Retrieval
If a endpoint URL is indicated, then the datalist will do an axios GET request with the table data to this URL.

The endpoint should return a list of objects.
ex.

[{
"firstName": "Kyle",
"lastName": "Watson"
},{
"firstName": "Shane",
"lastName": "Mcgrath"
},{
"firstName": "Ben",
"lastName": "Kahn"
}]

#### Javascript Function to Get Data
Instead of the default GET endpoint behaviour, the user can configure a custom function to be called instead. This function can be part of any object as long as it can be accessed through the javascript window object.
This function will be passed one parameter
- Path - the endpoint URL specified in the configuration

#### Javascript Function to Delete Data
If the table is selectable, the user can configure a custom function to delete data. If the load function is defined, this function must also be defined for table delete action to work correctly.
The function will be passed three parameters:
- Table Data - the data array currently backing the table
- Active - a boolean array denoting which rows of the table data array are currently selected
- Path - the endpoint URL specified in the configuration

This function is expected to return a new data array with the selected rows removed.

#### Table Configuration
Add columns with any header value with the data value being a property in the objects returned by the endpoint/local storage.
Each column takes three configuration options:
- Header - The name to be displayed in the column header
- Data Value - The data in the backing model to display in this column
- Column Alignment - The horizontal alignment to render text in the cell.

#### Row Alignment
Defines the default row vertical alignment for the table.

#### Striped Rows

Adjusts colors of every other row in the table.

#### Dense Table

Lowers the spacing of the table cells.

#### Scrollable Table

Allows user to scroll through table results. Can adjust the height of the container and make the headers stick to the top of table when scrolling or not.

#### Selectable Table

Allows user to select table rows and perform actions on the rows selected.
100 changes: 100 additions & 0 deletions docs/forms.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Forms Implementation

### Quickstart

Check out the Datalist documentation for a quickstart using a form that saves to your local browser storage and shows the results in a table.

This section will describe setting up a contact form that posts to an external URL.

Create a new page and add the Form - Contact sample component. This component has a form model configured with a first name, last name, email, and text area.

{
"fields": [
{
"type": "input",
"inputType": "text",
"label": "First Name",
"model": "first_name",
"id": "first_name",
"placeholder": "First Name"
},{
"type": "input",
"inputType": "text",
"label": "Last Name",
"model": "last_name",
"id": "last_name",
"placeholder": "Last Name"
},{
"type": "input",
"inputType": "text",
"label": "Email",
"model": "email",
"id": "email",
"placeholder": "Email",
"featured": true,
"required": true
},{
"type": "textArea",
"label": "Text",
"model": "text",
"id": "text",
"rows": 4,
"placeholder": "Enter text here",
"featured": true,
"required": true
}
]}

Edit the component configuration and update the following:
- Endpoint URL: *url you would like to post to*
- Failure Message: "Error processing form"
- Success Page: *path to page when form submits successfully*

Now the form will attempt to do an AJAX post to the endpoint URL. If you put an invalid URL, you can see that the failure message will show up when the form attempts to submit. If the submission is successful (the POST request gets a 200 OK HTTP status), then peregrine will forward the user to the configured success page.

### Form Javascript Events

#### form-clear
The form component has an event listener for the

### Form Component Configuration

#### Form Model
The Form Model takes a Vue Form Generator JSON configuration. For an example and a list of the configuration options for each type of field see the [Vue Form Generator fields documentation](https://vue-generators.gitbook.io/vue-generators/fields)

Here is an example form with a single field called name:

{
"fields": [
{
"type": "input",
"inputType": "text",
"label": "Name",
"model": "name",
"id": "user_name",
"placeholder": "Your name",
"featured": true,
"required": true
}
]}

#### Form Submit Endpoint URL
The form will do an ajax POST with the form data to this URL. If the response is successful, it will forward the user to the configured Submit Success Page.

#### Javascript Function to Call on Submit
Instead of the default POST behaviour, the user can configure a custom function to be called instead. This function can be part of any object as long as it can be accessed through the javascript window object.
It will be passed two parameters:
- model - the Vue object model with the component configuration
- formData - an object containing the form data

#### Submit Button Text

Configure the text for the submit button, defaults to "Submit"

#### Failure Message

If there is an error processing the form, this message will be shown in an error box above the form.

#### Submit Success Page

If not empty, on successful form submission it will forward the user to this page.
188 changes: 188 additions & 0 deletions fragments/datalist/hatch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
module.exports = {
convert: function($, f) {
f.wrap($, 'themecleanflex-components-block')
f.bindAttribute($.parent(),'model','model')

const selectedContainer = $.find('div.selected').eq(0)
const selectedContainerClasses = `{
'hidden': active.filter(element => element === true).length === 0,
}`
f.bindAttribute(selectedContainer, 'class', selectedContainerClasses, false)
const mobileSelectAction = selectedContainer.find('.action').eq(0)
f.addIf(mobileSelectAction, '(model.mobiletablestyle === "" || model.mobiletablestyle === "default") && isMobile' )
f.bindEvent(mobileSelectAction, 'click', 'toggleAllRows');
f.addIf(mobileSelectAction.find('.unchecked'), '(!active.every(element => element === true) || active.length === 0)');
f.addElse(mobileSelectAction.find('.checked'));
const selectedText = selectedContainer.find('.selected-text').eq(0)
f.mapField(selectedText, '`${active.filter(element =&gt; element === true).length} selected`', false)
const actionDelete = selectedContainer.find('.selected-actions svg').eq(0)
f.bindEvent(actionDelete, 'click', 'deleteAction');

const desktopContainer = $.find('div.overflow-x-scroll').eq(0);
const desktopContainerClasses = `{
'overflow-y-scroll': model.scrollabletable === 'true',
'hidden': isMobile,
}`
f.bindAttribute(desktopContainer, 'class', desktopContainerClasses, false)
f.addStyle(desktopContainer, 'height', "(model.scrollabletable === 'true') ? model.tableheight + 'px' : 'auto'", false)

const mobileContainer = $.find('div.mobile-table').eq(0);
const mobileContainerClasses = `{
'hidden': !isMobile,
}`
f.bindAttribute(mobileContainer, 'class', mobileContainerClasses, false)

//default mobile style
const mobileDefaultBody = mobileContainer.find('tbody').eq(0);
f.addIf(mobileDefaultBody, 'model.mobiletablestyle === "" || model.mobiletablestyle === "default"' )

const mobileDefaultTr = mobileContainer.find('tr.item-row').eq(0)
f.addFor(mobileDefaultTr, 'model.columns', 'col')
mobileDefaultTr.attr(':key', `data.path || j`)
f.addStyle(mobileDefaultTr, 'background', "active[j] ? 'var(--color-red-500) !important' : ''")

const mobileDefaultAction = mobileDefaultBody.find('td.action-head').eq(0)
f.addStyle(mobileDefaultAction, 'background', "active[j] ? 'var(--color-red-500) !important' : ''")
f.addIf(mobileDefaultAction, 'i === 0')
f.addIf(mobileDefaultAction.find('.unchecked'), '!active[j]');
f.addIf(mobileDefaultAction.find('.checked'), 'active[j]')
f.addStyle(mobileDefaultAction.find('.checked'), 'fill',"active[j] ? 'var(--text-secondary-color) !important' : ''");
f.bindEvent(mobileDefaultAction.find('.action').eq(0), 'click', 'toggleRow(j)');

const mobileDefaultActionSpacer = mobileDefaultBody.find('td.mobile-action-spacer').eq(0)
f.addIf(mobileDefaultActionSpacer, 'i !== 0')
f.addStyle(mobileDefaultActionSpacer, 'background', "active[j] ? 'var(--color-red-500) !important' : ''")

f.mapField(mobileDefaultBody.find('td.mobile-header').eq(0), 'col.header', false)
mobileDefaultBody.find('td.mobile-header').eq(0).attr(':key', `col.path || i`)

f.mapField(mobileDefaultBody.find('td.mobile-item').eq(0), 'data[col.value]', false)
f.addStyle(mobileDefaultBody.find('td.mobile-item').eq(0), 'background', "active[j] ? 'var(--color-red-500) !important' : ''")
f.addStyle(mobileDefaultBody.find('td.mobile-item').eq(0), 'color',"active[j] ? 'var(--text-secondary-color) !important' : ''");

f.wrap(mobileDefaultTr, 'template')

const mobileTemplate = mobileDefaultBody.find('template').first();
mobileTemplate.attr('v-for', `(data, j) in storageData`)
f.addIf(mobileTemplate, 'rowHasData(data,model.columns)')

//scroll mobile style
const scrollMobileBody = mobileContainer.find('tbody').eq(1)
f.addElse(scrollMobileBody)
const mobileScrollActionTr = scrollMobileBody.find('tr.action-row').eq(0)
const mobileScrollAction = scrollMobileBody.find('td.action-item').eq(0)
f.addFor(mobileScrollAction, 'storageData', 'data')
f.addIf(mobileScrollAction, 'rowHasData(data,model.columns)')
f.addIf(mobileScrollAction.find('.unchecked'), '!active[i]');
f.addIf(mobileScrollAction.find('.checked'), 'active[i]');
f.addStyle(mobileScrollAction, 'background', "active[i] ? 'var(--color-red-500) !important' : ''")
f.addStyle(mobileScrollAction.find('.checked'), 'fill',"active[i] ? 'var(--text-secondary-color) !important' : ''");
f.bindEvent(mobileScrollAction.find('.action').eq(0), 'click', 'toggleRow(i)');

const mobileScrollActionAll = mobileScrollActionTr.find('td.action-item-all').eq(0)
f.addIf(mobileScrollActionAll.find('.unchecked'), '(!active.every(element => element === true) || active.length === 0)');
f.addElse(mobileScrollActionAll.find('.checked'));
f.bindEvent(mobileScrollActionAll.find('.action').eq(0), 'click', 'toggleAllRows');

const mobileScrollBodyTr = scrollMobileBody.find('tr.item-row').first()
f.addFor(mobileScrollBodyTr, 'model.columns', 'col')

const mobileScrollTd = mobileScrollBodyTr.find('td').first()
mobileScrollTd.attr('v-for', `(data, j) in storageData`)
mobileScrollTd.attr(':key', `data.path || j`)
f.addIf(mobileScrollTd, 'rowHasData(data,model.columns)')
f.mapField(mobileScrollTd, 'data[col.value]', false)
f.addStyle(mobileScrollTd, 'background', "active[j] ? 'var(--color-red-500) !important' : ''")

mobileScrollBodyTr.prepend("<td class='mobile-header'>{{col.header}}</td>")

const mobileTdClasses = `{
'border': model.cellborders === 'true',
'p-3': model.densetable !== 'true',
'p-1': model.densetable === 'true',
'align-top': model.rowalignment === 'top' || model.rowalignment === '',
'align-center': model.rowalignment === 'center',
'align-bottom': model.rowalignment === 'bottom'
}`
f.bindAttribute($.find('.mobile-table td'), 'class', mobileTdClasses, false)

//desktop
const table = $.find('table')
const tableClasses = `{
'striped': model.stripedrows === 'true'
}`
f.bindAttribute(table, 'class', tableClasses, false)

const thText = $.find('th.header-item').first()
f.addFor(thText, 'model.columns', 'col')
const thTextClasses = `{
'p-3': model.densetable !== 'true',
'p-1': model.densetable === 'true',
'sticky': model.stickyheader === 'true',
'top-0': model.stickyheader === 'true',
'text-left': (col && col.textalignment === 'left') || (col && col.textalignment === ''),
'text-center': col && col.textalignment === 'center',
'text-right': col && col.textalignment === 'right',
}`
f.bindAttribute(thText, 'class', thTextClasses, false)
f.mapField(thText.find('span'), 'col.header', false)

const thAction = $.find('th.action-head').first()
f.addIf(thAction, "model.selectable === 'true'")
f.addIf(thAction.find('.unchecked'), '(!active.every(element => element === true) || active.length === 0)');
f.addElse(thAction.find('.checked'));
f.bindEvent(thAction.find('.action').eq(0), 'click', 'toggleAllRows');
f.bindAttribute(thAction, 'class', thTextClasses, false)

const tbody = $.find('tbody').first()
const tr = tbody.find('tr').first()
const tdItem = tr.find('td.item').first()
tr.attr('v-for', `(data, j) in storageData`)
tr.attr(':key', `data.path || j`)
f.addIf(tr, 'rowHasData(data,model.columns)')

f.addFor(tdItem, 'model.columns', 'col')
f.mapField(tdItem.find('span.item-text'), 'data[col.value]', false)

const tdClasses = `{
'border': model.cellborders === 'true',
'p-3': model.densetable !== 'true',
'p-1': model.densetable === 'true',
'text-left': (col && col.textalignment === 'left') || (col && col.textalignment === ''),
'text-center': col && col.textalignment === 'center',
'text-right': col && col.textalignment === 'right',
'align-top': model.rowalignment === 'top' || model.rowalignment === '',
'align-center': model.rowalignment === 'center',
'align-bottom': model.rowalignment === 'bottom'
}`
f.bindAttribute(tdItem, 'class', tdClasses, false)
f.addStyle(tdItem, 'background', "active[j] ? 'var(--color-red-500) !important' : ''")

f.addStyle(tdItem.find('span.item-text'), 'color',"active[j] ? 'var(--text-secondary-color) !important' : ''");

const tdAction = $.find('td.action-item').first()
f.addStyle(tdAction, 'background', "active[j] ? 'var(--color-red-500) !important' : ''")
f.addIf(tdAction, "model.selectable === 'true'")
f.addIf(tdAction.find('.unchecked'), '!active[j]');
f.addIf(tdAction.find('.checked'), 'active[j]');
f.addStyle(tdAction.find('.checked'), 'fill',"active[j] ? 'var(--text-secondary-color) !important' : ''");
f.bindEvent(tdAction.find('.action').eq(0), 'click', 'toggleRow(j)');
f.bindAttribute(tdAction, 'class', tdClasses, false)

const caption = $.find('caption')
const captionClasses = `{
'text-left': model.captionalignment === 'left',
'text-center': model.captionalignment === 'center',
'text-right': model.captionalignment === 'right',
'p-3': model.densetable !== 'true',
'p-1': model.densetable === 'true',
'hidden': model.caption !== 'true'
}`
f.bindAttribute(caption, 'class', captionClasses, false)
f.addStyle(caption, 'caption-side', "model.captionplacement", false);
f.mapField(caption, 'model.captiontext')

f.addElse($);
$.parent().prepend('<div class="p-5" v-if="isEditAndEmpty">no content defined for component</div>')
}
}
Loading