0
0
mirror of https://github.com/nextcloud/server.git synced 2024-12-29 00:18:42 +00:00
nextcloud_server/apps/settings/js/usersettings.js
Andy Scherzinger ec5b60af28
chore: Add SPDX header
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
2024-06-03 20:33:31 +02:00

61 lines
1.1 KiB
JavaScript

/* global OC */
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
(function() {
'use strict';
var errorNotification;
/**
* 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}),
isNew: function() {
return false; // Force PUT on .save()
},
parse: function(data) {
if (_.isUndefined(data)) {
return null;
}
if (errorNotification) {
errorNotification.hide();
}
if (data.status && data.status === 'error') {
errorNotification = OC.Notification.show(data.data.message, { type: 'error' });
}
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;
})();