app/views/properties/_form.html.erb
<%= simple_form_for property, html: {class: "js-validate"}, data: {controller: "property-form"}, wrapper: :front_form do |f| %>
<%= render(Form::ErrorMessageComponent.new(object: property)) %>
<%= render CardComponent.new do %>
<%= render Card::BodyComponent.new do %>
<%= render(Card::TitleComponent.new(classes: "mb-4")) { "Details" } %>
<div class="row">
<%= tag.div f.input(:status,
label: "Status",
collection: ENUMS::PROPERTY_STATUSES.values.map { |status| [status.capitalize, status] },
required: true,
input_html: {
class: "form-control", data: {controller: "select", "reflex-permanent": true}
}), class: "col-md-6 mb-3" if authorized_user.can_admin_system? %>
<%= tag.div f.input(:revenue_percentage,
required: true,
input_html: {
class: "form-control", data: {msg: "Please enter a property name", "reflex-permanent": true}
}), class: "col-md-6 mb-3" if authorized_user.can_admin_system? %>
<%= tag.div f.input(:name,
required: true,
input_html: {
class: "form-control", data: {msg: "Please enter a property name", "reflex-permanent": true}
}), class: "col-md-6 mb-3" %>
<%= tag.div f.input(:property_type,
label: "Type",
collection: ENUMS::PROPERTY_TYPES.values.map { |property_type| [property_type.capitalize, property_type] },
required: true,
input_html: {class: "form-control", data: {controller: "select", "reflex-permanent": true}
}), class: "col-md-6 mb-3" if authorized_user.can_admin_system? %>
<%= tag.div f.input(:audience_id,
label: "Audience",
collection: Audience.all.map { |audience| [audience.name, audience.id] },
required: true,
input_html: {
class: "form-control", data: {controller: "select", property_id: property.id, reflex: "cf:select:changed->PropertyFormReflex#update_audience"}
}), class: "col-md-6 mb-3" if authorized_user.can_admin_system? %>
<%= tag.div f.input(:language,
label: "Primary Language",
collection: ENUMS::LANGUAGES.values,
required: true,
input_html: {
class: "form-control", data: {controller: "select", "reflex-permanent": true}
}), class: "col-md-6 mb-3" %>
<%= tag.div f.input(:description,
input_html: {
class: "form-control", rows: 2, data: {"reflex-permanent": true}
}), class: "col-12 mb-3" %>
<%= tag.div f.input(:url,
as: :url,
required: true,
placeholder: "https://",
input_html: {
class: "form-control", data: {msg: "Please enter a valid website URL", rule_url: true, "reflex-permanent": true}
}), class: "col-12 mb-3" %>
<% if authorized_user.can_admin_system? %>
<div class="col-md-12 mb-3">
<%= f.input(:keywords,
label: "Programming Languages & Topics",
collection: ENUMS::KEYWORDS.keys,
required: true,
input_html: {
class: "form-control btn-primary", multiple: true, data: {controller: "select"}
}) %>
<small class="form-text text-muted mt-2">
<strong>IMPORTANT</strong>: Must be a subset of the <%= link_to "audience", audiences_path, target: "_blank" %>.
</small>
</div>
<% end %>
<%= tag.div f.input(:ad_template,
label: "Template",
collection: ENUMS::AD_TEMPLATES.values,
required: true,
input_html: {
class: "form-control", data: {controller: "select", "reflex-permanent": true}
}), class: "col-md-6" %>
<%= tag.div f.input(:ad_theme,
label: "Theme",
collection: ENUMS::AD_THEMES.values,
required: true,
input_html: {
class: "form-control", data: {controller: "select", "reflex-permanent": true}
}), class: "col-md-6" %>
<div class="col-md-12 mb-3">
<small class="form-text text-muted">
View examples of our ad templates <%= link_to "here", demo_path, class: "alert-link", target: "_blank" %>
</small>
</div>
<%= tag.div f.input(:fallback_ad_template,
label: "Fallback Template",
collection: ENUMS::AD_TEMPLATES.values,
input_html: {
class: "form-control", data: {controller: "select", "reflex-permanent": true}
}), class: "col-md-6 mb-3" %>
<%= tag.div f.input(:fallback_ad_theme,
label: "Fallback Theme",
collection: ENUMS::AD_THEMES.values,
input_html: {
class: "form-control", data: {controller: "select", "reflex-permanent": true}
}), class: "col-md-6 mb-3" %>
<div class="col-12 mb-3">
<%= f.input(:responsive_behavior,
label: "Responsive Behavior <small>for smaller screens</small>".html_safe,
collection: property_responsive_behaviors_for_select,
input_html: {class: "form-control", data: {controller: "select", "reflex-permanent": true}
}) %>
<small class="form-text text-muted mt-2">
<strong>IMPORTANT</strong>:
Responsive behavior on small screens requires that the viewport <code>meta</code> tag be included in your site's <code>head</code> section.
</small>
<pre class="mt-1 p-2" style="background-color:#d5dae3;"><code><meta name="viewport" content="width=device-width, initial-scale=1.0"></code></pre>
</div>
<%= tag.div f.input(:prohibited_organization_ids,
label: "Excluded Advertisers",
collection: organizations_for_select,
input_html: {
class: "form-control", multiple: true, data: {controller: "select", "reflex-permanent": true}
}), class: "col-12 mb-3" if authorized_user.can_admin_system? %>
<% if @assignable_fallback_campaigns&.exists? %>
<div class="col-12 mb-3" data-controller="select-multiple">
<%= f.input(:assigned_fallback_campaign_ids,
collection: @assignable_fallback_campaigns.map { |c| [c.scoped_name(truncate: true), c.id]},
label: "Assigned Fallback Campaigns <small class='ml-2 text-danger'><i class='fas fa-exclamation-triangle'></i> restricts fallback campaigns to this list</small>".html_safe,
input_html: {
multiple: true, data: {controller: "select", target: "select-multiple.select", "reflex-permanent": true}
}) %>
<div class="d-block">
<%= link_to "Clear", request.path, class: "btn text-uppercase btn-subtle-secondary btn-xs py-0", data: {action: "click->select-multiple#clearSelections"} %>
</div>
</div>
<% end %>
<% if authorized_user.can_admin_system? %>
<div class="col-12 mb-2 mt-2">
<div class="media align-items-center mb-3">
<%= f.label :restrict_to_assigner_campaigns, class: "switcher-control mb-0 mr-3" do %>
<%= f.check_box :restrict_to_assigner_campaigns, class: "switcher-input", data: {"reflex-permanent": true} %>
<span class="switcher-indicator"></span>
<% end %>
<label class="mb-0">
<span class="d-block">Restrict premium campaigns to those that have explicitly assigned this property</span>
</label>
</div>
</div>
<% end %>
<div class="col-12 mb-2 mt-2">
<div class="media align-items-center mb-3">
<%= f.label :prohibit_fallback_campaigns, class: "switcher-control mb-0 mr-3" do %>
<%= f.check_box :prohibit_fallback_campaigns, class: "switcher-input", data: {"reflex-permanent": true} %>
<span class="switcher-indicator"></span>
<% end %>
<label class="mb-0">
<span class="d-block">
Do not display fallback ads
<span class="text-link small"
data-toggle="popover"
title="Why allow fallback ads?"
data-content="CodeFund uses fallback ads to help subsidize revenue and display community messages. This allows us to maintain the highest publisher revenue rates.">
(why allow fallback ads?)
</span>
</span>
</label>
</div>
</div>
</div>
<% end %>
<%= render Card::FooterComponent.new do |component| %>
<% component.with(:actions) do %>
<%= cancel_button(properties_path) %>
<%= f.submit "Save Property", class: "btn btn-primary" %>
<% end %>
<% end %>
<% end %>
<% end %>