voluntary_survey 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/app/assets/javascripts/voluntary_survey/story/adapters/application_adapter.js.coffee +5 -0
  3. data/app/assets/javascripts/voluntary_survey/story/app.js.coffee +10 -0
  4. data/app/assets/javascripts/voluntary_survey/story/application.js +9 -0
  5. data/app/assets/javascripts/voluntary_survey/story/components/page_form_component.js.coffee +59 -0
  6. data/app/assets/javascripts/voluntary_survey/story/components/task_form_component.js.coffee +63 -0
  7. data/app/assets/javascripts/voluntary_survey/story/components/task_option_form_component.js.coffee +43 -0
  8. data/app/assets/javascripts/voluntary_survey/story/controllers/pages_controller.js.coffee +54 -0
  9. data/app/assets/javascripts/voluntary_survey/story/helpers/is_equal_helper.js.coffee +2 -0
  10. data/app/assets/javascripts/voluntary_survey/story/helpers/t_helper.js.coffee +10 -0
  11. data/app/assets/javascripts/voluntary_survey/story/models/survey_page.js.coffee +3 -0
  12. data/app/assets/javascripts/voluntary_survey/story/router.js.coffee +8 -0
  13. data/app/assets/javascripts/voluntary_survey/story/routes/application_route.js.coffee +3 -0
  14. data/app/assets/javascripts/voluntary_survey/story/routes/pages_route.js.coffee +26 -0
  15. data/app/assets/javascripts/voluntary_survey/story/templates/application.js.handlebars +11 -0
  16. data/app/assets/javascripts/voluntary_survey/story/templates/components/page-form.js.handlebars +57 -0
  17. data/app/assets/javascripts/voluntary_survey/story/templates/components/task-form.js.handlebars +126 -0
  18. data/app/assets/javascripts/voluntary_survey/story/templates/components/task-option-form.js.handlebars +19 -0
  19. data/app/assets/javascripts/voluntary_survey/story/templates/pages.js.handlebars +41 -0
  20. data/app/controllers/survey_results_controller.rb +14 -0
  21. data/app/controllers/voluntary/api/v1/survey_input_options_controller.rb +63 -0
  22. data/app/controllers/voluntary/api/v1/survey_pages_controller.rb +63 -0
  23. data/app/controllers/voluntary/api/v1/survey_tasks_controller.rb +63 -0
  24. data/app/controllers/workflow/user/survey_pages_controller.rb +27 -0
  25. data/app/models/product/survey/input_option.rb +16 -0
  26. data/app/models/product/survey/page.rb +57 -0
  27. data/app/models/product/survey/result.rb +42 -0
  28. data/app/models/product/survey/story.rb +19 -0
  29. data/app/models/product/survey/task.rb +25 -0
  30. data/app/models/product/survey.rb +2 -0
  31. data/app/serializers/survey_input_option_serializer.rb +3 -0
  32. data/app/serializers/survey_page_serializer.rb +7 -0
  33. data/app/serializers/survey_story_serializer.rb +7 -0
  34. data/app/serializers/survey_task_serializer.rb +7 -0
  35. data/app/views/products/types/survey/wizard.html.erb +15 -0
  36. data/app/views/products/types/survey/workflow/user/stories/_next_task.html.erb +1 -0
  37. data/app/views/survey_results/index.html.erb +54 -0
  38. data/app/views/workflow/user/survey_pages/show.html.erb +65 -0
  39. data/config/locales/resources/survey/en.yml +36 -0
  40. data/config/locales/resources/survey_input_option/en.yml +37 -0
  41. data/config/locales/resources/survey_page/en.yml +35 -0
  42. data/config/locales/resources/survey_result/en.yml +4 -0
  43. data/config/locales/resources/survey_task/en.yml +37 -0
  44. data/config/routes.rb +20 -0
  45. data/db/migrate/20150903170909_add_product_survey.rb +14 -0
  46. data/lib/voluntary_survey/engine.rb +8 -0
  47. data/lib/voluntary_survey/navigation.rb +22 -0
  48. data/lib/voluntary_survey/version.rb +2 -2
  49. data/lib/voluntary_survey.rb +5 -1
  50. metadata +317 -35
  51. data/MIT-LICENSE +0 -20
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3599c7e674078fabde3757cd9d2c9b70c02346d8
4
+ data.tar.gz: e6d9d4d8ced16425b4e089e9adc6c10079dc1c0a
5
+ SHA512:
6
+ metadata.gz: d76c0b38ca28c313d5515ffa50f832107221b04c2f8db2c91fa3d035439abd0d3f90778e00ebdab9234a74ae7eb1097255e9fb8a06eb432e0ccc5e7f071b5777
7
+ data.tar.gz: 38dfb6e4dad90113714b989aeceb5376c0491a6e80991b5e292457c495245a7b107da97122671db34dc2f9577007fb6842e80eba12f31c849f9a58c3ccbeb4cb
@@ -0,0 +1,5 @@
1
+ Volontariat.Survey.StoryApp.ApplicationAdapter = DS.RESTAdapter.extend
2
+ namespace: 'api/v1',
3
+ pathForType: (type) ->
4
+ underscored = Ember.String.underscore(type)
5
+ Ember.String.pluralize underscored
@@ -0,0 +1,10 @@
1
+ #= require_tree ./adapters
2
+ #= require_tree ./mixins
3
+ #= require_tree ./controllers
4
+ #= require_tree ./models
5
+ #= require ./router.js.coffee
6
+ #= require_tree ./routes
7
+ #= require_tree ./components
8
+ #= require_tree ./helpers
9
+ #= require_tree ./templates
10
+ #= require_self
@@ -0,0 +1,9 @@
1
+ //= require handlebars
2
+ //= require ember
3
+ //= require ember-data
4
+ //= require ember-template-compiler
5
+ //= require active-model-adapter
6
+ //= require voluntary/ember_js/lib
7
+ //= require_self
8
+ //= require ./app
9
+ Volontariat.Survey.StoryApp = Ember.Application.create({ LOG_TRANSITIONS: true, rootElement: '#outlet' });
@@ -0,0 +1,59 @@
1
+ Volontariat.Survey.StoryApp.PageFormComponent = Ember.Component.extend
2
+ computedPosition: (-> @get('position') + 1).property('position')
3
+ computedName: (-> if @get('name') then @get('name') else Volontariat.t('survey_pages.show.untitled_page') ).property('name')
4
+ computedText: (-> if @get('text') then @get('text') else Volontariat.t('survey_pages.show.page_without_text') ).property('text')
5
+ editMode: (-> @get('selectedId') == @get('id')).property('selectedId', 'id')
6
+
7
+ actions:
8
+
9
+ enterEditMode: ->
10
+ @sendAction 'editAction', @get('id')
11
+
12
+ cancel: ->
13
+ @sendAction 'editAction', null
14
+
15
+ save: ->
16
+ $.ajax(
17
+ type: if @get('id') then 'PUT' else 'POST'
18
+ url: '/api/v1/survey_pages' + if @get('id') then "/#{@get('id')}" else '',
19
+ data: {
20
+ survey_page: { story_id: Volontariat.Survey.StoryId, name: $('#page_name').val(), text: $('#page_text').val() }
21
+ }
22
+ ).success((data) =>
23
+ if data.errors
24
+ alert "#{Volontariat.t('survey_pages.save.failed')}: #{JSON.stringify(data.errors)}"
25
+ else
26
+ @set 'id', data._id.$oid
27
+ @sendAction 'reloadAction'
28
+ @sendAction 'editAction', data._id.$oid
29
+ alert Volontariat.t('survey_pages.save.successful')
30
+ ).fail((data) =>
31
+ alert "#{Volontariat.t('survey_pages.save.failed')}!"
32
+ )
33
+
34
+ addTask: (task) ->
35
+ tasks = @get('tasks')
36
+ tasks.pushObject task
37
+ @set 'tasks', tasks
38
+
39
+ destroy: ->
40
+ if confirm(Volontariat.t('survey_pages.destroy.confirmation'))
41
+ $.ajax("/api/v1/survey_pages/#{@get('id')}?story_id=#{Volontariat.Survey.StoryId}", type: 'DELETE').done((data) =>
42
+ @sendAction 'reloadAction'
43
+ ).fail((data) ->
44
+ alert Volontariat.t('activerecord.errors.models.survey_page.attributes.base.deletion_failed')
45
+ )
46
+
47
+ reload: ->
48
+ @sendAction 'reloadAction'
49
+
50
+ editPage: (id) ->
51
+ @sendAction 'editAction', id
52
+
53
+ addNewTask: ->
54
+ @set 'newTask', true
55
+ @set 'taskId', null
56
+
57
+ editTask: (id) ->
58
+ @set 'newTask', false
59
+ @set 'taskId', id
@@ -0,0 +1,63 @@
1
+ Volontariat.Survey.StoryApp.TaskFormComponent = Ember.Component.extend
2
+ computedPosition: (-> @get('position') + 1).property('position')
3
+ editMode: (-> @get('selectedId') == @get('id')).property('selectedId', 'id')
4
+ answerTypes: ['Multiple choice', 'Checkboxes', 'Drop-down list', 'Short text', 'Long text']
5
+ shortTextAnswer: (-> @get('answerType') == 'Short text').property('answerType')
6
+ longTextAnswer: (-> @get('answerType') == 'Long text').property('answerType')
7
+ answerWithOptions: (-> @get('answerType') == 'Multiple choice' || @get('answerType') == 'Checkboxes' || @get('answerType') == 'Drop-down list').property('answerType')
8
+ multipleChoiceAnswer: (-> @get('answerType') == 'Multiple choice').property('answerType')
9
+ checkboxesAnswer: (-> @get('answerType') == 'Checkboxes').property('answerType')
10
+ dropDownAnswer: (-> @get('answerType') == 'Drop-down list').property('answerType')
11
+
12
+ actions:
13
+
14
+ enterEditMode: ->
15
+ @sendAction 'editAction', @get('id')
16
+
17
+ cancel: ->
18
+ @sendAction 'editAction', null
19
+
20
+ changeAnswerType: ->
21
+ @set 'answerType', $('#task_answer_type').val()
22
+
23
+ addOption: (option) ->
24
+ options = @get('options')
25
+ options.pushObject option
26
+ @set 'options', options
27
+
28
+ save: ->
29
+ $.ajax(
30
+ type: if @get('id') then 'PUT' else 'POST'
31
+ url: '/api/v1/survey_tasks' + if @get('id') then "/#{@get('id')}" else '',
32
+ data: {
33
+ survey_task: {
34
+ story_id: Volontariat.Survey.StoryId, page_id: @get('pageId'), name: $('#task_name').val(),
35
+ answer_type: $('#task_answer_type').val()
36
+ text: $('#task_text').val()
37
+ }
38
+ }
39
+ ).success((data) =>
40
+ if data.errors
41
+ alert "#{Volontariat.t('survey_tasks.save.failed')}: #{JSON.stringify(data.errors)}"
42
+ else
43
+ if @get('id')
44
+ @sendAction 'editAction', null
45
+ else
46
+ @sendAction 'addTaskAction', data.survey_task
47
+
48
+ if @get('answerWithOptions')
49
+ @sendAction 'editAction', data.survey_task.id.$oid
50
+ else
51
+ @sendAction 'editAction', null
52
+
53
+ ).fail((data) =>
54
+ alert "#{Volontariat.t('survey_tasks.save.failed')}!"
55
+ )
56
+
57
+ destroy: ->
58
+ if confirm(Volontariat.t('survey_tasks.destroy.confirmation'))
59
+ $.ajax("/api/v1/survey_tasks/#{@get('id')}?story_id=#{Volontariat.Survey.StoryId}&page_id=#{@get('pageId')}", type: 'DELETE').done((data) =>
60
+ @sendAction 'reloadAction'
61
+ ).fail((data) ->
62
+ alert Volontariat.t('activerecord.errors.models.survey_task.attributes.base.deletion_failed')
63
+ )
@@ -0,0 +1,43 @@
1
+ Volontariat.Survey.StoryApp.TaskOptionFormComponent = Ember.Component.extend
2
+ keyInputId: (-> "input_option_key_#{@get('id')}").property('id')
3
+ valueInputId: (-> "input_option_value_#{@get('id')}").property('id')
4
+ keyPlaceholder: (-> Volontariat.t('activerecord.attributes.survey_input_option.key')).property('answerType')
5
+ valuePlaceholder: (-> Volontariat.t('activerecord.attributes.survey_input_option.value')).property('answerType')
6
+
7
+ actions:
8
+
9
+ save: ->
10
+ $.ajax(
11
+ type: if @get('id') then 'PUT' else 'POST'
12
+ url: '/api/v1/survey_input_options' + if @get('id') then "/#{@get('id')}" else '',
13
+ data: {
14
+ survey_input_option: {
15
+ story_id: Volontariat.Survey.StoryId, page_id: @get('pageId'),
16
+ task_id: @get('taskId'), key: $("##{@get('keyInputId')}").val(),
17
+ value: $("##{@get('valueInputId')}").val()
18
+ }
19
+ }
20
+ ).success((data) =>
21
+ if data.errors
22
+ alert "#{Volontariat.t('survey_input_options.save.failed')}: #{JSON.stringify(data.errors)}"
23
+ else
24
+ unless @get('id')
25
+ @sendAction 'addOptionAction', { id: data._id, key: data.key, value: data.value }
26
+
27
+ $("##{@get('keyInputId')}").val('')
28
+ $("##{@get('valueInputId')}").val('')
29
+
30
+ #@sendAction 'reloadAction'
31
+ #@sendAction 'editPageAction', @get('pageId')
32
+ #@sendAction 'editTaskAction', @get('taskId')
33
+ ).fail((data) =>
34
+ alert "#{Volontariat.t('survey_input_options.save.failed')}!"
35
+ )
36
+
37
+ destroy: ->
38
+ $.ajax("/api/v1/survey_input_options/#{@get('id')}?story_id=#{Volontariat.Survey.StoryId}&page_id=#{@get('pageId')}&task_id=#{@get('taskId')}", type: 'DELETE').done((data) =>
39
+ #@sendAction 'reloadAction'
40
+ @set 'deleted', true
41
+ ).fail((data) ->
42
+ alert Volontariat.t('activerecord.errors.models.survey_input_option.attributes.base.deletion_failed')
43
+ )
@@ -0,0 +1,54 @@
1
+ Volontariat.Survey.StoryApp.PagesController = Ember.Controller.extend
2
+ canActivateStory: (-> @get('storyState') == 'new' || @get('storyState') == 'tasks_defined').property('storyState')
3
+
4
+ actions:
5
+
6
+ saveStory: ->
7
+ $.ajax(
8
+ type: if Volontariat.Survey.NewRecord then 'POST' else 'PUT'
9
+ url: '/api/v1/stories' + if Volontariat.Survey.NewRecord then '' else "/#{Volontariat.Survey.StoryId}",
10
+ data: {
11
+ story: { project_id: Volontariat.Survey.ProjectId, name: $('#story_name').val(), text: $('#story_text').val() }
12
+ }
13
+ ).success((data) =>
14
+ if data.errors
15
+ Volontariat.alert 'danger', "#{Volontariat.t('stories.save.failed')}: #{JSON.stringify(data.errors)}"
16
+ else
17
+ if Volontariat.Survey.NewRecord
18
+ @set 'newPage', true
19
+ Volontariat.Survey.NewRecord = false
20
+ @set 'newRecord', false
21
+
22
+ Volontariat.Survey.StoryId = data.survey_story.id.$oid
23
+ @transitionToRoute 'no_data'
24
+ @transitionToRoute 'pages'
25
+ Volontariat.alert 'success', Volontariat.t('stories.save.successful')
26
+ ).fail((data) =>
27
+ Volontariat.alert 'danger', "#{Volontariat.t('stories.save.failed')}!"
28
+ )
29
+
30
+ addNewPage: ->
31
+ @set 'newPage', true
32
+ @set 'pageId', null
33
+
34
+ editPage: (id) ->
35
+ @set 'newPage', false
36
+ @set 'pageId', id
37
+
38
+ triggerStoryEvent: (event) ->
39
+ $.ajax(
40
+ type: 'PUT'
41
+ url: "/api/v1/stories/#{Volontariat.Survey.StoryId}/#{event}"
42
+ ).success((data) =>
43
+ if data.errors
44
+ Volontariat.alert 'danger', "#{Volontariat.t('stories.save.failed')}: #{JSON.stringify(data.errors)}"
45
+ else
46
+ @set 'storyState', data.survey_story.state
47
+ Volontariat.alert 'success', Volontariat.t('stories.save.successful')
48
+ ).fail((data) =>
49
+ Volontariat.alert 'danger', "#{Volontariat.t('stories.save.failed')}!"
50
+ )
51
+
52
+ reload: ->
53
+ @transitionToRoute 'no_data'
54
+ @transitionToRoute 'pages'
@@ -0,0 +1,2 @@
1
+ Ember.Handlebars.helper 'is-equal', (left, right, options) ->
2
+ left == right
@@ -0,0 +1,10 @@
1
+ Ember.Handlebars.helper 't', (key, no_html, options) ->
2
+ text = Volontariat.t key
3
+
4
+ if text == undefined
5
+ if no_html == true
6
+ "Missing translation: #{key}"
7
+ else
8
+ new (Ember.Handlebars.SafeString)('<span class="translation_missing" title="translation missing: ' + Volontariat.locale + '.' + key + '">' + key + '</span>')
9
+ else
10
+ text
@@ -0,0 +1,3 @@
1
+ Volontariat.Survey.StoryApp.SurveyPage = DS.Model.extend
2
+ name: DS.attr('string')
3
+ text: DS.attr('string')
@@ -0,0 +1,8 @@
1
+ Volontariat.Survey.StoryApp.Router.reopen location: 'hash'
2
+
3
+ Volontariat.Survey.StoryApp.Router.map ->
4
+ @_super
5
+
6
+ @resource 'pages'
7
+
8
+ @route 'no_data'
@@ -0,0 +1,3 @@
1
+ Volontariat.Survey.StoryApp.ApplicationRoute = Ember.Route.extend
2
+ redirect: ->
3
+ @transitionTo 'pages'
@@ -0,0 +1,26 @@
1
+ Volontariat.Survey.StoryApp.PagesRoute = Ember.Route.extend
2
+ model: (params) ->
3
+ @controllerFor('pages').set 'newRecord', Volontariat.Survey.NewRecord
4
+ @controllerFor('pages').set 'storyState', Volontariat.Survey.StoryState
5
+
6
+ if Volontariat.Survey.NewRecord
7
+ {}
8
+ else
9
+ Ember.$.getJSON("/api/v1/stories/#{Volontariat.Survey.StoryId}").then (json) =>
10
+ @controllerFor('pages').set 'name', json.survey_story.name
11
+ @controllerFor('pages').set 'text', json.survey_story.text
12
+
13
+ @controllerFor('pages').set 'newPage', true if json.survey_story.pages.length == 0
14
+
15
+ json.survey_story.pages = $.map json.survey_story.pages, (page, i) ->
16
+ page.survey_page.tasks = $.map page.survey_page.tasks, (task, j) ->
17
+ task = task.survey_task
18
+
19
+ task.options = $.map task.options, (option, k) ->
20
+ option.survey_input_option
21
+
22
+ task
23
+
24
+ page.survey_page
25
+
26
+ json.survey_story
@@ -0,0 +1,11 @@
1
+ <div class="container-fluid" style="padding-top:0px;">
2
+ <div class="row">
3
+ <div class="col-md-12">
4
+ <div id="alert" class="alert alert-dismissible" role="alert" style="display:none;">
5
+ <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
6
+ <span id="alert_message"></span>
7
+ </div>
8
+ {{outlet}}
9
+ </div>
10
+ </div>
11
+ </div>
@@ -0,0 +1,57 @@
1
+ {{#if deleted}}
2
+ {{else}}
3
+ {{#if editMode}}
4
+ <fieldset class="fieldset" style="border: 1px solid black; padding:15px; margin-top:15px;">
5
+ <legend>
6
+ {{t 'activerecord.models.survey_page_short'}} {{computedPosition}}
7
+ </legend>
8
+ <form class="simple_form form-vertical" novalidate="novalidate" action="/" accept-charset="UTF-8" method="post">
9
+ <div class="form-group string optional page_name">
10
+ <label class="string optional control-label control-label" for="page_name">
11
+ {{t 'attributes.name'}}
12
+ </label>
13
+ {{input value=name class="string optional form-control" type="text" name="page[name]" id="page_name"}}
14
+ </div>
15
+ <div class="form-group text optional page_text">
16
+ <label class="text optional control-label control-label" for="page_text">
17
+ {{t 'attributes.text'}}
18
+ </label>
19
+ {{textarea value=text style="width: 500px; height:300px;" class="text optional form-control" name="page[text]" id="page_text"}}
20
+ </div>
21
+
22
+ <p style="margin-bottom:15px;">
23
+ <input type="submit" name="commit" value="{{t 'general.cancel' true }}" class="btn btn-default" {{action 'cancel'}}/>
24
+
25
+ {{#if id}}
26
+ <input type="submit" name="commit" value="{{t 'survey_pages.update.title' true }}" class="btn btn-default" {{action 'save'}}/>
27
+ <input type="submit" name="commit" value="{{t 'survey_pages.destroy.title' true }}" class="btn btn-default" {{action 'destroy'}}/>
28
+ {{else}}
29
+ <input type="submit" name="commit" value="{{t 'survey_pages.create.title' true }}" class="btn btn-default" {{action 'save'}}/>
30
+ {{/if}}
31
+ </p>
32
+ </form>
33
+ {{#if id}}
34
+ {{#each tasks as |task taskIndex|}}
35
+ {{task-form pageId=id selectedId=taskId id=task.id.$oid position=taskIndex name=task.name text=task.text answerType=task.answer_type options=task.options editAction='editTask' editPageAction='editPage' reloadAction='reload'}}
36
+ {{/each}}
37
+
38
+ {{#if newTask}}
39
+ {{task-form pageId=id position=tasks.length answerType='Short text' options=[] addTaskAction='addTask' editAction='editTask' editPageAction='editPage' reloadAction='reload'}}
40
+ {{else}}
41
+ <button {{action 'addNewTask'}} style="margin-top:15px;">
42
+ <span class="glyphicon glyphicon-plus"></span> {{t 'survey_tasks.new.title' }}
43
+ </button>
44
+ {{/if}}
45
+ {{/if}}
46
+ </fieldset>
47
+ {{else}}
48
+ <h2>{{computedName}}</h2>
49
+ <p>{{computedText}}</p>
50
+ <a {{action 'enterEditMode'}}>
51
+ <span class="glyphicon glyphicon-pencil"></span> {{t 'general.edit'}}
52
+ </a>
53
+ <a {{action 'destroy'}}>
54
+ <span class="glyphicon glyphicon-remove"></span> {{t 'general.destroy'}}
55
+ </a>
56
+ {{/if}}
57
+ {{/if}}
@@ -0,0 +1,126 @@
1
+ {{#if deleted}}
2
+ {{else}}
3
+ {{#if editMode}}
4
+ <form class="simple_form form-horizontal" novalidate="novalidate" accept-charset="UTF-8" style="margin-top:15px;">
5
+ <div class="form-group string required task_name">
6
+ <label class="string required control-label col-sm-3 control-label" for="task_name">
7
+ <abbr title="required">*</abbr> {{t 'activerecord.attributes.survey_task.name'}}
8
+ </label>
9
+ <div class="col-sm-9">
10
+ {{input value=name class="string required form-control" type="text" name="task[name]" id="task_name"}}
11
+ </div>
12
+ </div>
13
+ <div class="form-group string optional task_text">
14
+ <label class="string optional control-label col-sm-3 control-label" for="task_text">
15
+ {{t 'attributes.text'}}
16
+ </label>
17
+ <div class="col-sm-9">
18
+ {{textarea value=text class="string optional form-control" type="text" name="task[text]" id="task_text"}}
19
+ </div>
20
+ </div>
21
+ <div class="form-group string optional task_text">
22
+ <label class="string optional control-label col-sm-3 control-label" for="task_text">
23
+ <abbr title="required">*</abbr> {{t 'activerecord.attributes.survey_task.answer_type'}}
24
+ </label>
25
+ <div class="col-sm-9">
26
+ <select {{action 'changeAnswerType' on='change'}} id="task_answer_type">
27
+ {{#each answerTypes key="@index" as |item|}}
28
+ <option value="{{item}}" selected={{is-equal item answerType}}>
29
+ {{item}}
30
+ </option>
31
+ {{/each}}
32
+ </select>
33
+ </div>
34
+ </div>
35
+
36
+ {{#if id}}
37
+ {{#if answerWithOptions}}
38
+ <div class="form-group">
39
+ <div class="col-sm-offset-3 col-sm-9">
40
+ {{#each options as |option optionIndex|}}
41
+ {{task-option-form pageId=pageId taskId=id id=option.id.$oid position=optionIndex key=option.key value=option.value editTaskAction='editTask' editPageAction='editPage' reloadAction='reload'}}
42
+ {{/each}}
43
+
44
+ {{task-option-form pageId=pageId taskId=id position=options.length addOptionAction='addOption' editTaskAction='editTask' editPageAction='editPage' reloadAction='reload'}}
45
+ </div>
46
+ </div>
47
+ {{/if}}
48
+ {{/if}}
49
+
50
+ <div class="form-group">
51
+ <div class="col-sm-offset-3 col-sm-9">
52
+ <input type="submit" name="commit" value="{{t 'general.cancel' true }}" class="btn btn-default" {{action 'cancel'}}/>
53
+
54
+ {{#if id}}
55
+ <input type="submit" name="commit" value="{{t 'survey_tasks.update.title' true }}" class="btn btn-default" {{action 'save'}}/>
56
+ <input type="submit" name="commit" value="{{t 'survey_tasks.destroy.title' true }}" class="btn btn-default" {{action 'destroy'}}/>
57
+ {{else}}
58
+ <input type="submit" name="commit" value="{{t 'survey_tasks.create.title' true }}" class="btn btn-default" {{action 'save'}}/>
59
+ {{/if}}
60
+ </div>
61
+ </div>
62
+ <div class="form-group">
63
+ <div class="col-sm-12">
64
+ {{#if shortTextAnswer}}
65
+ <input type="text" class="string required form-control"/>
66
+ {{/if}}
67
+ {{#if longTextAnswer}}
68
+ <textarea class="string required form-control"/>
69
+ {{/if}}
70
+ </div>
71
+ </div>
72
+ </form>
73
+ {{else}}
74
+ <form class="simple_form form-vertical" novalidate="novalidate" action="/" accept-charset="UTF-8" method="post">
75
+ <div class="form-group string required page_name">
76
+ <label class="string required control-label control-label">
77
+ {{name}}
78
+ </label>
79
+ {{#if text}}
80
+ <p>
81
+ {{text}}
82
+ </p>
83
+ {{/if}}
84
+
85
+ <p>
86
+ {{#if shortTextAnswer}}
87
+ <input type="text"/>
88
+ {{/if}}
89
+
90
+ {{#if longTextAnswer}}
91
+ <textarea/>
92
+ {{/if}}
93
+
94
+ {{#if multipleChoiceAnswer}}
95
+ {{#each options as |option|}}
96
+ <input type="radio"/> {{option.value}}<br/>
97
+ {{/each}}
98
+ {{/if}}
99
+
100
+ {{#if checkboxesAnswer}}
101
+ {{#each options as |option|}}
102
+ <input type="checkbox"/> {{option.value}}<br/>
103
+ {{/each}}
104
+ {{/if}}
105
+
106
+ {{#if dropDownAnswer}}
107
+ <select>
108
+ {{#each options as |option|}}
109
+ <option>{{option.value}}</option>
110
+ {{/each}}
111
+ </select>
112
+ {{/if}}
113
+ </p>
114
+
115
+ <p>
116
+ <a {{action 'enterEditMode'}}>
117
+ <span class="glyphicon glyphicon-pencil"></span> {{t 'general.edit'}}
118
+ </a>
119
+ <a {{action 'destroy'}}>
120
+ <span class="glyphicon glyphicon-remove"></span> {{t 'general.destroy'}}
121
+ </a>
122
+ </p>
123
+ </div>
124
+ </form>
125
+ {{/if}}
126
+ {{/if}}
@@ -0,0 +1,19 @@
1
+ {{#if deleted}}
2
+ {{else}}
3
+ <form class="form-inline" style="margin-left:15px;">
4
+ <div class="form-group string optional input_option_key">
5
+ {{input value=key class="string optional form-control" type="text" name="survey_input_option[key]" id=keyInputId placeholder=keyPlaceholder}}
6
+ </div>
7
+ <div class="form-group string required input_option_value">
8
+ {{input value=value class="string required form-control" type="text" name="survey_input_option[value]" id=valueInputId placeholder=valuePlaceholder}}
9
+ </div>
10
+ <div class="form-group">
11
+ {{#if id}}
12
+ <input type="submit" name="commit" value="{{t 'survey_input_options.update.title' true }}" class="btn btn-default" {{action 'save'}}/>
13
+ <input type="submit" name="commit" value="{{t 'survey_input_options.destroy.title' true }}" class="btn btn-default" {{action 'destroy'}}/>
14
+ {{else}}
15
+ <input type="submit" name="commit" value="{{t 'survey_input_options.create.title' true }}" class="btn btn-default" {{action 'save'}}/>
16
+ {{/if}}
17
+ </div>
18
+ </form>
19
+ {{/if}}
@@ -0,0 +1,41 @@
1
+ <form class="simple_form form-vertical" novalidate="novalidate" action="/" accept-charset="UTF-8" method="post">
2
+ <div class="form-group string required story_name">
3
+ <label class="string required control-label control-label" for="story_name">
4
+ <abbr title="required">*</abbr> {{t 'attributes.name'}}
5
+ </label>
6
+ {{input value=name class="string required form-control" type="text" name="story[name]" id="story_name"}}
7
+ </div>
8
+ <div class="form-group text required story_text">
9
+ <label class="text required control-label control-label" for="story_text">
10
+ <abbr title="required">*</abbr> {{t 'attributes.text'}}
11
+ </label>
12
+ {{textarea value=text style="width: 500px; height:300px;" class="text required form-control" name="story[text]" id="story_text"}}
13
+ </div>
14
+ <p>
15
+ {{#if newRecord}}
16
+ <input type="submit" name="commit" value="{{t 'stories.create.title' true }}" class="btn btn-default" {{action 'saveStory'}}/>
17
+ {{else}}
18
+ <input type="submit" name="commit" value="{{t 'stories.update.title' true }}" class="btn btn-default" {{action 'saveStory'}}/>
19
+ {{#if canActivateStory}}
20
+ <input type="submit" name="commit" value="{{t 'stories.steps.activate.title' true }}" class="btn btn-default" {{action 'triggerStoryEvent' 'activate'}}/>
21
+ {{else}}
22
+ <input type="submit" name="commit" value="{{t 'stories.steps.deactivate.title' true }}" class="btn btn-default" {{action 'triggerStoryEvent' 'deactivate'}}/>
23
+ {{/if}}
24
+ {{/if}}
25
+ </p>
26
+ </form>
27
+
28
+ {{#if newRecord}}
29
+ {{else}}
30
+ {{#each model.pages as |page pageIndex|}}
31
+ {{page-form selectedId=pageId id=page.id.$oid position=pageIndex name=page.name text=page.text tasks=page.tasks editAction='editPage' reloadAction='reload'}}
32
+ {{/each}}
33
+
34
+ {{#if newPage}}
35
+ {{page-form position=model.pages.length editAction='editPage' reloadAction='reload'}}
36
+ {{else}}
37
+ <button {{action 'addNewPage'}} style="margin-top:15px;">
38
+ <span class="glyphicon glyphicon-plus"></span> {{t 'survey_pages.new.title' }}
39
+ </button>
40
+ {{/if}}
41
+ {{/if}}
@@ -0,0 +1,14 @@
1
+ class SurveyResultsController < ApplicationController
2
+ def index
3
+ @story = Story.find(params[:story_id])
4
+ @project = @story.project
5
+ @results = {}
6
+ @hide_sidebar = true
7
+
8
+ @story.pages.each do |page|
9
+ page.tasks.where(answer_type: { '$in' => ['Short text', 'Long text'] }).each do |task|
10
+ @results[task.id.to_s] = task.results.paginate(page: params["result_#{task.id}_page".to_sym], per_page: 10)
11
+ end
12
+ end
13
+ end
14
+ end