You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

usersettings.js 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. var errorNotification;
  11. /**
  12. * Model for storing and saving user settings
  13. *
  14. * @class UserSettings
  15. */
  16. var UserSettings = OC.Backbone.Model.extend({
  17. url: OC.generateUrl('/settings/users/{id}/settings', {id: OC.currentUser}),
  18. isNew: function() {
  19. return false; // Force PUT on .save()
  20. },
  21. parse: function(data) {
  22. if (_.isUndefined(data)) {
  23. return null;
  24. }
  25. if (errorNotification) {
  26. errorNotification.hide();
  27. }
  28. if (data.status && data.status === 'error') {
  29. errorNotification = OC.Notification.show(data.data.message, { type: 'error' });
  30. }
  31. if (_.isUndefined(data.data)) {
  32. return null;
  33. }
  34. data = data.data;
  35. var ignored = [
  36. 'userId',
  37. 'message'
  38. ];
  39. _.each(ignored, function(ign) {
  40. if (!_.isUndefined(data[ign])) {
  41. delete data[ign];
  42. }
  43. });
  44. return data;
  45. }
  46. });
  47. OC.Settings = OC.Settings || {};
  48. OC.Settings.UserSettings = UserSettings;
  49. })();