<commit_before><?php

namespace SaltedHerring;

class Grid {
	public static function make($name, $label = '', $source, $sortable = true, $gridHeaderType = 'GridFieldConfig_RecordEditor') {
		/*
		GridFieldConfig_Base
		GridFieldConfig_RecordViewer
		GridFieldConfig_RecordEditor
		GridFieldConfig_RelationEditor
		*/
		if ($label == '') { $label = $name; }
		$grid = new \GridField($name, $label, $source);
		$config = $gridHeaderType::create();
		$config->removeComponentsByType('GridFieldPaginator')
				->addComponents(
					new \GridFieldPaginatorWithShowAll(30)
				);
		if ($sortable) {
			$config->addComponents(
				$sortable = new \GridFieldOrderableRows('SortOrder')
			);
		}
		
		$grid->setConfig($config);
		return $grid;
	}
}<commit_msg>introducing gridfield with  on-fly-editable fields<commit_after><?php

namespace SaltedHerring;

class Grid {
	public static function make($name, $label = '', $source, $sortable = true, $gridHeaderType = 'GridFieldConfig_RecordEditor') {
		/*
		GridFieldConfig_Base
		GridFieldConfig_RecordViewer
		GridFieldConfig_RecordEditor
		GridFieldConfig_RelationEditor
		*/
		if ($label == '') { $label = $name; }
		$grid = new \GridField($name, $label, $source);
		$config = $gridHeaderType::create();
		$config->removeComponentsByType('GridFieldPaginator')
				->addComponents(
					new \GridFieldPaginatorWithShowAll(30)
				);
		if ($sortable) {
			$config->addComponents(
				$sortable = new \GridFieldOrderableRows('SortOrder')
			);
		}
		
		$grid->setConfig($config);
		return $grid;
	}

	public static function makeEditable($name, $label = '', $source, $sortable = true, $fields = null) {
		$grid = self::make($name, $label, $source, $sortable);
		$config = $grid->getConfig();
		$fieldEditor = new \GridFieldEditableColumns();
		$btnInlineAdd = new \GridFieldAddNewInlineButton();
		
		if (!empty($fields)) {
			$fieldEditor->setDisplayFields($fields);
		}
		
		$config->removeComponentsByType('GridFieldAddNewButton')
				->addComponents(
					$fieldEditor, 
					$btnInlineAdd
				);
		
		return $grid;
	}
}
{'fraction_non_alphanumeric': 0.14451988360814744, 'fraction_numerical': 0.0019398642095053346, 'mean_word_length': 4.560646900269542, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '5765385', 'n_tokens_mistral': 763, 'n_tokens_neox': 663, 'n_words': 122}