PageRenderTime 46ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/core/js/systemtags/systemtagsmappingcollection.js

https://gitlab.com/wuhang2003/core
JavaScript | 87 lines | 35 code | 13 blank | 39 comment | 4 complexity | d620b6603404feb4efeab194344dc435 MD5 | raw file
  1. /*
  2. * Copyright (c) 2015
  3. *
  4. * This file is licensed under the Affero General Public License version 3
  5. * or later.
  6. *
  7. * See the COPYING-README file.
  8. *
  9. */
  10. (function(OC) {
  11. /**
  12. * @class OC.SystemTags.SystemTagsMappingCollection
  13. * @classdesc
  14. *
  15. * Collection of tags assigned to a an object
  16. *
  17. */
  18. var SystemTagsMappingCollection = OC.Backbone.Collection.extend(
  19. /** @lends OC.SystemTags.SystemTagsMappingCollection.prototype */ {
  20. sync: OC.Backbone.davSync,
  21. /**
  22. * Use PUT instead of PROPPATCH
  23. */
  24. usePUT: true,
  25. /**
  26. * Id of the file for which to filter activities by
  27. *
  28. * @var int
  29. */
  30. _objectId: null,
  31. /**
  32. * Type of the object to filter by
  33. *
  34. * @var string
  35. */
  36. _objectType: 'files',
  37. model: OC.SystemTags.SystemTagModel,
  38. url: function() {
  39. return OC.linkToRemote('dav') + '/systemtags-relations/' + this._objectType + '/' + this._objectId;
  40. },
  41. /**
  42. * Sets the object id to filter by or null for all.
  43. *
  44. * @param {int} objectId file id or null
  45. */
  46. setObjectId: function(objectId) {
  47. this._objectId = objectId;
  48. },
  49. /**
  50. * Sets the object type to filter by or null for all.
  51. *
  52. * @param {int} objectType file id or null
  53. */
  54. setObjectType: function(objectType) {
  55. this._objectType = objectType;
  56. },
  57. initialize: function(models, options) {
  58. options = options || {};
  59. if (!_.isUndefined(options.objectId)) {
  60. this._objectId = options.objectId;
  61. }
  62. if (!_.isUndefined(options.objectType)) {
  63. this._objectType = options.objectType;
  64. }
  65. },
  66. getTagIds: function() {
  67. return this.map(function(model) {
  68. return model.id;
  69. });
  70. }
  71. });
  72. OC.SystemTags = OC.SystemTags || {};
  73. OC.SystemTags.SystemTagsMappingCollection = SystemTagsMappingCollection;
  74. })(OC);