0.10.0 • Published 14 days ago

kintone-pretty-fields v0.10.0

Weekly downloads
-
License
MIT
Repository
github
Last release
14 days ago

kintone-pretty-fields

npm version

Retrieve kintone form field(@kintone/rest-api-client) information in a pretty format.

Description

Provides the field information needed to create a kintone plugin.

  1. Get both field and spacer.
    Check Kintone Developer Program for property details.

  2. Obtain in layout order. (top left first, bottom right after)

  3. Determine the fields in a table.
    Set the table field code to the table property.

{
  type: 'SINGLE_LINE_TEXT',
  code: '文字列__1行_',
  label: '文字列 (1行)',
  noLabel: false,
  required: false,
  minLength: '',
  maxLength: '',
  expression: '',
  hideExpression: false,
  unique: false,
  defaultValue: '',
  table: 'テーブル' // table field code
}
  1. Determine the fields in a group.
    Set the group field code to the group property.
  {
    type: 'SINGLE_LINE_TEXT',
    code: '文字列__1行_',
    label: '文字列 (1行)',
    noLabel: false,
    required: false,
    minLength: '',
    maxLength: '',
    expression: '',
    hideExpression: false,
    unique: false,
    defaultValue: '',
    group: 'グループ' // group field code
  }
  1. Determine the destination field for copying lookups.
    Set the true to the isLookupCopy property.(Requires lookup source app permissions)
{
  type: 'SINGLE_LINE_TEXT',
  code: '文字列__1行_',
  label: '文字列 (1行)',
  noLabel: false,
  required: false,
  minLength: '',
  maxLength: '',
  expression: '',
  hideExpression: false,
  unique: false,
  defaultValue: '',
  isLookupCopy: true // If true, lookup copy destination field
}
  1. Sorts the values of the options.
{
  type: 'CHECK_BOX',
  code: 'チェックボックス',
  label: 'チェックボックス',
  noLabel: false,
  required: false,
  options: {
    sample1: { label: 'sample1', index: '0' },
    sample4: { label: 'sample4', index: '3' },
    sample3: { label: 'sample3', index: '2' },
    sample2: { label: 'sample2', index: '1' }
  },
  defaultValue: [],
  align: 'HORIZONTAL',
  sortedOptions: [ 'sample1', 'sample2', 'sample3', 'sample4' ] // sorted options
}

Installation

1. Install with npm

This library is distributed on npm.

npm install kintone-pretty-fields

You can then use import to import the library.

// ES modules
import { kintonePrettyFields } from "kintone-pretty-fields";

Usage

Here is a sample code that retrieves form fields of an app.

import { KintoneRestAPIClient } from "@kintone/rest-api-client";
import { kintonePrettyFields, kintonePrettyType } from "kintone-pretty-fields";

const client = new KintoneRestAPIClient();
const { fields, spacers } = await kintonePrettyFields.get({ client, app: 1, lang: "en", preview: false });
console.log({ fields, spacers });

const checkBoxFields = fields.filter(kintonePrettyFields.isCheckBox);
console.log(checkBoxFields);

const inSubtableFields = fields.filter(kintonePrettyFields.isInSubtable);
console.log(inSubtableFields);

const myFunction1 = (fields: kintonePrettyType.OneOf[]) => {
  // do something
};

const myFunction2 = (field: kintonePrettyType.CheckBox) => {
  // do something
};

License

0.10.0

14 days ago

0.9.4

25 days ago

0.9.3

1 month ago

0.9.2

1 month ago

0.9.1

2 months ago

0.9.0

2 months ago

0.8.0

2 months ago

0.7.1

2 months ago

0.7.0

2 months ago

0.5.9

2 months ago

0.6.0

2 months ago

0.5.8

3 months ago

0.5.7

3 months ago

0.5.5

3 months ago

0.5.3

4 months ago

0.5.2

4 months ago

0.5.0

4 months ago

0.5.1

4 months ago

0.4.1

5 months ago

0.4.0

5 months ago

0.3.0

5 months ago

0.2.0

6 months ago

0.1.0

6 months ago