<commit_before>package omnitool::tool::action_tool;
# Tries to create some structure / order for your custom Action Tool sub-classes
# All Action Tools must have a proper sub-class chosen to work.  We provide some
# 'core' ones (create, update, delete, display), and you will surely need many
# more...assuming you don't just use Catalyst instead
#
# run_action() tries to call your methods in the order in which they be called
# based on what they *should* do.  I say 'should,' because I can only control
# the names; these are custom methods and can get crazy at your discretion.
# Remember that all of the display power is in the Template/Jemplate file for
# our view mode, so
#
# Also includes unlock_data() method which is called when omnitool_routines.js
# hides a locking tool.

$omnitool::tool::action_tool::VERSION = '6.0';

# time to grow up, old man
use strict;

# for tool access testing
use Data::Dumper;

# our main event: execute an action tool properly
sub run_action {
	my $self = shift;

	# declare vars
	my ($data_code, $lock_result, $lock_user,$lock_remaining_minutes,$record_name, $parent_altcode, $parent_tool_datacode, $parent_tool_datatype, $match_col, $match_col_name, $no_access, $this_match);

	# we need provide the title and uri for jemplate to show a return link, and we should do that first

	# for message/modal tools, we will want to show the URL we came from, the last-used Tool, which is sent via
	# get_tool_id_for_uri() in omnitool_routines.js, and this is most useful when tools share the inline actions
	# with their parent search.  However, we do not want a tool to link back to itself or get caught in a loop,
	# so apply this logic:
	if ($self->{attributes}{tool_type} =~ /Message|Modal/ && $self->{display_options}{return_tool_id} =~ /\d/ && $self->{display_options}{return_tool_id} ne $self->{tool_and_instance}) {
		($parent_tool_datacode = $self->{display_options}{return_tool_id}) =~ s/$self->{luggage}{app_instance}_//;

	# if any tests fail there, get the parent tool's URI.  This is often where they came from anyway.
	} else {
		($parent_tool_datacode = $self->{attributes}{parent}) =~ s/8_1://;
	}

	$self->{json_results}{return_link_uri} = '#/tools/'.$self->{luggage}{session}{tools}{$parent_tool_datacode}{uri_path_base};
	$self->{json_results}{return_link_title} = $self->{luggage}{session}{tools}{$parent_tool_datacode}{name};

	# so the previous/next buttons can work
	$self->{json_results}{parent_tool_id} = $self->{luggage}{app_instance}.'_'.$parent_tool_datacode;
	$self->{json_results}{datatype_name} = $self->{omniclass_object}{datatype_info}{name};
	# also provide a base uri for grabbing json for this tool
	# handy for the jemplates
	$self->{json_results}{my_json_uri} = $self->{my_json_uri};

	# determine the altcode of the target data record for the return link uri
	# if this is a Create Data tool, use the record/toool altcode as the parent for return
	if ($self->{attributes}{uri_path_base} =~ /(create|create_from)$/) {
		$parent_altcode = $self->{display_options}{altcode};

	# if it's a quick-action tool, best bet is to use the current altcode for the return link
	} elsif ($self->{display_options}{altcode} && $self->{attributes}{link_type} eq 'Quick Actions') {
		$self->{json_results}{return_link_uri} .= '/'.$self->{display_options}{altcode};

	# otherwise, figure out the parent of our current data, as we were operating on the parent<commit_msg>Return link is for self if at the top level.<commit_after>package omnitool::tool::action_tool;
# Tries to create some structure / order for your custom Action Tool sub-classes
# All Action Tools must have a proper sub-class chosen to work.  We provide some
# 'core' ones (create, update, delete, display), and you will surely need many
# more...assuming you don't just use Catalyst instead
#
# run_action() tries to call your methods in the order in which they be called
# based on what they *should* do.  I say 'should,' because I can only control
# the names; these are custom methods and can get crazy at your discretion.
# Remember that all of the display power is in the Template/Jemplate file for
# our view mode, so
#
# Also includes unlock_data() method which is called when omnitool_routines.js
# hides a locking tool.

$omnitool::tool::action_tool::VERSION = '6.0';

# time to grow up, old man
use strict;

# for tool access testing
use Data::Dumper;

# our main event: execute an action tool properly
sub run_action {
	my $self = shift;

	# declare vars
	my ($data_code, $lock_result, $lock_user,$lock_remaining_minutes,$record_name, $parent_altcode, $parent_tool_datacode, $parent_tool_datatype, $match_col, $match_col_name, $no_access, $this_match);

	# we need provide the title and uri for jemplate to show a return link, and we should do that first

	# for message/modal tools, we will want to show the URL we came from, the last-used Tool, which is sent via
	# get_tool_id_for_uri() in omnitool_routines.js, and this is most useful when tools share the inline actions
	# with their parent search.  However, we do not want a tool to link back to itself or get caught in a loop,
	# so apply this logic:
	if ($self->{attributes}{tool_type} =~ /Message|Modal/ && $self->{display_options}{return_tool_id} =~ /\d/ && $self->{display_options}{return_tool_id} ne $self->{tool_and_instance}) {
		($parent_tool_datacode = $self->{display_options}{return_tool_id}) =~ s/$self->{luggage}{app_instance}_//;

	# if any tests fail there, get the parent tool's URI.  This is often where they came from anyway.
	} else {
		($parent_tool_datacode = $self->{attributes}{parent}) =~ s/8_1://;
	}

	# the parent tool is the return link, unless there is no parent
	if ($self->{luggage}{session}{tools}{$parent_tool_datacode}{uri_path_base}) {
		$self->{json_results}{return_link_uri} = '#/tools/'.$self->{luggage}{session}{tools}{$parent_tool_datacode}{uri_path_base};
		$self->{json_results}{return_link_title} = $self->{luggage}{session}{tools}{$parent_tool_datacode}{name};
	} else { # in which case, the current tool is the return; think a top-level singleton
		$self->{json_results}{return_link_uri} = '#/tools/'.$self->{attributes}{uri_path_base};
		$self->{json_results}{return_link_title} = $self->{attributes}{name};
	}

	# so the previous/next buttons can work
	$self->{json_results}{parent_tool_id} = $self->{luggage}{app_instance}.'_'.$parent_tool_datacode;
	$self->{json_results}{datatype_name} = $self->{omniclass_object}{datatype_info}{name};
	# also provide a base uri for grabbing json for this tool
	# handy for the jemplates
	$self->{json_results}{my_json_uri} = $self->{my_json_uri};

	# determine the altcode of the target data record for the return link uri
	# if this is a Create Data tool, use the record/toool altcode as the parent for return
	if ($self->{attributes}{uri_path_base} =~ /(create|create_from)$/) {
		$parent_altcode = $self->{display_options}{altcode};

	# if it's a quick-action tool, best bet is to use the current altcode for the return link
	} elsif ($self->{display_options}{altcode} && $self->{attributes}{link_type} eq 'Quick Actions') {
		$self->{json_results}{return_link_uri} .= '/'.$self->{display_options}{altcode};

	# otherwise, figure out the parent of our current data, as we were operating on the parent
{'fraction_non_alphanumeric': 0.12099986265622854, 'fraction_numerical': 0.0010987501716797144, 'mean_word_length': 5.192176870748299, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 54, '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': '6060100', 'n_tokens_mistral': 2342, 'n_tokens_neox': 2299, 'n_words': 798}