silverstripe-contentreview/client/src/bundles/ContentReviewSettings.js
Robbie Averill 8b8b8e3620 API Add React modal popup for reviewing content in SiteTree
* Add i18n javascript source file and Transifex configuration
* Add npm requirements, React + entwine wrapper for CMS
* Overload LeftAndMain::getSchema... methods in extension so they can be used
* Refactor CSS to only the content review button
2017-09-15 16:06:37 +12:00

53 lines
1.2 KiB
JavaScript

import jQuery from 'jquery';
jQuery.entwine('ss', ($) => {
/**
* Class: .cms-edit-form #Form_EditForm_ContentReviewType_Holder
*
* Toggle display of group dropdown in "access" tab,
* based on selection of radiobuttons.
*/
$('.cms-edit-form #Form_EditForm_ContentReviewType_Holder').entwine({
// Constructor: onmatch
onmatch() {
const self = this;
this.find('.optionset :input').bind('change', (e) => {
self.show_option(e.target.value);
});
// initial state
const currentVal = this.find('input[name=ContentReviewType]:checked').val();
this.show_option(currentVal);
this._super();
},
onunmatch() {
return this._super();
},
show_option(value) {
if (value === 'Custom') {
this._custom();
} else if (value === 'Inherit') {
this._inherited();
} else {
this._disabled();
}
},
_custom() {
$('.review-settings').show();
$('.field.custom-setting').show();
},
_inherited() {
$('.review-settings').show();
$('.field.custom-setting').hide();
},
_disabled() {
$('.review-settings').hide();
},
});
});