Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
ad504f5
feature(jv-input-controls|jv-tools): add cascading feature support
ecanchev-jaspersoft Nov 28, 2024
da69576
feature(jv-input-controls|jv-tools): move logic for building the json…
ecanchev-jaspersoft Nov 28, 2024
7ddd35d
feature(jv-input-controls|jv-tools): update "selected" property for e…
ecanchev-jaspersoft Nov 28, 2024
d2947d8
feature(jv-input-controls|jv-tools): remove "buildLatestJSON" method …
ecanchev-jaspersoft Nov 28, 2024
e3a8cb3
feature(jv-input-controls): add request-like when updating an IC that…
ecanchev-jaspersoft Nov 29, 2024
f56a89a
feature(jv-input-controls): store input controls state into the conte…
ecanchev-jaspersoft Dec 3, 2024
fafe84c
Merge branch 'main' into cascading-ics
ecanchev-jaspersoft Dec 3, 2024
0c58701
feature(jv-input-controls): update values on the UI based on the state
ecanchev-jaspersoft Dec 4, 2024
6c687a1
feature(jv-input-controls): move logic for updating the input control…
ecanchev-jaspersoft Dec 4, 2024
787d89f
feature(jv-input-controls): restore callback with the result validati…
ecanchev-jaspersoft Dec 5, 2024
303f957
feature(jv-input-controls): add cascading feature for MultiSelect Inp…
ecanchev-jaspersoft Dec 5, 2024
0e7a973
feature(jv-input-controls): fix triggering multiple times the events.…
ecanchev-jaspersoft Dec 5, 2024
7438f4a
feature(jv-input-controls): improve code readability
ecanchev-jaspersoft Dec 5, 2024
59fcb51
feature(jv-input-controls): improve code readability II
ecanchev-jaspersoft Dec 5, 2024
6ba9066
feature(jv-input-controls): add skeleton while the cascading input co…
ecanchev-jaspersoft Dec 5, 2024
6ca8137
feature(jv-input-controls): create new custom hook to encapsulate the…
ecanchev-jaspersoft Dec 6, 2024
9122b89
feature(jv-input-controls): fix issue that was triggering the events.…
ecanchev-jaspersoft Dec 6, 2024
dd804b5
feature(jv-input-controls): extract methods that are used for Single …
ecanchev-jaspersoft Dec 6, 2024
9b20488
Logic for storing the input control values in the store. This is beca…
ecanchev-jaspersoft Dec 17, 2024
892cd46
Logic for storing the input control values in the store for SingleVal…
ecanchev-jaspersoft Dec 17, 2024
644a66e
useNumberErrorMsgs hook is not needed anymore, thanks to the store.
ecanchev-jaspersoft Dec 17, 2024
894efa1
DatePickerInput and DatePickerTextField input controls have been upda…
ecanchev-jaspersoft Dec 17, 2024
f988e52
DateTimePickerInput and DateTimePickerTextField input controls have b…
ecanchev-jaspersoft Dec 18, 2024
300e2b6
TimePickerInput and TimePickerTextField input controls have been upda…
ecanchev-jaspersoft Dec 18, 2024
852772b
removed custom hook that is not needed anymore
ecanchev-jaspersoft Dec 19, 2024
655668c
useLiveState custom hook tests updated after the new changes for the …
ecanchev-jaspersoft Dec 19, 2024
bcc3043
useChangeCallback custom hook tests added after the new changes for t…
ecanchev-jaspersoft Dec 19, 2024
cccf5e3
BooleanInputControl tests updated after the new changes for the store…
ecanchev-jaspersoft Dec 19, 2024
a100ba8
DatePickerInputControl tests updated after implementing the new chang…
ecanchev-jaspersoft Dec 19, 2024
794f909
DatePickerTextFieldInputControl tests updated after implementing the …
ecanchev-jaspersoft Dec 19, 2024
ede33df
DateTimePickerInputControl tests updated after implementing the new c…
ecanchev-jaspersoft Dec 19, 2024
99f400e
removed dependency that is not needed anymore on the DateTimePickerIn…
ecanchev-jaspersoft Dec 19, 2024
1196ff1
TimePickerInputControl tests updated after implementing the new chang…
ecanchev-jaspersoft Dec 19, 2024
459dc86
changed object to any for the typings
ecanchev-jaspersoft Dec 19, 2024
fe19423
TimePickerTextFieldInputControl tests updated after implementing the …
ecanchev-jaspersoft Dec 19, 2024
d6f2804
SingleValueNumberInputControl tests updated after implementing the ne…
ecanchev-jaspersoft Dec 19, 2024
05a3a4a
SingleValueTextInputControl tests updated after implementing the new …
ecanchev-jaspersoft Dec 19, 2024
968a88d
SingleSelectInputControl tests updated after implementing the new cha…
ecanchev-jaspersoft Dec 20, 2024
fe9586a
MultiSelectInputControl tests updated after implementing the new chan…
ecanchev-jaspersoft Dec 20, 2024
1aee2ce
BasePanel.test.tsx tests updated after implementing the new changes f…
ecanchev-jaspersoft Dec 20, 2024
28a8812
Merge branch 'main' into cascading-ics
ecanchev-jaspersoft Dec 20, 2024
f665b83
Request controls from REST
grantbacon-jaspersoft Dec 20, 2024
f584bfe
Ability to hit the JRS API has been added to jv-input-controls when a…
ecanchev-jaspersoft Dec 20, 2024
e7716b3
Merge branch 'cascading-ics' into cascading-rest
ecanchev-jaspersoft Dec 20, 2024
325a621
tests fixed
ecanchev-jaspersoft Dec 20, 2024
0505540
feature(jv-input-controls): fetching cascading input controls has bee…
ecanchev-jaspersoft Dec 23, 2024
1451ce3
feature(jv-input-controls): fix when making the API call for fetching…
ecanchev-jaspersoft Dec 23, 2024
6909a3a
feature(jv-input-controls): fix when fetching options and the API ret…
ecanchev-jaspersoft Dec 23, 2024
c5735bd
feature(jv-input-controls): remove redundant code
ecanchev-jaspersoft Dec 23, 2024
19583c4
feature(jv-input-controls): fix changing the values before the first …
ecanchev-jaspersoft Dec 26, 2024
33f41c6
feature(jv-input-controls): clean up the JS and the React approches f…
ecanchev-jaspersoft Dec 26, 2024
11ce9be
feature(jv-tools): useVisualize hook is now accepting: visualizePath,…
ecanchev-jaspersoft Dec 26, 2024
a8eee80
feature(jv-tools): add changelog file to show breaking changes
ecanchev-jaspersoft Jan 2, 2025
a0d91da
feature(jv-tools): add content to changelog
ecanchev-jaspersoft Jan 2, 2025
d7bc13e
feature(jv-input-controls): remove StringUtils and replaced it with .…
ecanchev-jaspersoft Jan 3, 2025
6e07124
feature(jv-input-controls): update reducer to use named method
ecanchev-jaspersoft Jan 3, 2025
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
94 changes: 52 additions & 42 deletions packages/demo-input-controls/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
*/

