activeadmin-selleo-cms 0.0.54 → 0.0.58

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. data/app/assets/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  2. data/app/assets/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  3. data/app/assets/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  4. data/app/assets/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  5. data/app/assets/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  6. data/app/assets/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  7. data/app/assets/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  8. data/app/assets/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  9. data/app/assets/images/ui-icons_222222_256x240.png +0 -0
  10. data/app/assets/images/ui-icons_2e83ff_256x240.png +0 -0
  11. data/app/assets/images/ui-icons_454545_256x240.png +0 -0
  12. data/app/assets/images/ui-icons_888888_256x240.png +0 -0
  13. data/app/assets/images/ui-icons_cd0a0a_256x240.png +0 -0
  14. data/app/assets/javascripts/activeadmin-selleo-cms/forms.storage.js +11 -0
  15. data/app/assets/stylesheets/active_admin/jquery-ui.css.scss +17 -17
  16. data/app/controllers/form_answer_attachments_controller.rb +8 -0
  17. data/app/controllers/form_answers_controller.rb +5 -2
  18. data/app/controllers/forms_controller.rb +5 -1
  19. data/app/views/activeadmin_selleo_cms/form_mailer/form_submission.html.erb +7 -1
  20. data/app/views/form_answer_attachments/destroy.js.erb +1 -0
  21. data/app/views/form_answers/_attachments.html.haml +3 -1
  22. data/app/views/forms/_download.haml +40 -0
  23. data/app/views/forms/_form.html.haml +57 -0
  24. data/config/locales/cms.en.yml +2 -1
  25. data/config/routes.rb +1 -0
  26. data/db/migrate/20130815104316_forms_strings_to_text.rb +6 -0
  27. data/lib/activeadmin-selleo-cms/version.rb +1 -1
  28. metadata +20 -4
  29. data/app/views/forms/_download.erb +0 -55
  30. data/app/views/forms/_form.html.erb +0 -71
@@ -69,4 +69,15 @@ function setupCmsForm(form_id) {
69
69
  $.each($('.file_upload'), function(){
70
70
  $(this).find('.files').load('/form_answers/attachments?form_uuid='+localStorage[form_id]+'&form_question_id='+$(this).data('question-id'));
71
71
  });
72
+ }
73
+
74
+ function deleteFormAttachment(answer_id, att_id) {
75
+ if(confirm('Are you sure?')) {
76
+ $.ajax({
77
+ url: '/form_answers/'+answer_id+'/form_answer_attachments/' + att_id + '.js',
78
+ type: 'DELETE'
79
+ }).error(function(){
80
+ alert('An error occured while trying to delete the asset');
81
+ });
82
+ }
72
83
  }
@@ -243,25 +243,25 @@ body .ui-tooltip { border-width: 2px; }
243
243
  .ui-widget { font-family: Verdana,Arial,sans-serif/*{ffDefault}*/; font-size: 1.1em/*{fsDefault}*/; }
244
244
  .ui-widget .ui-widget { font-size: 1em; }
245
245
  .ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Verdana,Arial,sans-serif/*{ffDefault}*/; font-size: 1em; }
