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

frappe.provide("frappe.customize_form");

frappe.ui.form.on("Customize Form", {
	setup: function(frm) {
		frm.get_docfield("fields").allow_bulk_edit = 1;
	},
	onload: function(frm) {
		frappe.customize_form.add_fields_help(frm);

		frm.set_query("doc_type", function() {
			return {
				translate_values: false,
				filters: [
					['DocType', 'issingle', '=', 0],
					['DocType', 'custom', '=', 0],
					['DocType', 'name', 'not in', 'DocType, DocField, DocPerm, User, Role, Has Role, \
						 Page, Has Role, Module Def, Print Format, Report, Customize Form, \
						 Customize Form Field']
				]
			};
		});

		$(frm.wrapper).on("grid-row-render", function(e, grid_row) {
			if(grid_row.doc && grid_row.doc.fieldtype=="Section Break") {
				$(grid_row.row).css({"font-weight": "bold"});
			}
		});

		$(frm.wrapper).on("grid-make-sortable", function(e, frm) {
			frm.trigger("setup_sortable");
		});
	},

	doc_type: function(frm) {
		if(frm.doc.doc_type) {
			return frm.call({
				method: "fetch_to_customize",
				doc: frm.doc,
				freeze: true,
				callback: function(r) {
					frm.refresh();
					frm.trigger("setup_sortable");
				}
			});
		}
	},

	setup_sortable: function(frm) {
		frm.page.body.find('.highlight').removeClass('highlight');
		frm.doc.fields.forEach(function(f, i) {
			var data_row = frm.page.body.find('[data-fieldname="fields"] [data-idx="'+ f.idx +'"] .data-row');

			if(!f.is_custom_field) {
				data_row.removeClass('sortable-handle');
			} else {
				data_row.addClass("highlight");
			}
		});
	},

	refresh: function(frm) {
		frm.disable_save();<commit_msg>[minor] hide custom buttons in customize form if form type is not selected<commit_after>// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// MIT License. See license.txt

frappe.provide("frappe.customize_form");

frappe.ui.form.on("Customize Form", {
	setup: function(frm) {
		frm.get_docfield("fields").allow_bulk_edit = 1;
	},
	onload: function(frm) {
		frappe.customize_form.add_fields_help(frm);

		frm.set_query("doc_type", function() {
			return {
				translate_values: false,
				filters: [
					['DocType', 'issingle', '=', 0],
					['DocType', 'custom', '=', 0],
					['DocType', 'name', 'not in', 'DocType, DocField, DocPerm, User, Role, Has Role, \
						 Page, Has Role, Module Def, Print Format, Report, Customize Form, \
						 Customize Form Field']
				]
			};
		});

		$(frm.wrapper).on("grid-row-render", function(e, grid_row) {
			if(grid_row.doc && grid_row.doc.fieldtype=="Section Break") {
				$(grid_row.row).css({"font-weight": "bold"});
			}
		});

		$(frm.wrapper).on("grid-make-sortable", function(e, frm) {
			frm.trigger("setup_sortable");
		});
	},

	doc_type: function(frm) {
		if(frm.doc.doc_type) {
			return frm.call({
				method: "fetch_to_customize",
				doc: frm.doc,
				freeze: true,
				callback: function(r) {
					frm.refresh();
					frm.trigger("setup_sortable");
				}
			});
		} else {
			frm.refresh();
		}
	},

	setup_sortable: function(frm) {
		frm.page.body.find('.highlight').removeClass('highlight');
		frm.doc.fields.forEach(function(f, i) {
			var data_row = frm.page.body.find('[data-fieldname="fields"] [data-idx="'+ f.idx +'"] .data-row');

			if(!f.is_custom_field) {
				data_row.removeClass('sortable-handle');
			} else {
				data_row.addClass("highlight");
			}
		});
	},

	refresh: function(frm) {
		frm.disable_save();
{'fraction_non_alphanumeric': 0.18849658314350798, 'fraction_numerical': 0.003986332574031891, 'mean_word_length': 3.604193971166448, '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': '5522731', 'n_tokens_mistral': 1544, 'n_tokens_neox': 1307, 'n_words': 223}