ファイル名変更(削除)
This commit is contained in:
@@ -1,96 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
//戻り値を持たないためvoid型
|
|
||||||
register(): void {
|
|
||||||
actionAddins[this.name]=this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
new FullWidthAction();
|
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
import { actionAddins } from ".";
|
|
||||||
import { IAction,IActionResult, IActionNode, IActionProperty, IField, IContext } from "../types/ActionTypes";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* アクションの属性定義
|
|
||||||
*/
|
|
||||||
interface HalfWidthProps{
|
|
||||||
field:IField
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 半角チェックアクション
|
|
||||||
*/
|
|
||||||
export class HalfWidthAction implements IAction{
|
|
||||||
name: string;
|
|
||||||
actionProps: IActionProperty[];
|
|
||||||
props:HalfWidthProps;
|
|
||||||
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 HalfWidthProps;
|
|
||||||
//条件式の計算結果を取得
|
|
||||||
const record = event.record;
|
|
||||||
const value = record[this.props.field.code]?.value;
|
|
||||||
//条件分岐
|
|
||||||
//未入力時は何も処理をせず終了
|
|
||||||
if(value===undefined || value===''){
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
//全角が含まれていた場合保存処理中止(エラー処理)
|
|
||||||
if(this.containsHalfWidthChars(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
|
|
||||||
containsHalfWidthChars(text: string): boolean {
|
|
||||||
|
|
||||||
//半角英数字カナ記号を除外、対象フィールドすべてに適応
|
|
||||||
// 全角文字 ^\x01-\x7E
|
|
||||||
const checkRegex="^[^\x01-\x7E\uFF61-\uFF9F]+$";
|
|
||||||
//正規表現オブジェクト生成
|
|
||||||
const halfWidthRegex = new RegExp(checkRegex);
|
|
||||||
|
|
||||||
//正規表現チェック
|
|
||||||
return halfWidthRegex.test(text);
|
|
||||||
}
|
|
||||||
//戻り値を持たないためvoid型
|
|
||||||
register(): void {
|
|
||||||
actionAddins[this.name]=this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
new HalfWidthAction();
|
|
||||||
Reference in New Issue
Block a user