2016-04-20 18:03:50 +03:00
|
|
|
/* global OC */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Copyright (c) 2016, Christoph Wurst <christoph@owncloud.com>
|
|
|
|
*
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or later.
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
'use strict';
|
|
|
|
|
2021-03-30 11:18:23 +03:00
|
|
|
var errorNotification;
|
|
|
|
|
2016-04-20 18:03:50 +03:00
|
|
|
/**
|
|
|
|
* Model for storing and saving user settings
|
|
|
|
*
|
|
|
|
* @class UserSettings
|
|
|
|
*/
|
|
|
|
var UserSettings = OC.Backbone.Model.extend({
|
|
|
|
url: OC.generateUrl('/settings/users/{id}/settings', {id: OC.currentUser}),
|
2016-04-21 12:19:10 +03:00
|
|
|
isNew: function() {
|
|
|
|
return false; // Force PUT on .save()
|
|
|
|
},
|
2016-04-20 18:03:50 +03:00
|
|
|
parse: function(data) {
|
|
|
|
if (_.isUndefined(data)) {
|
|
|
|
return null;
|
|
|
|
}
|
2020-12-01 17:15:51 +03:00
|
|
|
|
2021-03-30 11:18:23 +03:00
|
|
|
if (errorNotification) {
|
|
|
|
errorNotification.hide();
|
|
|
|
}
|
|
|
|
|
2020-12-01 17:15:51 +03:00
|
|
|
if (data.status && data.status === 'error') {
|
2021-03-30 11:18:23 +03:00
|
|
|
errorNotification = OC.Notification.show(data.data.message, { type: 'error' });
|
2020-12-01 17:15:51 +03:00
|
|
|
}
|
|
|
|
|
2016-04-20 18:03:50 +03:00
|
|
|
if (_.isUndefined(data.data)) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
data = data.data;
|
|
|
|
|
|
|
|
var ignored = [
|
|
|
|
'userId',
|
|
|
|
'message'
|
|
|
|
];
|
|
|
|
|
|
|
|
_.each(ignored, function(ign) {
|
|
|
|
if (!_.isUndefined(data[ign])) {
|
|
|
|
delete data[ign];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
OC.Settings = OC.Settings || {};
|
|
|
|
|
|
|
|
OC.Settings.UserSettings = UserSettings;
|
2020-12-01 17:15:51 +03:00
|
|
|
})();
|