Skip to content

Commit

Permalink
Use window.ss.config provided adminUrl (#1211)
Browse files Browse the repository at this point in the history
Co-authored-by: Michal Kleiner <[email protected]>
  • Loading branch information
michalkleiner and Michal Kleiner authored Jun 7, 2023
1 parent 3b043bf commit 0dfd299
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion client/dist/js/userforms-cms.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions client/src/bundles/ConfirmFolder.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jQuery.entwine('ss', ($) => {
$('#Form_ConfirmFolderForm_FolderID_Holder .treedropdownfield.is-open,#Form_ItemEditForm_FolderID .treedropdownfield.is-open').entwine({
onunmatch() {
// Build url
const adminUrl = $(this).closest('#Form_ConfirmFolderForm').data('adminUrl');
const adminUrl = window.ss.config.adminUrl || '/admin/';
const parsedURL = url.parse(`${adminUrl}user-forms/getfoldergrouppermissions`);
const parsedQs = qs.parse(parsedURL.query);
parsedQs.FolderID = $(this).find('input[name=FolderID]').val();
Expand Down Expand Up @@ -105,9 +105,7 @@ 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();
Expand Down Expand Up @@ -143,7 +141,7 @@ jQuery.entwine('ss', ($) => {
const editableFileFieldID = $(this).data('id');

// Build schema url
const adminUrl = $(this).data('adminUrl');
const adminUrl = window.ss.config.adminUrl || '/admin/';
const parsedURL = url.parse(`${adminUrl}user-forms/confirmfolderformschema`);
const parsedQs = qs.parse(parsedURL.query);
parsedQs.ID = editableFileFieldID;
Expand Down
3 changes: 1 addition & 2 deletions code/Control/UserDefinedFormAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,7 @@ private function buildConfirmFolderForm(string $suggestedFolderName = '', string

return Form::create($this, 'ConfirmFolderForm', $fields, $actions, RequiredFields::create('ID'))
->setFormAction($this->Link('ConfirmFolderForm'))
->addExtraClass('form--no-dividers')
->setAttribute('data-admin-url', AdminRootController::admin_url());
->addExtraClass('form--no-dividers');
}

/**
Expand Down
3 changes: 1 addition & 2 deletions code/Extension/UserFormFieldEditorExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ public function getFieldEditorGrid()
$fields,
$config
)
->addExtraClass('uf-field-editor')
->setAttribute('data-admin-url', AdminRootController::admin_url());
->addExtraClass('uf-field-editor');

return $fieldEditor;
}
Expand Down

0 comments on commit 0dfd299

Please sign in to comment.