This article introduces the Date Input Button Plug-in, which is a plug-in version of the sample code introduced in the "Input date with a button click" article.
The plug-in allows users to relate which Date fields and Blank Space fields will be used in the customization through the GUI on the config page.
The packaged sample plug-in zip file can be downloaded from the Releases page on Github.
Install the plug-in into your domain by following the plug-in installation guide on the Help page.
You can then add the plug-in to a specific App by following the plug-in adding guide on the Help page.
Set your form up to support the plug-in by adding a Date field and a Blank Space field in your App. Give the Blank Space field an Element ID.
Relate the fields in the form with the options in the plug-in settings.
Save the settings, and update the App.
Now, when adding a new record, a button that interacts with the date field will be displayed.
Clicking it will insert today's date into the designated Date field.
The sample codes used in the plug-in are listed under the src file in our Github repository.
The plug-in is created with the following file structure:
│ └──── config.html
│ ├──── 51-modern-default.css
│ └──── config.css
│ ├──── config.js
│ └──── desktop.js
│ └──── icon.png
This file builds the HTML of the plug-in settings page.
Each <div> tag with the "block" class represents 1 row of related HTML elements.
Specific class names are given to the HTML elements so that they can be styled with the 51-modern-default.css file to fit in with Kintone's UI.
IDs are allocated to the <select> tags to later populate the drop-down when config.js is called.
This CSS file is provided on Github. This file styles HTML elements on the plug-in config page to fit in with Kintone's UI.
We recommend that you do not make changes to 51-modern-default.css. If you need to style additional elements, or over-ride the default styles, those changes should be added into config.css.
This supporting CSS file is used to style some areas of the plug-in config page that 51-modern-default.css doesn't cover.
This file is used to populate the drop-down fields on the plug-in config page, and to also save the data inputted by the user.
In this plug-in, the 3 main functions to populate the drop-down fields are setDropDownForDate, getLayout and setDropDownForSpace, which are sequentially called after the previous process finishes.
Depending on the endpoint called, Get Form Fields can return either the deployed form fields (the user has clicked Update App in the App Settings and the changes have been committed) or the preview form fields (the form has been saved in the App settings, but the user has not clicked Update App and committed them). This function uses the preview endpoint as users may access the plug-in settings page before they are ready to commit their changes.
Each array in the response represents a row of fields, and the code loops through the rows to output Blank Space fields. The result is passed on to the next function, setDropDownForSpace.
Similar to the previous function, depending on the endpoint called, Get Form Layout can return either the deployed form layout (the user has clicked Update App in the App Settings and the changes have been committed) or the preview form layout (the form has been saved in the App settings, but the user has not clicked Update App and committed them). This function uses the preview endpoint as users may access the plug-in settings page before they are ready to commit their changes.
This function receives the output from the previous function, and appends the Blank Space field data to the drop-down field laid out in the plug-in settings.
The data saved by the user in the plug-in settings page can be retrieved by using the kintone.plugin.app.getConfig(PLUGIN_ID) method. The retrieved values are allocated to variables in the code. The rest of the code in desktop.js is mostly the same as the code in the "Input date with a button click" article.
The array in the value of the required_params key states which settings in the plug-in config page are required. If these settings are not saved using the setConfig API, errors will be displayed on other pages of the App, stating that the plug-in settings have not been configured yet.
The name, description, and homepage_url key-value pairs are labels and links displayed in the plug-in settings.
This plug-in is open sourced under the MIT License. It allows open- or closed-sourced distribution, including commercial use.
If you would like to add more functionality to the plug-in, you are welcome to clone our repository to make your own changes and redistribute it. We generally do not accept external pull requests for the sample plug-in as this repository exists for educational purposes.
If you have any questions related to building Kintone plug-ins, please post your question in the kintone developer network community.