Skip to content

Commit

Permalink
[IIMAGE-10] Fix not found app config and improved client check
Browse files Browse the repository at this point in the history
- fixed the message listener so that it should work on windows/google chrome
- adjusted the widget controller so that it returns a mapped error message if the content selected is from a site with no ImageShop app installed
- fix the client conditional for contents with no image fields found
- adjust translations and set the missing ones
  • Loading branch information
Marcelo committed Feb 4, 2025
1 parent 714fc0c commit f046ab3
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Gradle Project settings
projectName = imageshop
version = 2.0.3
version = 2.0.4

# XP App values
appDisplayName = ImageShop
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/admin/widgets/iimage/iimage.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ exports.get = function (req) {

const iimageAppConfig = libs.iimage.getSiteConfig(contentId || sitesWithIImageAppInstalled[0]._id)

if (!iimageAppConfig) {
return {
contentType: 'text/html',
body: `<widget class="error">${libs.iimage.translate('iimage.widget.context_panel.fragments.app_not_installed_in_site_fetched')}</widget>`
}
}

if (['iimage_host'].some(key => Object.keys(iimageAppConfig).indexOf(key) === -1)) {
return {
contentType: 'text/html',
Expand Down
19 changes: 9 additions & 10 deletions src/main/resources/assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,26 @@ function main() {
const syncImageShopInfoButton = document.getElementById('imageshop-sync-info-button')

function setMessageEventListener (event) {
if (event.origin.indexOf('client.imageshop.no') === -1) return

const eventData = event.data.split(';')
const selectedPropertyRadioElement = document.querySelector(`input[name="inputName"]:checked`) || {}
const selectedPropertyRadioElement = document.querySelector(`input[name="inputName"]:checked`)

changeUploadButtonState('loading')

storeImageInEnonic({
imageData: JSON.parse(eventData[0]),
propertyName: selectedPropertyRadioElement.value,
propertyPath: selectedPropertyRadioElement.getAttribute('data-property-path')
propertyName: selectedPropertyRadioElement ? selectedPropertyRadioElement.value : undefined,
propertyPath: selectedPropertyRadioElement ? selectedPropertyRadioElement.getAttribute('data-property-path') : undefined
})

window.removeEventListener('message', setMessageEventListener)
}

const imageshop = {
openWindow: function () {
if (window.addEventListener) {
window.addEventListener('message', setMessageEventListener, { once: true });
} else if (window.attachEvent) {
window.attachEvent('onmessage', setMessageEventListener);
} else {
window['message'] = setMessageEventListener
}
window.removeEventListener("message", setMessageEventListener);
window.addEventListener("message", setMessageEventListener);

window.open(imageShopURL, 'imageshop', "width=950, height=650, scrollbars=1, inline=1");
}
Expand Down
11 changes: 6 additions & 5 deletions src/main/resources/i18n/phrases.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
iimage.widget.context_panel.display_name = ImageShop
iimage.widget.context_panel.description = Search for images, edit and store them in Enonic
iimage.widget.context_panel.fragments.app_installed_in_multiples_sites = You have more than 1 site with the IImage app installed. Choose one to start uploading images
iimage.widget.context_panel.fragments.app_misconfigured = The IImage app is not configured properly. Please fill in the required fields in the IImage app settings
iimage.widget.context_panel.fragments.app_not_installed = The IImage app is not installed.
iimage.widget.context_panel.fragments.app_installed_in_multiples_sites = You have more than 1 site with the ImageShop app installed. Choose one to start uploading images
iimage.widget.context_panel.fragments.app_misconfigured = The ImageShop app is not configured properly. Please fill in the required fields in the ImageShop app settings
iimage.widget.context_panel.fragments.app_not_installed = The ImageShop app is not installed.
iimage.widget.context_panel.fragments.app_not_installed_in_site_fetched = Ensure the content you selected is placed under a site with the ImageShop installed

iimage.site.iimage_imported_resources_folder = Imported resources folder
iimage.site.settings = ImageShop Settings
Expand All @@ -26,10 +27,10 @@ image.site.iimage_language_caption.help-text = Image caption name to be searched
iimage.x-data.callback_url = Callback URL
iimage.x-data.document_id = ImageShop ID

iimage.service.import-image.no_site_with_iimage_app_installed = No site with the IImage app installed
iimage.service.import-image.no_site_with_iimage_app_installed = No site with the ImageShop app installed
iimage.service.import-image.no_folder_found = No imported image folder found
iimage.service.import-image.image_imported_successfully = Image imported successfully
iimage.service.image_import_failed = Error importing image
iimage.service.import-image.image_import_failed = Error importing image

iimage.fragments.general_error = An error occurred while importing the image. Please try again later.
iimage.fragments.edit_image = Edit Image
Expand Down

0 comments on commit f046ab3

Please sign in to comment.