<commit_before>define([
    'app/config',
    'app/counties',
    'app/graphicController',

    'dijit/_TemplatedMixin',
    'dijit/_WidgetBase',

    'dojo/dom-class',
    'dojo/keys',
    'dojo/on',
    'dojo/text!app/templates/FindParcel.html',
    'dojo/topic',
    'dojo/_base/declare',
    'dojo/_base/lang',

    'esri/Color',
    'esri/graphic',
    'esri/graphicsUtils',
    'esri/symbols/SimpleFillSymbol',
    'esri/symbols/SimpleLineSymbol',
    'esri/tasks/query',
    'esri/tasks/QueryTask'
], function (
    config,
    counties,
    graphicController,

    _TemplatedMixin,
    _WidgetBase,

    domClass,
    keys,
    on,
    template,
    topic,
    declare,
    lang,

    Color,
    Graphic,
    graphicsUtils,
    SimpleFillSymbol,
    SimpleLineSymbol,
    Query,
    QueryTask
) {
    return declare([_WidgetBase, _TemplatedMixin], {
        /**
         * @private
         * @const
         * @property {string} templateString - The class' html `templateString`.
         */
        templateString: template,
        /**
         * @const
         * @private
         * @default layer-selector
         * @property {string} baseClass - The class' css `baseClass` name.
         */
        baseClass: 'find-parcel',


        /**
         * Find a parcel based on a county and a parcel id.
         * @name find-parcel
         * @param {HTMLElement|string} [node] - The domNode or string id of a domNode to create this widget on. If null
         * a new div will be created but not placed in the dom. You will need to place it programmatically.
         * @param params {object}
         */
        constructor: function () {
            console.log('app.FindParcel::constructor', arguments);

            this.parcelQuery = new QueryTask(config.urls.parcel + '/0');
            this.parcelCriteria = new Query();
            this.parcelCriteria.returnGeometry = true;
            this.parcelCriteria.outFields = ['*'];
        },
        /**
         * This is fired after all properties of a widget are defined, and the document fragment representing the
         * widget is created—but before the fragment itself is added to the main document.
         * @private
         */
        postCreate: function () {
            console.log('app.FindParcel::postCreate', arguments);

            counties.forEach(function addOptions(county) {
                var option = document.createElement('option');
                option.value = county.replace(/\s+/g, '');
                option.innerHTML = county;

                this.county.appendChild(option);
            }, this);

            this._setupConnections();
            this.inherited(arguments);
        },
        /**
         * wire events, and such
         * @private
         */
        _setupConnections: function () {
            console.log('app.FindParcel::_setupConnections', arguments);

            this.watch('countyName', lang.hitch(this, '_showParcelId'));
            this.watch('parcelId', lang.hitch(this, '_showSubmit'));
            on(this.parcelId, 'keypress', lang.hitch(this, '_shouldSearch'));
            this.parcelQuery.on('error', lang.hitch(this, '_queryError'));
        },
        /** function to monitor changes to the county value. */
        _showParcelId: function (field, previous, current) {
            console.log('app.FindParcel:_showParcelId', arguments);

            domClass.toggle(this.parcelGroup, 'hidden', !current);
        },
        /** function to monitor changes to the parcel id value. */
        _showSubmit: function (field, previous, current) {
            console.log('app.FindParcel:_showParcelId', arguments);

            domClass.toggle(this.searchGroup, 'hidden', !current);
            graphicController.clearGraphics();

            domClass.add(this.errors, 'hidden');
            this.errors.innerHTML = '';
        },
        /** Triggered when the county select changes and sets the county for the where clause to query parcel ids.
         * @param event - evt - the on change event object
         * @returns string - The new value for county.
         */
        _setCounty: function (evt) {
            console.log('app.FindParcel:_setCounty', arguments);

            this.set('countyName', evt.target.value);
            return evt.target.value;
        },
        /** Triggered when the parcel input changes and sets the parcel id for the where clause to query parcel ids.<commit_msg>clear errors on county change<commit_after>define([
    'app/config',
    'app/counties',
    'app/graphicController',

    'dijit/_TemplatedMixin',
    'dijit/_WidgetBase',

    'dojo/dom-class',
    'dojo/keys',
    'dojo/on',
    'dojo/text!app/templates/FindParcel.html',
    'dojo/topic',
    'dojo/_base/declare',
    'dojo/_base/lang',

    'esri/Color',
    'esri/graphic',
    'esri/graphicsUtils',
    'esri/symbols/SimpleFillSymbol',
    'esri/symbols/SimpleLineSymbol',
    'esri/tasks/query',
    'esri/tasks/QueryTask'
], function (
    config,
    counties,
    graphicController,

    _TemplatedMixin,
    _WidgetBase,

    domClass,
    keys,
    on,
    template,
    topic,
    declare,
    lang,

    Color,
    Graphic,
    graphicsUtils,
    SimpleFillSymbol,
    SimpleLineSymbol,
    Query,
    QueryTask
) {
    return declare([_WidgetBase, _TemplatedMixin], {
        /**
         * @private
         * @const
         * @property {string} templateString - The class' html `templateString`.
         */
        templateString: template,
        /**
         * @const
         * @private
         * @default layer-selector
         * @property {string} baseClass - The class' css `baseClass` name.
         */
        baseClass: 'find-parcel',


        /**
         * Find a parcel based on a county and a parcel id.
         * @name find-parcel
         * @param {HTMLElement|string} [node] - The domNode or string id of a domNode to create this widget on. If null
         * a new div will be created but not placed in the dom. You will need to place it programmatically.
         * @param params {object}
         */
        constructor: function () {
            console.log('app.FindParcel::constructor', arguments);

            this.parcelQuery = new QueryTask(config.urls.parcel + '/0');
            this.parcelCriteria = new Query();
            this.parcelCriteria.returnGeometry = true;
            this.parcelCriteria.outFields = ['*'];
        },
        /**
         * This is fired after all properties of a widget are defined, and the document fragment representing the
         * widget is created—but before the fragment itself is added to the main document.
         * @private
         */
        postCreate: function () {
            console.log('app.FindParcel::postCreate', arguments);

            counties.forEach(function addOptions(county) {
                var option = document.createElement('option');
                option.value = county.replace(/\s+/g, '');
                option.innerHTML = county;

                this.county.appendChild(option);
            }, this);

            this._setupConnections();
            this.inherited(arguments);
        },
        /**
         * wire events, and such
         * @private
         */
        _setupConnections: function () {
            console.log('app.FindParcel::_setupConnections', arguments);

            this.watch('countyName', lang.hitch(this, '_showParcelId'));
            this.watch('parcelId', lang.hitch(this, '_showSubmit'));
            on(this.parcelId, 'keypress', lang.hitch(this, '_shouldSearch'));
            this.parcelQuery.on('error', lang.hitch(this, '_queryError'));
        },
        /** function to monitor changes to the county value. */
        _showParcelId: function (field, previous, current) {
            console.log('app.FindParcel:_showParcelId', arguments);

            domClass.toggle(this.parcelGroup, 'hidden', !current);

            graphicController.clearGraphics();

            domClass.add(this.errors, 'hidden');
            this.errors.innerHTML = '';
        },
        /** function to monitor changes to the parcel id value. */
        _showSubmit: function (field, previous, current) {
            console.log('app.FindParcel:_showParcelId', arguments);

            domClass.toggle(this.searchGroup, 'hidden', !current);
            graphicController.clearGraphics();

            domClass.add(this.errors, 'hidden');
            this.errors.innerHTML = '';
        },
        /** Triggered when the county select changes and sets the county for the where clause to query parcel ids.
         * @param event - evt - the on change event object
         * @returns string - The new value for county.
         */
        _setCounty: function (evt) {
            console.log('app.FindParcel:_setCounty', arguments);

            this.set('countyName', evt.target.value);
            return evt.target.value;
        },
        /** Triggered when the parcel input changes and sets the parcel id for the where clause to query parcel ids.
{'fraction_non_alphanumeric': 0.11648983200707339, 'fraction_numerical': 0.00022104332449160034, 'mean_word_length': 2.061231393775372, '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': '5286400', 'n_tokens_mistral': 2525, 'n_tokens_neox': 2471, 'n_words': 621}