Skip to content

Commit

Permalink
Merge pull request #92 from manu2699/board-csv
Browse files Browse the repository at this point in the history
added import csv in board
  • Loading branch information
saravanan10393 authored Apr 18, 2024
2 parents c787b0a + b3e2fa8 commit 8d16f17
Show file tree
Hide file tree
Showing 6 changed files with 164 additions and 23 deletions.
74 changes: 61 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -542,15 +542,19 @@ greetPopup.close();

### 8) Dataform

Get dataform instance like
In Kissflow apps, dataforms gather and store data, enabling users to submit data
into an app.

To begin with, obtain the dataform instance using:

```js
const dfInstance = kf.app.getDataform("dataform_id");
```

##### Import CSV

Opens up the import CSV modal where user could upload CSV file and map
respective columns to the field.
Launches the import CSV popup, where you can upload CSV file and map columns to
the corresponding fields.

```js
let defaultValues = { fieldId: "value" };
Expand All @@ -559,27 +563,71 @@ dfInstance.importCSV(defaultValues);

###### Example scenario

Consider scenario where few fields that aren't exposed to user(basically hidden
in form visibilty). In such cases Default values can be used to provide data to
hidden fields
Consider scenario where certain fields are not visible to the user(hidden in
form visibilty). In that case, default values can be used to populate data in
these hidden fields

```js
//Get the dataform with the dataform's flow_id
const dfInstance = kf.app.getDataform("Product_Dataform_A00"); //Product_Dataform_A00 is the flow_id
const dfInstance = kf.app.getDataform("Product_Dataform_A00"); //Product_Dataform_A00 is the flow_id

//Set field values for specific fields of the dataform
let defaultValues = { location: "India" }; //Location is the the field_id of a field inside the dataform
let defaultValues = { location: "India" }; //Location is the the field_id of a field inside the dataform

//Pass the field config into the import sdk method
dfInstance.importCSV(defaultValues); //All records imported through this importer would have Location field set as India
//Pass the field config into the import sdk method
dfInstance.importCSV(defaultValues); //All records imported through this importer would have Location field set as India
```

> Note:
> 1. Default values here is optional
>
> 1. Default values are optional
> 2. Any variables or parameter can also be mapped in `defaultValues`.
> 3. End user can't pass this value if default value is set by dev.
> 4. Some fields cannot be set as default eg. Auto calculated fields, Sequence numbers etc.
> 3. If a default value is set by the developer, end users cannot override it.
> 4. Certain fields cannot be set as default, such as auto-calculated fields and
> sequence numbers.
### 9) Board

Get board instance like

```js
const boardInstance = kf.app.getBoard("case_id");
```

##### Import CSV

Launches the import CSV modal, where you can upload a CSV file and map its
columns to the corresponding fields.

```js
let defaultValues = { fieldId: "value" };
boardInstance.importCSV(defaultValues);
```

###### Example scenario

Consider a scenario where certain fields are not visible to the user (hidden in
form visibility). In that case, default values can be used to populate data in
these hidden fields.

```js
// Get the board with the board's flow_id
const boardInstance = kf.app.getBoard("Asset_Tracking_A00"); // Asset_Tracking_A00 is the flow_id

// Set field values for specific fields of the board
let boardInstance = { location: "India" }; // Location is the the field_id of a field inside the board

// Pass the field config into the import sdk method
boardInstance.importCSV(defaultValues); // All records imported through this importer would have Location field set as India
```

> Note:
>
> 1. Default values are optional
> 2. Any variables or parameter can also be mapped in `defaultValues`.
> 3. If a default value is set by the developer, end users cannot override it.
> 4. Certain fields cannot be set as default, such as auto-calculated fields and
> sequence numbers.
### 7) Formatter

Expand Down
62 changes: 62 additions & 0 deletions docs/src/content/docs/app/board.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
title: Board
description: Usage of board methods
---
With Kissflow Boards, you can create highly adaptable workflows that let you keep track of information and manage work efficiently.

Get board instance using `getBoard` method from app's interface.

##### Parameters

| Parameters | type |
| ---------- | ------ |
| caseId | String |

##### Syntax

```js
const boardInstance = kf.app.getBoard("case_id");
```

### Import CSV

Launches the import CSV modal, where you can upload a CSV file and map its
columns to the corresponding fields.

##### Parameters

| Parameters | type | Description |
| ------------- | ------ | -------------------------------------------------------------------- |
| defaultValues | Object | Object with keys as field Id and its values in respective data types |

##### Syntax

```js
let defaultValues = { fieldId: "value" };
boardInstance.importCSV(defaultValues);
```

###### Example scenario

Consider a scenario where certain fields are not visible to the user (hidden in
form visibility). In that case, default values can be used to populate data in
these hidden fields.

```js
// Get the board with the board's flow_id
const boardInstance = kf.app.getBoard("Asset_Tracking_A00"); // Asset_Tracking_A00 is the flow_id

