drag and drop ordering of options
[bse.git] / site / templates / admin / edit_prodopts.tmpl
CommitLineData
4de47893 1<:wrap admin/xbase.tmpl title=>"[articleType] Options", showtitle=>1, menuitem=>prodopts, js=>"admin_prodopts.js":>
58baa27b
TC
2<:ifMessage:><div id="message"><:message:></div><:or:><:eif:>
3<:include admin/product_menu.tmpl:>
4
5<:if Dboptions:>
6<h2>Product options</h2>
4de47893
TC
7<div id="prodoptmenu">All options:
8<a id="sortoptions" href="<:script:>?a_option_reorder=1&amp;_t=prodopts&amp;id=<:article id:>&amp;_csrfp=<:csrfp admin_move_option:>&amp;option_ids=<:arithmetic join ",", map $_->{id}, sort { lc $a->{name} cmp lc $b->{name} } Products->getByPkey([article id])->db_options:>">Sort</a>
9<a id="reverseoptions" href="<:script:>?a_option_reorder=1&amp;_t=prodopts&amp;id=<:article id:>&amp;_csrfp=<:csrfp admin_move_option:>&amp;option_ids=<:arithmetic join ",", map $_->{id}, reverse Products->getByPkey([article id])->db_options:>">Reverse</a>
5825cab3 10<img src="/images/admin/busy.gif" id="busy_img" style="visibility: hidden" />
4de47893 11</div>
58baa27b
TC
12<div id="productoptions">
13<:iterator begin dboptions:>
14<div id="prodopt<:dboption id:>" class="prodopt">
4de47893
TC
15<div id="prodoptmenu<:dboption id:>" class="prodoptmenu">Option: <span id="prodoptname<:dboption id:>"><:dboption name:></span>
16<a href="<:script:>?id=<:article id:>&amp;a_edit_option=1&amp;option_id=<:dboption id:>">Edit</a>
17<a href="<:script:>?id=<:article id:>&amp;a_delconf_option=1&amp;option_id=<:dboption id:>">Delete</a>
18<a id="sortvals<:dboption id:>" href="<:script:>?id=<:article id:>&amp;a_option_value_reorder=1&amp;option_id=<:dboption id:>&amp;_csrfp=<:csrfp admin_move_option_value:>&amp;_t=prodopts&amp;value_ids=<:arithmetic join ',', map $_->{id}, sort { lc $a->{value} cmp lc $b->{value} } BSE::TB::ProductOptions->getByPkey([dboption id])->values:>">Sort</a>
19<a id="reversevals<:dboption id:>" href="<:script:>?id=<:article id:>&amp;a_option_value_reorder=1&amp;option_id=<:dboption id:>&amp;_csrfp=<:csrfp admin_move_option_value:>&amp;_t=prodopts&amp;value_ids=<:arithmetic join ',', map $_->{id}, reverse BSE::TB::ProductOptions->getByPkey([dboption id])->values:>">Reverse</a>
20<:dboption_move:>
21</div>
58baa27b
TC
22<:if Dboptionvalues:>
23<ul id="vallist<:dboption id:>" class="prodoptvalues">
24<:iterator begin dboptionvalues:>
25<li id="valentry<:dboptionvalue id:>"><:dboptionvalue value:> <:ifEq [dboptionvalue id] [dboption default_value]:>(default)<:or:><:eif:> <a href="<:script:>?id=<:product id:>&amp;value_id=<:dboptionvalue id:>&amp;a_edit_option_value=1">Edit</a> <a href="<:script:>?id=<:product id:>&amp;value_id=<:dboptionvalue id:>&amp;a_confdel_option_value=1">Delete</a> <:dboptionvalue_move:></li>
26<:iterator end dboptionvalues:>
27</ul>
28<form action="<:script:>" method="post" id="valform<:dboption id:>" /><input type="hidden" name="id" value="<:article id:>" /><input type="hidden" name="option_id" value="<:dboption id:>" /><input type="hidden" name="_t" value="prodopts" /><:csrfp admin_add_option_value hidden:><input type="text" name="value" /><input type="submit" name="a_add_option_value" value="Add Value" /></form>
29<:or Dboptionvalues:><:eif Dboptionvalues:>
30</div>
31<:iterator end dboptions:>
32</div>
33<:or Dboptions:><:eif Dboptions:>
34<div id="addoptionform">
35<form action="<:script:>" method="post">
36<:csrfp admin_add_option hidden:>
37<input type="hidden" name="_t" value="prodopts" />
38<input type="hidden" name="id" value="<:article id:>" />
39<table>
40 <tr>
41 <th>Name</th>
42 <td><input type="text" name="name" value="<:old name:>" size="40" maxlength="40" /><:error_img name:></td>
43 </tr>
44 <tr>
45 <th>Values</th>
46 <td><input type="text" name="value1" value="<:old value1:>" size="40" maxlength="40" /><:error_img value1:><br />
47<input type="text" name="value2" value="<:old value2:>" size="40" maxlength="40" /><:error_img value2:><br />
48<input type="text" name="value3" value="<:old value3:>" size="40" maxlength="40" /><:error_img value3:><br />
49<input type="text" name="value4" value="<:old value4:>" size="40" maxlength="40" /><:error_img value4:><br />
50<input type="text" name="value5" value="<:old value5:>" size="40" maxlength="40" /><:error_img value5:><br /></td>
51 </tr>
52 <tr>
53 <td colspan="2"><input type="submit" name="a_add_option" value="Add New Option" /></td>
54 </tr>
55</table>
56</form>
57</div>
58<div id="addoptionbutton" style="display: none">
59<a href="#" onclick="javascript: document.getElementById('addoptionform').style.display='block'; return false;">Add an option</a>
60</div>
58baa27b
TC
61<script>
62
4de47893 63<:ifDboptions:>
58baa27b
TC
64$('addoptionform').style.display='none';
65$('addoptionbutton').style.display='block';
4de47893
TC
66<:or:><:eif:>
67
58baa27b 68var prodopts = <:dboptionsjson:>;
58baa27b
TC
69var reorder_values_csrf = '<:csrfp admin_move_option_value:>';
70var reorder_options_csrf = '<:csrfp admin_move_option:>';
4de47893
TC
71var article_id = "<:article id:>";
72var edit_script = "<:script:>";
58baa27b 73
4de47893 74Event.observe(window, "load", function() { prodopts_start() });
58baa27b 75
58baa27b 76</script>