Refactoring code
This commit is contained in:
@@ -7,8 +7,8 @@
|
||||
// 「登園/帰園」ボタン
|
||||
const area = kintone.app.record.getSpaceElement('header-clocking-btn-area');
|
||||
|
||||
const clockIn = createBtn('clock-in', '登園', dateToFieldInDetailIn('登園時刻'));
|
||||
const clockOut = createBtn('clock-out', '帰園', dateToFieldInDetail('帰園時刻'));
|
||||
const clockIn = createBtn('clock-in', '登園', dateToFieldInDetailIn());
|
||||
const clockOut = createBtn('clock-out', '帰園', dateToFieldInDetailOut());
|
||||
area.appendChild(clockIn);
|
||||
area.appendChild(clockOut);
|
||||
|
||||
@@ -26,14 +26,18 @@
|
||||
return grade === "0歳児" || grade === "1歳児";
|
||||
}
|
||||
|
||||
function dateToFieldInDetail(fieldCode) {
|
||||
//PVC追加
|
||||
function dateToFieldInDetailIn() {
|
||||
return async function (e) {
|
||||
await new KintoneRestAPIClient().record.updateRecord({
|
||||
app: kintone.app.getId(),
|
||||
id: kintone.app.record.getId(),
|
||||
record: {
|
||||
[fieldCode]: {
|
||||
'登園時刻': {
|
||||
value: getCurrentTime()
|
||||
},
|
||||
"出欠": {
|
||||
value: "出席"
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -41,18 +45,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
//PVC追加
|
||||
function dateToFieldInDetailIn(fieldCode) {
|
||||
function dateToFieldInDetailOut() {
|
||||
return async function (e) {
|
||||
await new KintoneRestAPIClient().record.updateRecord({
|
||||
app: kintone.app.getId(),
|
||||
id: kintone.app.record.getId(),
|
||||
record: {
|
||||
[fieldCode]: {
|
||||
'帰園時刻': {
|
||||
value: getCurrentTime()
|
||||
},
|
||||
出欠: {
|
||||
value: "出席"
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -75,9 +75,9 @@
|
||||
// ------------------- 編集画面表示時の処理 -------------------
|
||||
kintone.events.on(['app.record.create.show', 'app.record.edit.show'], function (event) {
|
||||
// 「登園/帰園」ボタン
|
||||
const clockIn = createBtn('clock-in', '登園', dateToFieldInEditIn('登園時刻','出欠'));
|
||||
const clockIn = createBtn('clock-in', '登園', dateToFieldInEditIn());
|
||||
kintone.app.record.getSpaceElement('clock-in-btn-area').appendChild(clockIn);
|
||||
const clockOut = createBtn('clock-out', '帰園', dateToFieldInEdit('帰園時刻'));
|
||||
const clockOut = createBtn('clock-out', '帰園', dateToFieldInEditOut());
|
||||
kintone.app.record.getSpaceElement('clock-out-btn-area').appendChild(clockOut);
|
||||
|
||||
// 「伝達事項」
|
||||
@@ -87,20 +87,20 @@
|
||||
return event;
|
||||
});
|
||||
|
||||
function dateToFieldInEdit(fieldCode) {
|
||||
//PVC追加
|
||||
function dateToFieldInEditIn() {
|
||||
return function (e) {
|
||||
var record = kintone.app.record.get();
|
||||
record['record'][fieldCode]['value'] = getCurrentTime();
|
||||
record['record']['登園時刻']['value'] = getCurrentTime();
|
||||
record['record']['出欠']['value'] = "出席";
|
||||
kintone.app.record.set(record);
|
||||
}
|
||||
}
|
||||
|
||||
//PVC追加
|
||||
function dateToFieldInEditIn(fieldCode1,fieldCode2) {
|
||||
function dateToFieldInEditOut() {
|
||||
return function (e) {
|
||||
var record = kintone.app.record.get();
|
||||
record['record'][fieldCode1]['value'] = getCurrentTime();
|
||||
record['record'][fieldCode2]['value'] = "出席";
|
||||
record['record']['帰園時刻']['value'] = getCurrentTime();
|
||||
kintone.app.record.set(record);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user