code from amapei
This commit is contained in:
Executable
+46
@@ -0,0 +1,46 @@
|
||||
package form;
|
||||
import sugoi.form.elements.RadioGroup;
|
||||
import Common;
|
||||
|
||||
class ColorRadioGroup extends RadioGroup
|
||||
{
|
||||
|
||||
public function new(name:String, label:String,selected:String)
|
||||
{
|
||||
var data = [];
|
||||
var i = 0;
|
||||
for (c in db.CategoryGroup.COLORS) {
|
||||
data.push( { value:Std.string(c), label:Std.string(i) } );
|
||||
i++;
|
||||
}
|
||||
|
||||
super(name, label, data, selected, "1", false, true);
|
||||
}
|
||||
|
||||
override public function render():String
|
||||
{
|
||||
var s = "";
|
||||
var n = parentForm.name + "_" +name;
|
||||
|
||||
var c = 0;
|
||||
if (data != null)
|
||||
{
|
||||
for (row in data)
|
||||
{
|
||||
|
||||
var radio = "<input type=\"radio\" name=\""+n+"\" id=\""+n+c+"\" value=\"" + row.label + "\" " + (row.label == Std.string(value) ? "checked":"") +" />\n";
|
||||
|
||||
var img = "<div style='margin-right:16px;width:32px;height:32px;background:"+App.current.view.intToHex(Std.parseInt(row.value))+";'></div>";
|
||||
|
||||
s += "<label for=\"" + n+c + "\" class='checkbox' style='display: inline-block;'>"+radio + " "+img+" </label>";
|
||||
|
||||
c++;
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Executable
+50
@@ -0,0 +1,50 @@
|
||||
package form;
|
||||
import db.Product;
|
||||
import sugoi.form.elements.RadioGroup;
|
||||
import db.Product;
|
||||
import Common;
|
||||
/**
|
||||
* list des types de produits avec image
|
||||
* @author
|
||||
*/
|
||||
class ProductTypeRadioGroup extends RadioGroup
|
||||
{
|
||||
|
||||
public function new(name:String, label:String,selected:String)
|
||||
{
|
||||
var data = [];
|
||||
var i = 0;
|
||||
for (e in Type.getEnumConstructs(ProductType)) {
|
||||
data.push( { key:Std.string(i), value:Std.string(e) } );
|
||||
i++;
|
||||
}
|
||||
|
||||
super(name, label, data, selected, "1", false, true);
|
||||
}
|
||||
|
||||
override public function render():String
|
||||
{
|
||||
var s = "";
|
||||
var n = parentForm.name + "_" +name;
|
||||
|
||||
var c = 0;
|
||||
if (data != null)
|
||||
{
|
||||
for (row in data)
|
||||
{
|
||||
|
||||
|
||||
var radio = "<input type=\"radio\" name=\""+n+"\" id=\""+n+c+"\" value=\"" + row.key + "\" " + (row.key == Std.string(value) ? "checked":"") +" />\n";
|
||||
var e = Type.createEnumIndex(ProductType, Std.parseInt(row.key));
|
||||
var img = "<img src='/img/"+Std.string(e).toLowerCase().substring(2)+".png' />";
|
||||
|
||||
s += "<label for=\"" + n+c + "\" class='checkbox' style='display: inline-block;'>"+radio + " "+img+" </label>";
|
||||
|
||||
c++;
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package form;
|
||||
import Common;
|
||||
/**
|
||||
* ...
|
||||
* @author fbarbut
|
||||
*/
|
||||
class UnitQuantity extends sugoi.form.elements.FloatInput
|
||||
{
|
||||
|
||||
var unit : Unit;
|
||||
|
||||
public function new(name, label, value, ?required=false,unit){
|
||||
super(name, label, value, required);
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
override function render(){
|
||||
|
||||
var r = super.render();
|
||||
return '
|
||||
<div class="input-group">
|
||||
'+r+'
|
||||
<div class="input-group-addon">'+App.current.view.unit(unit)+'</div>
|
||||
</div>';
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user