<commit_before>%{--
  - Copyright 2016 SimplifyOps, Inc. (http://simplifyops.com)
  -
  - Licensed under the Apache License, Version 2.0 (the "License");
  - you may not use this file except in compliance with the License.
  - You may obtain a copy of the License at
  -
  -     http://www.apache.org/licenses/LICENSE-2.0
  -
  - Unless required by applicable law or agreed to in writing, software
  - distributed under the License is distributed on an "AS IS" BASIS,
  - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  - See the License for the specific language governing permissions and
  - limitations under the License.
  --}%

<%@ page import="java.util.regex.Pattern; grails.converters.JSON; grails.util.Environment" %>
<%--
used by _editOptions.gsp template
--%>
<g:set var="rkey" value="${g.rkey()}"/>
<g:if test="${optionSelections}">
    <g:set var="usePrefix" value="${paramsPrefix ?: ''}"/>
    <g:set var="showDTFormat" value="${false}"/>
    <g:hiddenField name="${usePrefix + 'argString'}" value=""/>
    <%
        def optsmap = [:]
        if (optionSelections) {
            optionSelections.each {
                optsmap[it.name] = [selopt: it]
            }
        }
    %>
    <g:embedJSON data="${[options:
                                  (optionordering ?: optsmap.keySet().sort()).collect {
                                      def optionSelect = optsmap[it].selopt
                                      def optName = optionSelect.name
                                      def optLabel = optionSelect.label
                                      def selectedMultiValues = null
                                      if (selectedoptsmap && selectedoptsmap[optName] &&
                                              optionSelect.multivalued &&
                                              optionSelect.delimiter) {
                                          def value = selectedoptsmap[optName]
                                          if (value instanceof String) {
                                              selectedMultiValues = value.split(
                                                      java.util.regex.Pattern.quote(optionSelect.delimiter)
                                              ) as List

                                          } else if (value instanceof Collection) {
                                              selectedMultiValues = value as List
                                          }
                                      }
                                      return [
                                              name               : optName,
                                              label              : optLabel?:optName,
                                              required           : optionSelect.required,
                                              description        : optionSelect.description,
                                              descriptionHtml    : optionSelect.description?.decodeMarkdown(),
                                              enforced           : optionSelect.enforced,
                                              isDate             : !!optionSelect.isDate,
                                              dateFormat         : optionSelect.dateFormat,
                                              optionType         : optionSelect.optionType,
//                                              config             : optionSelect.configMap,
                                              values             : optionSelect.values,
                                              defaultValue       : optionSelect.defaultValue,
                                              defaultStoragePath : optionSelect.defaultStoragePath,
                                              multivalued        : optionSelect.multivalued,
                                              defaultMultiValues : optionSelect.listDefaultMultiValues(),
                                              multivalueAllSelected : optionSelect.multivalueAllSelected,
                                              delimiter          : optionSelect.delimiter,
                                              selectedMultiValues: selectedMultiValues,
                                              fieldName          : usePrefix + 'option.' + optName,
                                              fieldId            : rkey + '_' + optName,
                                              hasError           : jobexecOptionErrors ? jobexecOptionErrors[optName] :
                                                      null,
                                              hasRemote          : optionSelect.realValuesUrl != null,
                                              optionDepsMet      : !optiondependencies[optName] || selectedoptsmap &&
                                                      optiondependencies[optName].every { selectedoptsmap[it] },
                                              secureInput        : optionSelect.secureInput,
                                              hasExtended        : !optionSelect.secureInput && (values || optionSelect.values ||
                                                      optionSelect.multivalued || optionSelect.valuesFromPlugin),
                                              value              : selectedvalue ? selectedvalue :
                                                      selectedoptsmap && null != selectedoptsmap[optName] ?
                                                              selectedoptsmap[optName] :
                                                              (optionSelect.defaultValue ?: ''),
                                              valuesFromPlugin   : optionSelect.valuesFromPlugin,
                                              hidden     : !!optionSelect.hidden
                                      ]
                                  }
    ]}" id="jobOptionData"/>