import "./App.css";
import { renderInputControls } from "@jaspersoft/jv-input-controls";
import {
InputControlsConfig,
renderInputControls,
} from "@jaspersoft/jv-input-controls";
import {
Authentication,
InputControlProperties,
Expand All @@ -22,18 +25,60 @@ const myAuth: Authentication = {
locale: "en_US",
};

const reportUri = "/public/Samples/Reports/07g.RevenueDetailReport";
const reportUri = "/public/Samples/Reports/16g.InteractiveSalesReport";
// const reportUri = "/public/Samples/Reports/07g.RevenueDetailReport";
const singleSelectReportUri = "/public/Samples/Reports/9g.CustomerDetailReport";

const visualizeUrl =
"https://mobiledemo.jaspersoft.com/jasperserver-pro/client/visualize.js";
const globalConfigForIcs: InputControlsConfig = {
success: () => {
console.log("Input controls rendered successfully");
},
error: (error) => {
console.log("Error rendering input controls: ", error);
},
typeConfig: {
singleValueDatetime: {
type: "default", // even if it isn't provided, this will be the default component
},
singleValueTime: {
type: "default", // even if it isn't provided, this will be the default component
},
singleValueDate: {
type: "default", // even if it isn't provided, this will be the default component
},
},
params: {
column_boolean_1: ["false"],
column_string_1: [
"This is a predefined text different than the stored in the server",
],
id_1: ["99"],
column_date_1: ["2009-03-02"],
column_timestamp_1: ["2014-03-02T10:00:00"],
column_time_1: ["14:00:00"],
ProductFamily: ["Drink", "Food"],
},
events: {
change: (ics, validationResult) => {
console.log("validationResult => ", validationResult);
console.log("ics => ", ics);
},
},
};

const errorCallback = (errorCaught: Error | VisualizeGenericError | string) => {
console.log("check the error! ", errorCaught);
};

function App() {
const vContainer = useVisualize(visualizeUrl, myAuth, { errorCallback });
const vContainer = useVisualize(
{
server: "https://mobiledemo.jaspersoft.com/jasperserver-pro",
visualizePath:
"https://mobiledemo.jaspersoft.com/jasperserver-pro/client/visualize.js",
auth: myAuth,
},
{ errorCallback },
);
const [controlBuffer, setControlBuffer] =
useState<InputControlProperties[]>();
const [vReport, setVReport] = useState<any>();
Expand All @@ -46,42 +91,7 @@ function App() {
vContainer.v,
reportUri,
document.getElementById("input-controls-container") as HTMLElement,
{
success: () => {
console.log("Input controls rendered successfully");
},
error: (error) => {
console.log("Error rendering input controls: ", error);
},
typeConfig: {
singleValueDatetime: {
type: "default", // even if it isn't provided, this will be the default component
},
singleValueTime: {
type: "default", // even if it isn't provided, this will be the default component
},
singleValueDate: {
type: "default", // even if it isn't provided, this will be the default component
},
},
params: {
column_boolean_1: ["false"],
column_string_1: [
"This is a predefined text different than the stored in the server",
],
id_1: ["99"],
column_date_1: ["2009-03-02"],
column_timestamp_1: ["2014-03-02T10:00:00"],
column_time_1: ["14:00:00"],
ProductFamily: ["Drink", "Food"],
},
events: {
change: (ics, validationResult) => {
console.log("validationResult => ", validationResult);
console.log("ics => ", ics);
},
},
},
globalConfigForIcs,
);

renderInputControls(
Expand Down
4 changes: 3 additions & 1 deletion packages/demo-scheduler/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import ReportPanel from "./report/ReportPanel";
import "./App.css";
import { Scheduler } from "./Scheduler";

const visualizeUrl = `${schedulerUIConfig.server}${schedulerUIConfig.contextPath}/client/visualize.js`;
const serverUrl = `${schedulerUIConfig.server}${schedulerUIConfig.contextPath}`;
const visualizeUrl = `${serverUrl}/client/visualize.js`;

const credentials: Authentication = {
name: "joeuser",
Expand All @@ -44,6 +45,7 @@ function SchedulerApp() {
loadVisualize().then((visualizeFactory: VisualizeFactory) => {
visualizeFactory(
{
server: serverUrl,
auth: { ...credentials },
},
(v: VisualizeClient) => {
Expand Down
16 changes: 11 additions & 5 deletions packages/jv-input-controls/src/InputControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import BasePanel from "./panels/BasePanel";
import { fillControlStructure } from "./methods";
import { MultiSelectICType } from "./controls/MultiSelectInputControl";
import { SingleSelectICType } from "./controls/SingleSelectInputControl";
import { InputControlsProvider } from "./reducer/InputControlsReducer";

export interface InputControlsTypeConfig {
bool?: {
Expand Down Expand Up @@ -108,12 +109,17 @@ export function InputControls(props: InputControlsProps) {
<JVStylesProvider>
{(props.v === undefined || !embedControls) && showLoadingSpinner()}
{props.v !== undefined && embedControls && (
<BasePanel
controls={embedControls}
config={props.config?.typeConfig}
<InputControlsProvider
initialState={embedControls.data}
overwriteParams={props.config?.params}
events={props.config?.events}
params={props.config?.params}
></BasePanel>
>
<BasePanel
server={props.v.server || ""}
uri={props.uri}
config={props.config?.typeConfig}
/>
</InputControlsProvider>
)}
</JVStylesProvider>
);
Expand Down
7 changes: 5 additions & 2 deletions packages/jv-input-controls/src/controls/BaseInputControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
* in the license file that is distributed with this file.
*/

import { InputControlProperties } from "@jaspersoft/jv-tools";
import {
CommonInputControlProperties,
InputControlProperties,
} from "@jaspersoft/jv-tools";

export const getInputControlProperties = (
ic: InputControlProperties,
updatedStateValue: any,
) => {
): CommonInputControlProperties => {
return {
id: ic.id,
type: ic.type,
Expand Down
38 changes: 26 additions & 12 deletions packages/jv-input-controls/src/controls/DatePickerInputControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ import {
InputControlValidationRule,
} from "@jaspersoft/jv-tools";
import { useControlClasses } from "./hooks/useControlClasses";
import { useErrorMsg } from "./hooks/useErrorMsg";
import { useLiveDateFormattedState } from "./hooks/useLiveDateFormattedState";
import { getTheInitialValue } from "../utils/DefaultValueUtils";
import { validateValueAgainstICValidationRules } from "../utils/ErrorMessageUtils";
import { useState } from "react";
import { getInputControlProperties } from "./BaseInputControl";

export type DatePickerICType = "material";

Expand All @@ -32,24 +34,36 @@ export const DatePickerInputControl = (props: DateICProps) => {
"YYYY-MM-DD",
).toUpperCase();

const liveState = useLiveDateFormattedState({
initialValue: getTheInitialValue(props.state?.value) || "",
format: dateFormat,
});
const controlClasses = useControlClasses([], props);
const [errorText, setErrorText] = useState<string>("");
const minAndMaxSettings = getMinAndMaxSettings(props.dataType, {
minKey: "minDate",
maxKey: "maxDate",
});
const errorText = useErrorMsg({
textValue: liveState.value,
props,
minAndMaxDate: minAndMaxSettings,
const liveState = useLiveDateFormattedState({
initialValue: getTheInitialValue(props.state?.value) || "",
format: dateFormat,
callback: (newValue) => {
const { errorMsg } = validateValueAgainstICValidationRules(
newValue,
liveState.value,
props,
"",
minAndMaxSettings,
);
setErrorText(errorMsg);
props.handleIcChange!(getInputControlProperties(props, newValue), {
[props.id]: errorMsg,
});
},
});
const { events, ...remainingProps } = props;
const controlClasses = useControlClasses([], props);
return (
<JVDatePicker
{...{ ...remainingProps, ...minAndMaxSettings }}
id={props.id}
label={props.label}
readOnly={props.readOnly}
disabled={!!props.disabled}
{...{ ...minAndMaxSettings }}
onChange={liveState.onChange}
value={liveState.value}
className={`${controlClasses.join(" ")} ${props.className || ""}`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import { JVDateTimeTextField } from "@jaspersoft/jv-ui-components";
import { getMinAndMaxSettings } from "../utils/DateInputControlUtils";
import { InputControlProperties } from "@jaspersoft/jv-tools";
import { useControlClasses } from "./hooks/useControlClasses";
import { useErrorMsg } from "./hooks/useErrorMsg";
import { useLiveState } from "./hooks/useLiveState";
import { getTheInitialValue } from "../utils/DefaultValueUtils";
import { validateValueAgainstICValidationRules } from "../utils/ErrorMessageUtils";
import { getInputControlProperties } from "./BaseInputControl";
import { useState } from "react";

export type DateICType = "default";

Expand All @@ -23,37 +25,47 @@ export interface DateTextFieldICProps extends InputControlProperties {
export const DatePickerTextFieldInputControl = (
props: DateTextFieldICProps,
) => {
const {
readOnly,
mandatory,
visible,
dataType,
validationRules,
events,
...remainingProps
} = props;
const liveState = useLiveState(getTheInitialValue(props.state?.value) || "");
const controlClasses = useControlClasses([], props);
const inputProps: any = {};
if (readOnly) {
inputProps.readOnly = true;
}
const { readOnly, dataType } = props;
const minAndMaxSettings: { min: string; max: string } = getMinAndMaxSettings(
dataType,
{
minKey: "min",
maxKey: "max",
},
);
const errorText = useErrorMsg({
textValue: liveState.value,
props,
minAndMaxDate: minAndMaxSettings,
});
const theInputProps = { ...inputProps, ...liveState };
const [errorText, setErrorText] = useState<string>("");
const liveState = useLiveState(
getTheInitialValue(props.state?.value) || "",
(newValue: string) => {
const { errorMsg } = validateValueAgainstICValidationRules(
newValue,
liveState.value,
props,
"",
minAndMaxSettings,
);
setErrorText(errorMsg);
props.handleIcChange!(getInputControlProperties(props, newValue), {
[props.id]: errorMsg,
});
},
);
const controlClasses = useControlClasses([], props);
const inputProps: any = {};
if (readOnly) {
inputProps.readOnly = true;
}
const theInputProps = {
...inputProps,
value: liveState.value,
onChange: liveState.onChange,
};

return (
<JVDateTimeTextField
{...remainingProps}
id={props.id}
label={props.label}
disabled={!!props.disabled}
type="date"
variant={props.variant || "outlined"}
className={`${props.className || ""}`}
Expand Down
Loading
Loading