<commit_before>jsio('from shared.javascript import Class, bind, forEach')
jsio('import ui.Component')

exports = Class(ui.Component, function(supr){
	
	this._domTag = 'select'
	this._className = 'Select'
	
	// (( ItemSetSelect type project title )) -> list of all items of type project, displayed by title
	this.init = function(jsArgs, viewArgs) {
		supr(this, 'init')
		
		var propertyName = viewArgs[0],
			propertyValue = viewArgs[1],
			displayProperty = viewArgs[2],
			itemId = jsArgs[0]
		
		this._targetProperty = propertyValue
		this._displayProperty = displayProperty
		this._query = {}
		this._query[propertyName] = propertyValue
		this._itemId = itemId
		this._options = {}
	}
	
	this._createContent = function() {
		var itemSet = fin.getItemSet(this._query)
		itemSet.addDependant(bind(this, '_onItemsChange'))

		this._item = fin.getItem(this._itemId)
		this._item.addDependant(this._targetProperty, bind(this, '_onTargetPropertyChange'))
		
		this._on('change', bind(this, '_onSelectionChange'))
	}
	
	this._onItemsChange = function(mutation) {
		forEach(mutation.add, this, function(itemId) {
			if (this._options[itemId]) { return }
			this._options[itemId] = new Option(itemId, 'Loading...', false, false)
			this._element.add(this._options[itemId], null)
			if (itemId == this._item.getProperty(this._targetProperty)) {
				this._element.selectedIndex = this._element.options.length - 1
			}
			fin.getItem(itemId).addDependant(this._displayProperty, bind(this, '_onDisplayPropertyChange', itemId))
		})
		forEach(mutation.remove, this, function(itemId) {
			for (var i=0, option; option = this._element.options[i]; i++) {
				if (option.value != itemId) { continue }<commit_msg>Oops - wrong order of arguments to the dom Option object. All items had id 'Loading...'<commit_after>jsio('from shared.javascript import Class, bind, forEach')
jsio('import ui.Component')

exports = Class(ui.Component, function(supr){
	
	this._domTag = 'select'
	this._className = 'Select'
	
	// (( ItemSetSelect type project title )) -> list of all items of type project, displayed by title
	this.init = function(jsArgs, viewArgs) {
		supr(this, 'init')
		
		var propertyName = viewArgs[0],
			propertyValue = viewArgs[1],
			displayProperty = viewArgs[2],
			itemId = jsArgs[0]
		
		this._targetProperty = propertyValue
		this._displayProperty = displayProperty
		this._query = {}
		this._query[propertyName] = propertyValue
		this._itemId = itemId
		this._options = {}
	}
	
	this._createContent = function() {
		var itemSet = fin.getItemSet(this._query)
		itemSet.addDependant(bind(this, '_onItemsChange'))

		this._item = fin.getItem(this._itemId)
		this._item.addDependant(this._targetProperty, bind(this, '_onTargetPropertyChange'))
		
		this._on('change', bind(this, '_onSelectionChange'))
	}
	
	this._onItemsChange = function(mutation) {
		forEach(mutation.add, this, function(itemId) {
			if (this._options[itemId]) { return }
			this._options[itemId] = new Option('Loading...', itemId, false, false)
			this._element.add(this._options[itemId], null)
			if (itemId == this._item.getProperty(this._targetProperty)) {
				this._element.selectedIndex = this._element.options.length - 1
			}
			fin.getItem(itemId).addDependant(this._displayProperty, bind(this, '_onDisplayPropertyChange', itemId))
		})
		forEach(mutation.remove, this, function(itemId) {
			for (var i=0, option; option = this._element.options[i]; i++) {
				if (option.value != itemId) { continue }
{'fraction_non_alphanumeric': 0.13688760806916425, 'fraction_numerical': 0.00345821325648415, 'mean_word_length': 4.571428571428571, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1173918', 'n_tokens_mistral': 1199, 'n_tokens_neox': 1084, 'n_words': 230}