Files
KintoneAppBuilder/plugin/kintone-addins/src/actions/must-input.ts

53 lines
1.4 KiB
TypeScript

import { actionAddins } from ".";
import { IAction,IActionResult, IActionNode, IActionProperty, IField } from "../types/ActionTypes";
interface IMustInputProps{
field:IField;
message:string;
}
export class MustInputAction implements IAction{
name: string;
actionProps: IActionProperty[];
props:IMustInputProps;
constructor(){
this.name="必須チェック";
this.actionProps=[];
this.register();
this.props={
field:{code:''},
message:''
}
this.register();
}
async process(actionNode:IActionNode,event:any):Promise<IActionResult> {
let result={
canNext:true,
result:false
};
this.actionProps=actionNode.actionProps;
if (!('field' in actionNode.ActionValue) && !('message' in actionNode.ActionValue)) {
return result
}
this.props = actionNode.ActionValue as IMustInputProps;
const record = event.record;
const value = record[this.props.field.code]?.value;
if(value===undefined || value===''){
record[this.props.field.code].error=this.props.message;
return result;
}
result= {
canNext:true,
result:true
}
return result;
}
register(): void {
actionAddins[this.name]=this;
}
}
new MustInputAction();