<commit_before>﻿using System;
using System.Text;
using Lib.AspNetCore.Mvc.JqGrid.Helper.Constants;
using Lib.AspNetCore.Mvc.JqGrid.Infrastructure.Constants;
using Lib.AspNetCore.Mvc.JqGrid.Infrastructure.Options;
using Lib.AspNetCore.Mvc.JqGrid.Infrastructure.Options.Navigator;
using Lib.AspNetCore.Mvc.JqGrid.Infrastructure.Searching;

namespace Lib.AspNetCore.Mvc.JqGrid.Helper.InternalHelpers
{
    internal static class JqGridNavigatorJavaScriptRenderingHelper
    {
        #region Fields
        private const string NULL_NAVIGATOR_OPTIONS = ",null";
        #endregion

        #region Extension Methods
        internal static StringBuilder AppendInlineNavigatorActionOptions(this StringBuilder javaScriptBuilder, JqGridInlineNavigatorActionOptions inlineNavigatorActionOptions)
        {
            if ((inlineNavigatorActionOptions != null) && !inlineNavigatorActionOptions.AreDefault())
            {
                javaScriptBuilder.AppendJavaScriptObjectScriptOrObjectField(JqGridOptionsNames.InlineNavigator.EXTRA_PARAM, inlineNavigatorActionOptions.ExtraParamScript, inlineNavigatorActionOptions.ExtraParam)
                    .AppendJavaScriptObjectBooleanField(JqGridOptionsNames.InlineNavigator.KEYS, inlineNavigatorActionOptions.Keys, JqGridOptionsDefaults.Navigator.InlineActionKeys)
                    .AppendJavaScriptObjectFunctionField(JqGridOptionsNames.InlineNavigator.ON_EDIT_FUNCTION, inlineNavigatorActionOptions.OnEditFunction)
                    .AppendJavaScriptObjectFunctionField(JqGridOptionsNames.InlineNavigator.SUCCESS_FUNCTION, inlineNavigatorActionOptions.SuccessFunction)
                    .AppendJavaScriptObjectStringField(JqGridOptionsNames.InlineNavigator.URL, inlineNavigatorActionOptions.Url)
                    .AppendJavaScriptObjectFunctionField(JqGridOptionsNames.InlineNavigator.AFTER_SAVE_FUNCTION, inlineNavigatorActionOptions.AfterSaveFunction)
                    .AppendJavaScriptObjectFunctionField(JqGridOptionsNames.InlineNavigator.ERROR_FUNCTION, inlineNavigatorActionOptions.ErrorFunction)
                    .AppendJavaScriptObjectFunctionField(JqGridOptionsNames.InlineNavigator.AFTER_RESTORE_FUNCTION, inlineNavigatorActionOptions.AfterRestoreFunction)
                    .AppendJavaScriptObjectBooleanField(JqGridOptionsNames.InlineNavigator.RESTORE_AFTER_ERROR, inlineNavigatorActionOptions.RestoreAfterError, JqGridOptionsDefaults.Navigator.InlineActionRestoreAfterError)
                    .AppendJavaScriptObjectEnumField(JqGridOptionsNames.InlineNavigator.METHOD_TYPE, inlineNavigatorActionOptions.MethodType, JqGridOptionsDefaults.Navigator.InlineActionMethodType);
            }

            return javaScriptBuilder;
        }

        internal static StringBuilder AppendNavigator(this StringBuilder javaScriptBuilder, JqGridOptions options, bool asSubgrid)
        {
            if (options.Navigator != null)
            {
                javaScriptBuilder.AppendLine(")")
                    .AppendFormat(".jqGrid('navGrid',{0}", options.GetJqGridPagerSelector(options.Navigator.Pager, asSubgrid))
                    .AppendNavigatorOptions(options.Navigator)
                    .AppendNavigatorEditActionOptions(null, options.Navigator.EditOptions)
                    .Append(NULL_NAVIGATOR_OPTIONS)  // TODO: ADD OPTIONS
                    .AppendNavigatorDeleteActionOptions(null, options.Navigator.DeleteOptions)
                    .AppendNavigatorSearchActionOptions(options.Navigator.SearchOptions)
                    .Append(NULL_NAVIGATOR_OPTIONS); // TODO: VIEW OPTIONS
            }

            return javaScriptBuilder;
        }

