reduce the JSON size needed to store the field settings by storing only what it's not assumed by default #7

This commit is contained in:
bfcamara 2015-07-22 22:05:15 +01:00
Родитель 6ac1684e61
Коммит 5404276522
3 изменённых файлов: 23 добавлений и 7 удалений

25
app.js
Просмотреть файл

@ -292,7 +292,12 @@
if (!this.vm.isAppLoadedOk) {
//Initialize global data
this.vm.fieldSettings = JSON.parse(this.setting('vso_field_settings') || DEFAULT_FIELD_SETTINGS);
try {
this.vm.fieldSettings = JSON.parse(this.setting('vso_field_settings') || DEFAULT_FIELD_SETTINGS);
} catch (ex) {
services.notify(this.I18n.t('errorReadingFieldSettings'), 'alert');
this.vm.fieldSettings = JSON.parse(DEFAULT_FIELD_SETTINGS);
}
this.when(
this.ajax('getVsoProjects'),
this.ajax('getVsoFields')
@ -439,10 +444,20 @@
var fieldSettings = {};
this.$('tr').each(function () {
var line = self.$(this);
fieldSettings[line.attr('data-refName')] = {
summary: line.find('.summary').is(':checked'),
details: line.find('.details').is(':checked')
};
var fieldName = line.attr('data-refName');
if (!fieldName) return true; //continue
var inSummary = line.find('.summary').is(':checked');
var inDetails = line.find('.details').is(':checked');
if (inSummary || inDetails) {
fieldSettings[fieldName] = {
summary: inSummary,
details: inDetails
};
} else if (fieldSettings[fieldName]) {
delete fieldName[fieldName];
}
});
this.vm.fieldSettings = fieldSettings;
this.ajax('saveSettings', { vso_field_settings: JSON.stringify(fieldSettings) })

Просмотреть файл

@ -9,7 +9,7 @@
"defaultLocale": "en",
"singleInstall": true,
"frameworkVersion": "1.0",
"version": "0.3",
"version": "0.3.1",
"parameters": [
{
"name": "vso_account",

Просмотреть файл

@ -120,5 +120,6 @@
"errorLoadingApp": "Something went wrong while loading the app. Confirm that your Visual Studio Online alternate credentials are correct by clicking in the user icon.",
"errorInvalidAccount": "The Visual Studio Online account '{{accountName}}' doesn't exist or you don't have access to it. Contact your Zendesk account Administrator to check and review the app settings.",
"errorLoadingWorkItems": "Something went wrong while loading working items. Click the refresh icon to try again.",
"errorOoops" : "Ooops!"
"errorOoops": "Ooops!",
"errorReadingFieldSettings": "There was an error while reading field settings. Applying default settings."
}