Rename 'hooks' to system or system_parts in backup stuff (#196)

* Fix a bug when trying to uncheck boxes of apps (id key does not exists)
* Rename 'hooks' to system or system_parts to be more semantic and match new option --system
This commit is contained in:
Alexandre Aubin 2018-06-15 15:30:41 +02:00 committed by GitHub
parent f9173548fa
commit 739bb08f4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 22 deletions

View file

@ -62,7 +62,7 @@
app.post('#/backup/:storage', function (c) { app.post('#/backup/:storage', function (c) {
var params = c.ungroupHooks(c.params['hooks'],c.params['apps']); var params = c.ungroupHooks(c.params['system_parts'],c.params['apps']);
c.api('/backup', function() { c.api('/backup', function() {
store.clear('slide'); store.clear('slide');
c.redirect('#/backup/'+ c.params['storage']); c.redirect('#/backup/'+ c.params['storage']);
@ -75,7 +75,7 @@
y18n.t('backup'), y18n.t('backup'),
y18n.t('confirm_restore', [c.params['archive']]), y18n.t('confirm_restore', [c.params['archive']]),
$.proxy(function(c){ $.proxy(function(c){
var params = c.ungroupHooks(c.params['hooks'],c.params['apps']); var params = c.ungroupHooks(c.params['system_parts'],c.params['apps']);
params['force'] = ''; params['force'] = '';
c.api('/backup/restore/'+c.params['archive'], function(data) { c.api('/backup/restore/'+c.params['archive'], function(data) {
store.clear('slide'); store.clear('slide');
@ -134,7 +134,7 @@
}; };
data.other_storages = []; data.other_storages = [];
data.name = c.params['archive']; data.name = c.params['archive'];
data.hooks = c.groupHooks(Object.keys(data['system'])); data.system_parts = c.groupHooks(Object.keys(data['system']));
data.items = (data['hooks']!={} || data['apps']!=[]); data.items = (data['hooks']!={} || data['apps']!=[]);
c.view('backup/backup_info', data); c.view('backup/backup_info', data);
}); });

View file

@ -359,32 +359,31 @@
return data; return data;
}, },
ungroupHooks: function(hooks,apps) { ungroupHooks: function(system_parts,apps) {
var data = {}; var data = {};
data['apps'] = apps || []; data['apps'] = apps || [];
data['hooks'] = hooks || []; data['system'] = system_parts || [];
if (data['hooks'].constructor !== Array) { if (data['system'].constructor !== Array) {
data['hooks'] = [data['hooks']]; data['system'] = [data['system']];
} }
if (data['apps'].constructor !== Array) { if (data['apps'].constructor !== Array) {
data['apps'] = [data['apps']]; data['apps'] = [data['apps']];
} }
if (data['hooks'].length == 0) {
data['ignore_hooks'] = '';
}
if (data['apps'].length == 0) {
data['ignore_apps'] = '';
}
// Some hook value contains multiple hooks separated by commas // Some hook value contains multiple hooks separated by commas
var split_hooks = []; var split_hooks = [];
$.each(data['hooks'], function(i, hook) { $.each(data['system'], function(i, hook) {
split_hooks = split_hooks.concat(hook.split(',')); split_hooks = split_hooks.concat(hook.split(','));
}); });
data['hooks'] = split_hooks; data['system'] = split_hooks;
if (data['system'].length == 0) {
delete data['system'];
}
if (data['apps'].length == 0) {
delete data['apps'];
}
return data; return data;
}, },

View file

@ -15,7 +15,7 @@
<div class="list-group"> <div class="list-group">
{{#each hooks}} {{#each hooks}}
<div class="list-group-item"> <div class="list-group-item">
<input type="checkbox" id="{{@key}}" name="hooks" value="{{value}}" checked class="nice-checkbox"> <input type="checkbox" id="{{@key}}" name="system_parts" value="{{value}}" checked class="nice-checkbox">
<label for="{{@key}}" class="pull-right"><span class="sr-only">{{t 'check'}}</span></label> <label for="{{@key}}" class="pull-right"><span class="sr-only">{{t 'check'}}</span></label>
<h2 class="list-group-item-heading">{{name}}</h2> <h2 class="list-group-item-heading">{{name}}</h2>
<p class="list-group-item-text">{{description}}</p> <p class="list-group-item-text">{{description}}</p>

View file

@ -29,9 +29,9 @@
</div> </div>
{{#if items}} {{#if items}}
<div class="list-group"> <div class="list-group">
{{#each hooks}} {{#each system_parts}}
<div class="list-group-item"> <div class="list-group-item">
<input type="checkbox" id="{{@key}}" name="hooks" value="{{value}}" checked class="nice-checkbox"> <input type="checkbox" id="{{@key}}" name="system_parts" value="{{value}}" checked class="nice-checkbox">
<label for="{{@key}}" class="pull-right"><span class="sr-only">{{t 'check'}}</span></label> <label for="{{@key}}" class="pull-right"><span class="sr-only">{{t 'check'}}</span></label>
<h2 class="list-group-item-heading">{{name}}</h2> <h2 class="list-group-item-heading">{{name}}</h2>
<p class="list-group-item-text">{{description}}</p> <p class="list-group-item-text">{{description}}</p>
@ -39,9 +39,9 @@
{{/each}} {{/each}}
{{#each apps}} {{#each apps}}
<div class="list-group-item"> <div class="list-group-item">
<input type="checkbox" id="{{id}}" name="apps" value="{{id}}" checked class="nice-checkbox"> <input type="checkbox" id="{{@key}}" name="apps" value="{{@key}}" checked class="nice-checkbox">
<label for="{{id}}" class="pull-right"><span class="sr-only">{{t 'check'}}</span></label> <label for="{{@key}}" class="pull-right"><span class="sr-only">{{t 'check'}}</span></label>
<h2 class="list-group-item-heading">{{name}} <small>{{id}}</small></h2> <h2 class="list-group-item-heading">{{name}} <small>{{@key}}</small></h2>
</div> </div>
{{/each}} {{/each}}
<div class="list-group-item clearfix"> <div class="list-group-item clearfix">