Handle 'choices' with radios on app_install.

This commit is contained in:
opi 2014-02-21 15:49:13 +01:00
parent 97b6d59d90
commit db9e70d34f
2 changed files with 23 additions and 1 deletions

View file

@ -524,6 +524,18 @@ app = Sammy('#main', function (sam) {
$.each(appData.manifest.arguments.install, function(k, v) {
appData.manifest.arguments.install[k].allowedValues = [];
// Radio button
if (typeof appData.manifest.arguments.install[k].choices !== 'undefined') {
// Update choices values with key and checked data
$.each(appData.manifest.arguments.install[k].choices, function(ck, cv){
appData.manifest.arguments.install[k].choices[ck] = {
value: cv,
key: ck,
checked: (cv == appData.manifest.arguments.install[k].default) ? true : false,
};
});
}
// Special case for domain input.
// Display a list of available domains
if (v.name == 'domain') {

View file

@ -43,7 +43,17 @@
{{#allowedValues}}<option value="{{value}}">{{label}}</option>{{/allowedValues}}
</select>
{{else}}
<input type="text" name="{{name}}" class="form-control" value="{{default}}" placeholder="{{example}}" required>
{{#if choices}}
{{#each choices}}
<div class="radio">
<label for="{{../name}}-{{key}}">
<input type="radio" id="{{../name}}-{{key}}" name="{{../name}}" value="{{value}}" {{#if checked}}checked{{/if}} required> {{value}}
</label>
</div>
{{/each}}
{{else}}
<input type="text" name="{{name}}" class="form-control" value="{{default}}" placeholder="{{example}}" required>
{{/if}}
{{/if}}
{{#if help}}