merge:DEVブランチとマージする
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -13,14 +13,14 @@ API_V1_AUTH_KEY = "X-Cybozu-Authorization"
|
||||
DEPLOY_MODE = "DEV" #DEV,PROD
|
||||
|
||||
DEPLOY_JS_URL = "https://ka-addin.azurewebsites.net/alc_runtime.js"
|
||||
#DEPLOY_JS_URL = "https://aee6-133-139-109-232.ngrok-free.app/alc_runtime.js"
|
||||
#DEPLOY_JS_URL = "https://e84c-133-139-70-142.ngrok-free.app/alc_runtime.js"
|
||||
|
||||
KINTONE_FIELD_TYPE=["GROUP","GROUP_SELECT","CHECK_BOX","SUBTABLE","DROP_DOWN","USER_SELECT","RADIO_BUTTON","RICH_TEXT","LINK","REFERENCE_TABLE","CALC","TIME","NUMBER","ORGANIZATION_SELECT","FILE","DATETIME","DATE","MULTI_SELECT","SINGLE_LINE_TEXT","MULTI_LINE_TEXT"]
|
||||
|
||||
KINTONE_FIELD_PROPERTY=['label','code','type','required','unique','maxValue','minValue','maxLength','minLength','defaultValue','defaultNowValue','options','expression','hideExpression','digit','protocol','displayScale','unit','unitPosition']
|
||||
|
||||
class KINTONE_ENV:
|
||||
|
||||
|
||||
BASE_URL = ""
|
||||
|
||||
API_V1_AUTH_VALUE = ""
|
||||
|
||||
6
node_modules/.package-lock.json
generated
vendored
Normal file
6
node_modules/.package-lock.json
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "App Builder for kintone",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {}
|
||||
}
|
||||
@@ -82,6 +82,7 @@ export class ButtonAddAction implements IAction {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
register(): void {
|
||||
actionAddins[this.name] = this;
|
||||
}
|
||||
|
||||
66
plugin/kintone-addins/src/actions/datetime-getter.ts
Normal file
66
plugin/kintone-addins/src/actions/datetime-getter.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
import { actionAddins } from ".";
|
||||
import { IAction, IActionResult, IActionNode, IActionProperty, IField ,IContext} from "../types/ActionTypes";
|
||||
/**
|
||||
* アクションの属性定義
|
||||
*/
|
||||
interface IDatetimeGetterProps {
|
||||
/**変数の名前 */
|
||||
verName:string;
|
||||
}
|
||||
/**
|
||||
* 現在日時を取得するアクション
|
||||
*/
|
||||
export class DatetimeGetterAction implements IAction {
|
||||
name: string;
|
||||
actionProps: IActionProperty[];
|
||||
props: IDatetimeGetterProps;
|
||||
constructor() {
|
||||
this.name = "現在日時";
|
||||
this.actionProps = [];
|
||||
this.props = {
|
||||
verName:''
|
||||
}
|
||||
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 (!('verName' in actionNode.ActionValue) ) {
|
||||
return result
|
||||
}
|
||||
this.props = actionNode.ActionValue as IDatetimeGetterProps;
|
||||
|
||||
let today = new Date();
|
||||
|
||||
if(this.props.verName){
|
||||
context.variables[this.props.verName]=today.toISOString();
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
} catch (error) {
|
||||
event.error = error;
|
||||
console.error(error);
|
||||
result.canNext = false;
|
||||
return result;
|
||||
}
|
||||
};
|
||||
register(): void {
|
||||
actionAddins[this.name] = this;
|
||||
}
|
||||
|
||||
}
|
||||
new DatetimeGetterAction();
|
||||
@@ -56,8 +56,8 @@ export class FieldShownAction implements IAction{
|
||||
}
|
||||
}
|
||||
result= {
|
||||
canNext:true,
|
||||
result:true
|
||||
canNext:true,
|
||||
result:true
|
||||
}
|
||||
return result;
|
||||
}catch(error){
|
||||
@@ -69,9 +69,9 @@ export class FieldShownAction implements IAction{
|
||||
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param context 条件式を実行する
|
||||
* @returns
|
||||
* @returns
|
||||
*/
|
||||
getConditionResult(context:any):boolean{
|
||||
const tree =this.getCondition(this.props.condition);
|
||||
@@ -84,7 +84,7 @@ export class FieldShownAction implements IAction{
|
||||
|
||||
/**
|
||||
* @param condition 条件式ツリーを取得する
|
||||
* @returns
|
||||
* @returns
|
||||
*/
|
||||
getCondition(condition:string):ConditionTree|null{
|
||||
try{
|
||||
@@ -93,7 +93,7 @@ export class FieldShownAction implements IAction{
|
||||
if(tree.getConditions(tree.root).length>0){
|
||||
return tree;
|
||||
}else{
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
}catch(error){
|
||||
return null;
|
||||
@@ -103,6 +103,5 @@ export class FieldShownAction implements IAction{
|
||||
register(): void {
|
||||
actionAddins[this.name]=this;
|
||||
}
|
||||
|
||||
}
|
||||
new FieldShownAction();
|
||||
507
plugin/kintone-addins/src/actions/insert-value.ts
Normal file
507
plugin/kintone-addins/src/actions/insert-value.ts
Normal file
@@ -0,0 +1,507 @@
|
||||
|
||||
|
||||
import { actionAddins } from ".";
|
||||
import { IAction,IActionResult, IActionNode, IActionProperty, IField, IContext } from "../types/ActionTypes";
|
||||
import { ConditionTree } from '../types/Conditions';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* アクションの属性定義
|
||||
*/
|
||||
interface IInsertValueProps{
|
||||
field:IField;
|
||||
condition:string;
|
||||
value:string;
|
||||
show:string;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
export class InsertValueAction implements IAction{
|
||||
name: string;
|
||||
actionProps: IActionProperty[];
|
||||
props:IInsertValueProps;
|
||||
constructor(){
|
||||
this.name="値を挿入する";// DBに登録したアクション名
|
||||
this.actionProps=[];
|
||||
//プロパティ属性の初期化
|
||||
this.props={
|
||||
field:{code:''},
|
||||
condition:'',
|
||||
value:'',
|
||||
show:''
|
||||
}
|
||||
//アクションを登録する
|
||||
this.register();
|
||||
}
|
||||
|
||||
/**
|
||||
* 空白文字を空白文字が非対応のフィールドに挿入しようとしていないか、必須項目フィールドに挿入しようとしていないかチェックする
|
||||
* @param {string} inputValue - 挿入する値
|
||||
* @return {boolean} -入力値が有効な日付形式の場合はtrueを返し、そうでない場合は例外を発生させる
|
||||
*/
|
||||
checkInputBlank(fieldType :string | undefined,inputValue :string,fieldCode :string,fieldRequired :boolean | undefined,event :any): boolean{
|
||||
//正規表現チェック
|
||||
let blankCheck= inputValue.match(/^(\s| )+?$/);//半角スペース・タブ文字・改行・改ページ・全角スペース
|
||||
|
||||
if(blankCheck !== null){
|
||||
//空白文字を空白文字が非対応のフィールドに挿入しようとしている場合、例外を発生させる
|
||||
if(fieldType === "NUMBER" || fieldType === "DATE" || fieldType === "DATETIME" || fieldType === "TIME" || fieldType === "USER_SELECT"
|
||||
|| fieldType === "ORGANIZATION_SELECT" || fieldType === "GROUP_SELECT" || fieldType === "RADIO_BUTTON" || fieldType === "DROP_DOWN" || fieldType === "CHECK_BOX" || fieldType === "MULTI_SELECT"){
|
||||
event.record[fieldCode]['error'] = "「"+fieldCode+"」"+"フィールドには、空白文字は挿入できません。"; //レコードにエラーを表示
|
||||
throw new Error("「"+fieldCode+"」"+"フィールドには、空白文字は挿入できません。「値を挿入する」コンポーネントの処理を中断しました。");
|
||||
|
||||
//空白文字を必須項目フィールドに挿入しようとしている場合、例外を発生させる
|
||||
}else if(fieldRequired){
|
||||
event.record[fieldCode]['error'] = "「"+fieldCode+"」"+"フィールドは必須項目のため、空白文字は挿入できません。"; //レコードにエラーを表示
|
||||
throw new Error("「"+fieldCode+"」"+"フィールドは必須項目のため、空白文字は挿入できません。「値を挿入する」コンポーネントの処理を中断しました。");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 入力値が半角数字かチェックする関数
|
||||
* @param {string} inputValue - 挿入する値
|
||||
* @return {boolean} -入力値が有効な数値の場合はtrueを返し、そうでない場合は例外を発生させる
|
||||
*/
|
||||
checkInputNumber(inputValue :string,fieldCode :string,event :any): boolean{
|
||||
let inputNumberValue = Number(inputValue);//数値型に変換
|
||||
|
||||
//有限数かどうか判定s
|
||||
if(!isFinite(inputNumberValue)){
|
||||
event.record[fieldCode]['error'] = "「"+fieldCode+"」"+"フィールドに入れようとした値は、無効な日付形式です。"; //レコードにエラーを表示
|
||||
throw new Error("「"+fieldCode+"」"+"フィールドに入れようとした値は、有効な数値ではありません。「値を挿入する」コンポーネントの処理を中断しました。");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** 入力値が有効な日付形式かチェックする関数
|
||||
* @param {string} inputValue - 挿入する値
|
||||
* @return {boolean} -入力値が有効な日付形式の場合はtrueを返し、そうでない場合は例外を発生させる
|
||||
*/
|
||||
checkInputDate(inputValue :string,fieldCode :string,event :any): boolean{
|
||||
//正規表現チェック
|
||||
let twoDigitMonthDay = inputValue.match(/(\d{4})-(\d{2})-(\d{2})$/);//4桁の数字-2桁の数字-2桁の数字
|
||||
let singleDigitMonthDay = inputValue.match(/(\d{4})-(\d{1})-(\d{1})$/);//4桁の数字-1桁の数字-2桁の数字
|
||||
let singleDigitMonth = inputValue.match(/(\d{4})-(\d{1})-(\d{2})$/);//4桁の数字-1桁の数字-2桁の数字
|
||||
let singleDigitDay = inputValue.match(/(\d{4})-(\d{2})-(\d{1})$/);//4桁の数字-2桁の数字-1桁の数字
|
||||
let dateTime = inputValue.match(/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}).000Z/);//時刻入りのUTCの日付形式
|
||||
let date;
|
||||
//date型に変換
|
||||
date = new Date(inputValue);
|
||||
|
||||
//date型変換できたか確認
|
||||
if(date !== undefined && !isNaN(date.getDate())){
|
||||
//正規表現チェック確認
|
||||
if(twoDigitMonthDay === null && singleDigitMonth === null && singleDigitDay === null && singleDigitMonthDay === null && dateTime === null){
|
||||
event.record[fieldCode]['error'] = "「"+fieldCode+"」"+"フィールドに入れようとした値は、無効な日付形式です。"; //レコードにエラーを表示
|
||||
throw new Error("「"+fieldCode+"」"+"フィールドに入れようとした値は、無効な日付形式です。「値を挿入する」コンポーネントの処理を中断しました。");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** 入力値が有効な時刻形式かチェックする関数
|
||||
* @param {string} inputValue - 挿入する値
|
||||
* @return {boolean} -入力値が有効な日付形式の場合はtrueを返し、そうでない場合は例外を発生させる
|
||||
*/
|
||||
checkInputTime(inputValue :string,fieldCode :string,event :any): boolean{
|
||||
//正規表現チェック
|
||||
let timeFormat =inputValue.match(/^([0-9]|1[0-9]|2[0-3]):[0-5][0-9]$/);
|
||||
|
||||
//正規表現チェック確認
|
||||
if(timeFormat === null){
|
||||
event.record[fieldCode]['error'] = "「"+fieldCode+"」"+"フィールドに入れようとした値は、無効な時刻形式です。"; //レコードにエラーを表示
|
||||
throw new Error("「"+fieldCode+"」"+"フィールドに入れようとした値は、無効な時刻形式です。「値を挿入する」コンポーネントの処理を中断しました。");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 入力値のフィールドタイプがDATETIMEであれば、時刻ありの日付形式変換し、DATEであれば時刻なしの日付形式変換する関数
|
||||
* @param {string} inputValue -挿入する値
|
||||
* @param {string} fieldType -フィールドタイプ
|
||||
* @return {string} -入力値が日付形式に変換できた場合は文字列を返し、そうでない場合は例外を発生させる
|
||||
*/
|
||||
changeDateFormat(inputValue :string, fieldType :string,fieldCode :string,event :any): string{
|
||||
let dateTime;
|
||||
let date;
|
||||
|
||||
//挿入する値をdate型に変換
|
||||
date = new Date(inputValue);
|
||||
//date型変換できたか確認
|
||||
if(date !== undefined && !isNaN(date.getDate())){
|
||||
|
||||
//日時フィールドの場合、時刻ありの日付形式変換
|
||||
if(fieldType === "DATETIME"){
|
||||
dateTime =date.toISOString();
|
||||
return dateTime;
|
||||
}
|
||||
|
||||
//日付フィールドの場合、時刻なしの日付形式変換
|
||||
let dateArray=inputValue.match(/(\d{4})-(\d{1,2})-(\d{1,2})$/);//4桁の数字-1~2桁の数字-1~2桁の数字
|
||||
if(dateArray !== null){
|
||||
let yearIndex = 1;
|
||||
let monthIndex = 2;
|
||||
let dayIndex = 3;
|
||||
let dateFormatted=`${dateArray[yearIndex]}-${dateArray[monthIndex]}-${dateArray[dayIndex]}`
|
||||
return dateFormatted;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
event.record[fieldCode]['error'] = "「"+fieldCode+"」"+"フィールドに入れようとした値は、無効な日付形式です。"; //レコードにエラーを表示
|
||||
throw new Error("「"+fieldCode+"」"+"フィールドに入れようとした値は、無効な日付形式です。「値を挿入する」コンポーネントの処理を中断しました。");
|
||||
}
|
||||
|
||||
/**
|
||||
* 入力値がフィールドタイプ(ラジオボタン・ドロップダウン・複数選択・ドロップダウン)の選択肢に存在する値かチェックする関数
|
||||
* @param {string} inputValue - 挿入する値
|
||||
* @return {boolean} -入力値が有効な値の場合はtrueを返し、そうでない場合は例外を発生させる
|
||||
*/
|
||||
checkInputOption(inputValue :string,fieldOptions :string | undefined,fieldCode :string,event :any): boolean {
|
||||
|
||||
//入力値が選択肢に存在する値かチェックし、存在したらtrueを返す
|
||||
if(fieldOptions !== undefined){
|
||||
let options = Object.keys(fieldOptions);
|
||||
for(var optionsIndex in options){
|
||||
if(options[optionsIndex] === inputValue){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
event.record[fieldCode]['error']="「"+fieldCode+"」"+"には、存在しない値を挿入しようとしたため、処理を中断しました。";
|
||||
throw new Error("「"+fieldCode+"」"+"には、存在しない値を挿入しようとしたため、処理を中断しました。「値を挿入する」コンポーネントの処理を中断しました。");
|
||||
}
|
||||
|
||||
/**
|
||||
* 入力値がフィールドタイプ(ユーザー選択)で、ユーザー情報に存在する値かチェックする関数
|
||||
* @param {string} inputValue - 挿入する値
|
||||
* @return {string | boolean} 入力値が登録されているユーザー情報から見つかった場合、trueを返し、見つからなかった場合、falseを返す
|
||||
*/
|
||||
async setInputUser(inputValue :string): Promise<string | boolean>{
|
||||
|
||||
//ユーザー名を格納する変数
|
||||
let usersName;
|
||||
const usersInfoColumnIndex=0;
|
||||
|
||||
try{
|
||||
//APIでユーザー情報を取得する
|
||||
const resp =await kintone.api(kintone.api.url('/v1/users', true), 'GET', {codes:[inputValue ]})
|
||||
|
||||
//入力されたログイン名(メールアドレス)がユーザー情報に登録されている場合、そのユーザー名を取得する
|
||||
if (resp.users[usersInfoColumnIndex].code === inputValue) {
|
||||
usersName=resp.users[usersInfoColumnIndex].name;
|
||||
}
|
||||
|
||||
//ユーザー名が取得できた場合、ログイン名とユーザー名をフィールドにセットする
|
||||
if(usersName === undefined){
|
||||
throw new Error();
|
||||
}
|
||||
}catch{
|
||||
return false;
|
||||
}
|
||||
|
||||
return usersName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 入力値がフィールドタイプ(組織選択)で、組織情報に存在する値かチェックする関数
|
||||
* @param {string} inputValue - 挿入する値
|
||||
* @return {string | boolean} 入力値が登録されている組織情報から見つかった場合、trueを返し、見つからなかった場合、falseを返す
|
||||
*/
|
||||
async setInputOrganization(inputValue :string): Promise<string | boolean>{
|
||||
|
||||
//組織名を格納する変数
|
||||
let organizationName;
|
||||
const organizationsInfoColumnIndex=0;
|
||||
|
||||
try{
|
||||
//APIで組織情報を取得する
|
||||
const resp =await kintone.api(kintone.api.url('/v1/organizations.json', true), 'GET', {codes:[inputValue ]})
|
||||
|
||||
//入力された組織コードが組織情報に登録されている場合、その組織名を取得する
|
||||
if (resp.organizations[organizationsInfoColumnIndex].code === inputValue) {
|
||||
organizationName=resp.organizations[organizationsInfoColumnIndex].name;
|
||||
}
|
||||
|
||||
//組織名が取得できた場合、組織コードと組織名をフィールドにセットする
|
||||
if(organizationName === undefined){
|
||||
throw new Error();
|
||||
}
|
||||
}catch{
|
||||
return false;
|
||||
}
|
||||
|
||||
return organizationName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 入力値がフィールドタイプ(グループ選択)で、グループ情報に存在する値かチェックする関数
|
||||
* @param {string} inputValue - 挿入する値
|
||||
* @return {string | boolean} 入力値が登録されているグループ情報から見つかった場合、trueを返し、見つからなかった場合、falseを返す
|
||||
*/
|
||||
async setInputGroup(inputValue :string): Promise<string | boolean>{
|
||||
|
||||
//グループ名を格納する変数
|
||||
let groupsName;
|
||||
const groupsInfoColumnIndex=0;
|
||||
|
||||
try{
|
||||
//APIでグループ情報を取得する
|
||||
const resp =await kintone.api(kintone.api.url('/v1/groups.json', true), 'GET', {codes:[inputValue ]})
|
||||
|
||||
//入力されたグループコードがグループ情報に登録されている場合、そのグループ名を取得する
|
||||
if (resp.groups[groupsInfoColumnIndex].code === inputValue) {
|
||||
groupsName=resp.groups[groupsInfoColumnIndex].name;
|
||||
}
|
||||
|
||||
//グループ名が取得できた場合、グループコードとグループ名をフィールドにセットする
|
||||
if(groupsName === undefined){
|
||||
throw new Error();
|
||||
}
|
||||
}catch{
|
||||
return false;
|
||||
}
|
||||
|
||||
return groupsName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* アクションの実行を呼び出す
|
||||
* @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) && !('value' in actionNode.ActionValue)) {
|
||||
return result
|
||||
}
|
||||
|
||||
const fieldColumnIndex=1;
|
||||
const valueColumnIndex=3;
|
||||
|
||||
//プロパティで選択されたフィールド
|
||||
const field=this.actionProps[fieldColumnIndex].props.modelValue.type;
|
||||
//プロパティの挿入する値
|
||||
const value=this.actionProps[valueColumnIndex].props.modelValue;
|
||||
|
||||
//条件式の結果を取得
|
||||
const conditionResult = this.getConditionResult(context);
|
||||
if(!conditionResult){
|
||||
return result;
|
||||
}
|
||||
|
||||
//プロパティの値を挿入するフィールドが未選択の場合、例外を発生させる
|
||||
if(field === null){
|
||||
throw new Error("「値を挿入する」コンポーネントで、値を挿入するフィールドが指定されていなかったため、処理が中断されました。");
|
||||
}
|
||||
|
||||
//プロパティの値を挿入するフィールドが非対応フィールドの場合、例外を発生させる
|
||||
//添付ファイル・テーブル・カテゴリー・ステータス・作成者・更新者・作業者・リビジョン番号・レコード番号・レコードID・計算・作成日時・更新日時フィールドが選択されている場合、例外を発生させる
|
||||
if(field === "FILE" || field === "SUBTABLE" || field === "CATEGORY" || field === "STATUS"
|
||||
|| field === "STATUS_ASSIGNEE" || field === "CREATOR" || field === "MODIFIER" || field === "__REVISION__"
|
||||
|| field === "RECORD_NUMBER"|| field === "__ID__" || field ==="CALC" || field === "CREATED_TIME" || field === "UPDATED_TIME" ){
|
||||
throw new Error("「値を挿入する」コンポーネントで、選択されたフィールドは、値を挿入するコンポーネントでは非対応のフィールドのため、処理を中断しました。");
|
||||
}
|
||||
|
||||
//プロパティの挿入する値が未入力の場合、例外を発生させる
|
||||
if(value === ""){
|
||||
throw new Error("「値を挿入する」コンポーネントで、フィールドに挿入する値が指定されていなかったため、処理が中断されました。");
|
||||
}
|
||||
|
||||
//既定のプロパティのインターフェースへ変換する
|
||||
this.props = actionNode.ActionValue as IInsertValueProps;
|
||||
|
||||
//挿入する値を取得
|
||||
let fieldValue = this.props.value;
|
||||
//フィールドの種類を取得
|
||||
const fieldType = this.props.field.type;
|
||||
//フィールドが必須項目なのか取得
|
||||
const fieldRequired=this.props.field.required;
|
||||
//挿入するフィールドのコードを取得
|
||||
const fieldCode=this.props.field.code;
|
||||
//挿入する値の形式(手入力か変数)を取得
|
||||
const insertValueType=this.props.show;
|
||||
//ラジオボタン・チェックボックス・複数選択・ドロップダウンの選択肢を取得
|
||||
let fieldOptions =this.props.field.options;
|
||||
//変数の値を格納する
|
||||
let variableValue;
|
||||
|
||||
//変数の場合、値が取得できるかチェック
|
||||
if(insertValueType === "変数" && conditionResult){
|
||||
variableValue = context.variables[fieldValue];
|
||||
|
||||
if(variableValue === undefined){
|
||||
throw new Error("「"+fieldCode+"」"+"フィールドに入れようとした変数は、無効な入力形式です。");
|
||||
}
|
||||
fieldValue = variableValue;
|
||||
}
|
||||
|
||||
//入力値チェック後、形式変換、型変換した値を格納する変数
|
||||
let correctFormattedValue;
|
||||
//入力値チェック後、形式変換、型変換した値を格納する配列
|
||||
let correctValues :string[] = [];
|
||||
//入力エラー(空白文字の混入)がないことをチェック
|
||||
let notInputError=this.checkInputBlank(fieldType,fieldValue,fieldCode,fieldRequired,event);
|
||||
|
||||
//条件式の結果がtrue、入力エラー(空白文字の混入)がない場合、挿入する値をフィールドタイプ別にチェックする
|
||||
if(conditionResult && notInputError){
|
||||
|
||||
//文字列型のフィールドに挿入しようとしている値が適切の場合、correctFormattedValueに代入する
|
||||
if(fieldType === "SINGLE_LINE_TEXT" || fieldType === "MULTI_LINE_TEXT" || fieldType === "RICH_TEXT" || fieldType === "LINK" ){
|
||||
correctFormattedValue = fieldValue;
|
||||
|
||||
//数値型のフィールドに挿入しようとしている値が適切の場合、数値型に型変換してcorrectFormattedValueに代入する
|
||||
}else if(fieldType === "NUMBER" ){
|
||||
if(this.checkInputNumber(fieldValue,fieldCode,event)){//入力値チェック
|
||||
correctFormattedValue = Number(fieldValue);//型変換
|
||||
}
|
||||
|
||||
//日付・日時型のフィールドに挿入しようとしている値が適切の場合、指定の日付・日時に形式変換してcorrectFormattedValueに代入する
|
||||
}else if(fieldType === "DATE" || fieldType === "DATETIME" ){
|
||||
if(this.checkInputDate(fieldValue,fieldCode,event)){//入力値チェック
|
||||
let formattedDate = this.changeDateFormat(fieldValue,fieldType,fieldCode,event)
|
||||
if(formattedDate){
|
||||
correctFormattedValue = formattedDate
|
||||
}
|
||||
}
|
||||
|
||||
//時刻フィールドに挿入しようとしている値が適切の場合、correctFormattedValueに代入する
|
||||
}else if(fieldType === "TIME"){
|
||||
if(this.checkInputTime(fieldValue,fieldCode,event)){//入力値チェック
|
||||
correctFormattedValue = fieldValue;
|
||||
}
|
||||
|
||||
//ラジオボタン・ドロップダウンのフィールドの選択肢と入力値が一致した場合、correctFormattedValueに代入する
|
||||
}else if(fieldType === "RADIO_BUTTON" || fieldType === "DROP_DOWN"){
|
||||
if(this.checkInputOption(fieldValue,fieldOptions,fieldCode,event)){//入力値チェック
|
||||
correctFormattedValue = fieldValue;
|
||||
}
|
||||
|
||||
//チェックボックス・複数選択のフィールドの選択肢と入力値が一致した場合、correctValuesの配列に代入する
|
||||
}else if(fieldType === "CHECK_BOX" || fieldType === "MULTI_SELECT" ){
|
||||
if(this.checkInputOption(fieldValue,fieldOptions,fieldCode,event)){//入力値チェック
|
||||
correctValues[0] = fieldValue;
|
||||
}
|
||||
|
||||
//ユーザー情報フィードに挿入しようとした値が適切な場合、correctFormattedValueに代入する
|
||||
}else if(fieldType === "USER_SELECT"){
|
||||
//挿入する値がユーザー情報から見つかれば、ユーザー名を格納
|
||||
let users=await this.setInputUser(fieldValue);
|
||||
|
||||
//ユーザー名が格納できている場合、ログイン名とユーザー名をcorrectFormattedValueに代入する
|
||||
if(!users){
|
||||
event.record[fieldCode]['error']="ユーザー選択に、挿入しようとしたユーザー情報は見つかりませんでした。「値を挿入する」コンポーネントの処理を中断しました。";
|
||||
throw new Error("ユーザー選択に、挿入しようとしたユーザー情報は見つかりませんでした。「値を挿入する」コンポーネントの処理を中断しました。");
|
||||
}else{
|
||||
correctFormattedValue=[{ code: fieldValue, name: users }];
|
||||
}
|
||||
|
||||
//組織情報フィードに挿入しようとした値が適切な場合、correctFormattedValueに代入する
|
||||
}else if(fieldType === "ORGANIZATION_SELECT"){
|
||||
//挿入する値が組織情報から見つかれば、組織名を格納
|
||||
let organizations=await this.setInputOrganization(fieldValue);
|
||||
|
||||
//組織名が格納できている場合、組織コードと組織名をcorrectFormattedValueに代入する
|
||||
if(!organizations){
|
||||
event.record[fieldCode]['error']="組織選択フィールドに、挿入しようとした組織情報は見つかりませんでした。「値を挿入する」コンポーネントの処理を中断しました。";
|
||||
throw new Error("組織選択フィールドに、挿入しようとした組織情報は見つかりませんでした。「値を挿入する」コンポーネントの処理を中断しました。");
|
||||
}else{
|
||||
correctFormattedValue=[{ code: fieldValue, name: organizations}];
|
||||
}
|
||||
|
||||
//グループ情報フィードに挿入しようとした値が適切な場合、correctFormattedValueに代入する
|
||||
}else if(fieldType === "GROUP_SELECT"){
|
||||
//挿入する値がグループ情報から見つかれば、グループ名を格納
|
||||
let groups=await this.setInputGroup(fieldValue);
|
||||
|
||||
//グループ名が格納できている場合、グループコードとグループ名をcorrectFormattedValueに代入する
|
||||
if(!groups){
|
||||
event.record[fieldCode]['error']="グループ選択フィールドに、挿入しようとしたグループ情報は見つかりませんでした。「値を挿入する」コンポーネントの処理を中断しました。";
|
||||
throw new Error("グループ選択フィールドに、挿入しようとしたグループ情報は見つかりませんでした。「値を挿入する」コンポーネントの処理を中断しました。");
|
||||
}else{
|
||||
correctFormattedValue=[{ code: fieldValue, name: groups}];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//条件式の結果がtrueかつ挿入する値が変換できた場合、フィールド(ラジオボタン・ドロップダウン・チェックボックス・複数選択・文字列一行・文字列複数行・リッチエディタ・数値・日付・日時・時刻)にセット
|
||||
if(conditionResult && (correctFormattedValue || correctValues)){
|
||||
//条件式の結果がtureかつ、値を正しい形式に変換できた場合、フィールドに値をセットする
|
||||
if(correctFormattedValue){
|
||||
event.record[fieldCode].value = correctFormattedValue;
|
||||
//条件式の結果がtureかつ、値を正しい形式(配列)に変換できた場合、フィールドに値(配列)をセットする
|
||||
}else if(correctValues.length > 0){
|
||||
event.record[fieldCode].value = correctValues;
|
||||
}
|
||||
}
|
||||
|
||||
result= {
|
||||
canNext:true,
|
||||
result:true
|
||||
}
|
||||
return result;
|
||||
}catch(error:any){
|
||||
event.record;
|
||||
event.error=error.message;
|
||||
console.error(error);
|
||||
result.canNext=true;//次のノードは処理を続ける
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param context 条件式を実行する
|
||||
* @returns
|
||||
*/
|
||||
getConditionResult(context:any):boolean{
|
||||
//プロパティ`condition`から条件ツリーを取得する
|
||||
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 InsertValueAction();
|
||||
211
plugin/kintone-addins/src/actions/string-join.ts
Normal file
211
plugin/kintone-addins/src/actions/string-join.ts
Normal file
@@ -0,0 +1,211 @@
|
||||
import { actionAddins } from ".";
|
||||
import { IField, IAction,IActionResult, IActionNode, IActionProperty } from "../types/ActionTypes";
|
||||
import { Formatter } from "../util/format";
|
||||
|
||||
//右UI画面propertyのname:型:
|
||||
interface IStringJoinProps{
|
||||
//保存先フィールド
|
||||
saveField:IField;
|
||||
//結合元フィールド1
|
||||
joinField1:IField;
|
||||
//結合元フィールド2
|
||||
joinField2:IField;
|
||||
//区切り文字
|
||||
delimiter:string;
|
||||
}
|
||||
|
||||
//IActionインタフェースを実装する新しいクラスActionを作成:
|
||||
export class StringJoinAction implements IAction{
|
||||
name: string;
|
||||
//importから導入顕示定義
|
||||
actionProps: IActionProperty[];
|
||||
//上方のinterface Propsから、props受ける属性を定義:
|
||||
props:IStringJoinProps;
|
||||
//関数定義に必要な類名を構築:
|
||||
constructor(){
|
||||
//pgAdminDBに登録したアクション名(name/subtitle)一致する必要がある:
|
||||
this.name="文字結合";
|
||||
this.actionProps=[];
|
||||
this.register();
|
||||
//プロパティ属性初期化:
|
||||
this.props={
|
||||
saveField:{code:''},
|
||||
joinField1:{code:''},
|
||||
joinField2:{code:''},
|
||||
delimiter:''
|
||||
}
|
||||
//リセット上記登録表:
|
||||
this.register();
|
||||
}
|
||||
/**
|
||||
* アクションの処理を実装する
|
||||
* @param actionNode アクションノード
|
||||
* @param event Kintoneのイベント
|
||||
* @param context コンテキスト(レコード、変数情報を持っている)
|
||||
* @returns
|
||||
*/
|
||||
//非同期処理ある関数下のある属性:
|
||||
async process(actionNode:IActionNode,event:any):Promise<IActionResult> {
|
||||
let result={
|
||||
//後継処理不可:
|
||||
canNext:false,
|
||||
result:false
|
||||
};
|
||||
try{
|
||||
//属性設定を取得する:
|
||||
this.actionProps=actionNode.actionProps;
|
||||
//プロパティ設定のデータ型は必要な情報含めますか?全部不存在時return:
|
||||
if (!('saveField' in actionNode.ActionValue) && !('joinField1' in actionNode.ActionValue) && !('joinField2' in actionNode.ActionValue)) {
|
||||
return result
|
||||
}
|
||||
|
||||
//既定のプロパティのインタフェースへ変換:
|
||||
this.props = actionNode.ActionValue as IStringJoinProps;
|
||||
const record = event.record;
|
||||
|
||||
//kintoneフィールドタイプ取得:
|
||||
const joinField1type=this.props.joinField1.type;
|
||||
const joinField2type=this.props.joinField2.type;
|
||||
const saveFieldtype=this.props.saveField.type;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// //保存先フィールドは文字列フィールドではない場合、エラー発生:
|
||||
if(!(saveFieldtype==='SINGLE_LINE_TEXT'||saveFieldtype==='MULTI_LINE_TEXT'||saveFieldtype==='RICH_TEXT')){
|
||||
event.error='[エラーメッセージ]:結合保存先対応不可。結合しません';
|
||||
if (event.type.includes('success')){
|
||||
window.alert("[windows alert]:"+event.error);
|
||||
}
|
||||
result = {
|
||||
canNext: false,
|
||||
result: false
|
||||
}
|
||||
return result;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
//値取得方法定義:
|
||||
function getValue(value:string,type:string|undefined,fieldCode:string,event:any){
|
||||
if(event.record[fieldCode]?.value===undefined||event.record[fieldCode]?.value===null){
|
||||
event.record[fieldCode].value='';
|
||||
}
|
||||
//作成者、更新者:
|
||||
if(type==='CREATOR'||type==='MODIFIER'){
|
||||
value = event.record[fieldCode]?.value.name;
|
||||
//日時、作成日時、更新日時:
|
||||
}else if(type==='DATETIME'||type==='CREATED_TIME'||type==='UPDATED_TIME'){
|
||||
if(event.record[fieldCode]?.value!==undefined && event.record[fieldCode]?.value!==''){
|
||||
value = Formatter.dateFormat(new Date(event.record[fieldCode]?.value),'yyyy-MM-dd HH:mm');
|
||||
}else{
|
||||
value=event.record[fieldCode]?.value;
|
||||
}
|
||||
//ユーザ選択、組織選択、グループ選択、添付ファイル名、作業者、カテゴリー:
|
||||
}else if(type==='USER_SELECT'||type==='ORGANIZATION_SELECT'||type==='GROUP_SELECT'||type==='FILE'||type==='STATUS_ASSIGNEE'){
|
||||
if(event.record[fieldCode]?.value===undefined || event.record[fieldCode]?.value===''){
|
||||
value = event.record[fieldCode]?.value;
|
||||
}else{
|
||||
const mototext=event.record[fieldCode]?.value;
|
||||
let arr=[];
|
||||
for(let i=0;i<mototext.length;i++){
|
||||
arr.push(mototext[i].name);
|
||||
}
|
||||
//配列要素を,で連結して文字列を作成:
|
||||
value=arr.join();
|
||||
}
|
||||
//カテゴリー、チェックボックス、複数選択:
|
||||
}else if(type==='CATEGORY'||type==='CHECK_BOX'||type==='MULTI_SELECT'){
|
||||
if(event.record[fieldCode]?.value===undefined || event.record[fieldCode]?.value===''){
|
||||
value = event.record[fieldCode]?.value;
|
||||
}else{
|
||||
const mototext=event.record[fieldCode]?.value;
|
||||
let arr=[];
|
||||
for(let i=0;i<mototext.length;i++){
|
||||
arr.push(mototext[i]);
|
||||
}
|
||||
//配列要素を,で連結して文字列を作成:
|
||||
value=arr.join();
|
||||
}
|
||||
//詳細画面プロセス実行後のステータス:
|
||||
}else if(type==='STATUS'&&event.type.includes('process')){
|
||||
value = event.nextStatus.value;
|
||||
}else{
|
||||
value = event.record[fieldCode]?.value;
|
||||
}
|
||||
if (value===undefined || value===null){
|
||||
value='';
|
||||
}
|
||||
return value;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//値取得方法呼出:
|
||||
let joinValue1:string='';
|
||||
joinValue1=getValue(joinValue1,joinField1type,this.props.joinField1.code,event);
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
let joinValue2:string='';
|
||||
joinValue2=getValue(joinValue2,joinField2type,this.props.joinField2.code,event);
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
const conString = this.props.delimiter;
|
||||
let saveValue:string='';
|
||||
//前後結合元が空白なら区切り文字も空白にする(例:1-8の8無いなら1。1-8の1無いなら8。1空白8の8無いなら1。結合元全部空白なら全部空白):
|
||||
if(joinValue1===''&&joinValue2===''){
|
||||
saveValue='';
|
||||
}else if(joinValue1===''&&joinValue2!==''){
|
||||
saveValue=joinValue2;
|
||||
}else if(joinValue2===''&&joinValue1!==''){
|
||||
saveValue=joinValue1;
|
||||
}else if(joinValue1!==''&&joinValue2!==''){
|
||||
saveValue=`${joinValue1}${conString}${joinValue2}`
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//新規/更新/一覧保存成功後の以外のeventでPUT使用しない:
|
||||
if (!event.type.includes('success')){
|
||||
//保存先フィールドに値セット:
|
||||
record[this.props.saveField.code].value=saveValue;
|
||||
window.alert("文字結合行いました。"+this.props.joinField1.name+":"+joinValue1+","+this.props.joinField2.name+":"+joinValue2+"。");
|
||||
}else{
|
||||
const params={
|
||||
"app":event.appId,
|
||||
"id":event.recordId,
|
||||
"record":{[this.props.saveField.code]:{"value":saveValue}}
|
||||
};
|
||||
return await kintone.api(kintone.api.url('/k/v1/record',true),'PUT',params).then((resp) => {
|
||||
//kintone保存先フィールド存在確認:
|
||||
record[this.props.saveField.code].value=saveValue;
|
||||
if (event.type.includes('index')){
|
||||
window.alert("文字結合行いました。"+this.props.joinField1.name+":"+joinValue1+","+this.props.joinField2.name+":"+joinValue2+"。一覧画面更新成功後自動リロードしません。必要に応じて手動リロードください。");
|
||||
}else{
|
||||
window.alert("文字結合行いました。"+this.props.joinField1.name+":"+joinValue1+","+this.props.joinField2.name+":"+joinValue2+"。");
|
||||
}
|
||||
//一覧画面更新成功後リロード:
|
||||
// if (event.type.includes('index')){
|
||||
// event.url = location.href.endsWith('/') || location.href.endsWith('&') ?
|
||||
// location.href.slice(0, -1) :
|
||||
// location.href + (location.href.includes('?') ? '&' : '/');
|
||||
// }
|
||||
}).catch((error) => {
|
||||
event.error = 'エラーが発生しました。結合しません。システム管理者へお問合せください';
|
||||
window.alert(event.error+"error message:"+error);
|
||||
return event;
|
||||
});
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
result= {
|
||||
canNext:true,
|
||||
result:true
|
||||
}
|
||||
return result;
|
||||
}catch(error){;
|
||||
if (event.type.includes('success')){
|
||||
window.alert("[windows alert]:処理中異常が発生しました。結合しません。システム担当者へお問合せください。errorメッセージ:"+error)
|
||||
}
|
||||
event.error="[エラーメッセージ]:処理中異常が発生しました。結合しません。システム担当者へお問合せください。errorメッセージ:"+error;
|
||||
return {
|
||||
canNext:false,
|
||||
result:false
|
||||
}
|
||||
}
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
register(): void {
|
||||
actionAddins[this.name]=this;
|
||||
}
|
||||
}
|
||||
new StringJoinAction();
|
||||
102
plugin/kintone-addins/src/actions/validation fullwidth.ts
Normal file
102
plugin/kintone-addins/src/actions/validation fullwidth.ts
Normal file
@@ -0,0 +1,102 @@
|
||||
import { actionAddins } from ".";
|
||||
import { IAction,IActionResult, IActionNode, IActionProperty, IField, IContext } from "../types/ActionTypes";
|
||||
|
||||
//クラス名を設計書に揃える
|
||||
/**
|
||||
* アクションの属性定義
|
||||
*/
|
||||
interface FullWidthProps{
|
||||
//checkOption:Array<string>,
|
||||
field:IField
|
||||
}
|
||||
/**
|
||||
* 全角チェックアクション
|
||||
*/
|
||||
export class FullWidthAction implements IAction{
|
||||
name: string;
|
||||
actionProps: IActionProperty[];
|
||||
props:FullWidthProps;
|
||||
constructor(){
|
||||
this.name="全角チェック"; /* pgadminのnameと同様 */
|
||||
this.actionProps=[];
|
||||
this.props={
|
||||
//checkOption:[],
|
||||
field:{code:''}
|
||||
}
|
||||
//アクションを登録する
|
||||
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) ) {
|
||||
return result
|
||||
}
|
||||
this.props = actionNode.ActionValue as FullWidthProps;
|
||||
//条件式の計算結果を取得
|
||||
const record = event.record;
|
||||
const value = record[this.props.field.code]?.value;
|
||||
//条件分岐
|
||||
//未入力時は何も処理をせず終了
|
||||
if(value===undefined || value===''){
|
||||
return result;
|
||||
}
|
||||
//半角が含まれていた場合resultがfalse
|
||||
if(!this.containsFullWidthChars(value)){
|
||||
//エラー時に出力される文字設定
|
||||
record[this.props.field.code].error="半角が含まれています";
|
||||
//次の処理を中止する値設定
|
||||
result.canNext=false;
|
||||
return result;
|
||||
}
|
||||
//resultプロパティ指定
|
||||
result= {
|
||||
canNext:true,
|
||||
result:true
|
||||
}
|
||||
return result;
|
||||
//例外処理
|
||||
}catch(error){
|
||||
event.error=error;
|
||||
console.error(error);
|
||||
result.canNext=false;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
//全て全角の文字列の場合はtrue、そうでない場合はfalse
|
||||
containsFullWidthChars(text: string): boolean {
|
||||
//半角英数字カナを除外
|
||||
const checkRegex="^[^\x01-\x7E\uFF61-\uFF9F]+$";
|
||||
//正規表現オブジェクト生成
|
||||
const fullWidthRegex = new RegExp(checkRegex);
|
||||
|
||||
//正規表現チェック
|
||||
return fullWidthRegex.test(text);
|
||||
|
||||
//全角を表すUnicodeの全角正規表現(参照先URL)
|
||||
// \u3000-\u303F:句読点・記号
|
||||
// \u3040-\u309F:すべてのひらがな
|
||||
// \u30A0-\u30FF:すべてのカタカナ
|
||||
// \u4E00-\u9FAF:すべての漢字
|
||||
// \uFF00-\uFFEF:全角英数字と半角カタカナ
|
||||
// \u3400-\u4DBF:CJK統合漢字拡張
|
||||
//const fullWidthRegex = /[/^[\u3000-\u303F\u3040-\u309F\u30A0-\u30FF\uFF00-\uFFEF\u4E00-\u9FAF\u3400-\u4DBF]+$/g;
|
||||
|
||||
}
|
||||
//戻り値を持たないためvoid型
|
||||
register(): void {
|
||||
actionAddins[this.name]=this;
|
||||
}
|
||||
}
|
||||
new FullWidthAction();
|
||||
68
plugin/kintone-addins/src/actions/value-getter.ts
Normal file
68
plugin/kintone-addins/src/actions/value-getter.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
import { actionAddins } from ".";
|
||||
import { IAction,IActionResult, IActionNode, IActionProperty, IField, IContext} from "../types/ActionTypes";
|
||||
/**
|
||||
* アクションの属性定義
|
||||
*/
|
||||
interface IGetValueProps{
|
||||
field:IField;//チェックするフィールドの対象
|
||||
verName:string;
|
||||
}
|
||||
/**
|
||||
* 正規表現チェックアクション
|
||||
*/
|
||||
export class GetValueAciton implements IAction{
|
||||
name: string;
|
||||
actionProps: IActionProperty[];
|
||||
props:IGetValueProps;
|
||||
constructor(){
|
||||
this.name="値を取得する";
|
||||
this.actionProps=[];
|
||||
this.props={
|
||||
field:{code:''},
|
||||
verName:''
|
||||
}
|
||||
//アクションを登録する
|
||||
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) && !('verName' in actionNode.ActionValue)) {
|
||||
return result
|
||||
}
|
||||
|
||||
this.props = actionNode.ActionValue as IGetValueProps;
|
||||
//条件式の計算結果を取得
|
||||
const record = event.record;
|
||||
const value = record[this.props.field.code].value;
|
||||
context.variables[this.props.verName] = value;
|
||||
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 GetValueAciton();
|
||||
@@ -89,6 +89,8 @@ export interface IField{
|
||||
name?:string;
|
||||
code:string;
|
||||
type?:string;
|
||||
required?:boolean;
|
||||
options?:string;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,6 +9,11 @@ import '../actions/condition-action';
|
||||
import '../actions/regular-check';
|
||||
import '../actions/mail-check';
|
||||
import '../actions/counter-check';
|
||||
import '../actions/datetime-getter';
|
||||
import '../actions/insert-value';
|
||||
import '../actions/value-getter';
|
||||
import '../actions/string-join';
|
||||
import '../actions/validation fullwidth';
|
||||
import { ActionFlow,IActionFlow, IActionResult,IContext } from "./ActionTypes";
|
||||
|
||||
export class ActionProcess{
|
||||
@@ -42,7 +47,7 @@ export class ActionProcess{
|
||||
result = await action.process(nextAction,this.event,this.context);
|
||||
}
|
||||
let nextInput = '';
|
||||
//outputPoints一つ以上の場合、次のInputPointは戻り値を設定する
|
||||
//outputPoints一㝤以上㝮場坈〝次㝮InputPoint㝯戻り値を設定㝙る
|
||||
if(nextAction.outputPoints && nextAction.outputPoints.length>1){
|
||||
nextInput = result.result||'';
|
||||
}
|
||||
|
||||
67
sample2.json
67
sample2.json
@@ -1,49 +1,22 @@
|
||||
[
|
||||
{
|
||||
"component": "InputText",
|
||||
"props": {
|
||||
"displayName": "ボタン名",
|
||||
"modelValue": "",
|
||||
"name": "buttonName",
|
||||
"placeholder": "ボタンのラベルを入力してください"
|
||||
}
|
||||
},
|
||||
{
|
||||
"component": "FieldInput",
|
||||
"props": {
|
||||
"displayName": "配置スペースを選択",
|
||||
"modelValue": {},
|
||||
"name": "space",
|
||||
"fieldTypes":["SPACER"],
|
||||
"placeholder": "ボタンを配置するスペースを選択"
|
||||
}
|
||||
},
|
||||
{
|
||||
"component": "SelectBox",
|
||||
"props": {
|
||||
"displayName": "追加位置",
|
||||
"modelValue": "",
|
||||
"name": "position",
|
||||
"options": [
|
||||
"一番右に追加する",
|
||||
"一番左に追加する"
|
||||
],
|
||||
"placeholder": "追加位置を選択してください"
|
||||
}
|
||||
},
|
||||
{
|
||||
"component": "EventSetter",
|
||||
"props": {
|
||||
"displayName": "イベント名",
|
||||
"modelValue": "",
|
||||
"name": "eventName",
|
||||
"connectProps": [
|
||||
{
|
||||
"key": "displayName",
|
||||
"propName": "buttonName"
|
||||
}
|
||||
],
|
||||
"placeholder": "イベント名を入力してください"
|
||||
}
|
||||
{
|
||||
"component": "FieldInput",
|
||||
"props": {
|
||||
"displayName": "フィールド",
|
||||
"modelValue": {},
|
||||
"name": "field",
|
||||
"placeholder": "対象項目を選択してください"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"component": "SelectBox",
|
||||
"props": {
|
||||
"displayName": "チェックする全角文字",
|
||||
"modelValue": null,
|
||||
"name": "options",
|
||||
"placeholder": "チェックしたい全角文字を選択する",
|
||||
"selectType":"multiple",
|
||||
"options":["全角記号および句読点","ひらがな","カタカナ","全角英数字","常用漢字","拡張漢字"]
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user