<commit_before>{title help="Category Transitions"}{tr}Transitions{/tr}{/title}

{tabset}
	{tab name="{tr}Subset Selection{/tr}"}
		<form method="post" action="tiki-admin_transitions.php?action=subset" style="text-align: left;">
			<fieldset>
				<legend>{tr}Type{/tr}</legend>

				<p>
					<input type="radio" name="transition_mode" value="category" id="transition-mode-category"{if $transition_mode eq 'category'} checked="checked"{/if}/>
					<label for="transition-mode-category">{tr}Category{/tr}</label>

					<input type="radio" name="transition_mode" value="group" id="transition-mode-group"{if $transition_mode eq 'group'} checked="checked"{/if}/>
					<label for="transition-mode-group">{tr}Group{/tr}</label>
				</p>
			</fieldset>

			<fieldset id="transition-category-selection">
				<legend>{tr}Category Selection{/tr}</legend>
				{$cat_tree}
			</fieldset>

			<fieldset id="transition-group-selection">
				<legend>{tr}Group Selection{/tr}</legend>
				<ul id="transition-group-list">
					{if $transition_mode eq 'group'}
						{foreach from=$available_states item=state}
							<li>
								<input type="hidden" name="groups[]" value="{$state|escape}"/>
								{$state|escape}
								{icon _id=cross class="removeitem"}
							</li>
						{/foreach}
					{/if}
				</ul>
				<p>
					<label for="transition-group-auto">{tr}Group name{/tr}</label>
					<input type="text" id="transition-group-auto"/>
				</p>
			</fieldset>

			<p>
				<input type="submit" value="{tr}Select{/tr}"/>
			</p>
		</form>
		{jq}
			var blocks = $jq('#transition-group-selection, #transition-category-selection');
			$jq(':radio[name=transition_mode]').change( function( e ) {
				if( $jq(this).attr('checked') ) {
					blocks.hide();
					blocks.filter( '#transition-' + $jq(this).val() + '-selection' ).show();
				}
			} ).change();

			$jq('#transition-group-auto')
				.tiki('autocomplete','groupname')
				.keypress( function( e ) {
					if( e.which !== 13 ) {
						return;
					}
					e.preventDefault();
					if( $jq(this).val() === '' ) {
						return;
					}
					$jq('#transition-group-list').append( 
						$jq('<li/>').text( $jq(this).val() )
							.append( $jq('<input type="hidden" name="groups[]"/>').val( $jq(this).val() ) )
							.append( $jq('{{icon _id=cross class="removeitem"}}') )
					);
					$jq(this).val('');
				} );
			$jq('#transition-group-list .removeitem').live( 'click', function( e ) {
				$jq(this).parent().remove();
			} );
		{/jq}
	{/tab}
	{if $available_states|@count > 0}
	{tab name="{tr}Transitions{/tr}"}
		<div id="graph-canvas"></div>
		<a href="#" id="graph-draw" class="button">{tr}Draw Transition Diagram{/tr}</a>
		{jq}
		$jq('#graph-draw').click( function( e ) {
			e.preventDefault();
			$jq(this).hide();
			var width = $jq('#graph-canvas').width();
			var height = Math.ceil( width * 9 / 16 );
			var nodes = {{$graph_nodes}};
			var edges = {{$graph_edges}};

			var g = new Graph;
			for( k in nodes ) {
				g.addNode( nodes[k] );
			}
			for( k in edges ) {
				var style = { directed: true };
				if( edges[k].preserve ) {
					style.color = 'red';
				}
				g.addEdge( edges[k].from, edges[k].to, style );
			}

			var layouter = new Graph.Layout.Spring(g);
			layouter.layout();
			
			var renderer = new Graph.Renderer.Raphael('graph-canvas', g, width, height );
			renderer.draw();
		} );
		{/jq}
		<table class="data">
			<thead>
				<tr>
					<th>{tr}Label{/tr}</th>
					<th>{tr}From{/tr}</th>
					<th>{tr}To{/tr}</th>
					<th>{tr}Guards{/tr}</th>
					<th>{tr}Actions{/tr}</th>
				</tr>
			</thead>
			<tbody>
				{foreach from=$transitions item=trans}
					<tr>
						<td>{$trans.name|escape}</td>
						<td>{$trans.from_label|escape} {if $trans.preserve} - <em>{tr}preserved{/tr}</em>{/if}</td>
						<td>{$trans.to_label|escape}</td>
						<td>{self_link transitionId=$trans.transitionId action=edit cookietab=4}{$trans.guards|@count|escape}{/self_link}</td>
						<td>
							{self_link transitionId=$trans.transitionId action=edit cookietab=3}{icon _id=page_edit alt="{tr}Edit{/tr}"}{/self_link}
							{self_link transitionId=$trans.transitionId action=remove}{icon _id=cross alt="{tr}Remove{/tr}"}{/self_link}
						</td>
					</tr>
				{foreachelse}
					<tr>
						<td colspan="4">{tr}No transitions{/tr}</td>
					</tr>
				{/foreach}
			</tbody>
		</table>
	{/tab}
		
	{tab name="{tr}New / Edit{/tr}"}
		<form method="post" action="tiki-admin_transitions.php?action={if $selected_transition}edit{else}new{/if}&amp;cookietab=2" style="text-align: left;">
			{if $selected_transition}
				<h2>
					{tr 0=$selected_transition.name}Edit <em>%0</em>{/tr}
					<input type="hidden" name="transitionId" value="{$selected_transition.transitionId|escape}"/>
					(<a href="tiki-admin_transitions.php">{tr}Create new{/tr}</a>)
				</h2>
			{else}
				<h2>{tr}New transition{/tr}</h2>
			{/if}
			<fieldset>
				<legend>{tr}General{/tr}</legend><commit_msg>[ENH] Adding link for transition permissions<commit_after>{title help="Category Transitions"}{tr}Transitions{/tr}{/title}

