/** * WP_団体_ボランティア募集情報フォーム */ class WpGroupVolRcrtInfoJsForm { /** * コンストラクタ */ constructor() { /** 募集情報ID */ this.rcrt_id = ""; /** ボランティアタイトル */ this.title = ""; /** 活動写真 */ this.act_img = ""; /** 活動写真(データ) */ this.act_img_data = ""; /** 活動写真(ファイル名) */ this.act_img_full_file_name = ""; /** 活動写真(ファイル名) */ this.act_img_file_name = ""; /** 活動写真(ファイルタイプ) */ this.act_img_file_type = ""; /** 活動写真(制御フラグ) */ this.act_img_ctrl_flag = ""; /** 活動ジャンル */ this.act_kind = ""; /** 応募種別 */ this.rcrt_kind = ""; /** 活動エリア */ this.act_area = ""; /** 募集対象 */ this.rcrt_target = ""; /** 募集人数 */ this.rcrt_num = ""; /** 活動日時 */ this.act_datetime = ""; /** 活動場所 */ this.act_place = ""; /** 集合場所 */ this.gather_place = ""; /** 持ち物 */ this.bring_item = ""; /** 支給するもの */ this.provide_item = ""; /** その他 */ this.others = ""; /** 事前研修 */ this.before_training = ""; /** 活動内容 */ this.act_contents = ""; /** 募集開始日 */ this.rcrt_start_date = ""; /** 募集期限 */ this.rcrt_term = ""; /** 団体ID */ this.group_id = ""; /** 団体名 */ this.group_name = ""; /** 団体連絡先 */ this.group_tel_number = ""; /** 団体URL */ this.group_homepage = ""; /** 団体SNS */ this.group_sns_x = ""; /** 団体SNS(Instgram) */ this.group_sns_instagram = ""; /** 団体SNS(facebook) */ this.group_sns_facebook = ""; /** 団体情報/PR */ this.group_pr = ""; /** 募集期間(From) */ this.sys_vol_start_date = ""; /** 募集期間(To) */ this.sys_vol_end_date = ""; /** 募集公開中止フラグ */ this.sys_vol_stop_flag = ""; /** ステータス */ this.status = ""; /** 応募先URL */ this.out_apply_url = ""; // コントロールクリア this.setControlStyle("title", "border: 1px solid #ccc;"); this.setControlStyle("act_img", "border: 1px solid #ccc;"); this.setControlStyle("act_kind", "border: 1px solid #ccc;"); this.setControlStyle("rcrt_kind", "border: 1px solid #ccc;"); this.setControlStyle("act_area", "border: 1px solid #ccc;"); this.setControlStyle("rcrt_target", "border: 1px solid #ccc;"); this.setControlStyle("rcrt_num", "border: 1px solid #ccc;"); this.setControlStyle("act_datetime", "border: 1px solid #ccc;"); this.setControlStyle("act_place", "border: 1px solid #ccc;"); this.setControlStyle("gather_place", "border: 1px solid #ccc;"); this.setControlStyle("bring_item", "border: 1px solid #ccc;"); this.setControlStyle("provide_item", "border: 1px solid #ccc;"); this.setControlStyle("others", "border: 1px solid #ccc;"); this.setControlStyle("before_training", "border: 1px solid #ccc;"); this.setControlStyle("act_contents", "border: 1px solid #ccc;"); this.setControlStyle("rcrt_start_date", "border: 1px solid #ccc;"); this.setControlStyle("rcrt_term", "border: 1px solid #ccc;"); this.setControlStyle("group_name", "border: 1px solid #ccc;"); this.setControlStyle("group_tel_number", "border: 1px solid #ccc;"); this.setControlStyle("group_homepage", "border: 1px solid #ccc;"); this.setControlStyle("group_sns_x", "border: 1px solid #ccc;"); this.setControlStyle("group_sns_instagram", "border: 1px solid #ccc;"); this.setControlStyle("group_sns_facebook", "border: 1px solid #ccc;"); this.setControlStyle("group_pr", "border: 1px solid #ccc;"); this.setControlStyle("sys_vol_start_date", "border: 1px solid #ccc;"); this.setControlStyle("sys_vol_end_date", "border: 1px solid #ccc;"); this.setControlStyle("sys_vol_stop_flag", "border: 1px solid #ccc;"); this.setControlStyle("status", "border: 1px solid #ccc;"); this.setControlStyle("out_apply_url", "border: 1px solid #ccc;"); } /** * フォームデータを設定 */ setFormData() { var elm_title = document.getElementById('vol_form').title; if (elm_title != null) { this.title = elm_title.value; } var elm_act_img = document.getElementById('vol_form').act_img; if (elm_act_img != null) { this.act_img = elm_act_img.value; } const chkActKind = document.querySelectorAll('input[name="act_kind[]"]:checked'); const selectedValueActKind = Array.from(chkActKind).map(checkbox => checkbox.value); this.act_kind = selectedValueActKind; var elm_rcrt_kind = document.getElementById('vol_form').rcrt_kind; if (elm_rcrt_kind != null) { this.rcrt_kind = elm_rcrt_kind.value; } const chkActArea = document.querySelectorAll('input[name="act_area[]"]:checked'); const selectedValueActArea = Array.from(chkActArea).map(checkbox => checkbox.value); this.act_area = selectedValueActArea; const chkRcrtTarget = document.querySelectorAll('input[name="rcrt_target[]"]:checked'); const selectedValueRcrtTarget = Array.from(chkRcrtTarget).map(checkbox => checkbox.value); this.rcrt_target = selectedValueRcrtTarget; var elm_rcrt_num = document.getElementById('vol_form').rcrt_num; if (elm_rcrt_num != null) { this.rcrt_num = elm_rcrt_num.value; } var elm_act_datetime = document.getElementById('vol_form').act_datetime; if (elm_act_datetime != null) { this.act_datetime = elm_act_datetime.value; } var elm_act_place = document.getElementById('vol_form').act_place; if (elm_act_place != null) { this.act_place = elm_act_place.value; } var elm_gather_place = document.getElementById('vol_form').gather_place; if (elm_gather_place != null) { this.gather_place = elm_gather_place.value; } var elm_bring_item = document.getElementById('vol_form').bring_item; if (elm_bring_item != null) { this.bring_item = elm_bring_item.value; } var elm_provide_item = document.getElementById('vol_form').provide_item; if (elm_provide_item != null) { this.provide_item = elm_provide_item.value; } var elm_others = document.getElementById('vol_form').others; if (elm_others != null) { this.others = elm_others.value; } var elm_before_training = document.getElementById('vol_form').before_training; if (elm_before_training != null) { this.before_training = elm_before_training.value; } var elm_act_contents = document.getElementById('vol_form').act_contents; if (elm_act_contents != null) { this.act_contents = elm_act_contents.value; } var elm_rcrt_start_date = document.getElementById('vol_form').rcrt_start_date; if (elm_rcrt_start_date != null) { this.rcrt_start_date = elm_rcrt_start_date.value; } var elm_rcrt_term = document.getElementById('vol_form').rcrt_term; if (elm_rcrt_term != null) { this.rcrt_term = elm_rcrt_term.value; } var elm_group_name = document.getElementById('vol_form').group_name; if (elm_group_name != null) { this.group_name = elm_group_name.value; } var elm_group_tel_number = document.getElementById('vol_form').group_tel_number; if (elm_group_tel_number != null) { this.group_tel_number = elm_group_tel_number.value; } var elm_group_homepage = document.getElementById('vol_form').group_homepage; if (elm_group_homepage != null) { this.group_homepage = elm_group_homepage.value; } var elm_group_sns_x = document.getElementById('vol_form').group_sns_x; if (elm_group_sns_x != null) { this.group_sns_x = elm_group_sns_x.value; } var elm_group_sns_instagram = document.getElementById('vol_form').group_sns_instagram; if (elm_group_sns_instagram != null) { this.group_sns_instagram = elm_group_sns_instagram.value; } var elm_group_sns_facebook = document.getElementById('vol_form').group_sns_facebook; if (elm_group_sns_facebook != null) { this.group_sns_facebook = elm_group_sns_facebook.value; } var elm_group_pr = document.getElementById('vol_form').group_pr; if (elm_group_pr != null) { this.group_pr = elm_group_pr.value; } var elm_sys_vol_start_date = document.getElementById('vol_form').sys_vol_start_date; if (elm_sys_vol_start_date != null) { this.sys_vol_start_date = elm_sys_vol_start_date.value; } var elm_sys_vol_end_date = document.getElementById('vol_form').sys_vol_end_date; if (elm_sys_vol_end_date != null) { this.sys_vol_end_date = elm_sys_vol_end_date.value; } var elm_sys_vol_stop_flag = document.getElementById('vol_form').sys_vol_stop_flag; if (elm_sys_vol_stop_flag != null) { this.sys_vol_stop_flag = elm_sys_vol_stop_flag.value; } var elm_status = document.getElementById('vol_form').status; if (elm_status != null) { this.status = elm_status.value; } var elm_out_apply_url = document.getElementById('vol_form').out_apply_url; if (elm_out_apply_url != null) { this.out_apply_url = elm_out_apply_url.value; } } /** * バリデーション */ validate() { let errInfo = []; // 必須チェック if (this.title == "") { errInfo.push(["title", "ボランティアタイトルを入力してください。"]); } if (this.act_kind == "") { errInfo.push(["act_kind", "活動ジャンルを入力してください。"]); } if (this.act_area == "") { errInfo.push(["act_area", "活動エリアを入力してください。"]); } if (this.rcrt_target == "") { errInfo.push(["rcrt_target", "募集対象を入力してください。"]); } if (this.rcrt_num == "") { errInfo.push(["rcrt_num", "募集人数を入力してください。"]); } if (this.act_datetime == "") { errInfo.push(["act_datetime", "活動日時を入力してください。"]); } if (this.act_place == "") { errInfo.push(["act_place", "活動場所を入力してください。"]); } if (this.gather_place == "") { errInfo.push(["gather_place", "集合場所を入力してください。"]); } if (this.bring_item == "") { errInfo.push(["bring_item", "持ち物を入力してください。"]); } if (this.provide_item == "") { errInfo.push(["provide_item", "支給するものを入力してください。"]); } if (this.act_contents == "") { errInfo.push(["act_contents", "活動内容を入力してください。"]); } // 桁数チェック if (errInfo.length == 0) { if (this.rcrt_id.length > 32) { errInfo.push(["rcrt_id", "募集情報IDの文字数が大きすぎます。"]); } if (this.title.length > 128) { errInfo.push(["title", "ボランティアタイトルの文字数が大きすぎます。"]); } if (this.act_kind.length > 64) { errInfo.push(["act_kind", "活動ジャンルの文字数が大きすぎます。"]); } if (this.rcrt_kind.length > 1) { errInfo.push(["rcrt_kind", "応募種別の文字数が大きすぎます。"]); } if (this.act_area.length > 64) { errInfo.push(["act_area", "活動エリアの文字数が大きすぎます。"]); } if (this.rcrt_target.length > 64) { errInfo.push(["rcrt_target", "募集対象の文字数が大きすぎます。"]); } if (this.rcrt_num.length > 256) { errInfo.push(["rcrt_num", "募集人数の文字数が大きすぎます。"]); } if (this.act_datetime.length > 256) { errInfo.push(["act_datetime", "活動日時の文字数が大きすぎます。"]); } if (this.act_place.length > 512) { errInfo.push(["act_place", "活動場所の文字数が大きすぎます。"]); } if (this.gather_place.length > 512) { errInfo.push(["gather_place", "集合場所の文字数が大きすぎます。"]); } if (this.bring_item.length > 512) { errInfo.push(["bring_item", "持ち物の文字数が大きすぎます。"]); } if (this.provide_item.length > 512) { errInfo.push(["provide_item", "支給するものの文字数が大きすぎます。"]); } if (this.others.length > 512) { errInfo.push(["others", "その他の文字数が大きすぎます。"]); } if (this.before_training.length > 512) { errInfo.push(["before_training", "事前研修の文字数が大きすぎます。"]); } if (this.act_contents.length > 2048) { errInfo.push(["act_contents", "活動内容の文字数が大きすぎます。"]); } if (this.rcrt_start_date.length > 256) { errInfo.push(["rcrt_start_date", "募集開始日の文字数が大きすぎます。"]); } if (this.rcrt_term.length > 256) { errInfo.push(["rcrt_term", "募集期限の文字数が大きすぎます。"]); } if (this.group_id.length > 32) { errInfo.push(["group_id", "団体IDの文字数が大きすぎます。"]); } if (this.group_name.length > 64) { errInfo.push(["group_name", "団体名の文字数が大きすぎます。"]); } if (this.group_tel_number.length > 256) { errInfo.push(["group_tel_number", "団体連絡先の文字数が大きすぎます。"]); } if (this.group_homepage.length > 256) { errInfo.push(["group_homepage", "団体URLの文字数が大きすぎます。"]); } if (this.group_sns_x.length > 256) { errInfo.push(["group_sns_x", "団体SNSの文字数が大きすぎます。"]); } if (this.group_sns_instagram.length > 256) { errInfo.push(["group_sns_instagram", "団体SNS(Instgram)の文字数が大きすぎます。"]); } if (this.group_sns_facebook.length > 256) { errInfo.push(["group_sns_facebook", "団体SNS(facebook)の文字数が大きすぎます。"]); } if (this.group_pr.length > 256) { errInfo.push(["group_pr", "団体情報/PRの文字数が大きすぎます。"]); } if (this.sys_vol_start_date.length > 12) { errInfo.push(["sys_vol_start_date", "募集期間(From)の文字数が大きすぎます。"]); } if (this.sys_vol_end_date.length > 12) { errInfo.push(["sys_vol_end_date", "募集期間(To)の文字数が大きすぎます。"]); } if (this.sys_vol_stop_flag.length > 1) { errInfo.push(["sys_vol_stop_flag", "募集公開中止フラグの文字数が大きすぎます。"]); } if (this.status.length > 1) { errInfo.push(["status", "ステータスの文字数が大きすぎます。"]); } if (this.out_apply_url.length > 256) { errInfo.push(["out_apply_url", "応募先URLの文字数が大きすぎます。"]); } } // 入力形式チェック if (errInfo.length == 0) { if (validString(this.title) != true) { errInfo.push(["title", "ボランティアタイトルの入力形式が正しくありません。"]); } if (validString(this.rcrt_num) != true) { errInfo.push(["rcrt_num", "募集人数の入力形式が正しくありません。"]); } if (validString(this.act_datetime) != true) { errInfo.push(["act_datetime", "活動日時の入力形式が正しくありません。"]); } if (validString(this.act_place) != true) { errInfo.push(["act_place", "活動場所の入力形式が正しくありません。"]); } if (validString(this.gather_place) != true) { errInfo.push(["gather_place", "集合場所の入力形式が正しくありません。"]); } if (validString(this.bring_item) != true) { errInfo.push(["bring_item", "持ち物の入力形式が正しくありません。"]); } if (validString(this.provide_item) != true) { errInfo.push(["provide_item", "支給するものの入力形式が正しくありません。"]); } if (validString(this.others) != true) { errInfo.push(["others", "その他の入力形式が正しくありません。"]); } if (validString(this.before_training) != true) { errInfo.push(["before_training", "事前研修の入力形式が正しくありません。"]); } if (validString(this.act_contents) != true) { errInfo.push(["act_contents", "活動内容の入力形式が正しくありません。"]); } if (validString(this.rcrt_start_date) != true) { errInfo.push(["rcrt_start_date", "募集開始日の入力形式が正しくありません。"]); } if (validString(this.rcrt_term) != true) { errInfo.push(["rcrt_term", "募集期限の入力形式が正しくありません。"]); } } // 範囲チェック if (errInfo.length == 0) { } // 相関チェック if (errInfo.length == 0) { } // エラー情報設定 errInfo.forEach(function(err) { this.setControlStyle(err[0], "border: 1px solid red;"); }, this); return errInfo; } /** * コントロールにスタイルを適用する */ setControlStyle(ctrlName, style) { let ctrls = document.getElementsByName(ctrlName); ctrls.forEach(function(ctrl) { ctrl.style = style; }); } }