<commit_before>// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// MIT License. See license.txt

frappe.provide('frappe.ui');

frappe.ui.FieldGroup = frappe.ui.form.Layout.extend({
	init: function(opts) {
		$.extend(this, opts);
		this._super();
		$.each(this.fields || [], function(i, f) {
			if(!f.fieldname && f.label) {
				f.fieldname = f.label.replace(/ /g, "_").toLowerCase();
			}
		})
		if(this.values) {
			this.set_values(this.values);
		}
	},
	make: function() {
		var me = this;
		if(this.fields) {
			this._super();
			this.refresh();
			// set default
			$.each(this.fields_list, function(i, field) {
				if(field.df["default"]) {
					field.set_input(field.df["default"]);
				}
			})

			if(!this.no_submit_on_enter) {
				this.catch_enter_as_submit();
			}

			$(this.body).find('input').on('change', function() {
				frappe.run_serially([
					() => me.refresh_dependency()
				]);
			})

			$(this.body).find('select').on("change", function() {
				frappe.run_serially([
					() => me.refresh_dependency()
				]);
			})
		}
	},
	add_fields: function(fields) {
		this.render(fields);
		this.refresh_fields(fields);
	},
	refresh_fields: function(fields) {
		let fieldnames = fields.map((field) => {
			if(field.fieldname) return field.fieldname;
		});

		this.fields_list.map(fieldobj => {
			if(fieldnames.includes(fieldobj.df.fieldname)) {
				fieldobj.refresh();
				if(fieldobj.df["default"]) {
					fieldobj.set_input(fieldobj.df["default"]);
				}
			}<commit_msg>Update field_group.js<commit_after>// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// MIT License. See license.txt

frappe.provide('frappe.ui');

frappe.ui.FieldGroup = frappe.ui.form.Layout.extend({
	init: function(opts) {
		$.extend(this, opts);
		this._super();
		$.each(this.fields || [], function(i, f) {
			if(!f.fieldname && f.label) {
				f.fieldname = f.label.replace(/ /g, "_").toLowerCase();
			}
		})
		if(this.values) {
			this.set_values(this.values);
		}
	},
	make: function() {
		var me = this;
		if(this.fields) {
			this._super();
			this.refresh();
			// set default
			$.each(this.fields_list, function(i, field) {
				if(field.df["default"]) {
					field.set_input(field.df["default"]);
				}
			})

			if(!this.no_submit_on_enter) {
				this.catch_enter_as_submit();
			}

			$(this.body).find('input, select').on('change', function() {
				frappe.run_serially([
					() => frappe.timeout(0.1),
					() => me.refresh_dependency()
				]);
			});

		}
	},
	add_fields: function(fields) {
		this.render(fields);
		this.refresh_fields(fields);
	},
	refresh_fields: function(fields) {
		let fieldnames = fields.map((field) => {
			if(field.fieldname) return field.fieldname;
		});

		this.fields_list.map(fieldobj => {
			if(fieldnames.includes(fieldobj.df.fieldname)) {
				fieldobj.refresh();
				if(fieldobj.df["default"]) {
					fieldobj.set_input(fieldobj.df["default"]);
				}
			}
{'fraction_non_alphanumeric': 0.19216354344122658, 'fraction_numerical': 0.0034071550255536627, 'mean_word_length': 3.362555720653789, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '7545712', 'n_tokens_mistral': 1264, 'n_tokens_neox': 1071, 'n_words': 149}