-
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
Showing
57 changed files
with
1,554 additions
and
1,144 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import assetsLibraryWidget from '../../../../../../../assets-library-widget/src/bundles/Resources/public/js/assets.library.widget'; | ||
|
||
(function (global, doc, React, ReactDOM) { | ||
let udwRoot = null; | ||
const container = doc.getElementById('react-udw'); | ||
const triggerElement = doc.querySelector('.ibexa-open-image-picker'); | ||
const closeUDW = () => udwRoot.unmount(); | ||
const openUdw = async () => { | ||
const config = { | ||
...JSON.parse(triggerElement.dataset.udwConfig), | ||
title: 'test image picker', | ||
activeTab: 'image_picker', | ||
rootLocationId: 51, | ||
onConfirm: () => { | ||
console.log('confirm'); | ||
}, | ||
onCancel: closeUDW, | ||
restInfo: { | ||
token: 'f72e8ac375def2c346d5d3e7057a.u0r1YnqgMyL6zbfVE5Mxdi3yA6TaXKZTmAALD7BzFTM.iH-qKyzHa3Oshv2ya6Z7B36xZfeqFskQwGYmTOo0cGDSL6RSKNV6dL6j1A', | ||
siteaccess: 'admin', | ||
}, | ||
}; | ||
|
||
udwRoot = ReactDOM.createRoot(container); | ||
udwRoot.render(React.createElement(assetsLibraryWidget, config)); | ||
}; | ||
|
||
triggerElement.addEventListener('click', openUdw, false); | ||
// setTimeout(() => { | ||
// openUdw(); | ||
// }, 100); | ||
})(window, window.document, window.React, window.ReactDOM); |
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
85 changes: 85 additions & 0 deletions
85
src/bundle/Resources/public/js/scripts/helpers/config.loader.js
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,85 @@ | ||
import { getContentTypeIconUrl, getContentTypeName } from './content.type.helper'; | ||
import { getCookie, setCookie, setBackOfficeCookie } from './cookies.helper'; | ||
import { formatErrorLine, validateIsEmptyField } from './form.validation.helper'; | ||
import { getIconPath } from './icon.helper'; | ||
import { removeRootFromPathString, findLocationsByIds, buildLocationsBreadcrumbs } from './location.helper'; | ||
import { getJsonFromResponse, getTextFromResponse, getStatusFromResponse } from './request.helper'; | ||
import { parse as parseTooltips, hideAll as hideAllTooltips, observe as observerTooltips } from './tooltips.helper'; | ||
import { convertDateToTimezone, formatFullDateTime, formatShortDateTime, getBrowserTimezone } from './timezone.helper'; | ||
import { | ||
showNotification, | ||
showInfoNotification, | ||
showSuccessNotification, | ||
showWarningNotification, | ||
showErrorNotification, | ||
} from './notification.helper'; | ||
import { parse as parseMiddleEllipsis, parseAll as parseAllMiddleEllipsis, update as updateMiddleEllipsis } from './middle.ellipsis'; | ||
import { setInstance, getInstance, clearInstance } from './object.instances'; | ||
import { computePages } from './pagination.helper'; | ||
import { | ||
isWindows, | ||
isMac, | ||
isLinux, | ||
isUndoPressed, | ||
isRedoPressed, | ||
isSavePressed, | ||
isCopyPressed, | ||
isCutPressed, | ||
isPastePressed, | ||
isPrintPressed, | ||
isSelectAllPressed, | ||
} from './system.helper'; | ||
import { parseCheckbox as parseCheckboxTable } from './table.helper'; | ||
import { buildItemsFromUDWResponse } from './tag.view.select.helper'; | ||
import { escapeHTML } from './text.helper'; | ||
import { getId as getUserId } from './user.helper'; | ||
|
||
(function (ibexa) { | ||
ibexa.addConfig('helpers.contentType', { getContentTypeIconUrl, getContentTypeName }); | ||
ibexa.addConfig('helpers.cookies', { getCookie, setCookie, setBackOfficeCookie }); | ||
ibexa.addConfig('helpers.formValidation', { formatErrorLine, validateIsEmptyField }); | ||
ibexa.addConfig('helpers.icon', { getIconPath }); | ||
ibexa.addConfig('helpers.location', { removeRootFromPathString, findLocationsByIds, buildLocationsBreadcrumbs }); | ||
ibexa.addConfig('helpers.request', { getJsonFromResponse, getTextFromResponse, getStatusFromResponse }); | ||
ibexa.addConfig('helpers.tooltips', { | ||
parse: parseTooltips, | ||
hideAll: hideAllTooltips, | ||
observe: observerTooltips, | ||
}); | ||
ibexa.addConfig('helpers.timezone', { convertDateToTimezone, formatFullDateTime, formatShortDateTime, getBrowserTimezone }); | ||
ibexa.addConfig('helpers.notification', { | ||
showNotification, | ||
showInfoNotification, | ||
showSuccessNotification, | ||
showWarningNotification, | ||
showErrorNotification, | ||
}); | ||
ibexa.addConfig('helpers.ellipsis.middle', { | ||
parse: parseMiddleEllipsis, | ||
parseAll: parseAllMiddleEllipsis, | ||
update: updateMiddleEllipsis, | ||
}); | ||
ibexa.addConfig('helpers.objectInstances', { | ||
setInstance, | ||
getInstance, | ||
clearInstance, | ||
}); | ||
ibexa.addConfig('helpers.pagination', { computePages }); | ||
ibexa.addConfig('helpers.system', { | ||
isWindows: isWindows(), | ||
isMac: isMac(), | ||
isLinux: isLinux(), | ||
isUndoPressed, | ||
isRedoPressed, | ||
isSavePressed, | ||
isCopyPressed, | ||
isCutPressed, | ||
isPastePressed, | ||
isPrintPressed, | ||
isSelectAllPressed, | ||
}); | ||
ibexa.addConfig('helpers.table', { parseCheckbox: parseCheckboxTable }); | ||
ibexa.addConfig('helpers.tagViewSelect', { buildItemsFromUDWResponse }); | ||
ibexa.addConfig('helpers.text', { escapeHTML }); | ||
ibexa.addConfig('helpers.user', { getId: getUserId }); | ||
})(window.ibexa); |
119 changes: 58 additions & 61 deletions
119
src/bundle/Resources/public/js/scripts/helpers/content.type.helper.js
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,63 +1,60 @@ | ||
(function (global, doc, ibexa) { | ||
let contentTypesDataMap = null; | ||
|
||
/** | ||
* Creates map with content types identifiers as keys for faster lookup | ||
* | ||
* @function createContentTypeDataMap | ||
* @returns {Object} contentTypesDataMap | ||
*/ | ||
const createContentTypeDataMap = () => | ||
Object.values(ibexa.adminUiConfig.contentTypes).reduce((contentTypeDataMap, contentTypeGroup) => { | ||
for (const contentTypeData of contentTypeGroup) { | ||
contentTypeDataMap[contentTypeData.identifier] = contentTypeData; | ||
} | ||
|
||
return contentTypeDataMap; | ||
}, {}); | ||
|
||
/** | ||
* Returns an URL to a content type icon | ||
* | ||
* @function getContentTypeIcon | ||
* @param {String} contentTypeIdentifier | ||
* @returns {String|null} url to icon | ||
*/ | ||
const getContentTypeIconUrl = (contentTypeIdentifier) => { | ||
if (!contentTypesDataMap) { | ||
contentTypesDataMap = createContentTypeDataMap(); | ||
import { getContext as getHelpersContext } from './helpers.service'; | ||
|
||
let contentTypesDataMap = null; | ||
|
||
/** | ||
* Creates map with content types identifiers as keys for faster lookup | ||
* | ||
* @function createContentTypeDataMap | ||
* @returns {Object} contentTypesDataMap | ||
*/ | ||
const createContentTypeDataMap = () => | ||
Object.values(getHelpersContext().contentTypes).reduce((contentTypeDataMap, contentTypeGroup) => { | ||
for (const contentTypeData of contentTypeGroup) { | ||
contentTypeDataMap[contentTypeData.identifier] = contentTypeData; | ||
} | ||
|
||
if (!contentTypeIdentifier || !contentTypesDataMap[contentTypeIdentifier]) { | ||
return null; | ||
} | ||
|
||
const iconUrl = contentTypesDataMap[contentTypeIdentifier].thumbnail; | ||
|
||
return iconUrl; | ||
}; | ||
|
||
/** | ||
* Returns contentType name from contentType identifier | ||
* | ||
* @function getContentTypeName | ||
* @param {String} contentTypeIdentifier | ||
* @returns {String|null} contentType name | ||
*/ | ||
const getContentTypeName = (contentTypeIdentifier) => { | ||
if (!contentTypesDataMap) { | ||
contentTypesDataMap = createContentTypeDataMap(); | ||
} | ||
|
||
if (!contentTypeIdentifier || !contentTypesDataMap[contentTypeIdentifier]) { | ||
return null; | ||
} | ||
|
||
return contentTypesDataMap[contentTypeIdentifier].name; | ||
}; | ||
|
||
ibexa.addConfig('helpers.contentType', { | ||
getContentTypeIconUrl, | ||
getContentTypeName, | ||
}); | ||
})(window, window.document, window.ibexa); | ||
return contentTypeDataMap; | ||
}, {}); | ||
|
||
/** | ||
* Returns an URL to a content type icon | ||
* | ||
* @function getContentTypeIcon | ||
* @param {String} contentTypeIdentifier | ||
* @returns {String|null} url to icon | ||
*/ | ||
const getContentTypeIconUrl = (contentTypeIdentifier) => { | ||
if (!contentTypesDataMap) { | ||
contentTypesDataMap = createContentTypeDataMap(); | ||
} | ||
|
||
if (!contentTypeIdentifier || !contentTypesDataMap[contentTypeIdentifier]) { | ||
return null; | ||
} | ||
|
||
const iconUrl = contentTypesDataMap[contentTypeIdentifier].thumbnail; | ||
|
||
return iconUrl; | ||
}; | ||
|
||
/** | ||
* Returns contentType name from contentType identifier | ||
* | ||
* @function getContentTypeName | ||
* @param {String} contentTypeIdentifier | ||
* @returns {String|null} contentType name | ||
*/ | ||
const getContentTypeName = (contentTypeIdentifier) => { | ||
if (!contentTypesDataMap) { | ||
contentTypesDataMap = createContentTypeDataMap(); | ||
} | ||
|
||
if (!contentTypeIdentifier || !contentTypesDataMap[contentTypeIdentifier]) { | ||
return null; | ||
} | ||
|
||
return contentTypesDataMap[contentTypeIdentifier].name; | ||
}; | ||
|
||
export { getContentTypeIconUrl, getContentTypeName }; |
Oops, something went wrong.