mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
Getting admin_url from data attribute
This commit is contained in:
parent
3d801379ab
commit
a2dc64542d
505
client/dist/js/userforms-cms.js
vendored
505
client/dist/js/userforms-cms.js
vendored
@ -1,504 +1 @@
|
||||
/******/ (function(modules) { // webpackBootstrap
|
||||
/******/ // The module cache
|
||||
/******/ var installedModules = {};
|
||||
/******/
|
||||
/******/ // The require function
|
||||
/******/ function __webpack_require__(moduleId) {
|
||||
/******/
|
||||
/******/ // Check if module is in cache
|
||||
/******/ if(installedModules[moduleId]) {
|
||||
/******/ return installedModules[moduleId].exports;
|
||||
/******/ }
|
||||
/******/ // Create a new module (and put it into the cache)
|
||||
/******/ var module = installedModules[moduleId] = {
|
||||
/******/ i: moduleId,
|
||||
/******/ l: false,
|
||||
/******/ exports: {}
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // Execute the module function
|
||||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
||||
/******/
|
||||
/******/ // Flag the module as loaded
|
||||
/******/ module.l = true;
|
||||
/******/
|
||||
/******/ // Return the exports of the module
|
||||
/******/ return module.exports;
|
||||
/******/ }
|
||||
/******/
|
||||
/******/
|
||||
/******/ // expose the modules object (__webpack_modules__)
|
||||
/******/ __webpack_require__.m = modules;
|
||||
/******/
|
||||
/******/ // expose the module cache
|
||||
/******/ __webpack_require__.c = installedModules;
|
||||
/******/
|
||||
/******/ // identity function for calling harmony imports with the correct context
|
||||
/******/ __webpack_require__.i = function(value) { return value; };
|
||||
/******/
|
||||
/******/ // define getter function for harmony exports
|
||||
/******/ __webpack_require__.d = function(exports, name, getter) {
|
||||
/******/ if(!__webpack_require__.o(exports, name)) {
|
||||
/******/ Object.defineProperty(exports, name, {
|
||||
/******/ configurable: false,
|
||||
/******/ enumerable: true,
|
||||
/******/ get: getter
|
||||
/******/ });
|
||||
/******/ }
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||||
/******/ __webpack_require__.n = function(module) {
|
||||
/******/ var getter = module && module.__esModule ?
|
||||
/******/ function getDefault() { return module['default']; } :
|
||||
/******/ function getModuleExports() { return module; };
|
||||
/******/ __webpack_require__.d(getter, 'a', getter);
|
||||
/******/ return getter;
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // Object.prototype.hasOwnProperty.call
|
||||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
||||
/******/
|
||||
/******/ // __webpack_public_path__
|
||||
/******/ __webpack_require__.p = "";
|
||||
/******/
|
||||
/******/ // Load entry module and return exports
|
||||
/******/ return __webpack_require__(__webpack_require__.s = "./client/src/bundles/bundle-cms.js");
|
||||
/******/ })
|
||||
/************************************************************************/
|
||||
/******/ ({
|
||||
|
||||
/***/ "./client/src/bundles/ConfirmFolder.js":
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
||||
|
||||
var _i18n = __webpack_require__(5);
|
||||
|
||||
var _i18n2 = _interopRequireDefault(_i18n);
|
||||
|
||||
var _jquery = __webpack_require__(0);
|
||||
|
||||
var _jquery2 = _interopRequireDefault(_jquery);
|
||||
|
||||
var _react = __webpack_require__(3);
|
||||
|
||||
var _react2 = _interopRequireDefault(_react);
|
||||
|
||||
var _reactDom = __webpack_require__(4);
|
||||
|
||||
var _reactDom2 = _interopRequireDefault(_reactDom);
|
||||
|
||||
var _Injector = __webpack_require__(1);
|
||||
|
||||
var _url = __webpack_require__(2);
|
||||
|
||||
var _url2 = _interopRequireDefault(_url);
|
||||
|
||||
var _qs = __webpack_require__(6);
|
||||
|
||||
var _qs2 = _interopRequireDefault(_qs);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var FormBuilderModal = (0, _Injector.loadComponent)('FormBuilderModal');
|
||||
|
||||
_jquery2.default.entwine('ss', function ($) {
|
||||
$('#Form_EditForm_Fields').entwine({
|
||||
onmatch: function onmatch() {
|
||||
var _this = this;
|
||||
|
||||
this._super();
|
||||
|
||||
this.on('addnewinline', function () {
|
||||
_this.one('reload', function () {
|
||||
var newField = _this.find('.ss-gridfield-item').last();
|
||||
newField.find('.col-ClassName select').attr('data-folderconfirmed', 0);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function toggleVisibility(check, show, hide) {
|
||||
if (check) {
|
||||
$(show).show();
|
||||
$(hide).hide();
|
||||
} else {
|
||||
$(hide).show();
|
||||
$(show).hide();
|
||||
}
|
||||
}
|
||||
|
||||
$('#Form_ConfirmFolderForm_FolderOptions-new').entwine({
|
||||
onmatch: function onmatch() {
|
||||
$('#Form_ConfirmFolderForm_CreateFolder_Holder').detach().appendTo($('#Form_ConfirmFolderForm_FolderOptions-new').parent().parent());
|
||||
toggleVisibility($(this).prop('checked'), '#Form_ConfirmFolderForm_CreateFolder_Holder', '#Form_ConfirmFolderForm_FolderID_Holder');
|
||||
},
|
||||
onchange: function onchange() {
|
||||
toggleVisibility($(this).prop('checked'), '#Form_ConfirmFolderForm_CreateFolder_Holder', '#Form_ConfirmFolderForm_FolderID_Holder');
|
||||
}
|
||||
});
|
||||
|
||||
$('#Form_ConfirmFolderForm_FolderOptions-existing').entwine({
|
||||
onmatch: function onmatch() {
|
||||
$('#Form_ConfirmFolderForm_FolderID_Holder').detach().appendTo($('#Form_ConfirmFolderForm_FolderOptions-existing').parent().parent());
|
||||
toggleVisibility($(this).prop('checked'), '#Form_ConfirmFolderForm_FolderID_Holder', '#Form_ConfirmFolderForm_CreateFolder_Holder');
|
||||
},
|
||||
onchange: function onchange() {
|
||||
toggleVisibility($(this).prop('checked'), '#Form_ConfirmFolderForm_FolderID_Holder', '#Form_ConfirmFolderForm_CreateFolder_Holder');
|
||||
}
|
||||
});
|
||||
|
||||
$('#Form_ConfirmFolderForm_FolderID_Holder .treedropdownfield.is-open,#Form_ItemEditForm_FolderID .treedropdownfield.is-open').entwine({
|
||||
onunmatch: function onunmatch() {
|
||||
var _this2 = this;
|
||||
|
||||
var adminUrl = window.location.pathname.split('/')[1];
|
||||
var parsedURL = _url2.default.parse(adminUrl + '/user-forms/getfoldergrouppermissions');
|
||||
var parsedQs = _qs2.default.parse(parsedURL.query);
|
||||
parsedQs.FolderID = $(this).find('input[name=FolderID]').val();
|
||||
var fetchURL = _url2.default.format(_extends({}, parsedURL, { search: _qs2.default.stringify(parsedQs) }));
|
||||
|
||||
return fetch(fetchURL, {
|
||||
credentials: 'same-origin'
|
||||
}).then(function (response) {
|
||||
return response.json();
|
||||
}).then(function (response) {
|
||||
$(_this2).siblings('.form__field-description').html(response);
|
||||
$(_this2).parent().siblings('.form__field-description').html(response);
|
||||
return response;
|
||||
}).catch(function (error) {
|
||||
_jquery2.default.noticeAdd({ text: error.message, stay: false, type: 'error' });
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$(".uf-field-editor .ss-gridfield-items .dropdown.editable-column-field.form-group--no-label:not([data-folderconfirmed='1'])").entwine({
|
||||
onchange: function onchange() {
|
||||
if (this.get(0).value !== 'SilverStripe\\UserForms\\Model\\EditableFormField\\EditableFileField') {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($(".uf-field-editor .ss-gridfield-items .dropdown.editable-column-field.form-group--no-label[data-folderconfirmed='1']").length) {
|
||||
return;
|
||||
}
|
||||
|
||||
var dialog = $('#confirm-folder__dialog-wrapper');
|
||||
|
||||
if (dialog.length) {
|
||||
dialog.remove();
|
||||
}
|
||||
|
||||
dialog = $('<div id="confirm-folder__dialog-wrapper" />');
|
||||
var id = $(this).closest('tr').data('id');
|
||||
dialog.data('id', id);
|
||||
$('body').append(dialog);
|
||||
|
||||
dialog.open();
|
||||
}
|
||||
});
|
||||
|
||||
$('#confirm-folder__dialog-wrapper').entwine({
|
||||
onunmatch: function onunmatch() {
|
||||
this._clearModal();
|
||||
},
|
||||
open: function open() {
|
||||
this._renderModal(true);
|
||||
},
|
||||
close: function close(noRevert) {
|
||||
if (!noRevert) {
|
||||
var id = $('#confirm-folder__dialog-wrapper').data('id');
|
||||
var select = $('.ss-gridfield-item[data-id=\'' + id + '\'] .dropdown.editable-column-field.form-group--no-label[data-folderconfirmed=\'0\']');
|
||||
select.val('SilverStripe\\UserForms\\Model\\EditableFormField\\EditableTextField');
|
||||
}
|
||||
|
||||
this._renderModal(false);
|
||||
},
|
||||
_renderModal: function _renderModal(isOpen) {
|
||||
var _this3 = this;
|
||||
|
||||
var handleHide = function handleHide() {
|
||||
return _this3._handleHideModal.apply(_this3, arguments);
|
||||
};
|
||||
var handleSubmit = function handleSubmit() {
|
||||
return _this3._handleSubmitModal.apply(_this3, arguments);
|
||||
};
|
||||
var title = _i18n2.default._t('UserForms.FILE_CONFIRMATION_TITLE', 'Select file upload folder');
|
||||
var editableFileFieldID = $(this).data('id');
|
||||
|
||||
var adminUrl = window.location.pathname.split('/')[1];
|
||||
var parsedURL = _url2.default.parse(adminUrl + '/user-forms/confirmfolderformschema');
|
||||
var parsedQs = _qs2.default.parse(parsedURL.query);
|
||||
parsedQs.ID = editableFileFieldID;
|
||||
var schemaUrl = _url2.default.format(_extends({}, parsedURL, { search: _qs2.default.stringify(parsedQs) }));
|
||||
|
||||
_reactDom2.default.render(_react2.default.createElement(FormBuilderModal, {
|
||||
title: title,
|
||||
isOpen: isOpen,
|
||||
onSubmit: handleSubmit,
|
||||
onClosed: handleHide,
|
||||
schemaUrl: schemaUrl,
|
||||
bodyClassName: 'modal__dialog',
|
||||
className: 'confirm-folder-modal',
|
||||
responseClassBad: 'modal__response modal__response--error',
|
||||
responseClassGood: 'modal__response modal__response--good',
|
||||
identifier: 'UserForms.ConfirmFolder'
|
||||
}), this[0]);
|
||||
},
|
||||
_clearModal: function _clearModal() {
|
||||
_reactDom2.default.unmountComponentAtNode(this[0]);
|
||||
},
|
||||
_handleHideModal: function _handleHideModal() {
|
||||
return this.close();
|
||||
},
|
||||
_handleSubmitModal: function _handleSubmitModal(data, action, submitFn) {
|
||||
var _this4 = this;
|
||||
|
||||
return submitFn().then(function () {
|
||||
_jquery2.default.noticeAdd({ text: _i18n2.default._t('UserForms.FILE_CONFIRMATION_CONFIRMATION', 'Folder confirmed successfully.'), stay: false, type: 'success' });
|
||||
_this4.close(true);
|
||||
$('[name=action_doSave], [name=action_save]').click();
|
||||
}).catch(function (error) {
|
||||
_jquery2.default.noticeAdd({ text: error.message, stay: false, type: 'error' });
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$('#Form_ConfirmFolderForm_action_cancel').entwine({
|
||||
onclick: function onclick() {
|
||||
$('#confirm-folder__dialog-wrapper').close();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "./client/src/bundles/FieldEditor.js":
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
var _jquery = __webpack_require__(0);
|
||||
|
||||
var _jquery2 = _interopRequireDefault(_jquery);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
_jquery2.default.entwine('ss', function ($) {
|
||||
var stickyHeaderInterval = null;
|
||||
|
||||
$('.uf-field-editor .ss-gridfield-items').entwine({
|
||||
onmatch: function onmatch() {
|
||||
var thisLevel = 0;
|
||||
var depth = 0;
|
||||
var $buttonrow = $('.uf-field-editor .ss-gridfield-buttonrow').addClass('sticky-buttons');
|
||||
var navHeight = $('.cms-content-header.north').first().height() + parseInt($('.sticky-buttons').css('padding-top'), 10);
|
||||
var fieldEditor = $('.uf-field-editor');
|
||||
|
||||
this._super();
|
||||
|
||||
this.find('.ss-gridfield-item').each(function (index, el) {
|
||||
switch ($(el).data('class')) {
|
||||
case 'SilverStripe\\UserForms\\Model\\EditableFormField\\EditableFormStep':
|
||||
{
|
||||
depth = 0;
|
||||
return;
|
||||
}
|
||||
case 'SilverStripe\\UserForms\\Model\\EditableFormField\\EditableFieldGroup':
|
||||
{
|
||||
depth += 1;
|
||||
thisLevel = depth;
|
||||
break;
|
||||
}
|
||||
case 'SilverStripe\\UserForms\\Model\\EditableFormField\\EditableFieldGroupEnd':
|
||||
{
|
||||
thisLevel = depth;
|
||||
depth -= 1;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
thisLevel = depth;
|
||||
}
|
||||
}
|
||||
|
||||
$(el).toggleClass('infieldgroup', thisLevel > 0);
|
||||
for (var i = 1; i <= 5; i++) {
|
||||
$(el).toggleClass('infieldgroup-level-' + i, thisLevel >= i);
|
||||
}
|
||||
});
|
||||
|
||||
stickyHeaderInterval = setInterval(function () {
|
||||
var offsetTop = fieldEditor.offset().top;
|
||||
$buttonrow.width('100%');
|
||||
if (offsetTop > navHeight || offsetTop === 0) {
|
||||
$buttonrow.removeClass('sticky-buttons');
|
||||
} else {
|
||||
$buttonrow.addClass('sticky-buttons');
|
||||
}
|
||||
}, 300);
|
||||
},
|
||||
onunmatch: function onunmatch() {
|
||||
this._super();
|
||||
|
||||
clearInterval(stickyHeaderInterval);
|
||||
}
|
||||
});
|
||||
|
||||
$('.uf-field-editor .ss-gridfield-buttonrow .action').entwine({
|
||||
onclick: function onclick(e) {
|
||||
this._super(e);
|
||||
|
||||
this.trigger('addnewinline');
|
||||
}
|
||||
});
|
||||
|
||||
$('.uf-field-editor').entwine({
|
||||
onmatch: function onmatch() {
|
||||
var _this = this;
|
||||
|
||||
this._super();
|
||||
|
||||
this.on('addnewinline', function () {
|
||||
_this.one('reload', function () {
|
||||
var $newField = _this.find('.ss-gridfield-item').last();
|
||||
var $groupEnd = null;
|
||||
var fqcn = 'SilverStripe\\UserForms\\Model\\EditableFormField\\EditableFieldGroupEnd';
|
||||
if ($newField.attr('data-class') === fqcn) {
|
||||
$groupEnd = $newField;
|
||||
$groupEnd.prev().find('.col-Title input').focus();
|
||||
$newField = $groupEnd.add($groupEnd.prev());
|
||||
$groupEnd.css('visibility', 'hidden');
|
||||
} else {
|
||||
$newField.find('.col-Title input').focus();
|
||||
}
|
||||
|
||||
$newField.addClass('flashBackground');
|
||||
var $contenFields = $('.cms-content-fields');
|
||||
if ($contenFields.length > 0) {
|
||||
$contenFields.scrollTop($contenFields[0].scrollHeight);
|
||||
}
|
||||
if ($groupEnd) {
|
||||
$groupEnd.css('visibility', 'visible');
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
onummatch: function onummatch() {
|
||||
this._super();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "./client/src/bundles/Recipient.js":
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
var _jquery = __webpack_require__(0);
|
||||
|
||||
var _jquery2 = _interopRequireDefault(_jquery);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
_jquery2.default.entwine('ss', function ($) {
|
||||
var recipient = {
|
||||
updateFormatSpecificFields: function updateFormatSpecificFields() {
|
||||
var sendPlainChecked = $('input[name="SendPlain"]').is(':checked');
|
||||
|
||||
$('.field.toggle-html-only')[sendPlainChecked ? 'hide' : 'show']();
|
||||
$('.field.toggle-plain-only')[sendPlainChecked ? 'show' : 'hide']();
|
||||
}
|
||||
};
|
||||
|
||||
$('#Form_ItemEditForm .EmailRecipientForm').entwine({
|
||||
onmatch: function onmatch() {
|
||||
recipient.updateFormatSpecificFields();
|
||||
},
|
||||
|
||||
onunmatch: function onunmatch() {
|
||||
undefined._super();
|
||||
}
|
||||
});
|
||||
|
||||
$('#Form_ItemEditForm .EmailRecipientForm input[name="SendPlain"]').entwine({
|
||||
onchange: function onchange() {
|
||||
recipient.updateFormatSpecificFields();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "./client/src/bundles/bundle-cms.js":
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
__webpack_require__("./client/src/bundles/FieldEditor.js");
|
||||
|
||||
__webpack_require__("./client/src/bundles/ConfirmFolder.js");
|
||||
|
||||
__webpack_require__("./client/src/bundles/Recipient.js");
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 0:
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
module.exports = jQuery;
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 1:
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
module.exports = Injector;
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 2:
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
module.exports = NodeUrl;
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 3:
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
module.exports = React;
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 4:
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
module.exports = ReactDom;
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 5:
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
module.exports = i18n;
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 6:
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
module.exports = qs;
|
||||
|
||||
/***/ })
|
||||
|
||||
/******/ });
|
||||
//# sourceMappingURL=userforms-cms.js.map
|
||||
!function(e){function o(t){if(r[t])return r[t].exports;var n=r[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,o),n.l=!0,n.exports}var r={};o.m=e,o.c=r,o.i=function(e){return e},o.d=function(e,r,t){o.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:t})},o.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(r,"a",r),r},o.o=function(e,o){return Object.prototype.hasOwnProperty.call(e,o)},o.p="",o(o.s="./client/src/bundles/bundle-cms.js")}({"./client/src/bundles/ConfirmFolder.js":function(e,o,r){"use strict";function t(e){return e&&e.__esModule?e:{default:e}}var n=Object.assign||function(e){for(var o=1;o<arguments.length;o++){var r=arguments[o];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},i=r(5),d=t(i),l=r(0),s=t(l),a=r(3),c=t(a),f=r(4),u=t(f),m=r(1),p=r(2),F=t(p),_=r(6),h=t(_),g=(0,m.loadComponent)("FormBuilderModal");s.default.entwine("ss",function(e){function o(o,r,t){o?(e(r).show(),e(t).hide()):(e(t).show(),e(r).hide())}e("#Form_EditForm_Fields").entwine({onmatch:function(){var e=this;this._super(),this.on("addnewinline",function(){e.one("reload",function(){e.find(".ss-gridfield-item").last().find(".col-ClassName select").attr("data-folderconfirmed",0)})})}}),e("#Form_ConfirmFolderForm_FolderOptions-new").entwine({onmatch:function(){e("#Form_ConfirmFolderForm_CreateFolder_Holder").detach().appendTo(e("#Form_ConfirmFolderForm_FolderOptions-new").parent().parent()),o(e(this).prop("checked"),"#Form_ConfirmFolderForm_CreateFolder_Holder","#Form_ConfirmFolderForm_FolderID_Holder")},onchange:function(){o(e(this).prop("checked"),"#Form_ConfirmFolderForm_CreateFolder_Holder","#Form_ConfirmFolderForm_FolderID_Holder")}}),e("#Form_ConfirmFolderForm_FolderOptions-existing").entwine({onmatch:function(){e("#Form_ConfirmFolderForm_FolderID_Holder").detach().appendTo(e("#Form_ConfirmFolderForm_FolderOptions-existing").parent().parent()),o(e(this).prop("checked"),"#Form_ConfirmFolderForm_FolderID_Holder","#Form_ConfirmFolderForm_CreateFolder_Holder")},onchange:function(){o(e(this).prop("checked"),"#Form_ConfirmFolderForm_FolderID_Holder","#Form_ConfirmFolderForm_CreateFolder_Holder")}}),e("#Form_ConfirmFolderForm_FolderID_Holder .treedropdownfield.is-open,#Form_ItemEditForm_FolderID .treedropdownfield.is-open").entwine({onunmatch:function(){var o=this,r=e(this).closest("#Form_ConfirmFolderForm").data("adminUrl"),t=F.default.parse(r+"user-forms/getfoldergrouppermissions"),i=h.default.parse(t.query);i.FolderID=e(this).find("input[name=FolderID]").val();var d=F.default.format(n({},t,{search:h.default.stringify(i)}));return fetch(d,{credentials:"same-origin"}).then(function(e){return e.json()}).then(function(r){return e(o).siblings(".form__field-description").html(r),e(o).parent().siblings(".form__field-description").html(r),r}).catch(function(e){s.default.noticeAdd({text:e.message,stay:!1,type:"error"})})}}),e(".uf-field-editor .ss-gridfield-items .dropdown.editable-column-field.form-group--no-label:not([data-folderconfirmed='1'])").entwine({onchange:function(){if("SilverStripe\\UserForms\\Model\\EditableFormField\\EditableFileField"===this.get(0).value&&!e(".uf-field-editor .ss-gridfield-items .dropdown.editable-column-field.form-group--no-label[data-folderconfirmed='1']").length){var o=e("#confirm-folder__dialog-wrapper");o.length&&o.remove(),o=e('<div id="confirm-folder__dialog-wrapper" />');var r=e(this).closest("tr").data("id"),t=e(this).closest(".uf-field-editor").data("adminUrl");o.data("id",r),o.data("adminUrl",t),e("body").append(o),o.open()}}}),e("#confirm-folder__dialog-wrapper").entwine({onunmatch:function(){this._clearModal()},open:function(){this._renderModal(!0)},close:function(o){if(!o){var r=e("#confirm-folder__dialog-wrapper").data("id");e(".ss-gridfield-item[data-id='"+r+"'] .dropdown.editable-column-field.form-group--no-label[data-folderconfirmed='0']").val("SilverStripe\\UserForms\\Model\\EditableFormField\\EditableTextField")}this._renderModal(!1)},_renderModal:function(o){var r=this,t=function(){return r._handleHideModal.apply(r,arguments)},i=function(){return r._handleSubmitModal.apply(r,arguments)},l=d.default._t("UserForms.FILE_CONFIRMATION_TITLE","Select file upload folder"),s=e(this).data("id"),a=e(this).data("adminUrl"),f=F.default.parse(a+"user-forms/confirmfolderformschema"),m=h.default.parse(f.query);m.ID=s;var p=F.default.format(n({},f,{search:h.default.stringify(m)}));u.default.render(c.default.createElement(g,{title:l,isOpen:o,onSubmit:i,onClosed:t,schemaUrl:p,bodyClassName:"modal__dialog",className:"confirm-folder-modal",responseClassBad:"modal__response modal__response--error",responseClassGood:"modal__response modal__response--good",identifier:"UserForms.ConfirmFolder"}),this[0])},_clearModal:function(){u.default.unmountComponentAtNode(this[0])},_handleHideModal:function(){return this.close()},_handleSubmitModal:function(o,r,t){var n=this;return t().then(function(){s.default.noticeAdd({text:d.default._t("UserForms.FILE_CONFIRMATION_CONFIRMATION","Folder confirmed successfully."),stay:!1,type:"success"}),n.close(!0),e("[name=action_doSave], [name=action_save]").click()}).catch(function(e){s.default.noticeAdd({text:e.message,stay:!1,type:"error"})})}}),e("#Form_ConfirmFolderForm_action_cancel").entwine({onclick:function(){e("#confirm-folder__dialog-wrapper").close()}})})},"./client/src/bundles/FieldEditor.js":function(e,o,r){"use strict";var t=r(0);(function(e){return e&&e.__esModule?e:{default:e}})(t).default.entwine("ss",function(e){var o=null;e(".uf-field-editor .ss-gridfield-items").entwine({onmatch:function(){var r=0,t=0,n=e(".uf-field-editor .ss-gridfield-buttonrow").addClass("sticky-buttons"),i=e(".cms-content-header.north").first().height()+parseInt(e(".sticky-buttons").css("padding-top"),10),d=e(".uf-field-editor");this._super(),this.find(".ss-gridfield-item").each(function(o,n){switch(e(n).data("class")){case"SilverStripe\\UserForms\\Model\\EditableFormField\\EditableFormStep":return void(t=0);case"SilverStripe\\UserForms\\Model\\EditableFormField\\EditableFieldGroup":t+=1,r=t;break;case"SilverStripe\\UserForms\\Model\\EditableFormField\\EditableFieldGroupEnd":r=t,t-=1;break;default:r=t}e(n).toggleClass("infieldgroup",r>0);for(var i=1;i<=5;i++)e(n).toggleClass("infieldgroup-level-"+i,r>=i)}),o=setInterval(function(){var e=d.offset().top;n.width("100%"),e>i||0===e?n.removeClass("sticky-buttons"):n.addClass("sticky-buttons")},300)},onunmatch:function(){this._super(),clearInterval(o)}}),e(".uf-field-editor .ss-gridfield-buttonrow .action").entwine({onclick:function(e){this._super(e),this.trigger("addnewinline")}}),e(".uf-field-editor").entwine({onmatch:function(){var o=this;this._super(),this.on("addnewinline",function(){o.one("reload",function(){var r=o.find(".ss-gridfield-item").last(),t=null;"SilverStripe\\UserForms\\Model\\EditableFormField\\EditableFieldGroupEnd"===r.attr("data-class")?(t=r,t.prev().find(".col-Title input").focus(),r=t.add(t.prev()),t.css("visibility","hidden")):r.find(".col-Title input").focus(),r.addClass("flashBackground");var n=e(".cms-content-fields");n.length>0&&n.scrollTop(n[0].scrollHeight),t&&t.css("visibility","visible")})})},onummatch:function(){this._super()}})})},"./client/src/bundles/Recipient.js":function(e,o,r){"use strict";var t=r(0);(function(e){return e&&e.__esModule?e:{default:e}})(t).default.entwine("ss",function(e){var o={updateFormatSpecificFields:function(){var o=e('input[name="SendPlain"]').is(":checked");e(".field.toggle-html-only")[o?"hide":"show"](),e(".field.toggle-plain-only")[o?"show":"hide"]()}};e("#Form_ItemEditForm .EmailRecipientForm").entwine({onmatch:function(){o.updateFormatSpecificFields()},onunmatch:function(){(void 0)._super()}}),e('#Form_ItemEditForm .EmailRecipientForm input[name="SendPlain"]').entwine({onchange:function(){o.updateFormatSpecificFields()}})})},"./client/src/bundles/bundle-cms.js":function(e,o,r){"use strict";r("./client/src/bundles/FieldEditor.js"),r("./client/src/bundles/ConfirmFolder.js"),r("./client/src/bundles/Recipient.js")},0:function(e,o){e.exports=jQuery},1:function(e,o){e.exports=Injector},2:function(e,o){e.exports=NodeUrl},3:function(e,o){e.exports=React},4:function(e,o){e.exports=ReactDom},5:function(e,o){e.exports=i18n},6:function(e,o){e.exports=qs}});
|
@ -60,8 +60,8 @@ jQuery.entwine('ss', ($) => {
|
||||
$('#Form_ConfirmFolderForm_FolderID_Holder .treedropdownfield.is-open,#Form_ItemEditForm_FolderID .treedropdownfield.is-open').entwine({
|
||||
onunmatch() {
|
||||
// Build url
|
||||
const adminUrl = window.location.pathname.split('/')[1];
|
||||
const parsedURL = url.parse(adminUrl + '/user-forms/getfoldergrouppermissions');
|
||||
const adminUrl = $(this).closest('#Form_ConfirmFolderForm').data('adminUrl');
|
||||
const parsedURL = url.parse(`${adminUrl}user-forms/getfoldergrouppermissions`);
|
||||
const parsedQs = qs.parse(parsedURL.query);
|
||||
parsedQs.FolderID = $(this).find('input[name=FolderID]').val();
|
||||
const fetchURL = url.format({ ...parsedURL, search: qs.stringify(parsedQs) });
|
||||
@ -105,7 +105,9 @@ jQuery.entwine('ss', ($) => {
|
||||
|
||||
dialog = $('<div id="confirm-folder__dialog-wrapper" />');
|
||||
const id = $(this).closest('tr').data('id');
|
||||
const adminUrl = $(this).closest('.uf-field-editor').data('adminUrl');
|
||||
dialog.data('id', id);
|
||||
dialog.data('adminUrl', adminUrl);
|
||||
$('body').append(dialog);
|
||||
|
||||
dialog.open();
|
||||
@ -141,8 +143,8 @@ jQuery.entwine('ss', ($) => {
|
||||
const editableFileFieldID = $(this).data('id');
|
||||
|
||||
// Build schema url
|
||||
const adminUrl = window.location.pathname.split('/')[1];
|
||||
const parsedURL = url.parse(adminUrl + '/user-forms/confirmfolderformschema');
|
||||
const adminUrl = $(this).data('adminUrl');
|
||||
const parsedURL = url.parse(`${adminUrl}user-forms/confirmfolderformschema`);
|
||||
const parsedQs = qs.parse(parsedURL.query);
|
||||
parsedQs.ID = editableFileFieldID;
|
||||
const schemaUrl = url.format({ ...parsedURL, search: qs.stringify(parsedQs) });
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace SilverStripe\UserForms\Control;
|
||||
|
||||
use SilverStripe\Admin\AdminRootController;
|
||||
use SilverStripe\Admin\LeftAndMain;
|
||||
use SilverStripe\Assets\Folder;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
@ -199,7 +200,8 @@ class UserDefinedFormAdmin extends LeftAndMain
|
||||
|
||||
return Form::create($this, 'ConfirmFolderForm', $fields, $actions, RequiredFields::create('ID'))
|
||||
->setFormAction($this->Link('ConfirmFolderForm'))
|
||||
->addExtraClass('form--no-dividers');
|
||||
->addExtraClass('form--no-dividers')
|
||||
->setAttribute('data-admin-url', AdminRootController::admin_url());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace SilverStripe\UserForms\Extension;
|
||||
|
||||
use SilverStripe\Admin\AdminRootController;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Forms\GridField\GridFieldPaginator;
|
||||
use SilverStripe\Forms\Tab;
|
||||
@ -124,7 +125,9 @@ class UserFormFieldEditorExtension extends DataExtension
|
||||
'',
|
||||
$fields,
|
||||
$config
|
||||
)->addExtraClass('uf-field-editor');
|
||||
)
|
||||
->addExtraClass('uf-field-editor')
|
||||
->setAttribute('data-admin-url', AdminRootController::admin_url());
|
||||
|
||||
return $fieldEditor;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user