条件エディタ追加
This commit is contained in:
69
plugin/kintone-addins/src/actions/field-shown.ts
Normal file
69
plugin/kintone-addins/src/actions/field-shown.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
|
||||
import { actionAddins } from ".";
|
||||
import { IAction,IActionResult, IActionNode, IActionProperty, IField } from "../types/ActionTypes";
|
||||
/**
|
||||
* アクションの属性定義
|
||||
*/
|
||||
interface IShownProps{
|
||||
field:IField;
|
||||
show:string;
|
||||
}
|
||||
/**
|
||||
* 表示/非表示アクション
|
||||
*/
|
||||
export class FieldShownAction implements IAction{
|
||||
name: string;
|
||||
actionProps: IActionProperty[];
|
||||
props:IShownProps;
|
||||
constructor(){
|
||||
this.name="表示/非表示";
|
||||
this.actionProps=[];
|
||||
this.register();
|
||||
this.props={
|
||||
field:{code:''},
|
||||
show:''
|
||||
}
|
||||
this.register();
|
||||
}
|
||||
/**
|
||||
* アクションの実行を呼び出す
|
||||
* @param actionNode
|
||||
* @param event
|
||||
* @returns
|
||||
*/
|
||||
async process(actionNode:IActionNode,event:any):Promise<IActionResult> {
|
||||
let result={
|
||||
canNext:true,
|
||||
result:false
|
||||
};
|
||||
try{
|
||||
this.actionProps=actionNode.actionProps;
|
||||
if (!('field' in actionNode.ActionValue) && !('show' in actionNode.ActionValue)) {
|
||||
return result
|
||||
}
|
||||
this.props = actionNode.ActionValue as IShownProps;
|
||||
if(this.props.show==='表示'){
|
||||
kintone.app.record.setFieldShown(this.props.field.code,true);
|
||||
}else if (this.props.show==='非表示'){
|
||||
kintone.app.record.setFieldShown(this.props.field.code,false);
|
||||
}
|
||||
result= {
|
||||
canNext:true,
|
||||
result:true
|
||||
}
|
||||
return result;
|
||||
}catch(error){
|
||||
event.error=error;
|
||||
console.error(error);
|
||||
result.canNext=false;
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
register(): void {
|
||||
actionAddins[this.name]=this;
|
||||
}
|
||||
|
||||
}
|
||||
new FieldShownAction();
|
||||
@@ -2,6 +2,7 @@
|
||||
import { actionAddins } from "../actions";
|
||||
import '../actions/must-input';
|
||||
import '../actions/auto-numbering';
|
||||
import '../actions/field-shown';
|
||||
import { ActionFlow,IActionFlow, IActionResult } from "./ActionTypes";
|
||||
|
||||
export class ActionProcess{
|
||||
|
||||
Reference in New Issue
Block a user