Limit editing of child campaigns
This commit is contained in:
parent
e5419408ce
commit
341d7511d2
5 changed files with 50 additions and 38 deletions
|
@ -180,6 +180,14 @@ class Campaign < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def child_campaign?
|
||||
true if parent_campaign.present?
|
||||
if parent_campaign.present?
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
def parent_campaign?
|
||||
!child_campaign?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,39 +5,42 @@
|
|||
|
||||
<p><strong>Manage Campaign</strong></p>
|
||||
|
||||
|
||||
<a class='button--tiny edit'>
|
||||
<!--= on 'click' (open_modal 'campaignSettings') -->
|
||||
<i class='fa fa-gear'></i> Settings
|
||||
</a>
|
||||
|
||||
<a class='button--tiny edit' target='_blank' href="<%= @campaign.url + '/supporters' %>">
|
||||
<i class='fa fa-th-list'></i> Dashboard
|
||||
</a>
|
||||
|
||||
<a class='button--tiny edit'>
|
||||
<!--= on 'click' (open_modal 'offlineCampaignDonation') -->
|
||||
<i class='fa fa-plus'></i> Offsite Donation
|
||||
</a>
|
||||
|
||||
<a class='button--tiny edit'>
|
||||
<!--= on 'click' (open_modal 'manageGiftOptionsModal') -->
|
||||
<i class='fa fa-gift'></i> Gift Options
|
||||
<!--= on 'click' (open_modal 'campaignSettings') -->
|
||||
<i class='fa fa-gear'></i> Settings
|
||||
</a>
|
||||
|
||||
<a class='button--tiny edit'>
|
||||
<!--= on 'click' (open_modal 'customReceiptModal') -->
|
||||
<i class='fa fa-pencil'></i> Custom Receipt
|
||||
</a>
|
||||
<% if @campaign.parent_campaign? %>
|
||||
<a class='button--tiny edit' target='_blank' href="<%= @campaign.url + '/supporters' %>">
|
||||
<i class='fa fa-th-list'></i> Dashboard
|
||||
</a>
|
||||
|
||||
<a class='button--tiny edit'>
|
||||
<!--= on 'click' (open_modal 'offlineCampaignDonation') -->
|
||||
<i class='fa fa-plus'></i> Offsite Donation
|
||||
</a>
|
||||
|
||||
<a class='button--tiny edit'>
|
||||
<!--= on 'click' (open_modal 'manageGiftOptionsModal') -->
|
||||
<i class='fa fa-gift'></i> Gift Options
|
||||
</a>
|
||||
|
||||
<a class='button--tiny edit'>
|
||||
<!--= on 'click' (open_modal 'customReceiptModal') -->
|
||||
<i class='fa fa-pencil'></i> Custom Receipt
|
||||
</a>
|
||||
<% end %>
|
||||
|
||||
<a class='button--tiny edit' href='?preview=t'>
|
||||
<i class='fa fa-eye'></i> Preview Mode
|
||||
</a>
|
||||
|
||||
<a class='button--tiny edit'>
|
||||
<!--= on 'click' (open_modal 'duplicateFundraiserModal') -->
|
||||
<i class='fa fa-copy'></i> Copy Campaign
|
||||
</a>
|
||||
<% if @campaign.parent_campaign? %>
|
||||
<a class='button--tiny edit'>
|
||||
<!--= on 'click' (open_modal 'duplicateFundraiserModal') -->
|
||||
<i class='fa fa-copy'></i> Copy Campaign
|
||||
</a>
|
||||
<% end %>
|
||||
|
||||
<%= render 'components/messages/deleted_campaign_or_event', type: 'campaign' %>
|
||||
|
||||
|
|
|
@ -16,14 +16,14 @@
|
|||
app.days_remaining = '<%= @campaign.days_left %>'
|
||||
app.recurring_fund = <%= @campaign.recurring_fund? %>
|
||||
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('campaign_is_deleted', <%= @campaign.deleted || false %>)
|
||||
appl.def('has_main_image', <%= @campaign.main_image.file.present? %>)
|
||||
</script>
|
||||
<%= render 'schema', campaign: @campaign, url: @url %>
|
||||
<%= render 'common/froala' if current_campaign_editor? %>
|
||||
appl.def('has_main_image', <%= @campaign.main_image.file.present? %>)
|
||||
</script>
|
||||
|
||||
<%= render 'schema', campaign: @campaign, url: @url %>
|
||||
<%= IncludeAsset.js '/client/js/campaigns/show/page.js' %>
|
||||
<% end %>
|
||||
|
||||
|
|
|
@ -17,10 +17,12 @@ require('../../components/ajax/toggle_soft_delete')(url, 'campaign')
|
|||
|
||||
// Initialize the froala wysiwyg
|
||||
var editable = require('../../common/editable')
|
||||
editable($('#js-campaignBody'), {
|
||||
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."
|
||||
})
|
||||
if (app.is_parent_campaign) {
|
||||
editable($('#js-campaignBody'), {
|
||||
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."
|
||||
})
|
||||
}
|
||||
|
||||
editable($('#js-customReceipt'), {
|
||||
button: ["bold", "italic", "formatBlock", "align", "createLink",
|
||||
|
|
|
@ -30,7 +30,7 @@ function init(giftsNeedRefresh$, parentState) {
|
|||
state.giftOptions$ = flyd.mergeAll([
|
||||
pageloadGifts$
|
||||
, refreshedGifts$
|
||||
, flyd.stream([]) // default before ajax loads
|
||||
, flyd.stream([]) // default before ajax loads
|
||||
])
|
||||
return state
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ const giftBox = state => gift => {
|
|||
, h('p.u-marginBottom--15', gift.description)
|
||||
, 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', {
|
||||
on: {click: ev => state.openEditGiftModal$(gift)}
|
||||
}, [
|
||||
|
@ -79,4 +79,3 @@ const totalContributions = gift => {
|
|||
}
|
||||
|
||||
module.exports = {view, init}
|
||||
|
||||
|
|
Loading…
Reference in a new issue