Merged PR 70: BUG527:エラーの共通処理追加
各の内容を対応しました。 1.エラーの共通処理追加 2.各アクションのtry..catch中のエラー関連処理の対応 3.BUG527,521,522,514,504修正 Related work items: #504, #514, #521, #522, #525, #527
This commit is contained in:
@@ -1 +1,68 @@
|
|||||||
@import 'bootstrap/scss/bootstrap';
|
// @import 'bootstrap/scss/bootstrap';
|
||||||
|
@import "bootstrap/scss/functions";
|
||||||
|
@import "bootstrap/scss/variables";
|
||||||
|
@import "bootstrap/scss/variables-dark";
|
||||||
|
@import "bootstrap/scss/maps";
|
||||||
|
@import "bootstrap/scss/mixins";
|
||||||
|
@import "bootstrap/scss/root";
|
||||||
|
.bs-scope{
|
||||||
|
// Required
|
||||||
|
@import "bootstrap/scss/utilities";
|
||||||
|
@import "bootstrap/scss/reboot";
|
||||||
|
@import "bootstrap/scss/type";
|
||||||
|
@import "bootstrap/scss/images";
|
||||||
|
@import "bootstrap/scss/containers";
|
||||||
|
@import "bootstrap/scss/grid";
|
||||||
|
// @import "bootstrap/scss/tables";
|
||||||
|
// @import "bootstrap/scss/forms";
|
||||||
|
@import "bootstrap/scss/buttons";
|
||||||
|
@import "bootstrap/scss/transitions";
|
||||||
|
@import "bootstrap/scss/dropdown";
|
||||||
|
// @import "bootstrap/scss/button-group";
|
||||||
|
// @import "bootstrap/scss/nav";
|
||||||
|
// @import "bootstrap/scss/navbar"; // Requires nav
|
||||||
|
@import "bootstrap/scss/card";
|
||||||
|
// @import "bootstrap/scss/breadcrumb";
|
||||||
|
// @import "bootstrap/scss/accordion";
|
||||||
|
// @import "bootstrap/scss/pagination";
|
||||||
|
// @import "bootstrap/scss/badge";
|
||||||
|
// @import "bootstrap/scss/alert";
|
||||||
|
// @import "bootstrap/scss/progress";
|
||||||
|
// @import "bootstrap/scss/list-group";
|
||||||
|
@import "bootstrap/scss/close";
|
||||||
|
// @import "bootstrap/scss/toasts";
|
||||||
|
@import "bootstrap/scss/modal"; // Requires transitions
|
||||||
|
// @import "bootstrap/scss/tooltip";
|
||||||
|
@import "bootstrap/scss/popover";
|
||||||
|
// @import "bootstrap/scss/carousel";
|
||||||
|
@import "bootstrap/scss/spinners";
|
||||||
|
@import "bootstrap/scss/offcanvas"; // Requires transitions
|
||||||
|
// @import "bootstrap/scss/placeholders";
|
||||||
|
|
||||||
|
// Helpers
|
||||||
|
// @import "bootstrap/scss/helpers";
|
||||||
|
|
||||||
|
// Utilities
|
||||||
|
@import "bootstrap/scss/utilities/api";
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-backdrop {
|
||||||
|
--bs-backdrop-zindex: 1050;
|
||||||
|
--bs-backdrop-bg: #000;
|
||||||
|
--bs-backdrop-opacity: .5;
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
z-index: var(--bs-backdrop-zindex);
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
background-color: var(--bs-backdrop-bg)
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-backdrop.fade {
|
||||||
|
opacity: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-backdrop.show {
|
||||||
|
opacity: var(--bs-backdrop-opacity)
|
||||||
|
}
|
||||||
@@ -96,14 +96,14 @@ export class AutoLookUpAction implements IAction {
|
|||||||
* アクセスのメインの処理関数
|
* アクセスのメインの処理関数
|
||||||
*/
|
*/
|
||||||
async process(
|
async process(
|
||||||
prop: IActionNode,
|
actionNode: IActionNode,
|
||||||
event: any,
|
event: any,
|
||||||
context: IContext
|
context: IContext
|
||||||
): Promise<IActionResult> {
|
): Promise<IActionResult> {
|
||||||
this.actionProps = prop.actionProps;
|
this.actionProps = actionNode.actionProps;
|
||||||
this.props = {
|
this.props = {
|
||||||
...prop.ActionValue,
|
...actionNode.ActionValue,
|
||||||
condition: JSON.parse((prop.ActionValue as any).condition),
|
condition: JSON.parse((actionNode.ActionValue as any).condition),
|
||||||
} as Props;
|
} as Props;
|
||||||
// console.log(context);
|
// console.log(context);
|
||||||
|
|
||||||
@@ -133,15 +133,9 @@ export class AutoLookUpAction implements IAction {
|
|||||||
await this.updateLookupTarget(updateRecords);
|
await this.updateLookupTarget(updateRecords);
|
||||||
this.showResult(this.props.lookupField.app,updateRecords.length);
|
this.showResult(this.props.lookupField.app,updateRecords.length);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("ルックアップ更新中例外が発生しました。", error);
|
context.errors.handleError(error,actionNode,"ルックアップ更新中例外が発生しました");
|
||||||
if(error instanceof Error){
|
|
||||||
event.error = error.message;
|
|
||||||
}else{
|
|
||||||
event.error = "ルックアップ更新中例外が発生しました。";
|
|
||||||
}
|
|
||||||
result.canNext = false;
|
result.canNext = false;
|
||||||
}
|
}
|
||||||
console.log("autoLookupProps", this.props);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,7 +207,7 @@ export class AutoLookUpAction implements IAction {
|
|||||||
showSpinnerModel = (app:App) => {
|
showSpinnerModel = (app:App) => {
|
||||||
let dialog = $("#alcLookupModal");
|
let dialog = $("#alcLookupModal");
|
||||||
if(dialog.length===0){
|
if(dialog.length===0){
|
||||||
const modalHTML = `
|
const modalHTML = `<div class="bs-scope">
|
||||||
<div class="modal" id="alcLookupModal" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
|
<div class="modal" id="alcLookupModal" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
|
||||||
<div class="modal-dialog-centered">
|
<div class="modal-dialog-centered">
|
||||||
<div class="modal-dialog modal-content">
|
<div class="modal-dialog modal-content">
|
||||||
@@ -230,13 +224,12 @@ export class AutoLookUpAction implements IAction {
|
|||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-primary" data-bs-dismiss="modal">OK</button>
|
<button type="button" class="btn btn-primary" data-bs-dismiss="modal">OK</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div></div></div></div>`;
|
||||||
</div>
|
$(modalHTML).appendTo("body");
|
||||||
</div>`;
|
dialog = $("#alcLookupModal");
|
||||||
dialog = $(modalHTML).appendTo("body");
|
|
||||||
dialog.get()[0].addEventListener('hidden.bs.modal',(ev)=>{
|
dialog.get()[0].addEventListener('hidden.bs.modal',(ev)=>{
|
||||||
Modal.getOrCreateInstance(dialog.get()[0]).dispose();
|
Modal.getOrCreateInstance(dialog.get()[0]).dispose();
|
||||||
$("#alcLookupModal").remove();
|
$("#alcLookupModal").parent().remove();
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
const dialogBody=$("#alcLookupModal .modal-body");
|
const dialogBody=$("#alcLookupModal .modal-body");
|
||||||
|
|||||||
@@ -65,8 +65,7 @@ export class AutoNumbering implements IAction{
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}catch(error){
|
}catch(error){
|
||||||
console.error(error);
|
context.errors.handleError(error,actionNode);
|
||||||
event.error="処理中異常が発生しました。";
|
|
||||||
return {
|
return {
|
||||||
canNext:false,
|
canNext:false,
|
||||||
result:false
|
result:false
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
import { actionAddins } from ".";
|
import { actionAddins } from ".";
|
||||||
import $ from 'jquery';
|
import $ from 'jquery';
|
||||||
import { IAction, IActionProperty, IActionNode, IActionResult } from "../types/ActionTypes";
|
import { IAction, IActionProperty, IActionNode, IActionResult, IContext } from "../types/ActionTypes";
|
||||||
import "./button-add.css";
|
import "./button-add.css";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,7 +43,7 @@ export class ButtonAddAction implements IAction {
|
|||||||
* @param event
|
* @param event
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
async process(actionNode: IActionNode, event: any): Promise<IActionResult> {
|
async process(actionNode: IActionNode, event: any,context:IContext): Promise<IActionResult> {
|
||||||
let result = {
|
let result = {
|
||||||
canNext: true,
|
canNext: true,
|
||||||
result: false
|
result: false
|
||||||
@@ -75,8 +75,7 @@ export class ButtonAddAction implements IAction {
|
|||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
event.error = error;
|
context.errors.handleError(error,actionNode);
|
||||||
console.error(error);
|
|
||||||
result.canNext = false;
|
result.canNext = false;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,8 +63,7 @@ export class ConditionAction implements IAction{
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}catch(error){
|
}catch(error){
|
||||||
event.error=error;
|
context.errors.handleError(error,actionNode);
|
||||||
console.error(error);
|
|
||||||
result.canNext=false;
|
result.canNext=false;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { actionAddins } from ".";
|
import { actionAddins } from ".";
|
||||||
import { IAction,IActionResult, IActionNode, IActionProperty, IField} from "../types/ActionTypes";
|
import { IAction,IActionResult, IActionNode, IActionProperty, IField, IContext} from "../types/ActionTypes";
|
||||||
/**
|
/**
|
||||||
* アクションの属性定義
|
* アクションの属性定義
|
||||||
*/
|
*/
|
||||||
@@ -32,7 +32,7 @@ export class StrCountCheckAciton implements IAction{
|
|||||||
* @param event
|
* @param event
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
async process(actionNode:IActionNode,event:any):Promise<IActionResult> {
|
async process(actionNode:IActionNode,event:any,context:IContext):Promise<IActionResult> {
|
||||||
let result={
|
let result={
|
||||||
canNext:true,
|
canNext:true,
|
||||||
result:false
|
result:false
|
||||||
@@ -63,8 +63,7 @@ export class StrCountCheckAciton implements IAction{
|
|||||||
return result;
|
return result;
|
||||||
|
|
||||||
}catch(error){
|
}catch(error){
|
||||||
event.error=error;
|
context.errors.handleError(error,actionNode);
|
||||||
console.error(error);
|
|
||||||
result.canNext=false;
|
result.canNext=false;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,13 +4,14 @@ import {
|
|||||||
IActionNode,
|
IActionNode,
|
||||||
IActionProperty,
|
IActionProperty,
|
||||||
IContext,
|
IContext,
|
||||||
|
IField,
|
||||||
} from "../types/ActionTypes";
|
} from "../types/ActionTypes";
|
||||||
import { actionAddins } from ".";
|
import { actionAddins } from ".";
|
||||||
|
|
||||||
|
|
||||||
interface Props {
|
interface ICurrentFieldGetProps {
|
||||||
displayName: string;
|
displayName: string;
|
||||||
field: Field;
|
field: IField;
|
||||||
verName: VerName;
|
verName: VerName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -18,49 +19,43 @@ interface VerName {
|
|||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Field {
|
|
||||||
name: string;
|
|
||||||
type: string;
|
|
||||||
code: string;
|
|
||||||
label: string;
|
|
||||||
noLabel: boolean;
|
|
||||||
required: boolean;
|
|
||||||
minLength: string;
|
|
||||||
maxLength: string;
|
|
||||||
expression: string;
|
|
||||||
hideExpression: boolean;
|
|
||||||
unique: boolean;
|
|
||||||
defaultValue: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class CurrentFieldGetAction implements IAction {
|
export class CurrentFieldGetAction implements IAction {
|
||||||
name: string;
|
name: string;
|
||||||
actionProps: IActionProperty[];
|
actionProps: IActionProperty[];
|
||||||
currentFieldGetProps: Props;
|
props: ICurrentFieldGetProps;
|
||||||
constructor() {
|
constructor() {
|
||||||
this.name = "フィールドの値を取得する";
|
this.name = "フィールドの値を取得する";
|
||||||
this.actionProps = [];
|
this.actionProps = [];
|
||||||
this.currentFieldGetProps = {} as Props;
|
this.props = {} as ICurrentFieldGetProps;
|
||||||
this.register();
|
this.register();
|
||||||
}
|
}
|
||||||
|
|
||||||
async process(
|
async process(
|
||||||
prop: IActionNode,
|
actionNode: IActionNode,
|
||||||
event: any,
|
event: any,
|
||||||
context: IContext
|
context: IContext
|
||||||
): Promise<IActionResult> {
|
): Promise<IActionResult> {
|
||||||
this.currentFieldGetProps = prop.ActionValue as Props;
|
this.props = actionNode.ActionValue as ICurrentFieldGetProps;
|
||||||
this.actionProps = prop.actionProps;
|
this.actionProps = actionNode.actionProps;
|
||||||
|
|
||||||
let result = {
|
let result = {
|
||||||
canNext: true,
|
canNext: true,
|
||||||
result: "",
|
result: '',
|
||||||
} as IActionResult;
|
} as IActionResult;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
context.variables[this.currentFieldGetProps.verName.name] = context.record[this.currentFieldGetProps.field.code].value;
|
const record = event.record;
|
||||||
} catch (error) {
|
if(!(this.props.field.code in record)){
|
||||||
console.error("CurrentFieldGetAction error", error);
|
throw new Error(`フィールド[${this.props.field.code}]が見つかりませんでした。`);
|
||||||
|
}
|
||||||
|
//変数設定
|
||||||
|
if(this.props.verName && this.props.verName.name!==''){
|
||||||
|
context.variables[this.props.verName.name]=record[this.props.field.code].value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
context.errors.handleError(error,actionNode);
|
||||||
result.canNext = false;
|
result.canNext = false;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -83,13 +83,13 @@ export class DataProcessingAction implements IAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async process(
|
async process(
|
||||||
nodes: IActionNode,
|
actionNode: IActionNode,
|
||||||
event: any,
|
event: any,
|
||||||
context: IContext
|
context: IContext
|
||||||
): Promise<IActionResult> {
|
): Promise<IActionResult> {
|
||||||
this.actionProps = nodes.actionProps;
|
this.actionProps = actionNode.actionProps;
|
||||||
|
|
||||||
this.props = nodes.ActionValue as IDataProcessingProps;
|
this.props = actionNode.ActionValue as IDataProcessingProps;
|
||||||
const condition = JSON.parse(this.props.condition) as Condition;
|
const condition = JSON.parse(this.props.condition) as Condition;
|
||||||
let result = {
|
let result = {
|
||||||
canNext: true,
|
canNext: true,
|
||||||
@@ -118,12 +118,7 @@ export class DataProcessingAction implements IAction {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("データ集計中例外が発生しました。", error);
|
context.errors.handleError(error,actionNode);
|
||||||
if(error instanceof Error){
|
|
||||||
event.error = `データ集計中例外が発生しました。 ${error.message}`;
|
|
||||||
}else{
|
|
||||||
event.error = "データ集計中例外が発生しました。";
|
|
||||||
}
|
|
||||||
result.canNext = false;
|
result.canNext = false;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,12 +74,12 @@ export class DataUpdateAction implements IAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async process(
|
async process(
|
||||||
prop: IActionNode,
|
actionNode: IActionNode,
|
||||||
event: any,
|
event: any,
|
||||||
context: IContext
|
context: IContext
|
||||||
): Promise<IActionResult> {
|
): Promise<IActionResult> {
|
||||||
this.actionProps = prop.actionProps;
|
this.actionProps = actionNode.actionProps;
|
||||||
this.dataMappingProps = prop.ActionValue as Props;
|
this.dataMappingProps = actionNode.ActionValue as Props;
|
||||||
console.log(context);
|
console.log(context);
|
||||||
let result = {
|
let result = {
|
||||||
canNext: true,
|
canNext: true,
|
||||||
@@ -121,7 +121,7 @@ export class DataUpdateAction implements IAction {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("DataMappingAction error", error);
|
context.errors.handleError(error,actionNode);
|
||||||
result.canNext = false;
|
result.canNext = false;
|
||||||
}
|
}
|
||||||
console.log("dataMappingProps", this.dataMappingProps);
|
console.log("dataMappingProps", this.dataMappingProps);
|
||||||
|
|||||||
@@ -52,8 +52,7 @@ export class DatetimeGetterAction implements IAction {
|
|||||||
return result;
|
return result;
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
event.error = error;
|
context.errors.handleError(error,actionNode);
|
||||||
console.error(error);
|
|
||||||
result.canNext = false;
|
result.canNext = false;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,12 +30,12 @@ export class ErrorShowAction implements IAction {
|
|||||||
* @param event
|
* @param event
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
async process(actionNode: IActionNode, event: any, context: IContext): Promise<IActionResult> { //异步处理某函数下的:xx属性
|
async process(actionNode: IActionNode, event: any, context: IContext): Promise<IActionResult> {
|
||||||
let result = {
|
let result = {
|
||||||
canNext: true,
|
canNext: true,
|
||||||
result: false
|
result: false
|
||||||
};
|
};
|
||||||
try { //尝试执行以下代码部分
|
try {
|
||||||
this.actionProps = actionNode.actionProps;
|
this.actionProps = actionNode.actionProps;
|
||||||
if (!('message' in actionNode.ActionValue) && !('condition' in actionNode.ActionValue)) { //如果message以及condition两者都不存在的情况下return
|
if (!('message' in actionNode.ActionValue) && !('condition' in actionNode.ActionValue)) { //如果message以及condition两者都不存在的情况下return
|
||||||
return result
|
return result
|
||||||
@@ -52,8 +52,7 @@ export class ErrorShowAction implements IAction {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
event.error = error;
|
context.errors.handleError(error,actionNode);
|
||||||
console.error(error);
|
|
||||||
result.canNext = false;
|
result.canNext = false;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
112
plugin/kintone-addins/src/actions/field-disable.ts
Normal file
112
plugin/kintone-addins/src/actions/field-disable.ts
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
|
||||||
|
import { actionAddins } from ".";
|
||||||
|
import { IAction,IActionResult, IActionNode, IActionProperty, IField, IContext } from "../types/ActionTypes";
|
||||||
|
import { ConditionTree } from '../types/Conditions';
|
||||||
|
/**
|
||||||
|
* アクションの属性定義
|
||||||
|
*/
|
||||||
|
interface IDisableProps{
|
||||||
|
//対象フィールド
|
||||||
|
field:IField;
|
||||||
|
//編集可/不可設定
|
||||||
|
editable:'編集可'|'編集不可'|'';
|
||||||
|
condition:string;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 編集可/不可アクション
|
||||||
|
*/
|
||||||
|
export class FieldDisableAction implements IAction{
|
||||||
|
name: string;
|
||||||
|
actionProps: IActionProperty[];
|
||||||
|
props:IDisableProps;
|
||||||
|
constructor(){
|
||||||
|
this.name="編集可/不可";
|
||||||
|
this.actionProps=[];
|
||||||
|
this.props={
|
||||||
|
field:{code:''},
|
||||||
|
editable:'',
|
||||||
|
condition:''
|
||||||
|
}
|
||||||
|
//アクションを登録する
|
||||||
|
this.register();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* アクションの実行を呼び出す
|
||||||
|
* @param actionNode
|
||||||
|
* @param event
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
async process(actionNode:IActionNode,event:any,context:IContext):Promise<IActionResult> {
|
||||||
|
let result={
|
||||||
|
canNext:true,
|
||||||
|
result:false
|
||||||
|
};
|
||||||
|
try{
|
||||||
|
//属性設定を取得する
|
||||||
|
this.actionProps=actionNode.actionProps;
|
||||||
|
if (!('field' in actionNode.ActionValue) && !('editable' in actionNode.ActionValue)) {
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
this.props = actionNode.ActionValue as IDisableProps;
|
||||||
|
//条件式の計算結果を取得
|
||||||
|
const conditionResult = this.getConditionResult(context);
|
||||||
|
const record = event.record;
|
||||||
|
if(!(this.props.field.code in record)){
|
||||||
|
throw new Error(`フィールド「${this.props.field.code}」が見つかりません。`);
|
||||||
|
}
|
||||||
|
if(conditionResult){
|
||||||
|
if(this.props.editable==='編集可'){
|
||||||
|
record[this.props.field.code].disabled=false;
|
||||||
|
}else if (this.props.editable==='編集不可'){
|
||||||
|
record[this.props.field.code].disabled=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result= {
|
||||||
|
canNext:true,
|
||||||
|
result:true
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}catch(error){
|
||||||
|
context.errors.handleError(error,actionNode);
|
||||||
|
result.canNext=false;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param context 条件式を実行する
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
getConditionResult(context:any):boolean{
|
||||||
|
const tree =this.getCondition(this.props.condition);
|
||||||
|
if(!tree){
|
||||||
|
//条件を設定されていません
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return tree.evaluate(tree.root,context);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param condition 条件式ツリーを取得する
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
getCondition(condition:string):ConditionTree|null{
|
||||||
|
try{
|
||||||
|
const tree = new ConditionTree();
|
||||||
|
tree.fromJson(condition);
|
||||||
|
if(tree.getConditions(tree.root).length>0){
|
||||||
|
return tree;
|
||||||
|
}else{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}catch(error){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
register(): void {
|
||||||
|
actionAddins[this.name]=this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
new FieldDisableAction();
|
||||||
@@ -61,8 +61,7 @@ export class FieldShownAction implements IAction{
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}catch(error){
|
}catch(error){
|
||||||
event.error=error;
|
context.errors.handleError(error,actionNode);
|
||||||
console.error(error);
|
|
||||||
result.canNext=false;
|
result.canNext=false;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -678,13 +678,10 @@ export class InsertValueAction implements IAction{
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}catch(error:any){
|
}catch(error:any){
|
||||||
event.record;
|
context.errors.handleError(error,actionNode);
|
||||||
event.error=error.message;
|
|
||||||
console.error(error);
|
|
||||||
result.canNext=true;//次のノードは処理を続ける
|
result.canNext=true;//次のノードは処理を続ける
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ export class LoginUserGetterAction implements IAction{
|
|||||||
return result;
|
return result;
|
||||||
//////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////
|
||||||
}catch(error:any){;
|
}catch(error:any){;
|
||||||
event.error=error.message;
|
context.errors.handleError(error,actionNode);
|
||||||
return {
|
return {
|
||||||
canNext:false,
|
canNext:false,
|
||||||
result:false
|
result:false
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { actionAddins } from ".";
|
import { actionAddins } from ".";
|
||||||
import { IAction, IActionResult, IActionNode, IActionProperty, IField } from "../types/ActionTypes";
|
import { IAction, IActionResult, IActionNode, IActionProperty, IField, IContext } from "../types/ActionTypes";
|
||||||
/**
|
/**
|
||||||
* アクションの属性定義
|
* アクションの属性定義
|
||||||
*/
|
*/
|
||||||
@@ -32,7 +32,7 @@ export class MailCheckAction implements IAction {
|
|||||||
* @param event
|
* @param event
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
async process(actionNode: IActionNode, event: any): Promise<IActionResult> {
|
async process(actionNode: IActionNode, event: any,context:IContext): Promise<IActionResult> {
|
||||||
let result = {
|
let result = {
|
||||||
canNext: true,
|
canNext: true,
|
||||||
result: false
|
result: false
|
||||||
@@ -46,8 +46,11 @@ export class MailCheckAction implements IAction {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
this.props = actionNode.ActionValue as IMailCheckProps;
|
this.props = actionNode.ActionValue as IMailCheckProps;
|
||||||
//条件式の計算結果を取得
|
|
||||||
const record = event.record;
|
const record = event.record;
|
||||||
|
//対象フィールドの存在チェック
|
||||||
|
if(!(this.props.field.code in record)){
|
||||||
|
throw new Error(`フィールド[${this.props.field.code}]が見つかりませんでした。`);
|
||||||
|
}
|
||||||
const value = record[this.props.field.code].value;
|
const value = record[this.props.field.code].value;
|
||||||
|
|
||||||
if (this.props.emailCheck === '厳格') {
|
if (this.props.emailCheck === '厳格') {
|
||||||
@@ -56,13 +59,15 @@ export class MailCheckAction implements IAction {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
record[this.props.field.code].error = null;
|
record[this.props.field.code].error = null;
|
||||||
|
result.result=true;
|
||||||
}
|
}
|
||||||
} else if (this.props.emailCheck === 'ゆるめ') {
|
} else if (this.props.emailCheck === 'ゆるめ') {
|
||||||
if (!/^[^@]+@[^@]+$/.test(value)) {
|
if (!/^[^@]+@[^@]+$/.test(value)) {
|
||||||
record[this.props.field.code].error = this.props.message;
|
record[this.props.field.code].error = this.props.message;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
record[this.props.field.code].error = null;
|
record[this.props.field.code].error = null;
|
||||||
|
result.result=true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
result = {
|
result = {
|
||||||
@@ -72,8 +77,7 @@ export class MailCheckAction implements IAction {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
event.error = error;
|
context.errors.handleError(error,actionNode);
|
||||||
console.error(error);
|
|
||||||
result.canNext = false;
|
result.canNext = false;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
import { actionAddins } from ".";
|
import { actionAddins } from ".";
|
||||||
import { IAction,IActionResult, IActionNode, IActionProperty, IField } from "../types/ActionTypes";
|
import { IAction,IActionResult, IActionNode, IActionProperty, IField, IContext } from "../types/ActionTypes";
|
||||||
|
|
||||||
interface IMustInputProps{
|
interface IMustInputProps{
|
||||||
field:IField;
|
field:IField;
|
||||||
@@ -22,25 +22,33 @@ export class MustInputAction implements IAction{
|
|||||||
this.register();
|
this.register();
|
||||||
}
|
}
|
||||||
|
|
||||||
async process(actionNode:IActionNode,event:any):Promise<IActionResult> {
|
async process(actionNode:IActionNode,event:any,context:IContext):Promise<IActionResult> {
|
||||||
let result={
|
let result={
|
||||||
canNext:true,
|
canNext:true,
|
||||||
result:false
|
result:false
|
||||||
};
|
};
|
||||||
this.actionProps=actionNode.actionProps;
|
try{
|
||||||
if (!('field' in actionNode.ActionValue) && !('message' in actionNode.ActionValue)) {
|
this.actionProps=actionNode.actionProps;
|
||||||
return result
|
if (!('field' in actionNode.ActionValue) && !('message' in actionNode.ActionValue)) {
|
||||||
}
|
return result
|
||||||
this.props = actionNode.ActionValue as IMustInputProps;
|
}
|
||||||
const record = event.record;
|
this.props = actionNode.ActionValue as IMustInputProps;
|
||||||
const value = record[this.props.field.code]?.value;
|
const record = event.record;
|
||||||
if(value===undefined || value===''){
|
if(!(this.props.field.code in record)){
|
||||||
record[this.props.field.code].error=this.props.message;
|
throw new Error(`フィールド[${this.props.field.code}]が見つかりませんでした。`);
|
||||||
return result;
|
}
|
||||||
}
|
const value = record[this.props.field.code].value;
|
||||||
result= {
|
if(value===undefined || value===''){
|
||||||
canNext:true,
|
record[this.props.field.code].error=this.props.message;
|
||||||
result:true
|
return result;
|
||||||
|
}
|
||||||
|
result= {
|
||||||
|
canNext:true,
|
||||||
|
result:true
|
||||||
|
}
|
||||||
|
}catch(error){
|
||||||
|
context.errors.handleError(error,actionNode);
|
||||||
|
result.canNext=false;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { actionAddins } from ".";
|
import { actionAddins } from ".";
|
||||||
import { IAction,IActionResult, IActionNode, IActionProperty, IField} from "../types/ActionTypes";
|
import { IAction,IActionResult, IActionNode, IActionProperty, IField, IContext} from "../types/ActionTypes";
|
||||||
/**
|
/**
|
||||||
* アクションの属性定義
|
* アクションの属性定義
|
||||||
*/
|
*/
|
||||||
@@ -32,7 +32,7 @@ export class RegularCheckAction implements IAction{
|
|||||||
* @param event
|
* @param event
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
async process(actionNode:IActionNode,event:any):Promise<IActionResult> {
|
async process(actionNode:IActionNode,event:any,context:IContext):Promise<IActionResult> {
|
||||||
let result={
|
let result={
|
||||||
canNext:true,
|
canNext:true,
|
||||||
result:false
|
result:false
|
||||||
@@ -60,8 +60,7 @@ export class RegularCheckAction implements IAction{
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}catch(error){
|
}catch(error){
|
||||||
event.error=error;
|
context.errors.handleError(error,actionNode);
|
||||||
console.error(error);
|
|
||||||
result.canNext=false;
|
result.canNext=false;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ export class FullWidthAction implements IAction{
|
|||||||
this.props = actionNode.ActionValue as FullWidthProps;
|
this.props = actionNode.ActionValue as FullWidthProps;
|
||||||
//条件式の計算結果を取得
|
//条件式の計算結果を取得
|
||||||
const record = event.record;
|
const record = event.record;
|
||||||
|
if(!(this.props.field.code in record)){
|
||||||
|
throw new Error(`フィールド「${this.props.field.code}」が見つかりません。`);
|
||||||
|
}
|
||||||
const value = record[this.props.field.code]?.value;
|
const value = record[this.props.field.code]?.value;
|
||||||
//条件分岐
|
//条件分岐
|
||||||
//未入力時は何も処理をせず終了
|
//未入力時は何も処理をせず終了
|
||||||
@@ -68,8 +71,9 @@ export class FullWidthAction implements IAction{
|
|||||||
|
|
||||||
//例外処理
|
//例外処理
|
||||||
}catch(error){
|
}catch(error){
|
||||||
event.error=error;
|
// event.error=error;
|
||||||
console.error(error);
|
// console.error(error);
|
||||||
|
context.errors.handleError(error,actionNode);
|
||||||
result.canNext=false;
|
result.canNext=false;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ export class HalfWidthAction implements IAction{
|
|||||||
this.props = actionNode.ActionValue as HalfWidthProps;
|
this.props = actionNode.ActionValue as HalfWidthProps;
|
||||||
//条件式の計算結果を取得
|
//条件式の計算結果を取得
|
||||||
const record = event.record;
|
const record = event.record;
|
||||||
|
if(!(this.props.field.code in record)){
|
||||||
|
throw new Error(`フィールド「${this.props.field.code}」が見つかりません。`);
|
||||||
|
}
|
||||||
const value = record[this.props.field.code]?.value;
|
const value = record[this.props.field.code]?.value;
|
||||||
//条件分岐
|
//条件分岐
|
||||||
//未入力時は何も処理をせず終了
|
//未入力時は何も処理をせず終了
|
||||||
@@ -68,8 +71,9 @@ export class HalfWidthAction implements IAction{
|
|||||||
return result;
|
return result;
|
||||||
//例外処理
|
//例外処理
|
||||||
}catch(error){
|
}catch(error){
|
||||||
event.error=error;
|
// event.error=error;
|
||||||
console.error(error);
|
// console.error(error);
|
||||||
|
context.errors.handleError(error,actionNode);
|
||||||
result.canNext=false;
|
result.canNext=false;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,8 +56,9 @@ export class GetValueAciton implements IAction{
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}catch(error){
|
}catch(error){
|
||||||
event.error=error;
|
// event.error=error;
|
||||||
console.error(error);
|
// console.error(error);
|
||||||
|
context.errors.handleError(error,actionNode);
|
||||||
result.canNext=false;
|
result.canNext=false;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* アプリ情報
|
* アプリ情報
|
||||||
*/
|
*/
|
||||||
@@ -67,7 +66,8 @@ export interface IActionResult{
|
|||||||
*/
|
*/
|
||||||
export interface IContext{
|
export interface IContext{
|
||||||
record:any,
|
record:any,
|
||||||
variables:any
|
variables:any,
|
||||||
|
errors:ErrorManager
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -85,6 +85,7 @@ export interface IAction{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export interface IField{
|
export interface IField{
|
||||||
name?:string;
|
name?:string;
|
||||||
code:string;
|
code:string;
|
||||||
@@ -275,3 +276,46 @@ export class ActionFlow implements IActionFlow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IActionError{
|
||||||
|
action: IActionNode,
|
||||||
|
error:string
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ErrorManager{
|
||||||
|
private errors:IActionError[]=[];
|
||||||
|
|
||||||
|
public get hasError():boolean{
|
||||||
|
return this.errors.length>0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public handleError(err:any,action:IActionNode,defaultMessage?:string){
|
||||||
|
const defMsg = defaultMessage ? defaultMessage : '';
|
||||||
|
let error = err instanceof Error? `${defMsg} ${err.message}` : defMsg ;
|
||||||
|
console.error(`「${action.name}」処理中例外発生しました。`,err);
|
||||||
|
this.errors.push({error,action});
|
||||||
|
}
|
||||||
|
|
||||||
|
public setEvent(event:any){
|
||||||
|
const messages = this.errors.map((err)=>{
|
||||||
|
return `「${err.action.name}」処理中例外発生しました。詳細:${err.error}`;
|
||||||
|
});
|
||||||
|
event.error=messages.join('\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
public showError(){
|
||||||
|
const msg =this.errors.map((err)=>{
|
||||||
|
return `「${err.action.name}」処理中例外発生しました。\n詳細:${err.error}`;
|
||||||
|
});
|
||||||
|
window.alert(msg);
|
||||||
|
// const html=
|
||||||
|
// `<div id="myalert" class="notifier-cybozu notifier-error-cybozu" style="left: 50%; top: 0px;">
|
||||||
|
// <div class="notifier-header-cybozu"><div class="notifier-title-cybozu">エラー</div>
|
||||||
|
// <ul class="notifier-body-cybozu"><li>${msg}</li></ul></div>
|
||||||
|
// <a class="notifier-remove-cybozu" href="javascript:void(0)"></a></div>`
|
||||||
|
// const alert = $(html).appendTo("body");
|
||||||
|
// alert.children("#myalert .notifier-remove-cybozu").on("click",(ev)=>{
|
||||||
|
// $("myalert").slideUp().remove();
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,21 +20,28 @@ import '../actions/validation-fullwidth';
|
|||||||
import '../actions/validation-halfwidth';
|
import '../actions/validation-halfwidth';
|
||||||
import '../actions/login-user-getter';
|
import '../actions/login-user-getter';
|
||||||
import '../actions/auto-lookup';
|
import '../actions/auto-lookup';
|
||||||
|
import '../actions/field-disable';
|
||||||
import { ActionFlow,IActionFlow, IActionResult,IContext } from "./ActionTypes";
|
import { ActionFlow,ErrorManager,IActionFlow, IActionResult,IContext } from "./ActionTypes";
|
||||||
|
const ShowErrorEvents:string[] = [
|
||||||
|
"app.record.create.submit.success",
|
||||||
|
"app.record.edit.submit.success",
|
||||||
|
"app.record.index.edit.submit.success",
|
||||||
|
];
|
||||||
export class ActionProcess{
|
export class ActionProcess{
|
||||||
eventId:string;
|
eventId:string;
|
||||||
flow:IActionFlow;
|
flow:IActionFlow;
|
||||||
event:any;
|
event:any;
|
||||||
context:IContext;
|
context:IContext;
|
||||||
constructor(eventId:string,flow:ActionFlow,event:any){
|
constructor(eventId:string,flow:ActionFlow,event:any){
|
||||||
this.eventId=eventId;
|
this.eventId=eventId;
|
||||||
this.flow=flow;
|
this.flow=flow;
|
||||||
this.event=event;
|
this.event=event;
|
||||||
|
const errormanager = new ErrorManager();
|
||||||
|
|
||||||
this.context={
|
this.context={
|
||||||
record:this.event.record,
|
record:this.event.record,
|
||||||
variables:{}
|
variables:{},
|
||||||
|
errors:errormanager
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
async exec(){
|
async exec(){
|
||||||
@@ -59,9 +66,14 @@ export class ActionProcess{
|
|||||||
nextInput = result.result||'';
|
nextInput = result.result||'';
|
||||||
}
|
}
|
||||||
id=nextAction.nextNodeIds.get(nextInput);
|
id=nextAction.nextNodeIds.get(nextInput);
|
||||||
if(id===undefined) return;
|
if(id===undefined) break;
|
||||||
nextAction = this.flow.findNodeById(id);
|
nextAction = this.flow.findNodeById(id);
|
||||||
}
|
}
|
||||||
|
if(this.context.errors.hasError){
|
||||||
|
this.context.errors.setEvent(this.event);
|
||||||
|
if(ShowErrorEvents.includes(this.event.type)){
|
||||||
|
this.context.errors.showError();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user