usersettings.js 946 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* global OC */
  2. /**
  3. * Copyright (c) 2016, Christoph Wurst <christoph@owncloud.com>
  4. *
  5. * This file is licensed under the Affero General Public License version 3 or later.
  6. * See the COPYING-README file.
  7. */
  8. (function() {
  9. 'use strict';
  10. /**
  11. * Model for storing and saving user settings
  12. *
  13. * @class UserSettings
  14. */
  15. var UserSettings = OC.Backbone.Model.extend({
  16. url: OC.generateUrl('/settings/users/{id}/settings', {id: OC.currentUser}),
  17. isNew: function() {
  18. return false; // Force PUT on .save()
  19. },
  20. parse: function(data) {
  21. if (_.isUndefined(data)) {
  22. return null;
  23. }
  24. if (_.isUndefined(data.data)) {
  25. return null;
  26. }
  27. data = data.data;
  28. var ignored = [
  29. 'userId',
  30. 'message'
  31. ];
  32. _.each(ignored, function(ign) {
  33. if (!_.isUndefined(data[ign])) {
  34. delete data[ign];
  35. }
  36. });
  37. return data;
  38. }
  39. });
  40. OC.Settings = OC.Settings || {};
  41. OC.Settings.UserSettings = UserSettings;
  42. })();