[mod] use manifest.json/actions.json args format for the config_panel.toml

This commit is contained in:
Laurent Peuch 2019-06-04 19:56:40 +02:00
parent 575d8ac6ba
commit 5383c2d4c8
3 changed files with 43 additions and 4 deletions

View file

@ -613,6 +613,9 @@ input[type='radio'].nice-radio {
margin-top: -5px; margin-top: -5px;
} }
.auto-width {
width: auto;
}
.app-card .panel-body { .app-card .panel-body {
padding: 1.5rem; padding: 1.5rem;

View file

@ -294,6 +294,11 @@
// Get app config panel // Get app config panel
app.get('#/apps/:app/config-panel', function (c) { app.get('#/apps/:app/config-panel', function (c) {
c.api('/apps/'+c.params['app']+'/config-panel', function(data) { c.api('/apps/'+c.params['app']+'/config-panel', function(data) {
$.each(data.config_panel.panel, function(_, panel) {
$.each(panel.sections, function(_, section) {
formatYunoHostStyleArguments(section.options, c.params);
});
});
c.view('app/app_config-panel', data); c.view('app/app_config-panel', data);
}); });
}); });
@ -430,6 +435,7 @@
if (args[k].type == 'boolean') { if (args[k].type == 'boolean') {
args[k].inputType = 'checkbox'; args[k].inputType = 'checkbox';
console.log(args[k]);
// Checked or not ? // Checked or not ?
if (typeof args[k].default !== 'undefined') { if (typeof args[k].default !== 'undefined') {
if (args[k].default == true) { if (args[k].default == true) {

View file

@ -36,18 +36,48 @@
<ul> <ul>
{{#options}} {{#options}}
<div class="form-group"> <div class="form-group">
<label for="{{id}}" class="col-sm-2 control-label">{{name}}</label> <label for="{{name}}" class="col-sm-2 control-label">{{label}}</label>
<div class="col-sm-10">
{{#if choices}}
<select id="{{name}}" name="{{name}}" required class="form-control" {{{attributes}}}>
{{#choices}}<option value="{{value}}" {{#if selected}}selected{{/if}}>{{label}}</option>{{/choices}}
</select>
{{else if (eq inputType "checkbox")}}
<input type="{{inputType}}" id="{{name}}" name="{{name}}" class="form-control auto-width" value="{{default}}" placeholder="{{example}}" {{required}} {{{attributes}}}>
{{else}}
<input type="{{inputType}}" id="{{name}}" name="{{name}}" class="form-control" value="{{default}}" placeholder="{{example}}" {{required}} {{{attributes}}}>
{{/if}}
{{#if helpLink}}
<span class="help-block help-block--link">{{{helpLink}}}</span>
{{/if}}
{{#if example}}
<span class="help-block help-block--example">{{t 'form_input_example' example}}</span>
{{/if}}
{{#if helpText}}
<span class="help-block">{{{helpText}}}</span>
{{/if}}
</div>
</div>
<!--
<div class="form-group">
<label for="{{name}}" class="col-sm-2 control-label">{{name}}</label>
<div class="col-sm-10"> <div class="col-sm-10">
{{#if (in type "number" "text" "password" "color" "date" "datetime-local" "email" "month number" "range" "search" "tel" "time" "url" "week")}} {{#if (in type "number" "text" "password" "color" "date" "datetime-local" "email" "month number" "range" "search" "tel" "time" "url" "week")}}
<input type="number" class="form-control" id="{{id}}" name="{{id}}" placeholder="{{placeholder}}"> <input type="number" class="form-control" id="{{name}}" name="{{name}}" placeholder="{{placeholder}}">
<span class="help-block">{{ help }}</span> <span class="help-block">{{ help }}</span>
{{else if (eq type "bool")}} {{else if (eq type "bool")}}
<input type="radio" name="{{id}}" value="true" {{#if value}}checked{{/if}}> yes <input type="radio" name="{{name}}" value="true" {{#if value}}checked{{/if}}> yes
<input type="radio" name="{{id}}" value="false"{{#if (eq value false)}}checked{{/if}}> no <input type="radio" name="{{name}}" value="false"{{#if (eq value false)}}checked{{/if}}> no
<span class="help-block">{{ help }}</span> <span class="help-block">{{ help }}</span>
{{/if}} {{/if}}
</div> </div>
</div> </div>
-->
{{/options}} {{/options}}
</ul></li> </ul></li>
</ul> </ul>