API Docs for: 0.25.0
Show:

File: addon/models/contributor.js

  1. import Ember from 'ember';
  2. import DS from 'ember-data';
  3.  
  4. import OsfModel from './osf-model';
  5.  
  6. /**
  7. * @module ember-osf
  8. * @submodule models
  9. */
  10.  
  11. /**
  12. * Model for OSF APIv2 contributors. Primarily accessed via relationship fields.
  13. * For field and usage information, see:
  14. * * https://api.osf.io/v2/docs/#!/v2/Node_Contributors_List_GET
  15. * @class Contributor
  16. */
  17. export default OsfModel.extend({
  18. bibliographic: DS.attr('boolean'),
  19. permission: DS.attr('fixstring'),
  20.  
  21. _userId: null,
  22. userId: Ember.computed('_userId', {
  23. get: function() {
  24. if (this.get('isNew')) {
  25. return this.get('_userId');
  26. } else {
  27. return this.get('id').split('-').pop();
  28. }
  29. },
  30. set: function(_, userId) {
  31. this.set('_userId', userId);
  32. }
  33. }).volatile(),
  34. _nodeId: null,
  35. nodeId: Ember.computed('_nodeId', {
  36. get: function() {
  37. if (this.get('isNew')) {
  38. return this.get('_nodeId');
  39. } else {
  40. return this.get('id').split('-').shift();
  41. }
  42. },
  43. set: function(_, nodeId) {
  44. this.set('_nodeId', nodeId);
  45. }
  46. }).volatile(),
  47.  
  48. users: DS.belongsTo('user'),
  49. unregisteredContributor: DS.attr('fixstring'),
  50. index: DS.attr('number'),
  51. fullName: DS.attr('fixstring'),
  52. email: DS.attr('fixstring'),
  53. sendEmail: DS.attr('boolean'),
  54.  
  55. node: DS.belongsTo('node', {
  56. inverse: 'contributors'
  57. }),
  58. preprint: DS.belongsTo('preprint', {
  59. inverse: 'contributors'
  60. })
  61. });
  62.