<%--
data for configuring remote option cascading/dependencies
--%>
    <g:embedJSON id="remoteOptionData"
                 data="${[options: remoteOptionData, optionsDependenciesCyclic: optionsDependenciesCyclic]}"/>

    <g:if test="${optionsDependenciesCyclic}">
        <div class="row">
            <div class="col-sm-12 text-warning">
                <g:message code="remote.options.warning.cyclicDependencies"/>
            </div>
        </div>
    </g:if>

    <div id="_commandOptions" data-bind="foreach: {data: options(), as: 'option' }">
        <div data-bind="visible: !hidden()">
            <div class="form-group " data-bind="
    css: { 'has-warning': hasError, 'remote': hasRemote }
    ">
                <label class="remoteoptionfield col-sm-2 control-label"
                       data-bind="attr: { for: fieldId }, click: reloadRemoteValues">
                    <span data-bind="if: hasRemote()">
                        <span data-bind="if: loading() ">
                            <g:img class="loading-spinner" file="spinner-gray.gif" width="16px" height="16px"/>
                        </span>
                        <span class="remotestatus"
                              data-bind=" css: {ok: !remoteError() && remoteValues().length>0 && remoteValues, error: remoteError()}">
                        </span>
                        <span data-bind="text: name"></span>
                    </span>
                    <span data-bind="if: !hasRemote()">
                        <span data-bind="text: label"></span>
                    </span>
                </label>

                <div class=" col-sm-9">

                    <g:render template="/framework/optionValuesSelectKO"/>

                </div>

                <div class="col-sm-1">
                    <span data-bind="if: required">
                        <span class="reqwarning has_tooltip"
                              data-bind="attr: {title: hasError()||message('option.value.required') }, visible: !hasValue(), bootstrapTooltip: true"
                              data-toggle="tooltip">
                            <i class="glyphicon glyphicon-warning-sign"></i>
                        </span>
                    </span>
                </div>

                <div class="col-sm-10 col-sm-offset-2">
                    %{--<span class="help-block" data-bind="text: description"></span>--}%
                    <span class="help-block" data-bind="html: descriptionHtml"></span>
                </div>

                <div class="col-sm-10 col-sm-offset-2" data-bind="if: hasError"><commit_msg>Display label instead of name for remote options<commit_after>%{--
  - Copyright 2016 SimplifyOps, Inc. (http://simplifyops.com)
  -
  - Licensed under the Apache License, Version 2.0 (the "License");
  - you may not use this file except in compliance with the License.
  - You may obtain a copy of the License at
  -
  -     http://www.apache.org/licenses/LICENSE-2.0
  -
  - Unless required by applicable law or agreed to in writing, software
  - distributed under the License is distributed on an "AS IS" BASIS,
  - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  - See the License for the specific language governing permissions and
  - limitations under the License.
  --}%

<%@ page import="java.util.regex.Pattern; grails.converters.JSON; grails.util.Environment" %>
<%--
used by _editOptions.gsp template
--%>
<g:set var="rkey" value="${g.rkey()}"/>
<g:if test="${optionSelections}">
    <g:set var="usePrefix" value="${paramsPrefix ?: ''}"/>
    <g:set var="showDTFormat" value="${false}"/>
    <g:hiddenField name="${usePrefix + 'argString'}" value=""/>
    <%
        def optsmap = [:]
        if (optionSelections) {
            optionSelections.each {
                optsmap[it.name] = [selopt: it]
            }
        }
    %>
    <g:embedJSON data="${[options:
                                  (optionordering ?: optsmap.keySet().sort()).collect {
                                      def optionSelect = optsmap[it].selopt
                                      def optName = optionSelect.name
                                      def optLabel = optionSelect.label
                                      def selectedMultiValues = null
                                      if (selectedoptsmap && selectedoptsmap[optName] &&
                                              optionSelect.multivalued &&
                                              optionSelect.delimiter) {
                                          def value = selectedoptsmap[optName]
                                          if (value instanceof String) {
                                              selectedMultiValues = value.split(
                                                      java.util.regex.Pattern.quote(optionSelect.delimiter)
                                              ) as List

                                          } else if (value instanceof Collection) {
                                              selectedMultiValues = value as List
                                          }
                                      }
                                      return [
                                              name               : optName,
                                              label              : optLabel?:optName,
                                              required           : optionSelect.required,
                                              description        : optionSelect.description,
                                              descriptionHtml    : optionSelect.description?.decodeMarkdown(),
                                              enforced           : optionSelect.enforced,
                                              isDate             : !!optionSelect.isDate,
                                              dateFormat         : optionSelect.dateFormat,
                                              optionType         : optionSelect.optionType,
//                                              config             : optionSelect.configMap,
                                              values             : optionSelect.values,
                                              defaultValue       : optionSelect.defaultValue,
                                              defaultStoragePath : optionSelect.defaultStoragePath,
                                              multivalued        : optionSelect.multivalued,
                                              defaultMultiValues : optionSelect.listDefaultMultiValues(),
                                              multivalueAllSelected : optionSelect.multivalueAllSelected,
                                              delimiter          : optionSelect.delimiter,
                                              selectedMultiValues: selectedMultiValues,
                                              fieldName          : usePrefix + 'option.' + optName,
                                              fieldId            : rkey + '_' + optName,
                                              hasError           : jobexecOptionErrors ? jobexecOptionErrors[optName] :
                                                      null,
                                              hasRemote          : optionSelect.realValuesUrl != null,
                                              optionDepsMet      : !optiondependencies[optName] || selectedoptsmap &&
                                                      optiondependencies[optName].every { selectedoptsmap[it] },
                                              secureInput        : optionSelect.secureInput,
                                              hasExtended        : !optionSelect.secureInput && (values || optionSelect.values ||
                                                      optionSelect.multivalued || optionSelect.valuesFromPlugin),
                                              value              : selectedvalue ? selectedvalue :
                                                      selectedoptsmap && null != selectedoptsmap[optName] ?
                                                              selectedoptsmap[optName] :
                                                              (optionSelect.defaultValue ?: ''),
                                              valuesFromPlugin   : optionSelect.valuesFromPlugin,
                                              hidden     : !!optionSelect.hidden
                                      ]
                                  }
    ]}" id="jobOptionData"/>
