Skip to content

Commit

Permalink
chore: auto update client extensions samples
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Nov 16, 2023
1 parent 660dfb8 commit 6a61bca
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"dependencies": {
"@liferay/js-api": "0.4.0-pre.0",
"@liferay/js-api": "0.5.1-pre.0",
"serve": "^14.2.0"
},
"description": "Liferay Sample Frontend Data Set Cell Renderer",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"dependencies": {
"@liferay/js-api": "0.4.0-pre.0",
"@liferay/js-api": "0.5.1-pre.0",
"serve": "^14.2.0"
},
"description": "Liferay Sample FDS Filter",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,60 @@
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
*/

import type {FDSFilterHTMLElementBuilder} from '@liferay/js-api/data-set';
import type {
FDSFilter,
FDSFilterHTMLElementBuilderArgs,
} from '@liferay/js-api/data-set';

const mySampleFilter: FDSFilterHTMLElementBuilder = ({filter, setFilter}) => {
const div = document.createElement('div');
const button = document.createElement('button');
// Declare the structure of the internal data that describes the filter state (in this case it will
// be the plain odata string the user enters through the filter's UI).

type FilterData = string;

function descriptionBuilder(selectedData: FilterData): string {
return selectedData;
}

function htmlElementBuilder({
filter,
setFilter,
}: FDSFilterHTMLElementBuilderArgs<FilterData>): HTMLElement {
const input = document.createElement('input');

div.className = 'dropdown-item';
if (filter.selectedData) {
input.value = filter.selectedData;
}

input.className = 'form-control';
input.placeholder = 'Search with Odata';

const button = document.createElement('button');

button.className = 'btn btn-block btn-secondary btn-sm mt-2';
button.innerText = 'Submit';
button.onclick = () =>
setFilter({
odataFilterString: input.value,
selectedData: input.value,
});

if (filter.selectedData) {
input.value = filter.selectedData;
}
const div = document.createElement('div');

input.className = 'form-control';
input.placeholder = 'Search with Odata';
div.className = 'dropdown-item';

div.appendChild(input);
div.appendChild(button);

return div;
}

function oDataQueryBuilder(selectedData: FilterData): string {
return selectedData;
}

const fdsFilter: FDSFilter<FilterData> = {
descriptionBuilder,
htmlElementBuilder,
oDataQueryBuilder,
};

export default mySampleFilter;
export default fdsFilter;

0 comments on commit 6a61bca

Please sign in to comment.