Commit 0d056ca9 authored by Floreal Cabanettes's avatar Floreal Cabanettes
Browse files

Auto-fill multiple parameters with files

parent 57f6d359
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="109.68"
height="24.615999"
viewBox="0 0 109.68 24.616"
id="svg3423"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="add_files-hover.svg">
<defs
id="defs3425" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="4.1497989"
inkscape:cx="12.788788"
inkscape:cy="58.46255"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
units="px"
inkscape:window-width="1680"
inkscape:window-height="961"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1" />
<metadata
id="metadata3428">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Calque 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1027.7461)">
<rect
style="fill:#646464;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
id="rect3465"
width="108.67997"
height="23.61554"
x="0.5"
y="1028.2466"
rx="3"
ry="3" />
<g
transform="translate(1.8079691,-0.79597884)"
id="g3394">
<path
style="fill:#27ae60"
inkscape:connector-curvature="0"
d="M 22,12 C 22,17.523 17.523,22 12,22 6.4772,22 2,17.523 2,12 2,6.4772 6.4772,2 12,2 17.523,2 22,6.4772 22,12 Z"
transform="translate(0,1029.4)"
id="path3396" />
<path
style="fill:#2ecc71"
inkscape:connector-curvature="0"
d="M 22,12 C 22,17.523 17.523,22 12,22 6.4772,22 2,17.523 2,12 2,6.4772 6.4772,2 12,2 17.523,2 22,6.4772 22,12 Z"
transform="translate(0,1028.4)"
id="path3398" />
<path
style="fill:#27ae60"
inkscape:connector-curvature="0"
d="m 6.0001,1042.4 4.9999,0 0,5 2,0 0,-5 5,0 0,-2 -5,0 0,-5 -2,0 0,5 -4.9999,0 0,2 z"
id="path3400" />
<path
style="fill:#ecf0f1"
inkscape:connector-curvature="0"
d="m 6,1041.4 5,0 0,5 2,0 0,-5 5,0 0,-2 -5,0 0,-5 -2,0 0,5 -5,0 0,2 z"
id="path3402" />
</g>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:40px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
x="30.453163"
y="1045.8376"
id="text4267"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan4269"
x="30.453163"
y="1045.8376"
style="font-size:17.5px;fill:#ffffff;fill-opacity:1">Add files</tspan></text>
</g>
</svg>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="109.68"
height="24.615999"
viewBox="0 0 109.68 24.616"
id="svg3423"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="add_files.svg">
<defs
id="defs3425" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="4.1497989"
inkscape:cx="54.959506"
inkscape:cy="58.46255"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
units="px"
inkscape:window-width="1680"
inkscape:window-height="961"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1" />
<metadata
id="metadata3428">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Calque 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1027.7461)">
<rect
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
id="rect3465"
width="108.67997"
height="23.61554"
x="0.5"
y="1028.2466"
rx="3"
ry="3" />
<g
transform="translate(1.8079691,-0.79597884)"
id="g3394">
<path
style="fill:#27ae60"
inkscape:connector-curvature="0"
d="M 22,12 C 22,17.523 17.523,22 12,22 6.4772,22 2,17.523 2,12 2,6.4772 6.4772,2 12,2 17.523,2 22,6.4772 22,12 Z"
transform="translate(0,1029.4)"
id="path3396" />
<path
style="fill:#2ecc71"
inkscape:connector-curvature="0"
d="M 22,12 C 22,17.523 17.523,22 12,22 6.4772,22 2,17.523 2,12 2,6.4772 6.4772,2 12,2 17.523,2 22,6.4772 22,12 Z"
transform="translate(0,1028.4)"
id="path3398" />
<path
style="fill:#27ae60"
inkscape:connector-curvature="0"
d="m 6.0001,1042.4 4.9999,0 0,5 2,0 0,-5 5,0 0,-2 -5,0 0,-5 -2,0 0,5 -4.9999,0 0,2 z"
id="path3400" />
<path
style="fill:#ecf0f1"
inkscape:connector-curvature="0"
d="m 6,1041.4 5,0 0,5 2,0 0,-5 5,0 0,-2 -5,0 0,-5 -2,0 0,5 -5,0 0,2 z"
id="path3402" />
</g>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:40px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
x="30.453163"
y="1045.8376"
id="text4267"
sodipodi:linespacing="125%"><tspan
sodipodi:role="line"
id="tspan4269"
x="30.453163"
y="1045.8376"
style="font-size:17.5px;fill:#ffffff;fill-opacity:1">Add files</tspan></text>
</g>
</svg>
......@@ -230,6 +230,20 @@ color:#777;
background-color:#F7F7F9;
}
.selectMultipleFiles {
margin-bottom: 5px;
background: transparent url("images/add_files.svg") no-repeat 0 0;
background-size: 99px 22px;
width: 99px;
height: 22px;
padding: 0;
border: None;
}
.selectMultipleFiles:hover {
background-image: url("images/add_files-hover.svg");
}
@-moz-keyframes fadeG{
0%{
background-color:#000000}
......
......@@ -470,10 +470,12 @@ class MultiParameter(dict, AbstractParameter):
class MultiParameterList(list, AbstractParameter):
def __init__(self, name, help, required=False, flag=None, group="default", display_name=None, cmd_format="", argpos=-1, rules=None):
def __init__(self, name, help, required=False, flag=None, group="default", display_name=None, cmd_format="",
argpos=-1, rules=None, fill_files=False):
AbstractParameter.__init__(self, name, help, required=required, type="multiple", flag=flag,
action="append", group=group, display_name=display_name,
cmd_format=cmd_format, argpos=argpos, rules=rules)
self.fill_files = fill_files
return list.__init__(self, [])
def add_sub_parameter(self, param):
......
......@@ -283,6 +283,8 @@ class JFlowServer (object):
"name": param.name + JFlowServer.MULTIPLE_TYPE_SPLITER + sub_param.flag,
"display_name": sub_param.display_name,
"group": sub_param.group})
if hasattr(param, "fill_files"):
hash_param["fill_files"] = param.fill_files
if hash_param["sub_parameters"][-1]["type"] == "date":
hash_param["sub_parameters"][-1]["format"] = self.jflow_config_reader.get_date_format()
if hash_param["sub_parameters"][-1]["format"] == '%d/%m/%Y':
......
......@@ -245,10 +245,11 @@ class Workflow(threading.Thread):
rules=rules)
self.__setattr__(name, new_param)
def add_multiple_parameter_list(self, name, help, required=False, flag=None, group="default", display_name=None, rules=None):
def add_multiple_parameter_list(self, name, help, required=False, flag=None, group="default", display_name=None,
rules=None, fill_files=False):
self.params_order.append(name)
new_param = MultiParameterList(name, help, flag=flag, required=required, group=group, display_name=display_name,
rules=rules)
rules=rules, fill_files=fill_files)
self.__setattr__(name, new_param)
def add_parameter(self, name, help, default=None, type=str, choices=None,
......
......@@ -15,7 +15,6 @@
script: '/get_user_files',
multiSelect: true
}).on('filetreeclicked', function(e, data) {
console.log("click")
var file = data.li.find("a").attr("rel");
if (data.li.find("input[type=checkbox]").is(":checked")) {
if (!multiple) {
......
......@@ -857,6 +857,13 @@ Handsontable.cellTypes["bootdate"] = Handsontable.BootstrapDateCell;
}
});
setClickServerBrowser(params);
$(".selectMultipleFiles").click(function() {
var func = $(this).attr("fill-function");
var fill_files = function(files) { eval(func)};
JflowBrowser.exec(fill_files, true);
return false;
})
$(".to-readonly").on("focusin", function(event) {
$(this).prop('readonly', true);
......@@ -1248,6 +1255,9 @@ Handsontable.cellTypes["bootdate"] = Handsontable.BootstrapDateCell;
// if it's a multiple type
' {{if param.type == "MultipleParameters"}}',
' <blockquote style="font-size:14px;">',
' {{if param.fill_files}}',
' <button class="selectMultipleFiles" for="${param.name}" fill-function="${param.fill_files}"></button>',
' {{/if}}',
' {{if param.action == "MiltipleAppendAction"}}', // if it's an append and multiple type
' <div id="handsontable_${param.name}" > </div>',
' <span id="error_handsontable_${param.name}" class="help-block" for="read_2"></span>',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment