<commit_before>﻿using Implem.Pleasanter.Libraries.Responses;
using Implem.Pleasanter.Libraries.ServerData;
using Implem.Pleasanter.Models;
using System.Web.Optimization;
namespace Implem.Pleasanter.Libraries.ViewParts
{
    public static class HtmlScripts
    {
        public static HtmlBuilder Scripts(
            this HtmlBuilder hb,
            BaseModel.MethodTypes methodType,
            string script,
            string modelName,
            bool allowAccess)
        {
            return hb
                .Script(src: Navigations.Get("Scripts/Plugins/jquery-2.1.4.min.js"))
                .Script(src: Navigations.Get("Scripts/Plugins/jquery-ui.min.js"))
                .Script(src: Navigations.Get("Scripts/Plugins/jquery.validate.min.js"))
                .Script(src: Navigations.Get("Scripts/Plugins/d3.min.js"))
                .Script(script: script, _using: script != string.Empty)
                .Validator(methodType: methodType, modelName: modelName, allowAccess: allowAccess)
                .Internationalization();
        }

        private static HtmlBuilder Validator(
            this HtmlBuilder hb,
            BaseModel.MethodTypes methodType,
            string modelName,
            bool allowAccess)
        {
            return Editor(methodType) && allowAccess
                ? hb.Script(src: Validator(modelName))
                : hb;
        }

        private static bool Editor(BaseModel.MethodTypes methodType)
        {
            return
                methodType == BaseModel.MethodTypes.Edit ||
                methodType == BaseModel.MethodTypes.New;
        }

        private static string Validator(string modelName)
        {
            switch (modelName)
            {
                case "Tenant": return ResolveBundleUrl("~/bundles/TenantValidator");
                case "Demo": return ResolveBundleUrl("~/bundles/DemoValidator");
                case "Dept": return ResolveBundleUrl("~/bundles/DeptValidator");
                case "User": return ResolveBundleUrl("~/bundles/UserValidator");
                case "OutgoingMail": return ResolveBundleUrl("~/bundles/OutgoingMailValidator");
                case "Site": return ResolveBundleUrl("~/bundles/SiteValidator");
                case "Issue": return ResolveBundleUrl("~/bundles/IssueValidator");
                case "Result": return ResolveBundleUrl("~/bundles/ResultValidator");
                case "Wiki": return ResolveBundleUrl("~/bundles/WikiValidator");
                default: return string.Empty;
            }<commit_msg>Bug fixed: メールフォーム検証用スクリプトが出力されていない問題を解消。<commit_after>﻿using Implem.Pleasanter.Libraries.Responses;
using Implem.Pleasanter.Libraries.ServerData;
using Implem.Pleasanter.Models;
using System.Web.Optimization;
namespace Implem.Pleasanter.Libraries.ViewParts
{
    public static class HtmlScripts
    {
        public static HtmlBuilder Scripts(
            this HtmlBuilder hb,
            BaseModel.MethodTypes methodType,
            string script,
            string modelName,
            bool allowAccess)
        {
            return hb
                .Script(src: Navigations.Get("Scripts/Plugins/jquery-2.1.4.min.js"))
                .Script(src: Navigations.Get("Scripts/Plugins/jquery-ui.min.js"))
                .Script(src: Navigations.Get("Scripts/Plugins/jquery.validate.min.js"))
                .Script(src: Navigations.Get("Scripts/Plugins/d3.min.js"))
                .Script(script: script, _using: script != string.Empty)
                .Validator(methodType: methodType, modelName: modelName, allowAccess: allowAccess)
                .Internationalization();
        }

        private static HtmlBuilder Validator(
            this HtmlBuilder hb,
            BaseModel.MethodTypes methodType,
            string modelName,
            bool allowAccess)
        {
            return Editor(methodType) && allowAccess
                ? hb
                    .Script(src: Validator(modelName))
                    .Script(src: Validator("OutgoingMail"))
                : hb;
        }

        private static bool Editor(BaseModel.MethodTypes methodType)
        {
            return
                methodType == BaseModel.MethodTypes.Edit ||
                methodType == BaseModel.MethodTypes.New;
        }

        private static string Validator(string modelName)
        {
            switch (modelName)
            {
                case "Tenant": return ResolveBundleUrl("~/bundles/TenantValidator");
                case "Demo": return ResolveBundleUrl("~/bundles/DemoValidator");
                case "Dept": return ResolveBundleUrl("~/bundles/DeptValidator");
                case "User": return ResolveBundleUrl("~/bundles/UserValidator");
                case "OutgoingMail": return ResolveBundleUrl("~/bundles/OutgoingMailValidator");
                case "Site": return ResolveBundleUrl("~/bundles/SiteValidator");
                case "Issue": return ResolveBundleUrl("~/bundles/IssueValidator");
                case "Result": return ResolveBundleUrl("~/bundles/ResultValidator");
                case "Wiki": return ResolveBundleUrl("~/bundles/WikiValidator");
                default: return string.Empty;
            }
{'fraction_non_alphanumeric': 0.09994256174612291, 'fraction_numerical': 0.0015316867700555237, 'mean_word_length': 2.0567583382094794, 'pattern_counts': {'":': 18, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2397653', 'n_tokens_mistral': 1447, 'n_tokens_neox': 1365, 'n_words': 257}