[enh] Support boolean argument type in app manifest. #141

This commit is contained in:
opi 2016-02-04 11:43:54 +01:00
parent 1a65ea8b20
commit 4b6ca71cfa
5 changed files with 34 additions and 5 deletions

View file

@ -477,6 +477,19 @@ input[type='radio'].nice-radio {
}
/** App install form **/
.form-app-install {
.form-group {
label {cursor: pointer;}
}
.form-control {
&[type="checkbox"] {
height: auto;
width: auto;
}
}
}
/** Flash messages **/
#flashMessage {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -101,6 +101,7 @@
data.manifest.arguments.install[k].type = (typeof v.type !== 'undefined') ? v.type : 'string';
data.manifest.arguments.install[k].inputType = 'text';
data.manifest.arguments.install[k].required = (typeof v.optional !== 'undefined' && v.optional == "true") ? '' : 'required';
data.manifest.arguments.install[k].attributes = "";
// Input with choices becomes select list
if (typeof data.manifest.arguments.install[k].choices !== 'undefined') {
@ -155,6 +156,21 @@
data.manifest.arguments.install[k].help = "<a href='#/apps'>"+y18n.t('manage_apps')+"</a>";
}
// Boolean fields
if (data.manifest.arguments.install[k].type == 'boolean') {
data.manifest.arguments.install[k].inputType = 'checkbox';
// Checked or not ?
if (typeof data.manifest.arguments.install[k].default !== 'undefined') {
if (data.manifest.arguments.install[k].default == "True" || data.manifest.arguments.install[k].default == "1") {
data.manifest.arguments.install[k].attributes = 'checked="checked"';
}
}
// 'default' is used as value, so we need to force it for checkboxes.
data.manifest.arguments.install[k].default = 1;
}
// 'password' type input.
if (v.name == 'password' || data.manifest.arguments.install[k].type == 'password') {
// Change html input type

View file

@ -7,7 +7,7 @@
<div class="separator"></div>
<form action="#/apps" method="POST" class="form-horizontal">
<form action="#/apps" method="POST" class="form-horizontal form-app-install">
<div class="panel panel-default">
<div class="panel-heading">
@ -43,11 +43,11 @@
<div class="col-sm-12">
{{#if choices}}
<select id="{{name}}" name="{{name}}" required class="form-control">
<select id="{{name}}" name="{{name}}" required class="form-control" {{attributes}}>
{{#choices}}<option value="{{value}}" {{#if selected}}selected{{/if}}>{{label}}</option>{{/choices}}
</select>
{{else}}
<input type="{{inputType}}" id="{{name}}" name="{{name}}" class="form-control" value="{{default}}" placeholder="{{example}}" {{required}}>
<input type="{{inputType}}" id="{{name}}" name="{{name}}" class="form-control" value="{{default}}" placeholder="{{example}}" {{required}} {{attributes}}>
{{/if}}
{{#if help}}