<% 
    my ($prj,$nm,$opthtml) = @_;
    use obfui::cmn;

    my $m = $prj->{modes}->{$nm};
    my $title = $m->{title};
    
%>

<form method=post action=modes.edit.<%$ $nm %>>
<input type=hidden name=havevals value=1>

<h2><%= __('Mode attributes') %></h2>

<table>
<tr><td><%$ hstr('mode.title',__('Title')) %></td><td class=width-of-select
    ><input type=text class=text name=title value="<%= $title %>"></td>
<% if ($m->{parent}) { %>
<tr><td><%$ hstr('mode.parent',__("Parent mode")) %></td><td><select name=parentid
class=wide-select
    <%$ substr($nm,0,1) eq '_' && !$m->{_can_change_parent} ? 
	' disabled=true ' : '' %> >
<%
	foreach my $k (sort { $prj->{modes}->{$a}->{title} cmp
				$prj->{modes}->{$b}->{title}
			    } keys %{$prj->{modes}})
	{
	    next if $k eq $nm;
	    my $t = $prj->{modes}->{$k}->{title};
	    my $sel = $m->{parent} eq $k ? ' selected ' : '';
%><option value=<%$ "$k $sel" %>><%= $t %>
<%
	}
%>
    </select></td>
<% } %>
<tr><td><%$ hstr('mode.filer_visible',__('Visible in filer')) %>&nbsp;&nbsp;&nbsp;</td><td><input type=checkbox class=checkbox
    name=filer_visible <%$ $m->{filer_visible} ? 'checked' : '' %>></td>
</table>

<h2><%$ hstr('mode.descr',__('Description of the mode')) %></h2>
<textarea style='width: 80%; height: 10em;' name=descr><%= $m->{descr} %></textarea>

<p>
<% $forge->include('wgt-gobtn',__("View resultant settings"),
    "modes.resultopts.$nm") %>
<% $forge->include('wgt-gobtn',__("View resultant commandline"),
    "modes.resultcmdline.$nm") %><p>

<% $forge->include('wgt-gobtn',__("View relatives of the mode"),
    "modes.relatives.$nm") %>
<% $forge->include('wgt-gobtn',__("View files using the mode"),
    "modes.filesusing.$nm") %><p>

<p>
<h2><%$ hstr('mode.settings',__('Overriden settings')) %></h2>
<% if ($m->{parent}) { %>
<%= __('Note: in order to override any parent mode setting, tick the checkbox before that setting.') %>
<br>
<% } %>
<%$ $$opthtml %>
<p>

<% $forge->include('wgt-gobtn',__('Set settings to defaults'), 
    "modes.reset.$nm",
    'confirm' => 
    __('Do you really wish to set settings of this mode to default values?')
    ) %>

<% $forge->include('wgt-gobtn',__('Delete this mode'), 
    "modes.delete.$nm",'confirm',
    __('Do you really wish to delete this mode?')
    ) if index($nm,0,1) ne '_' %>
<p>


<input type=radio class=radio name=rebuildfilestype
    value=none> <%= __("Do not mark any files for next rebuilding") %><br>
<input type=radio class=radio name=rebuildfilestype
    value=this> <%= __("Mark files with this mode for next rebuilding") %><br>
<input type=radio class=radio name=rebuildfilestype
    value=deps checked>
<%= __("Mark files with this mode and modes depending on it for next rebuilding") %>

<p>
<% $forge->include('wgt-submitbtn',__('Save')) %>
<% $forge->include('wgt-backbtn',__('Cancel')) %>
</form>