{tabset}
	{tab name="{tr}Subset Selection{/tr}"}
		<form method="post" action="tiki-admin_transitions.php?action=subset" style="text-align: left;">
			<fieldset>
				<legend>{tr}Type{/tr}</legend>

				<p>
					<input type="radio" name="transition_mode" value="category" id="transition-mode-category"{if $transition_mode eq 'category'} checked="checked"{/if}/>
					<label for="transition-mode-category">{tr}Category{/tr}</label>

					<input type="radio" name="transition_mode" value="group" id="transition-mode-group"{if $transition_mode eq 'group'} checked="checked"{/if}/>
					<label for="transition-mode-group">{tr}Group{/tr}</label>
				</p>
			</fieldset>

			<fieldset id="transition-category-selection">
				<legend>{tr}Category Selection{/tr}</legend>
				{$cat_tree}
			</fieldset>

			<fieldset id="transition-group-selection">
				<legend>{tr}Group Selection{/tr}</legend>
				<ul id="transition-group-list">
					{if $transition_mode eq 'group'}
						{foreach from=$available_states item=state}
							<li>
								<input type="hidden" name="groups[]" value="{$state|escape}"/>
								{$state|escape}
								{icon _id=cross class="removeitem"}
							</li>
						{/foreach}
					{/if}
				</ul>
				<p>
					<label for="transition-group-auto">{tr}Group name{/tr}</label>
					<input type="text" id="transition-group-auto"/>
				</p>
			</fieldset>

			<p>
				<input type="submit" value="{tr}Select{/tr}"/>
			</p>
		</form>
		{jq}
			var blocks = $jq('#transition-group-selection, #transition-category-selection');
			$jq(':radio[name=transition_mode]').change( function( e ) {
				if( $jq(this).attr('checked') ) {
					blocks.hide();
					blocks.filter( '#transition-' + $jq(this).val() + '-selection' ).show();
				}
			} ).change();

			$jq('#transition-group-auto')
				.tiki('autocomplete','groupname')
				.keypress( function( e ) {
					if( e.which !== 13 ) {
						return;
					}
					e.preventDefault();
					if( $jq(this).val() === '' ) {
						return;
					}
					$jq('#transition-group-list').append( 
						$jq('<li/>').text( $jq(this).val() )
							.append( $jq('<input type="hidden" name="groups[]"/>').val( $jq(this).val() ) )
							.append( $jq('{{icon _id=cross class="removeitem"}}') )
					);
					$jq(this).val('');
				} );
			$jq('#transition-group-list .removeitem').live( 'click', function( e ) {
				$jq(this).parent().remove();
			} );
		{/jq}
	{/tab}
	{if $available_states|@count > 0}
	{tab name="{tr}Transitions{/tr}"}
		<div id="graph-canvas"></div>
		<a href="#" id="graph-draw" class="button">{tr}Draw Transition Diagram{/tr}</a>
		{jq}
		$jq('#graph-draw').click( function( e ) {
			e.preventDefault();
			$jq(this).hide();
			var width = $jq('#graph-canvas').width();
			var height = Math.ceil( width * 9 / 16 );
			var nodes = {{$graph_nodes}};
			var edges = {{$graph_edges}};

			var g = new Graph;
			for( k in nodes ) {
				g.addNode( nodes[k] );
			}
			for( k in edges ) {
				var style = { directed: true };
				if( edges[k].preserve ) {
					style.color = 'red';
				}
				g.addEdge( edges[k].from, edges[k].to, style );
			}

			var layouter = new Graph.Layout.Spring(g);
			layouter.layout();
			
			var renderer = new Graph.Renderer.Raphael('graph-canvas', g, width, height );
			renderer.draw();
		} );
		{/jq}
		<table class="data">
			<thead>
				<tr>
					<th>{tr}Label{/tr}</th>
					<th>{tr}From{/tr}</th>
					<th>{tr}To{/tr}</th>
					<th>{tr}Guards{/tr}</th>
					<th>{tr}Actions{/tr}</th>
				</tr>
			</thead>
			<tbody>
				{foreach from=$transitions item=trans}
					<tr>
						<td>{$trans.name|escape}</td>
						<td>{$trans.from_label|escape} {if $trans.preserve} - <em>{tr}preserved{/tr}</em>{/if}</td>
						<td>{$trans.to_label|escape}</td>
						<td>{self_link transitionId=$trans.transitionId action=edit cookietab=4}{$trans.guards|@count|escape}{/self_link}</td>
						<td>
							{self_link transitionId=$trans.transitionId action=edit cookietab=3}{icon _id=page_edit alt="{tr}Edit{/tr}"}{/self_link}
							{self_link transitionId=$trans.transitionId action=remove}{icon _id=cross alt="{tr}Remove{/tr}"}{/self_link}
							<a class="link" href="tiki-objectpermissions.php?objectName={$trans.name|escape:url}&amp;objectType=transition&amp;permType=transition&amp;objectId={$trans.transitionId|escape:"url"}">
								{icon _id='key' class=titletips title='{tr}Assign permissions for transition{/tr}' alt='{tr}Permissions{/tr}'}
							</a>
						</td>
					</tr>
				{foreachelse}
					<tr>
						<td colspan="4">{tr}No transitions{/tr}</td>
					</tr>
				{/foreach}
			</tbody>
		</table>
	{/tab}
		
	{tab name="{tr}New / Edit{/tr}"}
		<form method="post" action="tiki-admin_transitions.php?action={if $selected_transition}edit{else}new{/if}&amp;cookietab=2" style="text-align: left;">
			{if $selected_transition}
				<h2>
					{tr 0=$selected_transition.name}Edit <em>%0</em>{/tr}
					<input type="hidden" name="transitionId" value="{$selected_transition.transitionId|escape}"/>
					(<a href="tiki-admin_transitions.php">{tr}Create new{/tr}</a>)
				</h2>
			{else}
				<h2>{tr}New transition{/tr}</h2>
			{/if}
			<fieldset>
				<legend>{tr}General{/tr}</legend>
{'fraction_non_alphanumeric': 0.21778300039169604, 'fraction_numerical': 0.003133568350959655, 'mean_word_length': 3.4813514699429575, 'pattern_counts': {'":': 0, '<': 185, '<?xml version=': 0, '>': 187, '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': '5091508', 'n_tokens_mistral': 4650, 'n_tokens_neox': 3663, 'n_words': 596}