fix:BUG553 ルックアップのキー重複許可する際エラーの処理
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -9,7 +9,7 @@ import {
|
|||||||
|
|
||||||
import { actionAddins } from ".";
|
import { actionAddins } from ".";
|
||||||
import type { Record} from "@kintone/rest-api-client/lib/src/client/types";
|
import type { Record} from "@kintone/rest-api-client/lib/src/client/types";
|
||||||
import { KintoneRestAPIClient} from "@kintone/rest-api-client";
|
import { KintoneAllRecordsError, KintoneRestAPIClient} from "@kintone/rest-api-client";
|
||||||
import "./auto-lookup.scss";
|
import "./auto-lookup.scss";
|
||||||
import "bootstrap/js/dist/modal";
|
import "bootstrap/js/dist/modal";
|
||||||
// import "bootstrap/js/dist/spinner";
|
// import "bootstrap/js/dist/spinner";
|
||||||
@@ -130,9 +130,12 @@ export class AutoLookUpAction implements IAction {
|
|||||||
const updateRecords = this.convertForLookup(targetRecords,lookUpField,key);
|
const updateRecords = this.convertForLookup(targetRecords,lookUpField,key);
|
||||||
console.log("updateRecords", updateRecords);
|
console.log("updateRecords", updateRecords);
|
||||||
this.showSpinnerModel(this.props.lookupField.app);
|
this.showSpinnerModel(this.props.lookupField.app);
|
||||||
await this.updateLookupTarget(updateRecords);
|
const updateResult = await this.updateLookupTarget(updateRecords);
|
||||||
this.showResult(this.props.lookupField.app,updateRecords.length);
|
if(updateResult){
|
||||||
|
this.showResult(this.props.lookupField.app,updateRecords.length);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
this.closeDialog();
|
||||||
context.errors.handleError(error,actionNode,"ルックアップ更新中例外が発生しました");
|
context.errors.handleError(error,actionNode,"ルックアップ更新中例外が発生しました");
|
||||||
result.canNext = false;
|
result.canNext = false;
|
||||||
}
|
}
|
||||||
@@ -186,18 +189,29 @@ export class AutoLookUpAction implements IAction {
|
|||||||
* ルックアップ先を更新する
|
* ルックアップ先を更新する
|
||||||
* @param updateRecords
|
* @param updateRecords
|
||||||
*/
|
*/
|
||||||
updateLookupTarget = async (updateRecords:Array<any>)=>{
|
updateLookupTarget = async (updateRecords:Array<any>):Promise<boolean>=>{
|
||||||
if (updateRecords && updateRecords.length > 0) {
|
if (updateRecords && updateRecords.length > 0) {
|
||||||
const client=new KintoneRestAPIClient();
|
try{
|
||||||
client.record.updateAllRecords({
|
const client=new KintoneRestAPIClient();
|
||||||
app:this.props.lookupField.app.id,
|
const result = await client.record.updateAllRecords({
|
||||||
records:updateRecords
|
app:this.props.lookupField.app.id,
|
||||||
});
|
records:updateRecords
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}catch(error ){
|
||||||
|
if(error instanceof KintoneAllRecordsError){
|
||||||
|
this.showError(this.props.lookupField.app,error as KintoneAllRecordsError,updateRecords.length);
|
||||||
|
return false;
|
||||||
|
}else{
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
// await kintone.api(kintone.api.url("/k/v1/records.json", true), "PUT", {
|
// await kintone.api(kintone.api.url("/k/v1/records.json", true), "PUT", {
|
||||||
// app: this.props.lookupField.app.id,
|
// app: this.props.lookupField.app.id,
|
||||||
// records: updateRecords
|
// records: updateRecords
|
||||||
// });
|
// });
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -257,6 +271,31 @@ export class AutoLookUpAction implements IAction {
|
|||||||
dialogBody.html(html);
|
dialogBody.html(html);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新結果を表示する
|
||||||
|
* @param app 更新先アプリ情報
|
||||||
|
* @param count 更新件数
|
||||||
|
*/
|
||||||
|
showError=(app:App,error:KintoneAllRecordsError,allCount:Number)=>{
|
||||||
|
const message=error.error.message;
|
||||||
|
const proRecords = error.numOfProcessedRecords;
|
||||||
|
const allRecords=error.numOfAllRecords;
|
||||||
|
const dialogBody=$(`#alcLookupModal .modal-body #app${app.id}`);
|
||||||
|
const html=`<div class="col-1 text-danger">✖</div>
|
||||||
|
<div class="col">${app.name}</div>
|
||||||
|
<div class="col">更新件数:${proRecords}/${allRecords}</div>
|
||||||
|
<div class="row text-danger">${message}<div>`;
|
||||||
|
dialogBody.html(html);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* ダイアログ画面を閉じる
|
||||||
|
*/
|
||||||
|
closeDialog=()=>{
|
||||||
|
const dialog = $("#alcLookupModal");
|
||||||
|
Modal.getOrCreateInstance(dialog.get()[0]).dispose();
|
||||||
|
$("#alcLookupModal").parent().remove();
|
||||||
|
}
|
||||||
|
|
||||||
register(): void {
|
register(): void {
|
||||||
actionAddins[this.name] = this;
|
actionAddins[this.name] = this;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user