[fix] Could not install app with no install arguments #39

This commit is contained in:
opi 2014-06-11 16:51:02 +02:00
parent d4a3e98fb3
commit 7f54fa7701

View file

@ -777,51 +777,54 @@ app = Sammy('#main', function (sam) {
c.api('/apps?raw', function(data) { // http://api.yunohost.org/#!/app/app_list_get_8 c.api('/apps?raw', function(data) { // http://api.yunohost.org/#!/app/app_list_get_8
appData = data[c.params['app']]; appData = data[c.params['app']];
$.each(appData.manifest.arguments.install, function(k, v) { // Loop through installation arguments
appData.manifest.arguments.install[k].allowedValues = []; if (typeof appData.manifest.arguments.install !== 'undefined') {
$.each(appData.manifest.arguments.install, function(k, v) {
appData.manifest.arguments.install[k].allowedValues = [];
// Radio button // Radio button
if (typeof appData.manifest.arguments.install[k].choices !== 'undefined') { if (typeof appData.manifest.arguments.install[k].choices !== 'undefined') {
// Update choices values with key and checked data // Update choices values with key and checked data
$.each(appData.manifest.arguments.install[k].choices, function(ck, cv){ $.each(appData.manifest.arguments.install[k].choices, function(ck, cv){
appData.manifest.arguments.install[k].choices[ck] = { appData.manifest.arguments.install[k].choices[ck] = {
value: cv, value: cv,
key: ck, key: ck,
checked: (cv == appData.manifest.arguments.install[k].default) ? true : false, 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') {
$.each(c.params.domains, function(key, domain){
appData.manifest.arguments.install[k].allowedValues.push({
value: domain,
label: domain,
}); });
}) }
appData.manifest.arguments.install[k].help = "<a href='#/domains'>"+y18n.t('manage_domains')+"</a>";
}
// Special case for admin input. // Special case for domain input.
// Display a list of available users // Display a list of available domains
if (v.name == 'admin') { if (v.name == 'domain') {
$.each(c.params.users, function(key, user){ $.each(c.params.domains, function(key, domain){
appData.manifest.arguments.install[k].allowedValues.push({ appData.manifest.arguments.install[k].allowedValues.push({
value: user.username, value: domain,
label: user.fullname+' ('+user.mail+')' label: domain,
}); });
}) })
appData.manifest.arguments.install[k].help = "<a href='#/users'>"+y18n.t('manage_users')+"</a>"; appData.manifest.arguments.install[k].help = "<a href='#/domains'>"+y18n.t('manage_domains')+"</a>";
} }
// Multilingual description // Special case for admin input.
appData.manifest.arguments.install[k].label = (typeof appData.manifest.arguments.install[k].ask[y18n.locale] !== 'undefined') ? // Display a list of available users
appData.manifest.arguments.install[k].ask[y18n.locale] : if (v.name == 'admin') {
appData.manifest.arguments.install[k].ask['en'] $.each(c.params.users, function(key, user){
; appData.manifest.arguments.install[k].allowedValues.push({
}); value: user.username,
label: user.fullname+' ('+user.mail+')'
});
})
appData.manifest.arguments.install[k].help = "<a href='#/users'>"+y18n.t('manage_users')+"</a>";
}
// Multilingual description
appData.manifest.arguments.install[k].label = (typeof appData.manifest.arguments.install[k].ask[y18n.locale] !== 'undefined') ?
appData.manifest.arguments.install[k].ask[y18n.locale] :
appData.manifest.arguments.install[k].ask['en']
;
});
}
// Multilingual description // Multilingual description
appData.description = (typeof appData.manifest.description[y18n.locale] !== 'undefined') ? appData.description = (typeof appData.manifest.description[y18n.locale] !== 'undefined') ?