2016-01-31 14:32:32 +01:00
|
|
|
import DS from 'ember-data';
|
2016-05-20 23:43:05 +02:00
|
|
|
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({
|
2015-08-23 06:18:35 +02:00
|
|
|
/*
|
|
|
|
* relationships
|
|
|
|
*/
|
2016-08-12 13:33:03 +02:00
|
|
|
users: DS.hasMany('user', { async: false }),
|
2015-11-20 00:18:09 +01:00
|
|
|
|
2015-08-23 06:18:35 +02: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
|
|
|
|
2015-08-23 06:18:35 +02:00
|
|
|
// array of possible answers
|
2016-01-31 14:32:32 +01:00
|
|
|
answers: MF.fragmentArray('answer'),
|
2015-08-23 06:18:35 +02:00
|
|
|
|
|
|
|
// 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'),
|
2015-08-23 06:18:35 +02:00
|
|
|
|
|
|
|
// polls description
|
2016-01-31 14:32:32 +01:00
|
|
|
description: DS.attr('string', {
|
2015-08-22 23:47:31 +02:00
|
|
|
defaultValue: ''
|
|
|
|
}),
|
2015-08-23 06:18:35 +02:00
|
|
|
|
2015-08-23 16:13:52 +02:00
|
|
|
// ISO 8601 date + time string in UTC
|
2016-01-31 14:32:32 +01:00
|
|
|
expirationDate: DS.attr('string', {
|
2015-08-23 16:13:52 +02:00
|
|
|
includePlainOnCreate: 'serverExpirationDate'
|
|
|
|
}),
|
2015-08-23 06:18:35 +02:00
|
|
|
|
|
|
|
// Must all options been answered?
|
2016-01-31 14:32:32 +01:00
|
|
|
forceAnswer: DS.attr('boolean'),
|
2015-08-23 06:18:35 +02:00
|
|
|
|
|
|
|
// array of polls options
|
2016-01-31 14:32:32 +01:00
|
|
|
options: MF.fragmentArray('option'),
|
2015-08-23 06:18:35 +02:00
|
|
|
|
|
|
|
// FindADate or MakeAPoll
|
2016-01-31 14:32:32 +01:00
|
|
|
pollType: DS.attr('string'),
|
2015-08-23 06:18:35 +02:00
|
|
|
|
|
|
|
// timezone poll got created in (like "Europe/Berlin")
|
2016-01-31 14:32:32 +01:00
|
|
|
timezone: DS.attr('string'),
|
2015-08-23 06:18:35 +02:00
|
|
|
|
|
|
|
// polls title
|
2016-01-31 14:32:32 +01:00
|
|
|
title: DS.attr('string'),
|
2015-08-23 06:18:35 +02:00
|
|
|
|
|
|
|
// Croodle version poll got created with
|
2016-01-31 14:32:32 +01:00
|
|
|
version: DS.attr('string', {
|
2015-08-23 06:18:35 +02:00
|
|
|
encrypted: false
|
|
|
|
}),
|
2015-11-20 00:18:09 +01:00
|
|
|
|
2015-08-23 06:18:35 +02:00
|
|
|
/*
|
|
|
|
* computed properties
|
|
|
|
*/
|
2016-05-20 23:43:05 +02:00
|
|
|
isFindADate: Ember.computed('pollType', function() {
|
2015-07-07 11:52:46 +02:00
|
|
|
return this.get('pollType') === 'FindADate';
|
2016-05-20 23:43:05 +02:00
|
|
|
}),
|
2015-11-20 00:18:09 +01:00
|
|
|
|
2016-05-20 23:43:05 +02:00
|
|
|
isFreeText: Ember.computed('answerType', function() {
|
2015-07-07 11:52:46 +02:00
|
|
|
return this.get('answerType') === 'FreeText';
|
2016-05-20 23:43:05 +02:00
|
|
|
}),
|
2015-11-20 00:18:09 +01:00
|
|
|
|
2016-05-20 23:43:05 +02:00
|
|
|
isMakeAPoll: Ember.computed('pollType', function() {
|
2015-07-07 11:52:46 +02:00
|
|
|
return this.get('pollType') === 'MakeAPoll';
|
2016-05-20 23:43:05 +02:00
|
|
|
})
|
2015-06-20 19:04:19 +02:00
|
|
|
});
|