        internal static StringBuilder AppendNavigatorOptions(this StringBuilder javaScriptBuilder, JqGridNavigatorOptions navigatorOptions)
        {<commit_msg>Helper support for navigator<commit_after>﻿using System;
using System.Text;
using Lib.AspNetCore.Mvc.JqGrid.Helper.Constants;
using Lib.AspNetCore.Mvc.JqGrid.Infrastructure.Constants;
using Lib.AspNetCore.Mvc.JqGrid.Infrastructure.Options;
using Lib.AspNetCore.Mvc.JqGrid.Infrastructure.Options.Navigator;
using Lib.AspNetCore.Mvc.JqGrid.Infrastructure.Searching;

namespace Lib.AspNetCore.Mvc.JqGrid.Helper.InternalHelpers
{
    internal static class JqGridNavigatorJavaScriptRenderingHelper
    {
        #region Fields
        private const string NULL_NAVIGATOR_OPTIONS = ",null";
        #endregion

        #region Extension Methods
        internal static StringBuilder AppendInlineNavigatorActionOptions(this StringBuilder javaScriptBuilder, JqGridInlineNavigatorActionOptions inlineNavigatorActionOptions)
        {
            if ((inlineNavigatorActionOptions != null) && !inlineNavigatorActionOptions.AreDefault())
            {
                javaScriptBuilder.AppendJavaScriptObjectScriptOrObjectField(JqGridOptionsNames.InlineNavigator.EXTRA_PARAM, inlineNavigatorActionOptions.ExtraParamScript, inlineNavigatorActionOptions.ExtraParam)
                    .AppendJavaScriptObjectBooleanField(JqGridOptionsNames.InlineNavigator.KEYS, inlineNavigatorActionOptions.Keys, JqGridOptionsDefaults.Navigator.InlineActionKeys)
                    .AppendJavaScriptObjectFunctionField(JqGridOptionsNames.InlineNavigator.ON_EDIT_FUNCTION, inlineNavigatorActionOptions.OnEditFunction)
                    .AppendJavaScriptObjectFunctionField(JqGridOptionsNames.InlineNavigator.SUCCESS_FUNCTION, inlineNavigatorActionOptions.SuccessFunction)
                    .AppendJavaScriptObjectStringField(JqGridOptionsNames.InlineNavigator.URL, inlineNavigatorActionOptions.Url)
                    .AppendJavaScriptObjectFunctionField(JqGridOptionsNames.InlineNavigator.AFTER_SAVE_FUNCTION, inlineNavigatorActionOptions.AfterSaveFunction)
                    .AppendJavaScriptObjectFunctionField(JqGridOptionsNames.InlineNavigator.ERROR_FUNCTION, inlineNavigatorActionOptions.ErrorFunction)
                    .AppendJavaScriptObjectFunctionField(JqGridOptionsNames.InlineNavigator.AFTER_RESTORE_FUNCTION, inlineNavigatorActionOptions.AfterRestoreFunction)
                    .AppendJavaScriptObjectBooleanField(JqGridOptionsNames.InlineNavigator.RESTORE_AFTER_ERROR, inlineNavigatorActionOptions.RestoreAfterError, JqGridOptionsDefaults.Navigator.InlineActionRestoreAfterError)
                    .AppendJavaScriptObjectEnumField(JqGridOptionsNames.InlineNavigator.METHOD_TYPE, inlineNavigatorActionOptions.MethodType, JqGridOptionsDefaults.Navigator.InlineActionMethodType);
            }

            return javaScriptBuilder;
        }

        internal static StringBuilder AppendNavigator(this StringBuilder javaScriptBuilder, JqGridOptions options, bool asSubgrid)
        {
            if (options.Navigator != null)
            {
                javaScriptBuilder.AppendLine(")")
                    .AppendFormat(".jqGrid('navGrid',{0}", options.GetJqGridPagerSelector(options.Navigator.Pager, asSubgrid))
                    .AppendNavigatorOptions(options.Navigator)
                    .AppendNavigatorEditActionOptions(null, options.Navigator.EditOptions)
                    .AppendNavigatorEditActionOptions(null, options.Navigator.AddOptions)
                    .AppendNavigatorDeleteActionOptions(null, options.Navigator.DeleteOptions)
                    .AppendNavigatorSearchActionOptions(options.Navigator.SearchOptions)
                    .Append(NULL_NAVIGATOR_OPTIONS); // TODO: VIEW OPTIONS
            }

            return javaScriptBuilder;
        }

        internal static StringBuilder AppendNavigatorOptions(this StringBuilder javaScriptBuilder, JqGridNavigatorOptions navigatorOptions)
        {
{'fraction_non_alphanumeric': 0.06078868072841609, 'fraction_numerical': 0.00026202017555351765, 'mean_word_length': 3.837769328263625, 'pattern_counts': {'":': 0, '<': 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': '2375671', 'n_tokens_mistral': 1870, 'n_tokens_neox': 1860, 'n_words': 221}