upload code
This commit is contained in:
36
src/js/mobile.ts
Normal file
36
src/js/mobile.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import type { Setting } from '@/types/model';
|
||||
import { KintoneRestAPIClient } from '@kintone/rest-api-client';
|
||||
|
||||
(function (PLUGIN_ID) {
|
||||
kintone.events.on('mobile.app.record.index.show', () => {
|
||||
// App id
|
||||
const appId = kintone.app.getId()?.toString();
|
||||
if (!appId) return;
|
||||
|
||||
// get setting
|
||||
const setting: Setting = kintone.plugin.app.getConfig(PLUGIN_ID);
|
||||
|
||||
// header space
|
||||
const headerSpace = kintone.mobile.app.getHeaderSpaceElement();
|
||||
if (!headerSpace) {
|
||||
throw new Error('このページではヘッダー要素が利用できません。');
|
||||
}
|
||||
|
||||
const btnId = 'template-btn-id';
|
||||
// ボタン追加
|
||||
if (document.getElementById(btnId)) return;
|
||||
const button = new Kucs[KUC_VERSION].MobileButton({
|
||||
text: setting.buttonName,
|
||||
type: 'submit',
|
||||
id: btnId,
|
||||
});
|
||||
const client = new KintoneRestAPIClient();
|
||||
button.addEventListener('click', async () => {
|
||||
const { plugins } = await client.app.getPlugins({
|
||||
app: appId
|
||||
})
|
||||
alert(setting.message + "\n--------\n【Plugins】 " + plugins.map(p => p.name).join('、'));
|
||||
});
|
||||
headerSpace.appendChild(button);
|
||||
});
|
||||
})(kintone.$PLUGIN_ID);
|
||||
Reference in New Issue
Block a user