<%
    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
    >
<% if (!$m->{_precreated}) { %>
    <input type=text class=text name=title style="witdh: 100%" value="<%= $title %>">
<% } else { %>
    <%= $title %>
<% } %>
</td>
<% if ($m->{parent}) { %>
<tr><td><%$ hstr('mode.parent',__("Parent mode")) %></td><td
>
<% if (substr($nm,0,1) eq '_' && !$m->{_can_change_parent}) { %>
   <a href=modes.edit.<%= $m->{parent} %> ><%=   $prj->{modes}->{$m->{parent}}->{title} %></a>
<% } else { %>
    <select name=parentid class=wide-select>
<%
	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>&nbsp;<a title="click to open that mode" style="text-decoration:none"
		href=modes.edit.<%= $m->{parent} %> >&#x21b3;</a>
<% } %>
</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>
<% if ($m->{_precreated}) { %>
    <input type=hidden name=nodescr value=1>
    <div class=mode-outer  style='width: 100%; display: block;'>
	<div class=mode>
    	    <%$ $m->{descr}  %>
	</div>
    </div>
<% } else { %>
<textarea style='width: 80%; height: 10em;' name=descr><%= $m->{descr} %></textarea>
<% }  %>
<p>
<% $forge->include('wgt-gobtn',__("View resultant settings"),
    "modes.resultopts.$nm",
     'hint',__('View settings in effect for files to which this mode is applied') ) %>
<% $forge->include('wgt-gobtn',__("View resultant commandline"),
    "modes.resultcmdline.$nm",
     'hint',__('View commandline options used for files to which this mode is applied')) %><p>

<% $forge->include('wgt-gobtn',__("View relatives of the mode"),
    "modes.relatives.$nm",
     'hint',__('View modes that inherit from this one, and modes which it is inherited from')) %>
<% $forge->include('wgt-gobtn',__("View files using the mode"),
    "modes.filesusing.$nm",
     'hint',__('View files that use this mode and files that use modes inherited from this one.')) %><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>
