Skip to content
This repository was archived by the owner on Mar 27, 2023. It is now read-only.

Commit 4c5b569

Browse files
committed
Merge pull request #384 from SumOfUs/hallway-mods
[Pre-deploy] Modifications from hallway tests
2 parents 3ada8f0 + 9b8c59e commit 4c5b569

27 files changed

Lines changed: 207 additions & 31 deletions

app/assets/javascripts/layout_picker.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const setupOnce = require('setup_once');
66

77
events: {
88
'click .radio-group__option': 'updateSelected',
9+
'change .layout-type-checkbox': 'showRelevantLayouts'
910
},
1011

1112
updateSelected(e) {
@@ -28,6 +29,25 @@ const setupOnce = require('setup_once');
2829
}
2930
},
3031

32+
showRelevantLayouts(e) {
33+
const $target = $(e.target);
34+
const layoutClasses = this.getLayoutClasses($target.attr('id'));
35+
const layoutRows = $target.closest('.form-group').find(layoutClasses.inverse_class).not(layoutClasses.own_class);
36+
if ($target.is(':checked')) {
37+
layoutRows.removeClass('hidden');
38+
} else {
39+
layoutRows.addClass('hidden');
40+
}
41+
},
42+
43+
getLayoutClasses(layout_select_id) {
44+
if (layout_select_id==='primary') {
45+
return {inverse_class: '.post-action-layout', own_class: '.primary-layout'}
46+
} else if (layout_select_id==='follow-up') {
47+
return {inverse_class: '.primary-layout', own_class: '.post-action-layout'}
48+
}
49+
}
50+
3151
});
3252

3353
$.subscribe("layout:edit pages:new", function(){

app/assets/stylesheets/page-edit.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,3 +430,7 @@ body.page-edit-body {
430430
.well .tooltip__trigger, .tooltip--white .tooltip__trigger {
431431
background: white;
432432
}
433+
434+
.checkbox input[type="checkbox"].layout-type-checkbox {
435+
margin-left: 0px;
436+
}

app/controllers/liquid_layouts_controller.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def set_liquid_layout
6565

6666
# Never trust parameters from the scary internet, only allow the white list through.
6767
def liquid_layout_params
68-
params.require(:liquid_layout).permit(:title, :content, :description, :experimental)
68+
params.require(:liquid_layout).permit(:title, :content, :description, :experimental,
69+
:primary_layout, :post_action_layout, :default_follow_up_layout_id)
6970
end
7071
end

app/helpers/api/actions_helper.rb

Lines changed: 0 additions & 2 deletions
This file was deleted.

app/helpers/campaigns_helper.rb

Lines changed: 0 additions & 2 deletions
This file was deleted.

app/helpers/form_elements_helper.rb

Lines changed: 0 additions & 2 deletions
This file was deleted.

app/helpers/forms_helper.rb

Lines changed: 0 additions & 2 deletions
This file was deleted.

app/helpers/home_helper.rb

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
module LayoutSelectHelper
2+
3+
def construct_layout_select_class(liquid_layout, page, field)
4+
hidden = check_hidden(liquid_layout, field)
5+
active = check_active(liquid_layout, page, field)
6+
post_action_layout = liquid_layout.post_action_layout ? 'post-action-layout' : ''
7+
primary_layout = liquid_layout.primary_layout ? 'primary-layout' : ''
8+
"#{hidden} #{active} #{primary_layout} #{post_action_layout}"
9+
end
10+
11+
def specify_layout_types(field)
12+
(field == :liquid_layout_id) ? 'primary' : 'follow-up'
13+
end
14+
15+
private
16+
17+
def check_hidden(liquid_layout, field)
18+
if field == :liquid_layout_id
19+
return 'hidden' unless liquid_layout.primary_layout
20+
elsif field == :follow_up_liquid_layout_id
21+
return 'hidden' unless liquid_layout.post_action_layout
22+
end
23+
''
24+
end
25+
26+
def check_active(liquid_layout, page, field)
27+
if field == :follow_up_liquid_layout_id && page.follow_up_plan.to_sym == :with_page
28+
return '' # the redirect option will be the active one in this case
29+
end
30+
# page.send(field) calls either page.liquid_layout_id or page.follow_up_liquid_layout_id
31+
liquid_layout.id == page.send(field) ? 'active' : ''
32+
end
33+
end

app/helpers/liquid_layouts_helper.rb

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)