Limit editing of child campaigns

This commit is contained in:
Kasia Jarmołkowicz 2018-07-06 19:06:39 +02:00 committed by Eric Schultz
parent e5419408ce
commit 341d7511d2
5 changed files with 50 additions and 38 deletions

View file

@ -180,6 +180,14 @@ class Campaign < ActiveRecord::Base
end end
def child_campaign? def child_campaign?
true if parent_campaign.present? if parent_campaign.present?
true
else
false
end
end
def parent_campaign?
!child_campaign?
end end
end end

View file

@ -5,12 +5,12 @@
<p><strong>Manage Campaign</strong></p> <p><strong>Manage Campaign</strong></p>
<a class='button--tiny edit'> <a class='button--tiny edit'>
<!--= on 'click' (open_modal 'campaignSettings') --> <!--= on 'click' (open_modal 'campaignSettings') -->
<i class='fa fa-gear'></i> Settings <i class='fa fa-gear'></i> Settings
</a> </a>
<% if @campaign.parent_campaign? %>
<a class='button--tiny edit' target='_blank' href="<%= @campaign.url + '/supporters' %>"> <a class='button--tiny edit' target='_blank' href="<%= @campaign.url + '/supporters' %>">
<i class='fa fa-th-list'></i> Dashboard <i class='fa fa-th-list'></i> Dashboard
</a> </a>
@ -29,15 +29,18 @@
<!--= on 'click' (open_modal 'customReceiptModal') --> <!--= on 'click' (open_modal 'customReceiptModal') -->
<i class='fa fa-pencil'></i> Custom Receipt <i class='fa fa-pencil'></i> Custom Receipt
</a> </a>
<% end %>
<a class='button--tiny edit' href='?preview=t'> <a class='button--tiny edit' href='?preview=t'>
<i class='fa fa-eye'></i> Preview Mode <i class='fa fa-eye'></i> Preview Mode
</a> </a>
<% if @campaign.parent_campaign? %>
<a class='button--tiny edit'> <a class='button--tiny edit'>
<!--= on 'click' (open_modal 'duplicateFundraiserModal') --> <!--= on 'click' (open_modal 'duplicateFundraiserModal') -->
<i class='fa fa-copy'></i> Copy Campaign <i class='fa fa-copy'></i> Copy Campaign
</a> </a>
<% end %>
<%= render 'components/messages/deleted_campaign_or_event', type: 'campaign' %> <%= render 'components/messages/deleted_campaign_or_event', type: 'campaign' %>

View file

@ -17,13 +17,13 @@
app.recurring_fund = <%= @campaign.recurring_fund? %> app.recurring_fund = <%= @campaign.recurring_fund? %>
app.vimeo_id = "<%= @campaign.vimeo_video_id ? @campaign.vimeo_video_id : '' %>" app.vimeo_id = "<%= @campaign.vimeo_video_id ? @campaign.vimeo_video_id : '' %>"
app.current_campaign_editor = <%= current_campaign_editor? %> app.current_campaign_editor = <%= current_campaign_editor? %>
app.is_parent_campaign = <%= @campaign.parent_campaign? %>
appl.def('has_video', <%= @campaign.video_url.present? %>) appl.def('has_video', <%= @campaign.video_url.present? %>)
appl.def('campaign_is_deleted', <%= @campaign.deleted || false %>) appl.def('campaign_is_deleted', <%= @campaign.deleted || false %>)
appl.def('has_main_image', <%= @campaign.main_image.file.present? %>) appl.def('has_main_image', <%= @campaign.main_image.file.present? %>)
</script> </script>
<%= render 'schema', campaign: @campaign, url: @url %>
<%= render 'common/froala' if current_campaign_editor? %>
<%= render 'schema', campaign: @campaign, url: @url %>
<%= IncludeAsset.js '/client/js/campaigns/show/page.js' %> <%= IncludeAsset.js '/client/js/campaigns/show/page.js' %>
<% end %> <% end %>

View file

@ -17,10 +17,12 @@ require('../../components/ajax/toggle_soft_delete')(url, 'campaign')
// Initialize the froala wysiwyg // Initialize the froala wysiwyg
var editable = require('../../common/editable') var editable = require('../../common/editable')
editable($('#js-campaignBody'), { if (app.is_parent_campaign) {
editable($('#js-campaignBody'), {
sticky: true, sticky: true,
placeholder: "Add your campaign's story here. We strongly recommend that this section is filled out with at least 250 words. It will be saved automatically as you type. You can add images, videos and custom HTML too." placeholder: "Add your campaign's story here. We strongly recommend that this section is filled out with at least 250 words. It will be saved automatically as you type. You can add images, videos and custom HTML too."
}) })
}
editable($('#js-customReceipt'), { editable($('#js-customReceipt'), {
button: ["bold", "italic", "formatBlock", "align", "createLink", button: ["bold", "italic", "formatBlock", "align", "createLink",

View file

@ -59,7 +59,7 @@ const giftBox = state => gift => {
, h('p.u-marginBottom--15', gift.description) , h('p.u-marginBottom--15', gift.description)
, h('div', [ giftButton(state, gift) ]) , h('div', [ giftButton(state, gift) ])
]) ])
, app.current_campaign_editor // Show edit button only if the current user is a campaign editor , (app.current_campaign_editor && app.is_parent_campaign) // Show edit button only if the current user is a parent campaign editor
? h('button.button--tiny.absolute.edit.hasShadow', { ? h('button.button--tiny.absolute.edit.hasShadow', {
on: {click: ev => state.openEditGiftModal$(gift)} on: {click: ev => state.openEditGiftModal$(gift)}
}, [ }, [
@ -79,4 +79,3 @@ const totalContributions = gift => {
} }
module.exports = {view, init} module.exports = {view, init}