<commit_before>'use strict';

var _  = require('mano').i18n.bind('User Offcial')
, toArray       = require('es5-ext/object/to-array')
, byOrder = function (a, b) { return this[a].order - this[b].order; }
, once          = require('timers-ext/once')
, dispatch      = require('dom-ext/html-element/#/dispatch-event-2')
, location     = require('mano/lib/client/location');

exports._parent = require('./user-base');

exports['sub-main'] = {
	class: { content: true, 'user-forms': true },
	content: function () {
		var searchForm, searchInput, rootUrl = url();

		section({ class: 'section-primary users-table-filter-bar' },
			searchForm = form({ action: rootUrl, autoSubmit: true },
				div({ class: 'users-table-filter-bar-status' },
					label({ for: 'state-select' }, _("Status"), ":"),
					select({ id: 'state-select', name: 'estado' },
						toArray(exports._statusMap(this), function (data, name) {
							return option({ value: name, selected:
								location.query.get('estado').map(function (value) {
									var selected = (name ? (value === name) : (value == null));
									return selected ? 'selected' : null;
								}) },
								data.label);
						}, null, byOrder))),
				div(
					label({ for: 'search-input' }, _("Search")),
					span({ class: 'input-append' },
						searchInput = input({ id: 'search-input', name: 'buscar', type: 'search',
							value: location.query.get('buscar') }),
						span({ class: 'add-on' }, span({ class: 'fa fa-search' })))
				),
				div(
					input({ type: 'submit', value: _("Search") })
				)),
			div(
				a({ href: mmap(location.query.get('estado'), function (status) {
					return mmap(location.query.get('page'), function (page) {
						var search = [];
						if (status) search.push('estado=' + status);
						if (page) search.push('page=' + page);
						if (search.length) search = '?' + search.join('&');
						else search = null;
						return url('imprimir', search);
					});
				}), class: 'users-table-filter-bar-print', target: '_blank' },
					span({ class: 'fa fa-print' },
						_("Print list of requests")), _("Print the list")
					)
			)
			);

		searchInput.oninput = once(function () { dispatch.call(searchForm, 'submit'); }, 300);
		exports._usersTable(this);
	}
};

exports._statusMap = Function.prototype;
exports._usersTable = Function.prototype;<commit_msg>Refactor configurations in official reusable view. #738<commit_after>'use strict';

var _  = require('mano').i18n.bind('User Offcial')
, toArray       = require('es5-ext/object/to-array')
, byOrder = function (a, b) { return this[a].order - this[b].order; }
, once          = require('timers-ext/once')
, dispatch      = require('dom-ext/html-element/#/dispatch-event-2')
, location     = require('mano/lib/client/location');

exports._parent = require('./user-base');

exports['sub-main'] = {
	class: { content: true, 'user-forms': true },
	content: function () {
		var searchForm, searchInput;

		section({ class: 'section-primary users-table-filter-bar' },
			searchForm = form({ action: '/', autoSubmit: true },
				div({ class: 'users-table-filter-bar-status' },
					label({ for: 'state-select' }, _("Status"), ":"),
					select({ id: 'state-select', name: 'status' },
						toArray(exports._statusMap(this), function (data, name) {
							return option({ value: name, selected:
								location.query.get('status').map(function (value) {
									var selected = (name ? (value === name) : (value == null));
									return selected ? 'selected' : null;
								}) },
								data.label);
						}, null, byOrder))),
				div(
					label({ for: 'search-input' }, _("Search")),
					span({ class: 'input-append' },
						searchInput = input({ id: 'search-input', name: 'search', type: 'search',
							value: location.query.get('search') }),
						span({ class: 'add-on' }, span({ class: 'fa fa-search' })))
				),
				div(
					input({ type: 'submit', value: _("Search") })
				)),
			div(
				a({ href: mmap(location.query.get('status'), function (status) {
					return mmap(location.query.get('page'), function (page) {
						var search = [];
						if (status) search.push('status=' + status);
						if (page) search.push('page=' + page);
						if (search.length) search = '?' + search.join('&');
						else search = null;
						return url('print', search);
					});
				}), class: 'users-table-filter-bar-print', target: '_blank' },
					span({ class: 'fa fa-print' },
						_("Print list of requests")), _("Print the list")
					)
			)
			);

		searchInput.oninput = once(function () { dispatch.call(searchForm, 'submit'); }, 300);
		exports._usersTable(this);
	}
};

exports._statusMap = Function.prototype;
exports._usersTable = Function.prototype;
{'fraction_non_alphanumeric': 0.196892294593444, 'fraction_numerical': 0.0036185610898254576, 'mean_word_length': 3.1657801418439715, 'pattern_counts': {'":': 2, '<': 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': '5727507', 'n_tokens_mistral': 1840, 'n_tokens_neox': 1482, 'n_words': 338}