mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
[enh] Support boolean argument type in app manifest. #141
This commit is contained in:
parent
1a65ea8b20
commit
4b6ca71cfa
5 changed files with 34 additions and 5 deletions
|
@ -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 **/
|
/** Flash messages **/
|
||||||
#flashMessage {
|
#flashMessage {
|
||||||
|
|
2
src/dist/css/style.min.css
vendored
2
src/dist/css/style.min.css
vendored
File diff suppressed because one or more lines are too long
2
src/dist/js/script.min.js
vendored
2
src/dist/js/script.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -101,6 +101,7 @@
|
||||||
data.manifest.arguments.install[k].type = (typeof v.type !== 'undefined') ? v.type : 'string';
|
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].inputType = 'text';
|
||||||
data.manifest.arguments.install[k].required = (typeof v.optional !== 'undefined' && v.optional == "true") ? '' : 'required';
|
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
|
// Input with choices becomes select list
|
||||||
if (typeof data.manifest.arguments.install[k].choices !== 'undefined') {
|
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>";
|
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.
|
// 'password' type input.
|
||||||
if (v.name == 'password' || data.manifest.arguments.install[k].type == 'password') {
|
if (v.name == 'password' || data.manifest.arguments.install[k].type == 'password') {
|
||||||
// Change html input type
|
// Change html input type
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
<div class="separator"></div>
|
<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 panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
|
@ -43,11 +43,11 @@
|
||||||
<div class="col-sm-12">
|
<div class="col-sm-12">
|
||||||
|
|
||||||
{{#if choices}}
|
{{#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}}
|
{{#choices}}<option value="{{value}}" {{#if selected}}selected{{/if}}>{{label}}</option>{{/choices}}
|
||||||
</select>
|
</select>
|
||||||
{{else}}
|
{{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}}
|
||||||
|
|
||||||
{{#if help}}
|
{{#if help}}
|
||||||
|
|
Loading…
Reference in a new issue