Merged PR 38: 半角チェック、全角チェックファイル名変更
それぞれfull widthcheck,half widthcheckをfull-widthcheck,half-widthcheckに変更しました Related work items: #380
This commit is contained in:
@@ -13,7 +13,7 @@ API_V1_AUTH_KEY = "X-Cybozu-Authorization"
|
|||||||
DEPLOY_MODE = "DEV" #DEV,PROD
|
DEPLOY_MODE = "DEV" #DEV,PROD
|
||||||
|
|
||||||
DEPLOY_JS_URL = "https://ka-addin.azurewebsites.net/alc_runtime.js"
|
DEPLOY_JS_URL = "https://ka-addin.azurewebsites.net/alc_runtime.js"
|
||||||
#DEPLOY_JS_URL = "https://e84c-133-139-70-142.ngrok-free.app/alc_runtime.js"
|
#DEPLOY_JS_URL = "https://ce1c-133-139-70-194.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_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"]
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ export class FullWidthAction implements IAction{
|
|||||||
result:true
|
result:true
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
//例外処理
|
//例外処理
|
||||||
}catch(error){
|
}catch(error){
|
||||||
event.error=error;
|
event.error=error;
|
||||||
@@ -76,24 +77,17 @@ export class FullWidthAction implements IAction{
|
|||||||
}
|
}
|
||||||
//全て全角の文字列の場合はtrue、そうでない場合はfalse
|
//全て全角の文字列の場合はtrue、そうでない場合はfalse
|
||||||
containsFullWidthChars(text: string): boolean {
|
containsFullWidthChars(text: string): boolean {
|
||||||
//半角英数字カナを除外
|
|
||||||
const checkRegex="^[^\x01-\x7E\uFF61-\uFF9F]+$";
|
//半角英数字カナ記号を除外
|
||||||
|
const checkRegex="[^\x01-\x7E\uFF61-\uFF9F]";
|
||||||
|
|
||||||
//正規表現オブジェクト生成
|
//正規表現オブジェクト生成
|
||||||
const fullWidthRegex = new RegExp(checkRegex);
|
const fullWidthRegex = new RegExp(checkRegex);
|
||||||
|
|
||||||
//正規表現チェック
|
//正規表現チェック
|
||||||
return fullWidthRegex.test(text);
|
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型
|
//戻り値を持たないためvoid型
|
||||||
register(): void {
|
register(): void {
|
||||||
actionAddins[this.name]=this;
|
actionAddins[this.name]=this;
|
||||||
93
plugin/kintone-addins/src/actions/validation-halfwidth.ts
Normal file
93
plugin/kintone-addins/src/actions/validation-halfwidth.ts
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
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();
|
||||||
@@ -13,7 +13,9 @@ import '../actions/datetime-getter';
|
|||||||
import '../actions/insert-value';
|
import '../actions/insert-value';
|
||||||
import '../actions/value-getter';
|
import '../actions/value-getter';
|
||||||
import '../actions/string-join';
|
import '../actions/string-join';
|
||||||
import '../actions/validation fullwidth';
|
import '../actions/validation-fullwidth';
|
||||||
|
import '../actions/validation-halfwidth';
|
||||||
|
|
||||||
import { ActionFlow,IActionFlow, IActionResult,IContext } from "./ActionTypes";
|
import { ActionFlow,IActionFlow, IActionResult,IContext } from "./ActionTypes";
|
||||||
|
|
||||||
export class ActionProcess{
|
export class ActionProcess{
|
||||||
|
|||||||
Reference in New Issue
Block a user