From 6c56694bdedda733020298d96d48b432f20e29ad Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Wed, 20 Jun 2018 19:31:33 +1200 Subject: [PATCH] BUG Update modal API for Reactstrap in SilverStripe 4.2, bump constraint --- client/dist/js/contentreview.js | 2 +- client/src/bundles/ContentReviewForm.js | 12 +++++++----- composer.json | 8 ++++---- src/Extensions/SiteTreeContentReview.php | 2 +- src/Forms/ReviewContentHandler.php | 3 +++ 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/client/dist/js/contentreview.js b/client/dist/js/contentreview.js index de17c30..d1f1155 100644 --- a/client/dist/js/contentreview.js +++ b/client/dist/js/contentreview.js @@ -1 +1 @@ -!function(n){function e(o){if(t[o])return t[o].exports;var i=t[o]={i:o,l:!1,exports:{}};return n[o].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var t={};e.m=n,e.c=t,e.i=function(n){return n},e.d=function(n,t,o){e.o(n,t)||Object.defineProperty(n,t,{configurable:!1,enumerable:!0,get:o})},e.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return e.d(t,"a",t),t},e.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},e.p="",e(e.s=4)}([function(n,e){n.exports=jQuery},function(n,e,t){"use strict";var o=t(8),i=t.n(o),r=t(0),s=t.n(r),c=t(6),a=t.n(c),u=t(7),d=t.n(u),l=t(5),f=(t.n(l),t.i(l.loadComponent)("FormBuilderModal"));s.a.entwine("ss",function(n){n(".cms-content-actions .content-review__button").entwine({onclick:function(){var e=n("#content-review__dialog-wrapper");return e.length||(e=n('
'),n("body").append(e)),e.open(),!1}}),n(".content-review-modal .content-review-modal__nav-link").entwine({onclick:function(e){e.preventDefault();var t=n(e.target);window.location=t.attr("href")}}),n("#content-review__dialog-wrapper").entwine({onunmatch:function(){this._clearModal()},open:function(){this._renderModal(!0)},close:function(){this._renderModal(!1)},_renderModal:function(e){var t=this,o=function(){return t.close()},r=function(){return t._handleSubmitModal.apply(t,arguments)},s=n("form.cms-edit-form :input[name=ID]").val(),c=window.ss.store,u=c.getState().config.sections.find(function(n){return"SilverStripe\\CMS\\Controllers\\CMSPageEditController"===n.name}),l=u.form.ReviewContentForm.schemaUrl+"/"+s,_=i.a._t("ContentReview.CONTENT_DUE_FOR_REVIEW","Content due for review");d.a.render(a.a.createElement(f,{title:_,show:e,onSubmit:r,onHide:o,schemaUrl:l,bodyClassName:"modal__dialog",className:"content-review-modal",responseClassBad:"modal__response modal__response--error",responseClassGood:"modal__response modal__response--good",identifier:"ContentReview.CONTENT_DUE_FOR_REVIEW"}),this[0])},_clearModal:function(){d.a.unmountComponentAtNode(this[0])},_handleSubmitModal:function(e,t,o){return n(".content-review__button-holder").remove(),o()}})})},function(n,e,t){"use strict";var o=t(0);t.n(o).a.entwine("ss",function(n){n(".cms-edit-form #Form_EditForm_ContentReviewType_Holder").entwine({onmatch:function(){var n=this;this.find(".optionset :input").bind("change",function(e){n.show_option(e.target.value)});var e=this.find("input[name=ContentReviewType]:checked").val();this.show_option(e),this._super()},onunmatch:function(){return this._super()},show_option:function(n){"Custom"===n?this._custom():"Inherit"===n?this._inherited():this._disabled()},_custom:function(){n(".review-settings").show(),n(".field.custom-setting").show()},_inherited:function(){n(".review-settings").show(),n(".field.custom-setting").hide()},_disabled:function(){n(".review-settings").hide()}})})},function(n,e,t){"use strict";var o=t(0);t.n(o).a.entwine("ss",function(n){function e(e){var t="ContentReviewOwnerID"+e,o=n("div.subsiteSpecificOwnerID"),i=0;for(i=0;i'),e("body").append(t)),t.open(),!1}}),e(".content-review-modal .content-review-modal__nav-link").entwine({onclick:function(n){n.preventDefault();var t=e(n.target);window.location=t.attr("href")}}),e("#content-review__dialog-wrapper").entwine({onunmatch:function(){this._clearModal()},open:function(){this._renderModal(!0)},close:function(){this._renderModal(!1)},_renderModal:function(n){var t=this,o=function(){return t.close()},r=function(){return t._handleSubmitModal.apply(t,arguments)},s=e("form.cms-edit-form :input[name=ID]").val(),c=window.ss.store,u=c.getState().config.sections.find(function(e){return"SilverStripe\\CMS\\Controllers\\CMSPageEditController"===e.name}),l=u.form.ReviewContentForm.schemaUrl+"/"+s,_=i.a._t("ContentReview.CONTENT_DUE_FOR_REVIEW","Content due for review");d.a.render(a.a.createElement(f,{title:_,isOpen:n,onSubmit:r,onClosed:o,schemaUrl:l,bodyClassName:"modal__dialog",className:"content-review-modal",responseClassBad:"modal__response modal__response--error",responseClassGood:"modal__response modal__response--good",identifier:"ContentReview.CONTENT_DUE_FOR_REVIEW"}),this[0])},_clearModal:function(){d.a.unmountComponentAtNode(this[0])},_handleSubmitModal:function(n,t,o){return e(".content-review__button-holder").remove(),o()}})})},function(e,n,t){"use strict";var o=t(0);t.n(o).a.entwine("ss",function(e){e(".cms-edit-form #Form_EditForm_ContentReviewType_Holder").entwine({onmatch:function(){var e=this;this.find(".optionset :input").bind("change",function(n){e.show_option(n.target.value)});var n=this.find("input[name=ContentReviewType]:checked").val();this.show_option(n),this._super()},onunmatch:function(){return this._super()},show_option:function(e){"Custom"===e?this._custom():"Inherit"===e?this._inherited():this._disabled()},_custom:function(){e(".review-settings").show(),e(".field.custom-setting").show()},_inherited:function(){e(".review-settings").show(),e(".field.custom-setting").hide()},_disabled:function(){e(".review-settings").hide()}})})},function(e,n,t){"use strict";var o=t(0);t.n(o).a.entwine("ss",function(e){function n(n){var t="ContentReviewOwnerID"+n,o=e("div.subsiteSpecificOwnerID"),i=0;for(i=0;i { * Kick off a "content due for review" dialog from the CMS actions. */ $('.cms-content-actions .content-review__button').entwine({ - onclick() { + onclick(event) { + event.preventDefault(); + let dialog = $('#content-review__dialog-wrapper'); if (!dialog.length) { @@ -41,7 +43,7 @@ jQuery.entwine('ss', ($) => { }); /** - * Uses React-Bootstrap in order to replicate the bootstrap styling and JavaScript behaviour. + * Uses reactstrap in order to replicate the bootstrap styling and JavaScript behaviour. */ $('#content-review__dialog-wrapper').entwine({ onunmatch() { @@ -57,7 +59,7 @@ jQuery.entwine('ss', ($) => { this._renderModal(false); }, - _renderModal(show) { + _renderModal(isOpen) { const handleHide = () => this.close(); const handleSubmit = (...args) => this._handleSubmitModal(...args); const id = $('form.cms-edit-form :input[name=ID]').val(); @@ -71,9 +73,9 @@ jQuery.entwine('ss', ($) => { ReactDOM.render( getTimestamp() ); - $this->owner->NextReviewDate = DBDate::create()->setValue($nextDateTimestamp)->Format('y-MM-dd'); + $this->owner->NextReviewDate = DBDate::create()->setValue($nextDateTimestamp)->Format(DBDate::ISO_DATE); $this->owner->write(); } diff --git a/src/Forms/ReviewContentHandler.php b/src/Forms/ReviewContentHandler.php index bea06bd..9ddf58f 100644 --- a/src/Forms/ReviewContentHandler.php +++ b/src/Forms/ReviewContentHandler.php @@ -2,6 +2,8 @@ namespace SilverStripe\ContentReview\Forms; +use SilverStripe\ContentReview\Extensions\SiteTreeContentReview; +use SilverStripe\Control\Controller; use SilverStripe\Control\Director; use SilverStripe\Control\HTTPResponse; use SilverStripe\Core\Injector\Injectable; @@ -84,6 +86,7 @@ class ReviewContentHandler */ public function submitReview($record, $data) { + /** @var DataObject|SiteTreeContentReview $record */ if (!$this->canSubmitReview($record)) { throw new ValidationException(_t( __CLASS__ . '.ErrorReviewPermissionDenied',