[enh] Display help text from manifest during app installation. (#152)

This commit is contained in:
opi 2017-04-06 15:49:57 +02:00 committed by Alexandre Aubin
parent b7d9e3c28b
commit eef82ec93d
3 changed files with 45 additions and 18 deletions

View file

@ -356,14 +356,16 @@ div.br {
background-position: center top; background-position: center top;
} }
.help-block { .help-block--link {
text-align: right; float: right;
margin-left: 2em;
} }
.example-help-block { .help-block--help {
text-align: left; margin: 0 0 5px 0;
float: left;
} }
.help-block--example {}
.quota-help-block { .quota-help-block {
text-align: left; text-align: left;
line-height: 1.2; line-height: 1.2;
@ -514,6 +516,7 @@ input[type='radio'].nice-radio {
/** App install form **/ /** App install form **/
.form-app-install { .form-app-install {
.form-group { .form-group {
margin-bottom: 25px;
label {cursor: pointer;} label {cursor: pointer;}
} }
.form-control { .form-control {

View file

@ -100,6 +100,23 @@
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 = ""; data.manifest.arguments.install[k].attributes = "";
data.manifest.arguments.install[k].helpText = "";
data.manifest.arguments.install[k].helpLink = "";
// Multilingual label
data.manifest.arguments.install[k].label = (typeof data.manifest.arguments.install[k].ask[y18n.locale] !== 'undefined') ?
data.manifest.arguments.install[k].ask[y18n.locale] :
data.manifest.arguments.install[k].ask['en']
;
// Multilingual help text
if (typeof data.manifest.arguments.install[k].help !== 'undefined') {
data.manifest.arguments.install[k].helpText = (typeof data.manifest.arguments.install[k].help[y18n.locale] !== 'undefined') ?
data.manifest.arguments.install[k].help[y18n.locale] :
data.manifest.arguments.install[k].help['en']
;
}
// 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') {
@ -132,7 +149,9 @@
selected: false selected: false
}); });
}); });
data.manifest.arguments.install[k].help = "<a href='#/domains'>"+y18n.t('manage_domains')+"</a>";
// Custom help link
data.manifest.arguments.install[k].helpLink += "<a href='#/domains'>"+y18n.t('manage_domains')+"</a>";
} }
// Special case for admin / user input. // Special case for admin / user input.
@ -146,7 +165,9 @@
selected: false selected: false
}); });
}); });
data.manifest.arguments.install[k].help = "<a href='#/users'>"+y18n.t('manage_users')+"</a>";
// Custom help link
data.manifest.arguments.install[k].helpLink += "<a href='#/users'>"+y18n.t('manage_users')+"</a>";
} }
// 'app' type input display a list of available apps // 'app' type input display a list of available apps
@ -159,7 +180,9 @@
selected: false selected: false
}); });
}); });
data.manifest.arguments.install[k].help = "<a href='#/apps'>"+y18n.t('manage_apps')+"</a>";
// Custom help link
data.manifest.arguments.install[k].helpLink += "<a href='#/apps'>"+y18n.t('manage_apps')+"</a>";
} }
// Boolean fields // Boolean fields
@ -194,12 +217,6 @@
data.manifest.arguments.install[k].inputType = 'password'; data.manifest.arguments.install[k].inputType = 'password';
} }
// Multilingual label
data.manifest.arguments.install[k].label = (typeof data.manifest.arguments.install[k].ask[y18n.locale] !== 'undefined') ?
data.manifest.arguments.install[k].ask[y18n.locale] :
data.manifest.arguments.install[k].ask['en']
;
}); });
} }

View file

@ -40,6 +40,11 @@
{{#manifest.arguments.install}} {{#manifest.arguments.install}}
<div class="form-group"> <div class="form-group">
<label for="{{name}}" class="col-sm-12">{{label}}</label> <label for="{{name}}" class="col-sm-12">{{label}}</label>
{{#if helpText}}
<span class="help-block help-block--help col-sm-12">{{{helpText}}}</span>
{{/if}}
<div class="col-sm-12"> <div class="col-sm-12">
{{#if choices}} {{#if choices}}
@ -50,12 +55,14 @@
<input type="{{inputType}}" id="{{name}}" name="{{name}}" class="form-control" value="{{default}}" placeholder="{{example}}" {{required}} {{{attributes}}}> <input type="{{inputType}}" id="{{name}}" name="{{name}}" class="form-control" value="{{default}}" placeholder="{{example}}" {{required}} {{{attributes}}}>
{{/if}} {{/if}}
{{#if helpLink}}
<span class="help-block help-block--link">{{{helpLink}}}</span>
{{/if}}
{{#if example}} {{#if example}}
<span class="help-block example-help-block">{{t 'form_input_example' example}}</span> <span class="help-block help-block--example">{{t 'form_input_example' example}}</span>
{{/if}}
{{#if help}}
<span class="help-block">{{{help}}}</span>
{{/if}} {{/if}}
</div> </div>
</div> </div>
{{/manifest.arguments.install}} {{/manifest.arguments.install}}