tiki-admin_transitions.tpl 8.4 KB
Newer Older
1
{title help="Transitions"}{tr}Transitions{/tr}{/title}
2 3 4 5 6 7 8 9

{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>
10
					{if $prefs.feature_categories eq 'y'}
11 12
					<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>
13
					{/if}
14

15
					<input type="radio" name="transition_mode" value="group" id="transition-mode-group"{if $transition_mode eq 'group' or $prefs.feature_categories ne 'y'} checked="checked"{/if}/>
16 17 18 19
					<label for="transition-mode-group">{tr}Group{/tr}</label>
				</p>
			</fieldset>

20
			{if $prefs.feature_categories eq 'y'}
21 22 23 24
			<fieldset id="transition-category-selection">
				<legend>{tr}Category Selection{/tr}</legend>
				{$cat_tree}
			</fieldset>
25
			{/if}
26 27 28

			<fieldset id="transition-group-selection">
				<legend>{tr}Group Selection{/tr}</legend>
29 30 31 32 33 34 35 36 37 38 39 40
				<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>
41 42
					<label for="transition-group-auto">{tr}Type in a group name and click "enter"{/tr}</label>
					<input type="text" id="transition-group-auto"/> 
43
				</p>
44 45 46
			</fieldset>

			<p>
47
				{tr}Once you have selected at least two, click:{/tr} <input type="submit" value="{tr}Select{/tr}"/> {tr}and then, click the "New/Edit" tab which will appear above.{/tr}
48 49 50
			</p>
		</form>
		{jq}
51 52 53
			var blocks = $('#transition-group-selection, #transition-category-selection');
			$(':radio[name=transition_mode]').change( function( e ) {
				if( $(this).attr('checked') ) {
54
					blocks.hide();
55
					blocks.filter( '#transition-' + $(this).val() + '-selection' ).show();
56 57
				}
			} ).change();
58

59
			$('#transition-group-auto')
60 61 62 63 64 65
				.tiki('autocomplete','groupname')
				.keypress( function( e ) {
					if( e.which !== 13 ) {
						return;
					}
					e.preventDefault();
66
					if( $(this).val() === '' ) {
67 68
						return;
					}
69 70 71 72
					$('#transition-group-list').append( 
						$('<li/>').text( $(this).val() )
							.append( $('<input type="hidden" name="groups[]"/>').val( $(this).val() ) )
							.append( $('{{icon _id=cross class="removeitem"}}') )
73
					);
74
					$(this).val('');
75
				} );
76 77
			$('#transition-group-list .removeitem').live( 'click', function( e ) {
				$(this).parent().remove();
78
			} );
79 80 81 82
		{/jq}
	{/tab}
	{if $available_states|@count > 0}
	{tab name="{tr}Transitions{/tr}"}
83 84
		{$headerlib->add_dracula()}
		<div id="graph-canvas" class="graph-canvas" data-graph-nodes="{$graph_nodes|escape}" data-graph-edges="{$graph_edges|escape}"></div>
85 86
		<a href="#" id="graph-draw" class="button">{tr}Draw Transition Diagram{/tr}</a>
		{jq}
87 88
		$('#graph-draw').click( function( e ) {
			$(this).hide();
89 90
			$('#graph-canvas').drawGraph();
			return false;
91 92
		} );
		{/jq}
93
		<table class="normal">
94 95 96 97 98
			<thead>
				<tr>
					<th>{tr}Label{/tr}</th>
					<th>{tr}From{/tr}</th>
					<th>{tr}To{/tr}</th>
lphuberdeau's avatar
lphuberdeau committed
99
					<th>{tr}Guards{/tr}</th>
100 101 102 103 104 105
					<th>{tr}Actions{/tr}</th>
				</tr>
			</thead>
			<tbody>
				{foreach from=$transitions item=trans}
					<tr>
106 107 108 109 110
						<td class="text">{$trans.name|escape}</td>
						<td class="text">{$trans.from_label|escape} {if $trans.preserve} - <em>{tr}preserved{/tr}</em>{/if}</td>
						<td class="text">{$trans.to_label|escape}</td>
						<td class="integer">{self_link transitionId=$trans.transitionId action=edit cookietab=4}{$trans.guards|@count|escape}{/self_link}</td>
						<td class="action">
111
							{self_link transitionId=$trans.transitionId action=edit cookietab=3}{icon _id=page_edit alt="{tr}Edit{/tr}"}{/self_link}
112
							{self_link transitionId=$trans.transitionId action=remove}{icon _id=cross alt="{tr}Remove{/tr}"}{/self_link}
113
							<a class="link" href="tiki-objectpermissions.php?objectName={$trans.name|escape:url}&amp;objectType=transition&amp;permType=transition&amp;objectId={$trans.transitionId|escape:"url"}">
changi67's avatar
changi67 committed
114
								{icon _id='key' class=titletips title="{tr}Assign permissions for transition{/tr}" alt="{tr}Permissions{/tr}"}
115
							</a>
116 117 118 119 120 121 122 123 124
						</td>
					</tr>
				{foreachelse}
					<tr>
						<td colspan="4">{tr}No transitions{/tr}</td>
					</tr>
				{/foreach}
			</tbody>
		</table>
125
	{/tab}
126
		
127 128
	{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;">
129 130
			{if $selected_transition}
				<h2>
131
					{tr _0=$selected_transition.name}Edit <em>%0</em>{/tr}
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
					<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>
				<p>
					<label for="new-transition-name">{tr}Label{/tr}</label>
					<br/>
					<input type="text" name="label" {if $selected_transition}value="{$selected_transition.name|escape}"{/if}/>
				</p>
				<p>
					<input type="checkbox" name="preserve" value="y" id="new-transition-preserve" {if $selected_transition && $selected_transition.preserve}checked="checked"{/if}/>
					<label for="new-transition-preserve">{tr}Upon trigger, preserve the initial state{/tr}</label>
				</p>
			</fieldset>
			<fieldset style="float: left; width: 48%;">
				<legend>{tr}From{/tr}</legend>
				{foreach from=$available_states item=label key=value}
					<p>
						<input type="radio" name="from" value="{$value|escape}" id="state-from-{$value|escape}"{if $selected_transition && $selected_transition.from eq $value} checked="checked"{/if}/>
						<label for="state-from-{$value|escape}">{$label|escape}</label>
					</p>
				{/foreach}
			</fieldset>
			<fieldset style="float: left; width: 48%;">
				<legend>{tr}To{/tr}</legend>
				{foreach from=$available_states item=label key=value}
					<p>
						<input type="radio" name="to" value="{$value|escape}" id="state-to-{$value|escape}"{if $selected_transition && $selected_transition.to eq $value} checked="checked"{/if}/>
						<label for="state-to-{$value|escape}">{$label|escape}</label>
					</p>
				{/foreach}
			</fieldset>
			<p>
				<input type="submit" value="{tr}Save{/tr}"/>
			</p>
		</form>
	{/tab}
173 174 175

	{if $selected_transition}
		{tab name="{tr}Guards{/tr}"}
176
			<table class="normal">
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240
				<thead>
					<tr>
						<th>{tr}Type{/tr}</th>
						<th>{tr}Count{/tr}</th>
						<th>{tr}Members{/tr}</th>
						<th>{tr}Actions{/tr}</th>
					</tr>
				</thead>
				<tbody>
					{foreach from=$guards item=guard key=key}
						<tr>
							<td>{$guard.type|escape}</td>
							<td>{$guard.count|escape}</td>
							<td>
								<ul>
									{foreach from=$guard.members item=name}
										<li>{$name|escape}</li>
									{/foreach}
								</ul>
							</td>
							<td>
								{self_link transitionId=$selected_transition.transitionId action=removeguard guard=$key cookietab=4}{icon _id=cross}{/self_link}
							</td>
						</tr>
					{foreachelse}
						<tr>
							<td colspan="4">{tr}No guards on this transition.{/tr}</td>
						</tr>
					{/foreach}
				</tbody>
			</table>
			<form method="post" action="tiki-admin_transitions.php?action=addguard&amp;transitionId={$selected_transition.transitionId|escape}&amp;cookietab=4" style="text-align: left;">
				<h2>{tr}New Guard{/tr}</h2>
				<fieldset>
					<legend>{tr}General{/tr}</legend>
					<p>
						<label for="guard-type">{tr}Type{/tr}</label>
						<select id="guard-type" name="type">
							<option value="exactly">{tr}Exactly{/tr}</option>
							<option value="atLeast">{tr}At Least{/tr}</option>
							<option value="atMost">{tr}At Most{/tr}</option>
						</select>
					</p>
					<p>
						<label for="guard-count">{tr}Count{/tr}</label>
						<input type="text" name="count"/>
					</p>
				</fieldset>
				<fieldset>
					<legend>{tr}States{/tr}</legend>
					{foreach from=$available_states item=label key=value}
						<p>
							<input type="checkbox" name="states[]" value="{$value|escape}" id="guard-state-{$value|escape}"/>
							<label for="guard-state-{$value|escape}">{$label|escape}</label>
						</p>
					{/foreach}
				</fieldset>
				<p>
					<input type="submit" value="{tr}Add{/tr}"/>
				</p>
			</form>
		{/tab}
	{/if}

241 242
	{/if}
{/tabset}