I have to refresh the page to get the uploaded image to show in the library.

Comments

jcisio’s picture

Status: Active » Postponed (maintainer needs more info)

It should work. Do you have any JS error? Do you use the default library or a custom one?

RobKoberg’s picture

Hmmm.. yes I am. After I click the upload button, I am getting an error coming from the radioactivity module:

Uncaught TypeError: Cannot read property 'emitters' of undefined
radioactivity.js line 10

I tried to fix that by adding the radioactivity form element to the scald atom for image, but the error is still there. So that is probably stopping the JS from there on, and probably not your issue?

Then on the next form, I am getting a Drupal error coming from my base theme (bootstrap):

Notice: Undefined index: #type in bootstrap_form_alter() (line 17 of /Users/rkoberg/Sites/proj-mash/docroot/sites/all/themes/bootstrap/includes/form.inc).

So it is producing that notice because the form does not have an $form['actions']['#type'] .
isset($form['actions']) && ($form['actions']['#type'] == 'actions'
The actions key must be being added by ctools_wizard_multistep_form() as I don't see it in your code. I could add it in a form_alter, or perhaps it could be set on the wizard form?

RobKoberg’s picture

I go t rid of the javascript error in radioactivity JS, but the image still does not show in the library after upload and submit of all wizard forms. So it wasn't the cause of the library not refreshing with all of the latest images.

RobKoberg’s picture

I did try scald galaxy on http://simplytest.me/project/scald_galaxy/7.x-1.x and it works as expected. So it has to be something with my setup. But here is something weird:

In trying to debug this, I wanted to see if a search would refresh the list. I filtered by image (any search does the same), hit submit and was presented with a JSON page. So, I added some console.logs to the dnd-library.js, like so:

console.log('#edit-submit-scald-library', $('#edit-submit-scald-library'));
console.log('#edit-submit-scald-library, this', $('#edit-submit-scald-library', $this));
console.log('.view-filters input[type=submit], this: ', $('.view-filters input[type=submit]', $this));
  // Turns Views exposed filters' submit button into an ajaxSubmit trigger
  $('.view-filters input[type=submit]', $this).click(function(e) {
    var submit = $(this);
    settings = Drupal.settings.dnd;
console.log('settings: ', settings);
    $('.view-filters form', $this).ajaxSubmit({
      'url' : settings.url,
      'dataType' : 'json',

The result was that $('.view-filters input[type=submit]', $this) had a length of zero (nothing found), while $('#edit-submit-scald-library', $this) had the correct length of one. I am using jquery_update and version 1.7 (so the views ui works). Should I be using a different version of jquery? Or does this trigger any other ideas? This was in FF and Chrome on Mountain Lion - latest versions.

RobKoberg’s picture

I am not seeing where form/@id="scald-atom-add-form-options" is handled in JS> Can you point that out to me? I am using the latest dev release that was updated today.

Also, where is the submit handled in the PHP?

Another part of this (which I think is all related): If I delete an image, should I be sent to new confirm page (it opens in a new tab)

FWIW, I made a screencast of the experience: http://www.youtube.com/watch?v=RQ5h3zHkvR4

jcisio’s picture

Form/@id="scald-atom-add-form-options" is handled by (you guess) scald_atom_add_form_options(_submit).

From your screencast, I think there is something that changes the ID/class of that view and the submit button, also intercepts the Views Ajax results. You can debug to see what happens in dnd-library.js.

RobKoberg’s picture

StatusFileSize
new342.08 KB

Part of my question is where in the javascript is the submit for the modal happening. I can't see anything that would catch that submit.

"I think there is something that changes the ID/class of that view and the submit button, also intercepts the Views Ajax results. You can debug to see what happens in dnd-library.js."

I did debug in dnd-library.js, which I showed the results in #4. The classes are not changed. See attached screen grab of the real time state. I am not sure why length is coming in at zero -- the code looks perfectly fine. I do have some code that affects form-autocomplete, which I commented out and retested and got the same results.

I love the interface, but I think I am going to have to go back to IMCE, unfortunately. Another issue that makes it so I can't use scald is the issue ( https://drupal.org/node/2059775 ) about restricting user access. I did set the file destination at the field level, but after a few hours could not see how to restrict the library view. It looks like that issue is fixed, even though the fix did not address the main issue.

jcisio’s picture

I'd love to help, but I can't help debugging. About your question:

I can't see anything that would catch that submit.

The server sends a "dnd_refresh" command when you submit and close the modal, then on the client side, that command executes a library refresh. Just grep "dnd_refresh" and you'll know it all.

jcisio’s picture

Status: Postponed (maintainer needs more info) » Fixed

Well, I've just seen the screenshot, some module change the "input" element into "button", it invalidates the selector "input[type=submit]". There are many ways to fix that, one is to add a special class to that element and use class selector. Feel free to submit a patch. Otherwise just use a form_alter to change that back into an input.

RobKoberg’s picture

Doh! Didn't notice that. My theme is changing that to get the twitter bootstrap look and feel -- only works on <a> and <button> -- http://getbootstrap.com/2.3.2/base-css.html#buttons -- so I can't change it back to an input.

Patch attached. Thanks!

RobKoberg’s picture

BTW, I should mention this fixes the issue with the icon not appearing and searches. It should also handle any issue where the selector is based on an input that has been converted to an <button> (so bootstrap users can use scald now).

jcisio’s picture

Title: uploaded images not displaying in library after upload » Support the customisation of submit button in dnd library
Component: User interface » Library/DnD
Category: bug » support
Status: Fixed » Needs work

Nice, thanks for the patch. I can see it adds another selector, but there are color codes in the patch that prevent the review. Don't forget to change the issue into "need reviews" when uploading patch to launch the testbot.

RobKoberg’s picture

Status: Needs work » Needs review
StatusFileSize
new2.46 KB

Whoops, did a git diff (which I do have color coded) and then a git diff > the.patch and did not look at it before posting. Here is another one.

Status: Needs review » Needs work

The last submitted patch, 2058225-scald-add-button-selectors-13.patch, failed testing.

jcisio’s picture

Patch does not apply with testbot because of "patch unexpectedly ends in middle of line". Could you upload a new one?

RobKoberg’s picture

StatusFileSize
new12.55 KB

Not sure what you mean. There is no new line at the bottom and no space(s) or other whitespace characters after the last line produced by the git diff. diff'ing again produced the exact same as what I attached yesterday. This is against a clone from yesterday. I'd love to know whqt I am doing wrong, but I have attached the JS file so perhaps you can get a correct patch? (had to add .txt extension for for the upload to work)

jcisio’s picture

Title: Support the customisation of submit button in dnd library » Support the customisation of submit buttons in dnd library (e.g. support Twitter Bootstrap)
Status: Needs work » Fixed

I don't know what happened. Patch #10 passed and #13 failed. BTW I committed it, but shortened the selector by removing duplicate code: 43403f2. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.