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

71 lines
1.5 KiB
JavaScript
Raw Normal View History

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