全角チェックのアップデート
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -12,8 +12,8 @@ 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://3f05-133-139-70-194.ngrok-free.app/alc_runtime.js"
|
#DEPLOY_JS_URL = "https://fff3-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"]
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
#KAB_BACKEND_URL="https://kab-backend.azurewebsites.net/"
|
KAB_BACKEND_URL="https://kab-backend.azurewebsites.net/"
|
||||||
KAB_BACKEND_URL="http://127.0.0.1:8000/"
|
#KAB_BACKEND_URL="http://127.0.0.1:8000/"
|
||||||
|
|
||||||
|
|||||||
@@ -98,7 +98,6 @@ export class ButtonAddAction implements IAction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
register(): void {
|
register(): void {
|
||||||
actionAddins[this.name] = this;
|
actionAddins[this.name] = this;
|
||||||
}
|
}
|
||||||
|
|||||||
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();
|
||||||
@@ -6,7 +6,7 @@ import '../actions/field-shown';
|
|||||||
import '../actions/error-show';
|
import '../actions/error-show';
|
||||||
import '../actions/button-add';
|
import '../actions/button-add';
|
||||||
import '../actions/condition-action';
|
import '../actions/condition-action';
|
||||||
import '../actions/fullwidth-check';
|
import '../actions/validation fullwidth';
|
||||||
import { ActionFlow,IActionFlow, IActionResult,IContext } from "./ActionTypes";
|
import { ActionFlow,IActionFlow, IActionResult,IContext } from "./ActionTypes";
|
||||||
|
|
||||||
export class ActionProcess{
|
export class ActionProcess{
|
||||||
|
|||||||
55
sample2.json
55
sample2.json
@@ -1,55 +1,22 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"component": "InputText",
|
"component": "FieldInput",
|
||||||
"props": {
|
"props": {
|
||||||
"displayName": "文字入力",
|
"displayName": "フィールド",
|
||||||
"modelValue": "",
|
|
||||||
"name": "str",
|
|
||||||
"placeholder": "文字を入力してください",
|
|
||||||
"maxLength":"20",
|
|
||||||
"hint":"文字列入力<br>入力ルール指定可能。ルールの設定例:[val=>!!val||'必須入力です']",
|
|
||||||
"rules":"[val=>!!val||'必須入力です']"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"component": "AppFieldSelect",
|
|
||||||
"props": {
|
|
||||||
"displayName": "フィールド選択(複数)",
|
|
||||||
"modelValue": {},
|
"modelValue": {},
|
||||||
"name": "selectFields",
|
"name": "field",
|
||||||
"placeholder": "アプリ選択後、フィールドを選んでください",
|
"placeholder": "対象項目を選択してください"
|
||||||
"selectType":"multiple"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"component": "AppFieldSelect",
|
"component": "SelectBox",
|
||||||
"props": {
|
"props": {
|
||||||
"displayName": "フィールド選択(単一)",
|
"displayName": "チェックする全角文字",
|
||||||
"modelValue": {},
|
"modelValue": null,
|
||||||
"name": "selectField",
|
"name": "options",
|
||||||
"placeholder": "アプリ選択後、フィールドを選んでください",
|
"placeholder": "チェックしたい全角文字を選択する",
|
||||||
"selectType":"single"
|
"selectType":"multiple",
|
||||||
}
|
"options":["全角記号および句読点","ひらがな","カタカナ","全角英数字","常用漢字","拡張漢字"]
|
||||||
},
|
|
||||||
{
|
|
||||||
"component": "ColorPicker",
|
|
||||||
"props": {
|
|
||||||
"displayName": "色選択",
|
|
||||||
"modelValue": "",
|
|
||||||
"name": "color",
|
|
||||||
"placeholder": "カラーを選択してください"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"component": "NumInput",
|
|
||||||
"props": {
|
|
||||||
"displayName": "数値入力フィールド",
|
|
||||||
"modelValue": "",
|
|
||||||
"name": "num",
|
|
||||||
"max":100,
|
|
||||||
"min":0,
|
|
||||||
"placeholder": "数値を入力してください",
|
|
||||||
"rules":"[val=>!!val ||'数値を入力してください',val=>val<=100 && val>=1 || '1-100の範囲内の数値を入力してください']"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
Reference in New Issue
Block a user