246
- .ui-widget-content { border: 1px solid #aaaaaa/*{borderColorContent}*/; background: #ffffff/*{bgColorContent}*/ url(images/ui-bg_flat_75_ffffff_40x100.png)/*{bgImgUrlContent}*/ 50%/*{bgContentXPos}*/ 50%/*{bgContentYPos}*/ repeat-x/*{bgContentRepeat}*/; color: #222222/*{fcContent}*/; }
246
+ .ui-widget-content { border: 1px solid #aaaaaa/*{borderColorContent}*/; background: #ffffff/*{bgColorContent}*/ url(ui-bg_flat_75_ffffff_40x100.png)/*{bgImgUrlContent}*/ 50%/*{bgContentXPos}*/ 50%/*{bgContentYPos}*/ repeat-x/*{bgContentRepeat}*/; color: #222222/*{fcContent}*/; }
247
247
  .ui-widget-content a { color: #222222/*{fcContent}*/; }
248
- .ui-widget-header { border: 1px solid #aaaaaa/*{borderColorHeader}*/; background: #cccccc/*{bgColorHeader}*/ url(images/ui-bg_highlight-soft_75_cccccc_1x100.png)/*{bgImgUrlHeader}*/ 50%/*{bgHeaderXPos}*/ 50%/*{bgHeaderYPos}*/ repeat-x/*{bgHeaderRepeat}*/; color: #222222/*{fcHeader}*/; font-weight: bold; }
248
+ .ui-widget-header { border: 1px solid #aaaaaa/*{borderColorHeader}*/; background: #cccccc/*{bgColorHeader}*/ url(ui-bg_highlight-soft_75_cccccc_1x100.png)/*{bgImgUrlHeader}*/ 50%/*{bgHeaderXPos}*/ 50%/*{bgHeaderYPos}*/ repeat-x/*{bgHeaderRepeat}*/; color: #222222/*{fcHeader}*/; font-weight: bold; }
249
249
  .ui-widget-header a { color: #222222/*{fcHeader}*/; }
250
250
 
251
251
  /* Interaction states
252
252
  ----------------------------------*/
253
- .ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #d3d3d3/*{borderColorDefault}*/; background: #e6e6e6/*{bgColorDefault}*/ url(images/ui-bg_glass_75_e6e6e6_1x400.png)/*{bgImgUrlDefault}*/ 50%/*{bgDefaultXPos}*/ 50%/*{bgDefaultYPos}*/ repeat-x/*{bgDefaultRepeat}*/; font-weight: normal/*{fwDefault}*/; color: #555555/*{fcDefault}*/; }
253
+ .ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #d3d3d3/*{borderColorDefault}*/; background: #e6e6e6/*{bgColorDefault}*/ url(ui-bg_glass_75_e6e6e6_1x400.png)/*{bgImgUrlDefault}*/ 50%/*{bgDefaultXPos}*/ 50%/*{bgDefaultYPos}*/ repeat-x/*{bgDefaultRepeat}*/; font-weight: normal/*{fwDefault}*/; color: #555555/*{fcDefault}*/; }
254
254
  .ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #555555/*{fcDefault}*/; text-decoration: none; }
255
- .ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { border: 1px solid #999999/*{borderColorHover}*/; background: #dadada/*{bgColorHover}*/ url(images/ui-bg_glass_75_dadada_1x400.png)/*{bgImgUrlHover}*/ 50%/*{bgHoverXPos}*/ 50%/*{bgHoverYPos}*/ repeat-x/*{bgHoverRepeat}*/; font-weight: normal/*{fwDefault}*/; color: #212121/*{fcHover}*/; }
255
+ .ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { border: 1px solid #999999/*{borderColorHover}*/; background: #dadada/*{bgColorHover}*/ url(ui-bg_glass_75_dadada_1x400.png)/*{bgImgUrlHover}*/ 50%/*{bgHoverXPos}*/ 50%/*{bgHoverYPos}*/ repeat-x/*{bgHoverRepeat}*/; font-weight: normal/*{fwDefault}*/; color: #212121/*{fcHover}*/; }
256
256
  .ui-state-hover a, .ui-state-hover a:hover, .ui-state-hover a:link, .ui-state-hover a:visited { color: #212121/*{fcHover}*/; text-decoration: none; }
257
- .ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { border: 1px solid #aaaaaa/*{borderColorActive}*/; background: #ffffff/*{bgColorActive}*/ url(images/ui-bg_glass_65_ffffff_1x400.png)/*{bgImgUrlActive}*/ 50%/*{bgActiveXPos}*/ 50%/*{bgActiveYPos}*/ repeat-x/*{bgActiveRepeat}*/; font-weight: normal/*{fwDefault}*/; color: #212121/*{fcActive}*/; }
257
+ .ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { border: 1px solid #aaaaaa/*{borderColorActive}*/; background: #ffffff/*{bgColorActive}*/ url(ui-bg_glass_65_ffffff_1x400.png)/*{bgImgUrlActive}*/ 50%/*{bgActiveXPos}*/ 50%/*{bgActiveYPos}*/ repeat-x/*{bgActiveRepeat}*/; font-weight: normal/*{fwDefault}*/; color: #212121/*{fcActive}*/; }
258
258
  .ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited { color: #212121/*{fcActive}*/; text-decoration: none; }
259
259
 
260
260
  /* Interaction Cues
261
261
  ----------------------------------*/
262
- .ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight {border: 1px solid #fcefa1/*{borderColorHighlight}*/; background: #fbf9ee/*{bgColorHighlight}*/ url(images/ui-bg_glass_55_fbf9ee_1x400.png)/*{bgImgUrlHighlight}*/ 50%/*{bgHighlightXPos}*/ 50%/*{bgHighlightYPos}*/ repeat-x/*{bgHighlightRepeat}*/; color: #363636/*{fcHighlight}*/; }
262
+ .ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight {border: 1px solid #fcefa1/*{borderColorHighlight}*/; background: #fbf9ee/*{bgColorHighlight}*/ url(ui-bg_glass_55_fbf9ee_1x400.png)/*{bgImgUrlHighlight}*/ 50%/*{bgHighlightXPos}*/ 50%/*{bgHighlightYPos}*/ repeat-x/*{bgHighlightRepeat}*/; color: #363636/*{fcHighlight}*/; }
263
263
  .ui-state-highlight a, .ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a { color: #363636/*{fcHighlight}*/; }
264
- .ui-state-error, .ui-widget-content .ui-state-error, .ui-widget-header .ui-state-error {border: 1px solid #cd0a0a/*{borderColorError}*/; background: #fef1ec/*{bgColorError}*/ url(images/ui-bg_glass_95_fef1ec_1x400.png)/*{bgImgUrlError}*/ 50%/*{bgErrorXPos}*/ 50%/*{bgErrorYPos}*/ repeat-x/*{bgErrorRepeat}*/; color: #cd0a0a/*{fcError}*/; }
264
+ .ui-state-error, .ui-widget-content .ui-state-error, .ui-widget-header .ui-state-error {border: 1px solid #cd0a0a/*{borderColorError}*/; background: #fef1ec/*{bgColorError}*/ url(ui-bg_glass_95_fef1ec_1x400.png)/*{bgImgUrlError}*/ 50%/*{bgErrorXPos}*/ 50%/*{bgErrorYPos}*/ repeat-x/*{bgErrorRepeat}*/; color: #cd0a0a/*{fcError}*/; }
265
265
  .ui-state-error a, .ui-widget-content .ui-state-error a, .ui-widget-header .ui-state-error a { color: #cd0a0a/*{fcError}*/; }
266
266
  .ui-state-error-text, .ui-widget-content .ui-state-error-text, .ui-widget-header .ui-state-error-text { color: #cd0a0a/*{fcError}*/; }
267
267
  .ui-priority-primary, .ui-widget-content .ui-priority-primary, .ui-widget-header .ui-priority-primary { font-weight: bold; }
@@ -273,14 +273,14 @@ body .ui-tooltip { border-width: 2px; }
273
273
  ----------------------------------*/
274
274
 
275
275
  /* states and images */
276
- .ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_222222_256x240.png)/*{iconsContent}*/; }
277
- .ui-widget-content .ui-icon {background-image: url(images/ui-icons_222222_256x240.png)/*{iconsContent}*/; }
278
- .ui-widget-header .ui-icon {background-image: url(images/ui-icons_222222_256x240.png)/*{iconsHeader}*/; }
279
- .ui-state-default .ui-icon { background-image: url(images/ui-icons_888888_256x240.png)/*{iconsDefault}*/; }
280
- .ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(images/ui-icons_454545_256x240.png)/*{iconsHover}*/; }
281
- .ui-state-active .ui-icon {background-image: url(images/ui-icons_454545_256x240.png)/*{iconsActive}*/; }
282
- .ui-state-highlight .ui-icon {background-image: url(images/ui-icons_2e83ff_256x240.png)/*{iconsHighlight}*/; }
283
- .ui-state-error .ui-icon, .ui-state-error-text .ui-icon {background-image: url(images/ui-icons_cd0a0a_256x240.png)/*{iconsError}*/; }
276
+ .ui-icon { width: 16px; height: 16px; background-image: url(ui-icons_222222_256x240.png)/*{iconsContent}*/; }
277
+ .ui-widget-content .ui-icon {background-image: url(ui-icons_222222_256x240.png)/*{iconsContent}*/; }
278
+ .ui-widget-header .ui-icon {background-image: url(ui-icons_222222_256x240.png)/*{iconsHeader}*/; }
279
+ .ui-state-default .ui-icon { background-image: url(ui-icons_888888_256x240.png)/*{iconsDefault}*/; }
280
+ .ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(ui-icons_454545_256x240.png)/*{iconsHover}*/; }
281
+ .ui-state-active .ui-icon {background-image: url(ui-icons_454545_256x240.png)/*{iconsActive}*/; }
282
+ .ui-state-highlight .ui-icon {background-image: url(ui-icons_2e83ff_256x240.png)/*{iconsHighlight}*/; }
283
+ .ui-state-error .ui-icon, .ui-state-error-text .ui-icon {background-image: url(ui-icons_cd0a0a_256x240.png)/*{iconsError}*/; }
284
284
 
285
285
  /* positioning */
286
286
  .ui-icon-carat-1-n { background-position: 0 0; }
@@ -470,8 +470,8 @@ body .ui-tooltip { border-width: 2px; }
470
470
  .ui-corner-all, .ui-corner-bottom, .ui-corner-right, .ui-corner-br { -moz-border-radius-bottomright: 4px/*{cornerRadius}*/; -webkit-border-bottom-right-radius: 4px/*{cornerRadius}*/; -khtml-border-bottom-right-radius: 4px/*{cornerRadius}*/; border-bottom-right-radius: 4px/*{cornerRadius}*/; }
471
471
 
472
472
  /* Overlays */
473
- .ui-widget-overlay { background: #aaaaaa/*{bgColorOverlay}*/ url(images/ui-bg_flat_0_aaaaaa_40x100.png)/*{bgImgUrlOverlay}*/ 50%/*{bgOverlayXPos}*/ 50%/*{bgOverlayYPos}*/ repeat-x/*{bgOverlayRepeat}*/; opacity: .7;filter:Alpha(Opacity=70)/*{opacityOverlay}*/; }
474
- .ui-widget-shadow { margin: -8px/*{offsetTopShadow}*/ 0 0 -8px/*{offsetLeftShadow}*/; padding: 8px/*{thicknessShadow}*/; background: #aaaaaa/*{bgColorShadow}*/ url(images/ui-bg_flat_0_aaaaaa_40x100.png)/*{bgImgUrlShadow}*/ 50%/*{bgShadowXPos}*/ 50%/*{bgShadowYPos}*/ repeat-x/*{bgShadowRepeat}*/; opacity: .3;filter:Alpha(Opacity=30)/*{opacityShadow}*/; -moz-border-radius: 8px/*{cornerRadiusShadow}*/; -khtml-border-radius: 8px/*{cornerRadiusShadow}*/; -webkit-border-radius: 8px/*{cornerRadiusShadow}*/; border-radius: 8px/*{cornerRadiusShadow}*/; }
473
+ .ui-widget-overlay { background: #aaaaaa/*{bgColorOverlay}*/ url(ui-bg_flat_0_aaaaaa_40x100.png)/*{bgImgUrlOverlay}*/ 50%/*{bgOverlayXPos}*/ 50%/*{bgOverlayYPos}*/ repeat-x/*{bgOverlayRepeat}*/; opacity: .7;filter:Alpha(Opacity=70)/*{opacityOverlay}*/; }
474
+ .ui-widget-shadow { margin: -8px/*{offsetTopShadow}*/ 0 0 -8px/*{offsetLeftShadow}*/; padding: 8px/*{thicknessShadow}*/; background: #aaaaaa/*{bgColorShadow}*/ url(ui-bg_flat_0_aaaaaa_40x100.png)/*{bgImgUrlShadow}*/ 50%/*{bgShadowXPos}*/ 50%/*{bgShadowYPos}*/ repeat-x/*{bgShadowRepeat}*/; opacity: .3;filter:Alpha(Opacity=30)/*{opacityShadow}*/; -moz-border-radius: 8px/*{cornerRadiusShadow}*/; -khtml-border-radius: 8px/*{cornerRadiusShadow}*/; -webkit-border-radius: 8px/*{cornerRadiusShadow}*/; border-radius: 8px/*{cornerRadiusShadow}*/; }
475
475
 
476
476
  li.hidden {
477
477
  display: none;
@@ -0,0 +1,8 @@
1
+ class FormAnswerAttachmentsController < ApplicationController
2
+
3
+ def destroy
4
+ @attachment = ActiveadminSelleoCms::FormAnswerAttachment.find(params[:id])
5
+ @attachment.destroy
6
+ end
7
+
8
+ end
@@ -31,8 +31,11 @@ class FormAnswersController < ApplicationController
31
31
  end
32
32
 
33
33
  def attachments
34
- @form_answer = ActiveadminSelleoCms::FormAnswer.where(form_uuid: params[:form_uuid], form_question_id: params[:form_question_id]).first
35
- render partial: 'attachments'
34
+ if @form_answer = ActiveadminSelleoCms::FormAnswer.where(form_uuid: params[:form_uuid], form_question_id: params[:form_question_id]).first
35
+ render partial: 'attachments'
36
+ else
37
+ render nothing: true
38
+ end
36
39
  end
37
40
 
38
41
  end
@@ -21,7 +21,11 @@ class FormsController < ApplicationController
21
21
  def deliver
22
22
  respond_to do |format|
23
23
  format.html do
24
- ActiveadminSelleoCms::FormMailer.form_submission(@form, params[:form_uuid]).deliver
24
+ if ActiveadminSelleoCms::FormMailer.respond_to? :delay
25
+ ActiveadminSelleoCms::FormMailer.delay.form_submission(@form, params[:form_uuid])
26
+ else
27
+ ActiveadminSelleoCms::FormMailer.form_submission(@form, params[:form_uuid]).deliver
28
+ end
25
29
  flash[:notice] = "Your form has been sent. Thank you."
26
30
  end
27
31
  end
@@ -6,7 +6,13 @@
6
6
  <body>
7
7
  <h3>A new form "<%= @form.title %>" has been submitted!</h3>
8
8
  <p>
9
- <%= link_to "Click here for details.", "http://#{ActionMailer::Base.default_url_options[:host]}/forms/#{@form.id}/download?form_uuid=#{@form_uuid}" %>
9
+ <%= link_to "Click here to preview the form", "http://#{ActionMailer::Base.default_url_options[:host]}/forms/#{@form.id}/download?form_uuid=#{@form_uuid}" %>
10
+ </p>
11
+ <p>
12
+ <%= link_to "Print", "http://#{ActionMailer::Base.default_url_options[:host]}/forms/#{@form.id}/download?form_uuid=#{@form_uuid}&print=true" %>
13
+ </p>
14
+ <p>
15
+ <%= link_to "Download PDF", "http://#{ActionMailer::Base.default_url_options[:host]}/forms/#{@form.id}/download.pdf?form_uuid=#{@form_uuid}" %>
10
16
  </p>
11
17
  </body>
12
18
  </html>
@@ -0,0 +1 @@
1
+ $('[data-attachment-id="<%= @attachment.id %>"]').remove();
@@ -1,3 +1,5 @@
1
1
  %ol
2
2
  - @form_answer.form_answer_attachments.each do |att|
3
- %li= att.data_file_name
3
+ %li{ :data => { "attachment-id" => att.id } }
4
+ = att.data_file_name
5
+ %small= link_to_function t("active_admin.cms.forms.delete"), "deleteFormAttachment(#{@form_answer.id},#{att.id})"
@@ -0,0 +1,40 @@
1
+ !!!
2
+ %html{:lang => "en", "xml:lang" => "en", :xmlns => "http://www.w3.org/1999/xhtml"}
3
+ %head
4
+ %meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
5
+ = wicked_pdf_stylesheet_link_tag "components/forms"
6
+ %body
7
+ = form_tag '/forms', multipart: true, id: dom_id(@form), data: {form_id: @form.id} do
8
+ %ol.questions
9
+ - @form.questions.each do |question|
10
+ %li{:class => "question #{question.input_type}"}
11
+ - unless question.input_type == :legend
12
+ .questions_labels
13
+ = label_tag dom_id(question), question.title
14
+ - if question.hint.present?
15
+ %p.hint= question.hint
16
+ - if [:check_box_tag].include? question.input_type
17
+ .questions_options
18
+ - question.options.each do |option|
19
+ = send(question.input_type, "#{dom_id(question)}[]", option.id, ActiveadminSelleoCms::FormAnswer.value_for(params[:form_uuid], dom_id(option))=="true", required: question.is_required, id: dom_id(option), data: {form_question_id: question.id} )
20
+ = label_tag dom_id(option), option.title
21
+ - if question.has_other_option
22
+ = label_tag "#{dom_id(question)}_other", t("active_admin.cms.forms.other")
23
+ = text_field_tag "#{dom_id(question)}_other", ActiveadminSelleoCms::FormAnswer.value_for(params[:form_uuid], "#{dom_id(question)}_other"), data: {form_question_id: question.id} if question.has_other_option
24
+ - elsif [:radio_button_tag].include? question.input_type
25
+ .questions_options
26
+ - question.options.each do |option|
27
+ = send(question.input_type, dom_id(question), option.id, ActiveadminSelleoCms::FormAnswer.value_for(params[:form_uuid], dom_id(option)), required: question.is_required, id: dom_id(option), data: {form_question_id: question.id})
28
+ = label_tag dom_id(option), option.title
29
+ - if question.has_other_option
30
+ = label_tag "#{dom_id(question)}_other", t("active_admin.cms.forms.other")
31
+ = text_field_tag "#{dom_id(question)}_other", ActiveadminSelleoCms::FormAnswer.value_for(params[:form_uuid], "#{dom_id(question)}_other"), data: {form_question_id: question.id} if question.has_other_option
32
+ - elsif [:file_field_tag].include? question.input_type
33
+ .file_upload
34
+ %ol
35
+ - ActiveadminSelleoCms::FormAnswer.files_for(params[:form_uuid], dom_id(question)).each do |file|
36
+ %li= link_to file.data_file_name, file.data.url
37
+ - elsif question.input_type == :legend
38
+ %legend= question.label
39
+ - else
40
+ = send(question.input_type, dom_id(question), ActiveadminSelleoCms::FormAnswer.value_for(params[:form_uuid], dom_id(question)), required: question.is_required, data: {form_question_id: question.id})
@@ -0,0 +1,57 @@
1
+ = button_to_function t("active_admin.cms.forms.submit"), "deliver(#{form.id}, '#{dom_id(form)}')", class: 'send'
2
+ = form_tag '/forms', multipart: true, id: dom_id(form), data: {form_id: form.id} do
3
+ %ol.questions
4
+ - form.questions.each do |question|
5
+ %li{:class => "question #{question.input_type}"}
6
+ - unless question.input_type == :legend
7
+ .questions_labels
8
+ = label_tag dom_id(question), question.label
9
+ - if question.hint.present?
10
+ %p.hint= question.hint
11
+ - if [:check_box_tag].include? question.input_type
12
+ .questions_options
13
+ - question.options.each do |option|
14
+ = send(question.input_type, "#{dom_id(question)}[]", option.id, false, required: question.is_required, id: dom_id(option), data: {form_question_id: question.id} )
15
+ = label_tag dom_id(option), option.label
16
+ - if question.has_other_option
17
+ = label_tag "#{dom_id(question)}_other", t("active_admin.cms.forms.other")
18
+ = text_field_tag "#{dom_id(question)}_other", "", data: {form_question_id: question.id} if question.has_other_option
19
+ - elsif [:radio_button_tag].include? question.input_type
20
+ .questions_options
21
+ - question.options.each do |option|
22
+ = send(question.input_type, dom_id(question), option.id, false, required: question.is_required, id: dom_id(option), data: {form_question_id: question.id})
23
+ = label_tag dom_id(option), option.label
24
+ - if question.has_other_option
25
+ = label_tag "#{dom_id(question)}_other", t("active_admin.cms.forms.other")
26
+ = text_field_tag "#{dom_id(question)}_other", "", data: {form_question_id: question.id}
27
+ - elsif [:file_field_tag].include? question.input_type
28
+ .file_upload{"data-question-id" => question.id}
29
+ .files
30
+ = button_to_function t("active_admin.cms.forms.upload_new_file"), "fileUpload('#{dom_id(form)}', '#{dom_id(question)}', #{question.id})", style: "padding: 5px;"
31
+ - elsif question.input_type == :legend
32
+ %legend= question.label
33
+ - else
34
+ = send(question.input_type, dom_id(question), "", required: question.is_required, data: {form_question_id: question.id})
35
+
36
+ = button_to_function "", "print(#{form.id}, '#{dom_id(form)}')", class: 'print', title: t("active_admin.cms.forms.print")
37
+ = button_to_function "", "downloadPDF(#{form.id}, '#{dom_id(form)}')", class: 'save', title: t("active_admin.cms.forms.pdf")
38
+ = button_to_function t("active_admin.cms.forms.submit"), "deliver(#{form.id}, '#{dom_id(form)}')", class: 'send'
39
+
40
+ :javascript
41
+ $(function(){
42
+ setupCmsForm('#{dom_id(form)}');
43
+ });
44
+
45
+ function downloadPDF(form_id, form_dom_id){
46
+ window.location='/forms/'+form_id+'/download.pdf?form_uuid='+localStorage[form_dom_id];
47
+ }
48
+
49
+ function print(form_id, form_dom_id){
50
+ window.open('/forms/'+form_id+'/download?print=true&form_uuid='+localStorage[form_dom_id]);
51
+ }
52
+
53
+ function deliver(form_id, form_dom_id) {
54
+ if ($('#'+form_dom_id).valid() == true) {
55
+ window.location='/forms/'+form_id+'/deliver?form_uuid='+localStorage[form_dom_id];
56
+ }
57
+ }
@@ -45,4 +45,5 @@ en:
45
45
  email_subject: "New form has been submitted"
46
46
  upload: "Upload"
47
47
  upload_new_file: "Upload new file"
48
- uploaded_files: "Uploaded files"
48
+ uploaded_files: "Uploaded files"
49
+ delete: "(delete)"
data/config/routes.rb CHANGED
@@ -13,6 +13,7 @@ Rails.application.routes.draw do
13
13
  post :find_or_create
14
14
  get :attachments
15
15
  end
16
+ resources :form_answer_attachments, only: :destroy
16
17
  end
17
18
 
18
19
  scope ":locale", :locale => /\w{2}/ do
@@ -0,0 +1,6 @@
1
+ class FormsStringsToText < ActiveRecord::Migration
2
+ def up
3
+ change_column :activeadmin_selleo_cms_form_questions, :hint, :text
4
+ change_column :activeadmin_selleo_cms_form_answers, :value, :text
5
+ end
6
+ end
@@ -1,3 +1,3 @@
1
1
  module ActiveadminSelleoCms
2
- VERSION = "0.0.54"
2
+ VERSION = "0.0.58"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin-selleo-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.54
4
+ version: 0.0.58
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-14 00:00:00.000000000 Z
12
+ date: 2013-08-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -423,6 +423,7 @@ files:
423
423
  - app/controllers/cms_controller.rb
424
424
  - app/controllers/locales_controller.rb
425
425
  - app/controllers/form_answers_controller.rb
426
+ - app/controllers/form_answer_attachments_controller.rb
426
427
  - app/controllers/searches_controller.rb
427
428
  - app/admin/translation.rb
428
429
  - app/admin/active_admin/views_helper.rb
@@ -441,6 +442,7 @@ files:
441
442
  - app/assets/stylesheets/active_admin/jquery-ui.css.scss
442
443
  - app/assets/stylesheets/active_admin/cms.css.scss
443
444
  - app/assets/stylesheets/active_admin/jquery.Jcrop.css
445
+ - app/assets/images/ui-icons_cd0a0a_256x240.png
444
446
  - app/assets/images/admin/question_2.png
445
447
  - app/assets/images/admin/edit.png
446
448
  - app/assets/images/admin/question_0.png
@@ -448,7 +450,19 @@ files:
448
450
  - app/assets/images/admin/question_3.png
449
451
  - app/assets/images/admin/question_1.png
450
452
  - app/assets/images/admin/question_4.png
453
+ - app/assets/images/ui-icons_222222_256x240.png
454
+ - app/assets/images/ui-icons_454545_256x240.png
455
+ - app/assets/images/ui-bg_glass_75_e6e6e6_1x400.png
456
+ - app/assets/images/ui-bg_highlight-soft_75_cccccc_1x100.png
457
+ - app/assets/images/ui-bg_flat_0_aaaaaa_40x100.png
458
+ - app/assets/images/ui-icons_2e83ff_256x240.png
459
+ - app/assets/images/ui-bg_glass_55_fbf9ee_1x400.png
460
+ - app/assets/images/ui-bg_flat_75_ffffff_40x100.png
461
+ - app/assets/images/ui-bg_glass_95_fef1ec_1x400.png
451
462
  - app/assets/images/activeadmin-selleo-cms/Jcrop.gif
463
+ - app/assets/images/ui-bg_glass_75_dadada_1x400.png
464
+ - app/assets/images/ui-icons_888888_256x240.png
465
+ - app/assets/images/ui-bg_glass_65_ffffff_1x400.png
452
466
  - app/assets/javascripts/active_admin.js
453
467
  - app/assets/javascripts/ckeditor/config.js
454
468
  - app/assets/javascripts/ckeditor/toolbars.js
@@ -468,10 +482,10 @@ files:
468
482
  - app/assets/javascripts/activeadmin-selleo-cms/jquery.browser.js
469
483
  - app/assets/javascripts/activeadmin-selleo-cms/inline-editing.js
470
484
  - app/assets/javascripts/activeadmin-selleo-cms/forms.js
485
+ - app/views/forms/_form.html.haml
471
486
  - app/views/forms/download.html.erb
472
487
  - app/views/forms/deliver.html.erb
473
- - app/views/forms/_download.erb
474
- - app/views/forms/_form.html.erb
488
+ - app/views/forms/_download.haml
475
489
  - app/views/forms/download.pdf.erb
476
490
  - app/views/admin/sections/_form.html.haml
477
491
  - app/views/admin/sections/update.js.erb
@@ -528,6 +542,7 @@ files:
528
542
  - app/views/form_answers/edit.html.haml
529
543
  - app/views/form_answers/_attachments.html.haml
530
544
  - app/views/activeadmin_selleo_cms/form_mailer/form_submission.html.erb
545
+ - app/views/form_answer_attachments/destroy.js.erb
531
546
  - app/modules/activeadmin_selleo_cms/content_translation.rb
532
547
  - app/models/translation.rb
533
548
  - app/models/ckeditor/asset.rb
@@ -562,6 +577,7 @@ files:
562
577
  - db/migrate/20130625104333_create_activeadmin_selleo_cms_forms.rb
563
578
  - db/migrate/20121204112326_create_ckeditor_assets.rb
564
579
  - db/migrate/20130814151821_add_email_to_forms.rb
580
+ - db/migrate/20130815104316_forms_strings_to_text.rb
565
581
  - db/migrate/20130102113712_create_activeadmin_selleo_cms_assets.rb
566
582
  - db/migrate/20130206173233_change_activeadmin_selleo_cms_searches.rb
567
583
  - db/migrate/20121129160200_create_activeadmin_selleo_cms_locales.rb
@@ -1,55 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
- <head>
5
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6
- <%= wicked_pdf_stylesheet_link_tag "components/forms" -%>
7
- </head>
8
- <body>
9
-
10
- <%= form_tag '/forms', multipart: true, id: dom_id(@form), data: {form_id: @form.id} do %>
11
- <ol class="questions">
12
- <% @form.questions.each do |question| %>
13
- <li class="question <%= question.input_type %>">
14
- <div class="questions_labels">
15
- <%= label_tag dom_id(question), question.title %>
16
- <% if question.hint.present? %>
17
- <p class="hint"><%= question.hint %></p>
18
- <% end %>
19
- </div>
20
- <% if [:check_box_tag].include? question.input_type %>
21
- <div class="questions_options">
22
- <% question.options.each do |option| %>
23
- <%= send(question.input_type, "#{dom_id(question)}[]", option.id, ActiveadminSelleoCms::FormAnswer.value_for(params[:form_uuid], dom_id(option))=="true", required: question.is_required, id: dom_id(option), data: {form_question_id: question.id} ) %>
24
- <%= label_tag dom_id(option), option.title %>
25
- <% end %>
26
- <%= text_field_tag "#{dom_id(question)}_other", ActiveadminSelleoCms::FormAnswer.value_for(params[:form_uuid], "#{dom_id(question)}_other"), data: {form_question_id: question.id} if question.has_other_option %>
27
- </div>
28
- <% elsif [:radio_button_tag].include? question.input_type %>
29
- <div class="questions_options">
30
- <% question.options.each do |option| %>
31
- <%= send(question.input_type, dom_id(question), option.id, ActiveadminSelleoCms::FormAnswer.value_for(params[:form_uuid], dom_id(option)), required: question.is_required, id: dom_id(option), data: {form_question_id: question.id}) %>
32
- <%= label_tag dom_id(option), option.title %>
33
- <% end %>
34
- <%= text_field_tag "#{dom_id(question)}_other", ActiveadminSelleoCms::FormAnswer.value_for(params[:form_uuid], "#{dom_id(question)}_other"), data: {form_question_id: question.id} if question.has_other_option %>
35
- </div>
36
- <% elsif [:file_field_tag].include? question.input_type %>
37
- <div class="file_upload">
38
- <ol>
39
- <% ActiveadminSelleoCms::FormAnswer.files_for(params[:form_uuid], dom_id(question)).each do |file| %>
40
- <li><%= file.data_file_name %></li>
41
- <% end %>
42
- </ol>
43
- </div>
44
- <% elsif question.input_type == :legend %>
45
- <legend><%= question.label %></legend>
46
- <% else %>
47
- <%= send(question.input_type, dom_id(question), ActiveadminSelleoCms::FormAnswer.value_for(params[:form_uuid], dom_id(question)), required: question.is_required, data: {form_question_id: question.id}) %>
48
- <% end %>
49
- </li>
50
- <% end %>
51
- </ol>
52
- <% end %>
53
-
54
- </body>
55
- </html>
@@ -1,71 +0,0 @@
1
- <%= button_to_function t("active_admin.cms.forms.submit"), "deliver(#{form.id}, '#{dom_id(form)}')", class: 'send' %>
2
-
3
- <%= form_tag '/forms', multipart: true, id: dom_id(form), data: {form_id: form.id} do %>
4
- <ol class="questions">
5
- <% form.questions.each do |question| %>
6
- <li class="question <%= question.input_type %>">
7
-
8
- <% unless question.input_type == :legend %>
9
- <div class="questions_labels">
10
- <%= label_tag dom_id(question), question.label %>
11
- <% if question.hint.present? %>
12
- <p class="hint"><%= question.hint %></p>
13
- <% end %>
14
- </div>
15
- <% end %>
16
-
17
- <% if [:check_box_tag].include? question.input_type %>
18
- <div class="questions_options">
19
- <% question.options.each do |option| %>
20
- <%= send(question.input_type, "#{dom_id(question)}[]", option.id, false, required: question.is_required, id: dom_id(option), data: {form_question_id: question.id} ) %>
21
- <%= label_tag dom_id(option), option.label %>
22
- <% end %>
23
- <%= text_field_tag "#{dom_id(question)}_other", "", data: {form_question_id: question.id} if question.has_other_option %>
24
- </div>
25
- <% elsif [:radio_button_tag].include? question.input_type %>
26
- <div class="questions_options">
27
- <% question.options.each do |option| %>
28
- <%= send(question.input_type, dom_id(question), option.id, false, required: question.is_required, id: dom_id(option), data: {form_question_id: question.id}) %>
29
- <%= label_tag dom_id(option), option.label %>
30
- <% end %>
31
- <%= label_tag "#{dom_id(question)}_other", t("active_admin.cms.forms.other") %>
32
- <%= text_field_tag "#{dom_id(question)}_other", "", data: {form_question_id: question.id} if question.has_other_option %>
33
- </div>
34
- <% elsif [:file_field_tag].include? question.input_type %>
35
- <div class="file_upload" data-question-id="<%= question.id %>">
36
- <div class="files"></div>
37
- <%= button_to_function t("active_admin.cms.forms.upload_new_file"), "fileUpload('#{dom_id(form)}', '#{dom_id(question)}', #{question.id})", style: "padding: 5px;" %>
38
- </div>
39
- <% elsif question.input_type == :legend %>
40
- <legend><%= question.label %></legend>
41
- <% else %>
42
- <%= send(question.input_type, dom_id(question), "", required: question.is_required, data: {form_question_id: question.id}) %>
43
- <% end %>
44
- </li>
45
- <% end %>
46
- </ol>
47
- <% end %>
48
-
49
- <%= button_to_function "", "print(#{form.id}, '#{dom_id(form)}')", class: 'print', title: t("active_admin.cms.forms.print") %>
50
- <%= button_to_function "", "downloadPDF(#{form.id}, '#{dom_id(form)}')", class: 'save', title: t("active_admin.cms.forms.pdf") %>
51
- <%= button_to_function t("active_admin.cms.forms.submit"), "deliver(#{form.id}, '#{dom_id(form)}')", class: 'send' %>
52
-
53
- <script>
54
- $(function(){
55
- setupCmsForm('<%= dom_id(form) %>');
56
- });
57
-
58
- function downloadPDF(form_id, form_dom_id){
59
- window.location='/forms/'+form_id+'/download.pdf?form_uuid='+localStorage[form_dom_id];
60
- }
61
-
62
- function print(form_id, form_dom_id){
63
- window.open('/forms/'+form_id+'/download?print=true&form_uuid='+localStorage[form_dom_id]);
64
- }
65
-
66
- function deliver(form_id, form_dom_id) {
67
- if ($('#'+form_dom_id).valid() == true) {
68
- window.location='/forms/'+form_id+'/deliver?form_uuid='+localStorage[form_dom_id];
69
- }
70
- }
71
- </script>