]> git.imager.perl.org - bse.git/commitdiff
support for new templating for product options
authorTony Cook <tony@develop-help.com>
Sat, 11 Apr 2020 04:15:46 +0000 (14:15 +1000)
committerTony Cook <tony@develop-help.com>
Sat, 11 Apr 2020 04:15:46 +0000 (14:15 +1000)
site/cgi-bin/modules/BSE/Edit/Product.pm
site/templates/admin/prodopt_delete.tmpl
site/templates/admin/prodopt_edit.tmpl
site/templates/admin/prodopt_value_delete.tmpl
site/templates/admin/prodopt_value_edit.tmpl

index 80978069e7abff4e374f8cb8d4dfc194a66a9937..4a67f698f09cbeb81137e1a4c62f42d6b1feb12b 100644 (file)
@@ -838,6 +838,8 @@ sub _common_option {
   keys %errors
     and return $self->_service_error($req, $article, $articles, undef, \%errors);
 
+  $req->set_variable(option => $option);
+  $req->messages($errors);
   my $it = BSE::Util::Iterate->new;
   my %acts;
   %acts =
@@ -1271,6 +1273,8 @@ sub _common_option_value {
   keys %errors
     and return $self->_service_error($req, $article, $articles, undef, \%errors);
 
+  $req->set_variable(option => $option);
+  $req->set_variable(option_value => $option_value);
   my %acts;
   %acts =
     (
index a7a5adc943cdd4d9b898d44359dee324193711fb..4e9fd61caad2c07f9e9b31d3aa6046118e5bcc02 100644 (file)
@@ -1,25 +1,26 @@
 <:wrap admin/base.tmpl title => "Delete Product Option", menuitem=>"none", showtitle=>"1" :>
 <:include admin/product_menu.tmpl:>
 <form action="<:script:>" method="post">
-<input type="hidden" name="id" value="<:article id:>" />
-<input type="hidden" name="option_id" value="<:option id:>" />
+<input type="hidden" name="id" value="<:= article.id:>" />
+<input type="hidden" name="option_id" value="<:= option.id:>" />
 <input type="hidden" name="_t" value="prodopts" />
 <:csrfp admin_delete_option hidden:>
 <table class="editform editformtiny">
 <tr>
   <th>Option:</th>
-  <td><:option name:></td>
+  <td><:= option.name:></td>
 </tr>
 <tr>
   <th>Values:</th>
 <td>
-<:if Dboptionvalues:>
-<:iterator begin dboptionvalues:>
-<div><:dboptionvalue value:></div>
-<:iterator end dboptionvalues:>
-<:or Dboptionvalues:>
+<:.set values = [ option.values ] :>
+<:.if values.size :>
+<:.for dboptionvalue in values :>
+<div><:= dboptionvalue.value:></div>
+<:.end for :>
+<:.else :>
 <p>No values defined for this option</p>
-<:eif Dboptionvalues:>
+<:.end if:>
 </td>
 </tr>
 <tr>
index 4d7ef5a8b268dc8b27d4f589ca3922f2d9c3da9b..ed84d6a5b0b1d12de779862106d2dc48b2cc0099 100644 (file)
@@ -1,21 +1,21 @@
 <:wrap admin/base.tmpl title => "Edit Product Option", menuitem=>"none", showtitle=>"1", js => "admin_editprodopt.js" :>
 <:include admin/product_menu.tmpl:>
 <form action="<:script:>" method="post">
-<input type="hidden" name="id" value="<:article id:>" />
-<input type="hidden" name="option_id" value="<:option id:>" />
+<input type="hidden" name="id" value="<:=article.id:>" />
+<input type="hidden" name="option_id" value="<:=option.id:>" />
 <input type="hidden" name="_t" value="prodopts" />
-<input type="hidden" name="newvaluecount" id="newvaluecount" value="<:ifCgi newvaluecount:><:cgi newvaluecount:><:or:>0<:eif:>" />
+<input type="hidden" name="newvaluecount" id="newvaluecount" value="<:= cgi.param("newvalue_count") or 0 :>" />
 <:csrfp admin_save_option hidden:>
 <input type="hidden" name="save_enabled" value="1" />
 <table class="editform editformsmall">
 <tr>
   <th>Name:</th>
-  <td><input type="text" name="name" value="<:old name option name:>" /></td>
-  <td class="help"><:error_img name:></td>
+  <td><input type="text" name="name" value="<:.call "old", field: "name", default: option.name :>" /></td>
+  <td class="help"><:.call "error_img", field: "name" :></td>
 </tr>
 <tr>
   <th>Enabled:</th>
-  <td><input type="checkbox" name="enabled" value="1" <:ifOld enabled option enabled:>checked="checked"<:or:><:eif:> /></td>
+  <td><input type="checkbox" name="enabled" value="1" <:.if cgi.param("save_enabled") ? cgi.param("enabled") : option.enabled:>checked="checked"<:.end if:> /></td>
   <td class="help"><:error_img name:></td>
 </tr>
 <tr>
 <table class="editform">
 <tr>
   <td colspan="2"></td>
-  <th>Default<:error_img default_value:></th>
+  <th>Default<:.call "error_img", field:"default_value":></th>
 </tr>
-<:iterator begin dboptionvalues:>
+<:.for value in [ option.values ] :>
 <tr>
   <th>Value:</th>
-  <td><input type="text" name="value<:dboptionvalue id:>" value="<:oldi [concatenate value [dboptionvalue id]] 0 dboptionvalue value:>" /><:error_img [concatenate value [dboptionvalue id]]:></td>
-  <td class="check"><input type="radio" name="default_value" value="<:dboptionvalue id:>" <:ifEq [dboptionvalue id] [option default_value]:>checked="checked"<:or:><:eif:> /></td>
+  <td><input type="text" name="value<:= value.id:>" value="<:= cgi.param("save_enabled") ? cgi.param("value" _ value.id) : value.value:>" /><:.call "error_img", field:"value" _ value.id:></td>
+  <td class="check"><input type="radio" name="default_value" value="<:= value.id:>" <:.if value.id == option.default_value:>checked="checked"<:.end if:> /></td>
 </tr>
-<:iterator end dboptionvalues:>
+<:.end for:>
 </table>
-<:if Cgi newvaluecount:>
-<:iterator begin repeats [cgi newvaluecount]:>
-<div><label for="newvalue<:repeat value:>">Value:</label>
-<input type="text" name="newvalue<:repeat value:>" value="<:cgi [cat newvalue [repeat value]]:>" /><:error_img [cat newvalue [repeat value]]:></div>
-<:iterator end repeats:>
-<:or Cgi:><:eif Cgi:>
+<:.if cgi.param("newvaluecount"):>
+<:.for i in [ 1 .. cgi.param("newvaluecount") ] :>
+<div><label for="newvalue<:= i:>">Value:</label>
+<input type="text" name="newvalue<:= i:>" value="<:=cgi.param("newvalue" _ i) :>:>" /><:.call "error_img", field:"newvalue" _ i :></div>
+<:.end for :>
+<:.end if :>
 </td>
 <td class="help"></td>
 </tr>
index 6eb5d16a7c6488be13e077804778b24f25f2875f..febed0b55651e40a2cc1db7adcd3e977c4a5bcb1 100644 (file)
@@ -1,8 +1,8 @@
 <:wrap admin/base.tmpl title => "Delete Product Option Value", menuitem=>"prodopt_delete", showtitle => "1" :>
 <:include admin/product_menu.tmpl:>
 <form action="<:script:>" method="post">
-<input type="hidden" name="id" value="<:article id:>" />
-<input type="hidden" name="value_id" value="<:option_value id:>" />
+<input type="hidden" name="id" value="<:= article.id:>" />
+<input type="hidden" name="value_id" value="<:= option_value.id:>" />
 <input type="hidden" name="_t" value="prodopts" />
 <:csrfp admin_delete_option_value hidden:>
 <table class="editform editformtiny">
@@ -12,7 +12,7 @@
 </tr>
 <tr>
   <th>Value:</th>
-  <td><:option_value value:></td>
+  <td><:= option_value.value:></td>
 </tr>
 <tr>
   <td colspan="2" class="buttons">
index af29c70d34e17245b8d04c4c4f62fbda32744857..21207cbfb9b0aeabb333293f1e8c91fe9c86b2e7 100644 (file)
@@ -1,19 +1,19 @@
 <:wrap admin/base.tmpl title => "Edit Product Option Value", menuitem=>"none", showtitle=>"1" :>
 <:include admin/product_menu.tmpl:>
 <form action="<:script:>" method="post">
-<input type="hidden" name="id" value="<:article id:>" />
-<input type="hidden" name="value_id" value="<:option_value id:>" />
+<input type="hidden" name="id" value="<:= article.id:>" />
+<input type="hidden" name="value_id" value="<:= option_value.id:>" />
 <input type="hidden" name="_t" value="prodopts" />
 <:csrfp admin_save_option_value hidden:>
 <table class="editform editformsmall">
 <tr>
   <th>Option:</th>
-  <td><:option name:></td>
+  <td><:= option.name:></td>
   <td></td>
 </tr>
 <tr>
 <th>Value:</th>
-<td><input type="text" name="value" value="<:old value option_value value:>" /></td><td class="help"><:error_img value:></td></tr>
+<td><input type="text" name="value" value="<:.call "old", field: "value", default: option_value.value :>" /></td><td class="help"><:.call "error_img", field: "value":></td></tr>
 <tr>
   <td class="buttons" colspan="3"><input type="submit" name="a_save_option_value" value="Save" /><input type="submit" value="Return to product options" /></td>
 </tr>