-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bfadee5
commit 5ccd01c
Showing
18 changed files
with
1,528 additions
and
1,359 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
Name: campaign-admin-extensions | ||
--- | ||
SilverStripe\Assets\Shortcodes\FileLink: | ||
extensions: | ||
- SilverStripe\CampaignAdmin\Extensions\HideInCampaignsExtension | ||
--- | ||
Name: campaign-admin-extensions-elemental | ||
Only: | ||
moduleexists: dnadesign/silverstripe-elemental | ||
--- | ||
DNADesign\Elemental\Models\ElementalArea: | ||
extensions: | ||
- SilverStripe\CampaignAdmin\Extensions\HideInCampaignsExtension | ||
--- | ||
Name: campaign-admin-extensions-asset-admin | ||
Only: | ||
moduleexists: silverstripe/asset-admin | ||
After: assetadmin | ||
--- | ||
SilverStripe\AssetAdmin\Forms\FileFormFactory: | ||
extensions: | ||
- SilverStripe\CampaignAdmin\Extensions\FileFormFactoryExtension | ||
SilverStripe\AssetAdmin\Controller\AssetAdmin: | ||
campaign_admin_managed_data_class: SilverStripe\Assets\File | ||
extensions: | ||
- SilverStripe\CampaignAdmin\Extensions\AddToCampaignExtension | ||
--- | ||
Name: campaign-admin-extensions-cms | ||
Only: | ||
moduleexists: silverstripe/cms | ||
--- | ||
SilverStripe\CMS\Model\SiteTree: | ||
extensions: | ||
- SilverStripe\CampaignAdmin\SiteTreeExtension | ||
SilverStripe\CMS\Controllers\CMSPageEditController: | ||
campaign_admin_managed_data_class: Page | ||
extensions: | ||
- SilverStripe\CampaignAdmin\Extensions\AddToCampaignExtension |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
require('../boot/index'); | ||
import '../legacy/AddToCampaignForm'; | ||
import '../boot/index'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* global window */ | ||
import i18n from 'i18n'; | ||
import jQuery from 'jquery'; | ||
import React from 'react'; | ||
import { createRoot } from 'react-dom/client'; | ||
import { loadComponent } from 'lib/Injector'; | ||
|
||
const FormBuilderModal = loadComponent('FormBuilderModal'); | ||
|
||
jQuery.entwine('ss', ($) => { | ||
/** | ||
* Kick off an "add to campaign" dialog from the CMS actions. | ||
*/ | ||
$( | ||
'.cms-content-actions .add-to-campaign-action,' + | ||
'#add-to-campaign__action' | ||
).entwine({ | ||
onclick() { | ||
let dialog = $('#add-to-campaign__dialog-wrapper'); | ||
|
||
if (!dialog.length) { | ||
dialog = $('<div id="add-to-campaign__dialog-wrapper" />'); | ||
$('body').append(dialog); | ||
} | ||
|
||
dialog.open(); | ||
|
||
return false; | ||
}, | ||
}); | ||
|
||
// This is required because the React version of e.preventDefault() doesn't work | ||
// this is to prevent PJAX request to occur when clicking a link the modal | ||
$('.add-to-campaign-modal .add-to-campaign-modal__nav-link').entwine({ | ||
onclick: (e) => { | ||
e.preventDefault(); | ||
const $link = $(e.target); | ||
window.location = $link.attr('href'); | ||
}, | ||
}); | ||
|
||
/** | ||
* Uses reactstrap in order to replicate the bootstrap styling and JavaScript behaviour. | ||
* The "add to campaign" dialog is used in a similar fashion in AssetAdmin. | ||
*/ | ||
$('#add-to-campaign__dialog-wrapper').entwine({ | ||
ReactRoot: null, | ||
|
||
onunmatch() { | ||
// solves errors given by ReactDOM "no matched root found" error. | ||
this._clearModal(); | ||
}, | ||
|
||
open() { | ||
this._renderModal(true); | ||
}, | ||
|
||
close() { | ||
this._renderModal(false); | ||
}, | ||
|
||
_renderModal(isOpen) { | ||
const handleHide = () => this.close(); | ||
const handleSubmit = (...args) => this._handleSubmitModal(...args); | ||
const id = $('form.cms-edit-form :input[name=ID]').val(); | ||
const sectionConfigKey = 'SilverStripe\\CMS\\Controllers\\CMSPageEditController'; | ||
const store = window.ss.store; | ||
const sectionConfig = store.getState().config.sections | ||
.find((section) => section.name === sectionConfigKey); | ||
const modalSchemaUrl = `${sectionConfig.form.addToCampaignForm.schemaUrl}/${id}`; | ||
const title = i18n._t('Admin.ADD_TO_CAMPAIGN', 'Add to campaign'); | ||
|
||
let root = this.getReactRoot(); | ||
if (!root) { | ||
root = createRoot(this[0]); | ||
} | ||
root.render( | ||
<FormBuilderModal | ||
title={title} | ||
isOpen={isOpen} | ||
onSubmit={handleSubmit} | ||
onClosed={handleHide} | ||
schemaUrl={modalSchemaUrl} | ||
bodyClassName="modal__dialog" | ||
className="add-to-campaign-modal" | ||
responseClassBad="modal__response modal__response--error" | ||
responseClassGood="modal__response modal__response--good" | ||
identifier="Admin.AddToCampaign" | ||
/> | ||
); | ||
this.setReactRoot(root); | ||
}, | ||
|
||
_clearModal() { | ||
const root = this.getReactRoot(); | ||
if (root) { | ||
root.unmount(); | ||
this.setReactRoot(null); | ||
} | ||
// this.empty(); | ||
}, | ||
|
||
_handleSubmitModal(data, action, submitFn) { | ||
return submitFn(); | ||
}, | ||
|
||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.