mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Correct campaign badges, "revert" placeholder button
This commit is contained in:
parent
37d3d22fbd
commit
8554b43ccc
@ -23,5 +23,6 @@ if(typeof(ss) == 'undefined' || typeof(ss.i18n) == 'undefined') {
|
||||
"Campaigns.PUBLISHCAMPAIGN": "Publish campaign",
|
||||
"Campaigns.ITEM_SUMMARY_SINGULAR": "%s item",
|
||||
"Campaigns.ITEM_SUMMARY_PLURAL": "%s items",
|
||||
"Campaigns.REVERTCAMPAIGN": "Revert",
|
||||
});
|
||||
}
|
||||
|
@ -16,4 +16,7 @@
|
||||
"LeftAndMain.PAGEWASDELETED": "This page was deleted. To edit a page, select it from the left.",
|
||||
"Campaigns.ADDCAMPAIGN": "Add campaign",
|
||||
"Campaigns.PUBLISHCAMPAIGN": "Publish campaign",
|
||||
"Campaigns.ITEM_SUMMARY_SINGULAR": "%s item",
|
||||
"Campaigns.ITEM_SUMMARY_PLURAL": "%s items",
|
||||
"Campaigns.REVERTCAMPAIGN": "Revert",
|
||||
}
|
||||
|
@ -10,28 +10,32 @@ class CampaignItem extends SilverStripeComponent {
|
||||
let thumbnail = null;
|
||||
const badge = {};
|
||||
const item = this.props.item;
|
||||
const campaign = this.props.campaign;
|
||||
|
||||
// @todo customise these status messages for already-published changesets
|
||||
|
||||
// change badge
|
||||
switch (item.ChangeType) {
|
||||
case 'created':
|
||||
badge.className = 'label label-warning';
|
||||
badge.Title = i18n._t('CampaignItem.DRAFT', 'Draft');
|
||||
break;
|
||||
case 'modified':
|
||||
badge.className = 'label label-warning';
|
||||
badge.Title = i18n._t('CampaignItem.MODIFIED', 'Modified');
|
||||
break;
|
||||
case 'deleted':
|
||||
badge.className = 'label label-error';
|
||||
badge.Title = i18n._t('CampaignItem.REMOVED', 'Removed');
|
||||
break;
|
||||
case 'none':
|
||||
default:
|
||||
badge.className = 'label label-success item_visible-hovered';
|
||||
badge.Title = i18n._t('CampaignItem.NO_CHANGES', 'No changes');
|
||||
break;
|
||||
// Change badge. If the campaign has been published,
|
||||
// don't apply a badge at all
|
||||
if (campaign.State === 'open') {
|
||||
switch (item.ChangeType) {
|
||||
case 'created':
|
||||
badge.className = 'label label-warning';
|
||||
badge.Title = i18n._t('CampaignItem.DRAFT', 'Draft');
|
||||
break;
|
||||
case 'modified':
|
||||
badge.className = 'label label-warning';
|
||||
badge.Title = i18n._t('CampaignItem.MODIFIED', 'Modified');
|
||||
break;
|
||||
case 'deleted':
|
||||
badge.className = 'label label-error';
|
||||
badge.Title = i18n._t('CampaignItem.REMOVED', 'Removed');
|
||||
break;
|
||||
case 'none':
|
||||
default:
|
||||
badge.className = 'label label-success item_visible-hovered';
|
||||
badge.Title = i18n._t('CampaignItem.NO_CHANGES', 'No changes');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Linked items
|
||||
@ -48,9 +52,17 @@ class CampaignItem extends SilverStripeComponent {
|
||||
{thumbnail}
|
||||
<h4 className="list-group-item-heading">{item.Title}</h4>
|
||||
{links}
|
||||
<span className={badge.className}>{badge.Title}</span>
|
||||
{badge.className && badge.Title &&
|
||||
<span className={badge.className}>{badge.Title}</span>
|
||||
}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
CampaignItem.propTypes = {
|
||||
campaign: React.PropTypes.object.isRequired,
|
||||
item: React.PropTypes.object.isRequired,
|
||||
};
|
||||
|
||||
export default CampaignItem;
|
||||
|
@ -38,6 +38,7 @@ class CampaignListContainer extends SilverStripeComponent {
|
||||
render() {
|
||||
const itemID = 1; // todo - hook up to "click" handler for changesetitems
|
||||
const campaignId = this.props.campaignId;
|
||||
const campaign = this.props.record;
|
||||
|
||||
// Trigger different layout when preview is enabled
|
||||
const previewUrl = this.previewURLForItem(itemID);
|
||||
@ -60,13 +61,13 @@ class CampaignListContainer extends SilverStripeComponent {
|
||||
// Add extra css class for published items
|
||||
let itemClassName = '';
|
||||
|
||||
if (item.ChangeType === 'none') {
|
||||
if (item.ChangeType === 'none' || campaign.State === 'published') {
|
||||
itemClassName = 'list-group-item--published';
|
||||
}
|
||||
|
||||
accordionItems.push(
|
||||
<AccordionItem key={item.ID} className={itemClassName}>
|
||||
<CampaignItem item={item} />
|
||||
<CampaignItem item={item} campaign={this.props.record} />
|
||||
</AccordionItem>
|
||||
);
|
||||
});
|
||||
@ -123,20 +124,24 @@ class CampaignListContainer extends SilverStripeComponent {
|
||||
// TODO Implement "revert" feature
|
||||
button = (
|
||||
<FormAction
|
||||
label={i18n._t('Campaigns.PUBLISHCAMPAIGN')}
|
||||
style={'success'}
|
||||
label={i18n._t('Campaigns.REVERTCAMPAIGN')}
|
||||
style={'warning'}
|
||||
disabled
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
// TODO Fix indicator positioning
|
||||
// const itemCountIndicator = (
|
||||
// <span className="text-muted">
|
||||
// <span className="label label-warning label--empty"> </span>
|
||||
// {itemSummaryLabel}
|
||||
// </span>
|
||||
// );
|
||||
|
||||
return (
|
||||
<div className="btn-toolbar">
|
||||
{button}
|
||||
<span className="text-muted">
|
||||
<span className="label label-warning label--empty"> </span>
|
||||
{itemSummaryLabel}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user