<%--
data for configuring remote option cascading/dependencies
--%>
    <g:embedJSON id="remoteOptionData"
                 data="${[options: remoteOptionData, optionsDependenciesCyclic: optionsDependenciesCyclic]}"/>

    <g:if test="${optionsDependenciesCyclic}">
        <div class="row">
            <div class="col-sm-12 text-warning">
                <g:message code="remote.options.warning.cyclicDependencies"/>
            </div>
        </div>
    </g:if>

    <div id="_commandOptions" data-bind="foreach: {data: options(), as: 'option' }">
        <div data-bind="visible: !hidden()">
            <div class="form-group " data-bind="
    css: { 'has-warning': hasError, 'remote': hasRemote }
    ">
                <label class="remoteoptionfield col-sm-2 control-label"
                       data-bind="attr: { for: fieldId }, click: reloadRemoteValues">
                    <span data-bind="if: hasRemote()">
                        <span data-bind="if: loading() ">
                            <g:img class="loading-spinner" file="spinner-gray.gif" width="16px" height="16px"/>
                        </span>
                        <span class="remotestatus"
                              data-bind=" css: {ok: !remoteError() && remoteValues().length>0 && remoteValues, error: remoteError()}">
                        </span>
                        <span data-bind="text: label"></span>
                    </span>
                    <span data-bind="if: !hasRemote()">
                        <span data-bind="text: label"></span>
                    </span>
                </label>

                <div class=" col-sm-9">

                    <g:render template="/framework/optionValuesSelectKO"/>

                </div>

                <div class="col-sm-1">
                    <span data-bind="if: required">
                        <span class="reqwarning has_tooltip"
                              data-bind="attr: {title: hasError()||message('option.value.required') }, visible: !hasValue(), bootstrapTooltip: true"
                              data-toggle="tooltip">
                            <i class="glyphicon glyphicon-warning-sign"></i>
                        </span>
                    </span>
                </div>

                <div class="col-sm-10 col-sm-offset-2">
                    %{--<span class="help-block" data-bind="text: description"></span>--}%
                    <span class="help-block" data-bind="html: descriptionHtml"></span>
                </div>

                <div class="col-sm-10 col-sm-offset-2" data-bind="if: hasError">
{'fraction_non_alphanumeric': 0.09315323707498836, 'fraction_numerical': 0.0027945971122496508, 'mean_word_length': 1.0156066651020887, 'pattern_counts': {'":': 0, '<': 111, '<?xml version=': 0, '>': 113, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 202, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3398245', 'n_tokens_mistral': 3467, 'n_tokens_neox': 3288, 'n_words': 736}