// Set field values for specific fields of the board
let boardInstance = { location: "India" }; // Location is the the field_id of a field inside the board

// Pass the field config into the import sdk method
boardInstance.importCSV(defaultValues); // All records imported through this importer would have Location field set as India
```

> Note:
>
> 1. Default values are optional
> 2. Any variables or parameter can also be mapped in `defaultValues`.
> 3. If a default value is set by the developer, end users cannot override it.
> 4. Certain fields cannot be set as default, such as auto-calculated fields and
> sequence numbers.
24 changes: 15 additions & 9 deletions docs/src/content/docs/app/dataform.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ title: Dataform
description: Usage of dataform methods
---

In Kissflow apps, dataforms gather and store data, enabling users to submit data into an app.

Get dataform instance using `getDataform` method from app's interface.

##### Parameters
Expand All @@ -19,8 +21,8 @@ let dataformInstance = kf.app.getDataform(dataformId);

### Import CSV

This method lets you to trigger the import CSV modal where user could upload CSV
file and map respective columns to the field.
Launches the import CSV popup, where you can upload CSV file and map columns to
the corresponding fields.

##### Parameters

Expand All @@ -37,15 +39,19 @@ dataformInstance.importCSV(defaultValues);

##### Example

Consider scenario where few fields that aren't exposed to user(basically hidden
in form visibilty). In such cases Default values can be used to provide data to
hidden fields
Consider scenario where certain fields are not visible to the user(hidden in
form visibilty). In that case, default values can be used to populate data in
these hidden fields

```js
// Here the location field is hidden to user,
// thus user isn't aware to include this on import csv.
let defaultValues = { location: "India" };
dataformInstance.importCSV(defaultValues);
// Get the dataform with the dataform's flow_id
const dfInstance = kf.app.getDataform("Product_Dataform_A00"); // Product_Dataform_A00 is the flow_id

// Set field values for specific fields of the dataform
let defaultValues = { location: "India" }; // Location is the the field_id of a field inside the dataform

// Pass the field config into the import sdk method
dfInstance.importCSV(defaultValues); // All records imported through this importer would have Location field set as India
```

> Note:
Expand Down
5 changes: 5 additions & 0 deletions packages/sdk/src/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { AppContext } from "../types/internal";

import { DecisionTable } from "./decisiontable";
import { Dataform } from "./dataform";
import { Board } from "../board";

export class Application extends BaseSDK {
page: Page;
Expand Down Expand Up @@ -43,6 +44,10 @@ export class Application extends BaseSDK {
getDataform(flowId: string): Dataform {
return new Dataform(flowId);
}

getBoard(flowId: string) {
return new Board(flowId);
}
}

export * from "./component";
Expand Down
17 changes: 17 additions & 0 deletions packages/sdk/src/board/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { BaseSDK, LISTENER_CMDS } from "../core";

export class Board extends BaseSDK {
private _id: string;

constructor(flowId: string) {
super();
this._id = flowId;
}

importCSV(defaultValues: object) {
return this._postMessageAsync(LISTENER_CMDS.BOARD_IMPORT_CSV, {
flowId: this._id,
defaultValues
});
}
}
5 changes: 4 additions & 1 deletion packages/sdk/src/core/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ export const LISTENER_CMDS = {
DECISION_TABLE_EXECUTE: "DECISION_TABLE_EXECUTE",

// Dataform methods
DATAFORM_IMPORT_CSV: "DATAFORM_IMPORT_CSV"
DATAFORM_IMPORT_CSV: "DATAFORM_IMPORT_CSV",

// Board methods
BOARD_IMPORT_CSV: "BOARD_IMPORT_CSV"
};

export const EVENT_TYPES = {
Expand Down

0 comments on commit 8d16f17

Please sign in to comment.