[enh] modifying a section of a config panel works

This commit is contained in:
Laurent Peuch 2018-06-18 04:19:46 +02:00
parent bacc9c5e7c
commit 1444883b9a
2 changed files with 23 additions and 2 deletions

View file

@ -167,6 +167,27 @@
});
});
app.post('#/apps/:app/config', function(c) {
// taken from app install
$.each(c.params, function(k, v) {
if (typeof(v) === 'object' && Array.isArray(v)) {
// And return only first value
c.params[k] = v[0];
}
});
var app_id = c.params['app'];
delete c.params['app'];
var params = {
'args': c.serialize(c.params.toHash())
}
c.api('/apps/'+app_id+'/config', function() { // http://api.yunohost.org/#!/app/app_install_post_2
c.redirect('#/apps/'+app_id+'/config-panel');
}, 'POST', params);
})
// Special case for custom app installation.
app.get('#/apps/install/custom', function (c) {
// If we try to GET /apps/install/custom, it means that installation fail.

View file

@ -25,7 +25,7 @@
</div>
<div id="collapse-{{ @index }}" class="panel-collapse {{#if (neq @index 0)}}collapse{{/if}}" role="tabpanel" aria-labelledby="heading-{{ @index }}">
<div class="panel-body">
<form class="form-horizontal">
<form class="form-horizontal" action="#/apps/{{../../app_id}}/config" method="POST">
{{#sections}}
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title">{{name}} <small>{{help}}</small></h3></div>
@ -36,7 +36,7 @@
<label for="{{id}}" class="col-sm-2 control-label">{{name}}</label>
<div class="col-sm-10">
{{#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}}" placeholder="{{placeholder}}">
<input type="number" class="form-control" id="{{id}}" name="{{id}}" placeholder="{{placeholder}}">
<span class="help-block">{{ help }}</span>
{{else if (eq type "bool")}}
<input type="radio" name="{{id}}" value="true" {{#if value}}checked{{/if}}> yes