Skip to content
This repository has been archived by the owner on May 26, 2020. It is now read-only.

Use of JS Promise för aply and save in image edit view + some modal messages + a modal progress #561

Open
wants to merge 12 commits into
base: dev
Choose a base branch
from

Conversation

schnuti
Copy link
Collaborator

@schnuti schnuti commented Jun 4, 2018

Pull Request for Issue #497 .

Summary of Changes

  1. Promise is used for apply and save. i.e. no problem with the asynchronous change of window breaking the upload.
  2. Added a few modal notifications for errors. Not active for success.
  3. Added a modal progress bar. Be aware that this very often only show 0 and 100%. Depends on browser and file size.

Testing Instructions

Please first review this code. It works without any known problems but I know some edit has to be done.

So first a few questions.

  1. The com_media language files are not loaded. Where do I add the few used texts?
  2. Have a look at the code for modal Progress. I used inline CSS that has to be replaced.
  3. I'm not sure about error handling. As is, there are only "Buh -an Error!" Messages. I really do not know how to catch meaningful errors.
  4. Some unused code is kept in the XMLHTTPRequest code (available in core or Not available ). Here we e.g. need the upload-progress event.
  5. Do the server sided PHP send any error related code more than success = 1/0?
  6. Integrate common Notification code?

Edited 1x!

@schnuti
Copy link
Collaborator Author

schnuti commented Jun 4, 2018

The Progress and an Error message.

progress-error

@laoneo
Copy link
Contributor

laoneo commented Jun 5, 2018

Thanks for that. Gave it the JS gurus for review.

@laoneo laoneo added this to the Stabilize milestone Jun 5, 2018
@laoneo laoneo added the bug label Jun 5, 2018

// Update the progress bar
Joomla.MediaManager.Edit.updateProgressBar = function(e) {
let value = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please no let here, this is not polyfilled

@schnuti
Copy link
Collaborator Author

schnuti commented Jun 5, 2018

@dgrammatiko And const for objects is allowed?

@dgrammatiko
Copy link
Contributor

@schnuti sorry I should phrase that better, you need to have ES5 code here...

@schnuti
Copy link
Collaborator Author

schnuti commented Jun 5, 2018

I removed the inline CSS style for progress bar.
It looks better with some styling
e.g.

.media-manager-progress, .media-manager-progress + span {
   font-size: 18px;
   vertical-align: middle;
   margin-right: 3px;
}

@schnuti
Copy link
Collaborator Author

schnuti commented Jun 5, 2018

I found out how to add the text strings to JS.

Do I have to minify the Javascript somehow?
Otherwise it's testable now..

@kasvith
Copy link
Contributor

kasvith commented Jun 6, 2018

I would like to have something like this for file uploading
cropped

@schnuti
Copy link
Collaborator Author

schnuti commented Jun 6, 2018

@kasvith Nice idea! Could you please open a new issue? This is about the Edit view. I guess something like your idea is possible.

@kasvith
Copy link
Contributor

kasvith commented Jun 6, 2018

I will open this, for the edit are i prefer just a message as "Item saved" because a progress bar is not suitable here for me

@schnuti
Copy link
Collaborator Author

schnuti commented Jun 6, 2018

@kasvith The idea is that something should happen when you click on the button. The progress bar gives you both started and ended. I'm trying to make it reusable.

@laoneo
Copy link
Contributor

laoneo commented Jun 6, 2018

I like the idea of a progress bar, especially as editing now also works with cloud adapters, the upload can take longer.

@kasvith
Copy link
Contributor

kasvith commented Jun 6, 2018

ahh yes we now support editing remote files too totally forgot it

Filename in the message pop up.
Progress into 2 separate functions
@schnuti
Copy link
Collaborator Author

schnuti commented Jun 7, 2018

Added filename to the progress pop up and 2 reusable functions for the progress.

Do I have to minimize the Javascript somehow? I do not know the Joomla way.

progress-filename

@laoneo
Copy link
Contributor

laoneo commented Jun 7, 2018

You can do node build.js --compilejs media/com_media/js/edit-images.js to compile it.

@schnuti
Copy link
Collaborator Author

schnuti commented Jun 7, 2018

@laoneo Thanks! I have only fragments of a "modern" developer environment. node did it.

I have no more open issues. A few comments should be removed before a merge.

Ready for a normal test.

@laoneo
Copy link
Contributor

laoneo commented Jun 20, 2018

Promises do not work in IE 11 https://caniuse.com/#feat=promises. So either way, we use a polifill, do a fallback or just got with the onSuccess function in Joomla.request. But in the current state it will break IE11.

@dgrammatiko
Copy link
Contributor

Promises should be polyfilled whenever there is a web component in the page (for backend that is always due to alerts)

@kasvith
Copy link
Contributor

kasvith commented Jun 20, 2018

Issue regarding IE11

@laoneo
Copy link
Contributor

laoneo commented Jun 20, 2018

So can we load the polyfill in this pr here too?

@dgrammatiko
Copy link
Contributor

it should be loaded already, unless for some reason we're rendering the component and not the index.php.
Also from https://github.com/webcomponents/webcomponentsjs

For browsers that need it, there are also some minor polyfills included:

HTMLTemplateElement
Promise
Event, CustomEvent, MouseEvent constructors and Object.assign, Array.from (see webcomponents-platform)
URL constructor

@kasvith
Copy link
Contributor

kasvith commented Jun 21, 2018

hmm weired, can you see #565 @dgrammatiko

@dgrammatiko
Copy link
Contributor

Actually I figured it out, in J4 I've removed the webcomponents-bundle.js in favour of webcomponents-sd-ce-pf.js, but it seems the second one is missing all the mentioned polyfills on my previous comment.

@laoneo
Copy link
Contributor

laoneo commented Jun 27, 2018

@dgrammatiko are you going to fix this in upstream?

@dgrammatiko
Copy link
Contributor

dgrammatiko commented Jun 29, 2018

@laoneo I'm waiting for an answer here: #565 (comment) from @kasvith or anyone with IE11

Also @kasvith can you check one more thing:
https://github.com/schnuti/media-manager-improvement/blob/c9e7fe8a4a028231671febe87569e7fc6f9e110d/media/com_media/js/edit-images.js#L342

change DOMContentLoaded to WebComponentsReady with the current codebase, does it work?

@kasvith
Copy link
Contributor

kasvith commented Jul 3, 2018

@dgrammatiko there seems to be an issue with upstream, i will check ASAP when it fixed

@kasvith
Copy link
Contributor

kasvith commented Jul 12, 2018

@dgrammatiko cant check until #565 passes

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants