decide.nolog.cz/app/models/poll.js

72 lines
1.6 KiB
JavaScript
Raw Normal View History

2014-10-30 21:44:22 +01:00
import DS from "ember-data";
2014-07-06 17:37:54 +02:00
export default DS.Model.extend({
/*
* relationships
*/
2015-07-07 11:52:46 +02:00
users : DS.hasMany('user'),
2015-11-20 00:18:09 +01:00
/*
* properties
*/
// Is participation without user name possibile?
anonymousUser : DS.attr('boolean'),
2015-11-20 00:18:09 +01:00
// array of possible answers
2015-11-20 00:18:09 +01:00
answers : MF.fragmentArray('answer'),
// YesNo, YesNoMaybe or Freetext
answerType: DS.attr('string'),
// ISO-8601 combined date and time string in UTC
creationDate : DS.attr('date'),
// polls description
2015-08-22 23:47:31 +02:00
description : DS.attr('string', {
defaultValue: ''
}),
// ISO 8601 date + time string in UTC
expirationDate : DS.attr('string', {
includePlainOnCreate: 'serverExpirationDate'
}),
// Must all options been answered?
forceAnswer : DS.attr('boolean'),
// If poll type is FindADate: are options only dates or dates + times?
isDateTime : DS.attr('boolean'),
// array of polls options
2015-11-20 00:18:09 +01:00
options : MF.fragmentArray('option'),
// FindADate or MakeAPoll
pollType : DS.attr('string'),
// timezone poll got created in (like "Europe/Berlin")
timezone : DS.attr('string'),
// polls title
title : DS.attr('string'),
// Croodle version poll got created with
version : DS.attr('string', {
encrypted: false
}),
2015-11-20 00:18:09 +01:00
/*
* computed properties
*/
2015-07-07 11:52:46 +02:00
isFindADate: function() {
return this.get('pollType') === 'FindADate';
}.property('pollType'),
2015-11-20 00:18:09 +01:00
2015-07-07 11:52:46 +02:00
isFreeText: function() {
return this.get('answerType') === 'FreeText';
}.property('answerType'),
2015-11-20 00:18:09 +01:00
2015-07-07 11:52:46 +02:00
isMakeAPoll: function() {
return this.get('pollType') === 'MakeAPoll';
}.property('pollType'),
});