feat:#262ログインユーザー取得コンポーネントの追加
This commit is contained in:
76
plugin/kintone-addins/src/actions/login-user-getter.ts
Normal file
76
plugin/kintone-addins/src/actions/login-user-getter.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
import { actionAddins } from ".";
|
||||
import { IField,IAction,IActionResult, IActionNode, IActionProperty,IContext,IVarName} from "../types/ActionTypes";
|
||||
//右UI画面propertyのname:型:
|
||||
interface ILoginUserGetterProps{
|
||||
//変数名にセット:値がオブジェクトの形式
|
||||
verName:IVarName;
|
||||
}
|
||||
//IActionインタフェースを実装する新しいクラスActionを作成:
|
||||
export class LoginUserGetterAction implements IAction{
|
||||
name: string;
|
||||
//importから導入顕示定義
|
||||
actionProps: IActionProperty[];
|
||||
//上方のinterface Propsから、props受ける属性を定義:
|
||||
props:ILoginUserGetterProps;
|
||||
//関数定義に必要な類名を構築:
|
||||
constructor(){
|
||||
//pgAdminDBに登録したアクション名(name/subtitle)一致する必要がある:
|
||||
this.name="ログインユーザー取得";
|
||||
this.actionProps=[];
|
||||
this.register();
|
||||
//プロパティ属性初期化:
|
||||
this.props={
|
||||
verName:{name:''}
|
||||
}
|
||||
//リセット上記登録表:
|
||||
this.register();
|
||||
}
|
||||
/**
|
||||
* アクションの処理を実装する
|
||||
* @param actionNode アクションノード
|
||||
* @param event Kintoneのイベント
|
||||
* @param context コンテキスト(レコード、変数情報を持っている)
|
||||
* @returns
|
||||
*/
|
||||
//非同期処理ある関数下のある属性:
|
||||
async process(actionNode:IActionNode,event:any,context:IContext):Promise<IActionResult> {
|
||||
let result={
|
||||
canNext:true,
|
||||
result:false
|
||||
};
|
||||
try{
|
||||
//属性設定を取得する:
|
||||
this.actionProps=actionNode.actionProps;
|
||||
//プロパティ設定のデータ型は必要な情報含めますか?全部不存在時return:
|
||||
if (!('verName' in actionNode.ActionValue)) {
|
||||
return result
|
||||
}
|
||||
//既定のプロパティのインタフェースへ変換:
|
||||
this.props = actionNode.ActionValue as ILoginUserGetterProps;
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
if(this.props.verName&&this.props.verName.name!==''){
|
||||
context.variables[this.props.verName.name]=kintone.getLoginUser();
|
||||
// window.alert("変数名"+this.props.verName.name+"の値は"+context.variables[this.props.verName.name]+"です");
|
||||
// event.record["変数運用先のユーザ選択フィールド"].value= [{code:context.variables[this.props.verName.name].code}];
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
result= {
|
||||
canNext:true,
|
||||
result:true
|
||||
}
|
||||
return result;
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
}catch(error:any){;
|
||||
event.error=error.message;
|
||||
return {
|
||||
canNext:false,
|
||||
result:false
|
||||
}
|
||||
}
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
register(): void {
|
||||
actionAddins[this.name]=this;
|
||||
}
|
||||
}
|
||||
new LoginUserGetterAction();
|
||||
@@ -15,6 +15,7 @@ import '../actions/value-getter';
|
||||
import '../actions/string-join';
|
||||
import '../actions/validation-fullwidth';
|
||||
import '../actions/validation-halfwidth';
|
||||
import '../actions/login-user-getter';
|
||||
|
||||
import { ActionFlow,IActionFlow, IActionResult,IContext } from "./ActionTypes";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user