Skip to content

Conversation

pfmziota
Copy link

@pfmziota pfmziota commented Jan 8, 2019

Corrected issue where the ID of the removed file stayed in the hidden input after removal.

Corrected issue where the ID of the removed file stayed in the hidden input after removal.
Copy link
Collaborator

@jankapunkt jankapunkt left a comment

Choose a reason for hiding this comment

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

I actually peeked deeper into the functionality because this worked for a long time with no problems at all and I found that you were on the right track but did not fixed the cause of this issue.

The problem comes from the remove event:

'click [data-remove-file]'(e, template) {
  e.preventDefault();
  template.fileId.set(false);
  // template.data.value is not removed here :-S
  try {
    this.remove();
  } catch (error) {
    // we're good here
  }
  return false;
},

While the reactive variable is reset, the value property remains, causing the template to return the Id String to AutoForm but makes ImageFiles not find any Image related to the id (because the image has successfully been removed).

Suggested change:

'click [data-remove-file]'(e, template) {
  e.preventDefault();
  template.fileId.set(false);
  if (template.data.value) {
    delete template.data.value;
  }
  try {
    this.remove();
  } catch (error) {
    // we're good here
  }
  return false;
},

@pfmziota
Copy link
Author

pfmziota commented Jan 24, 2019

I'm sorry @jankapunkt , I did not have the time to do this in the last few days.
Here, I gladly made those changes.
The repository with the demo (mentioned in the issue #47 ) has also been updated and now uses my fork as a submodule so I can check that the changes I have made are working correctly.

I think it would be a good idea to implement unit tests.

@jankapunkt jankapunkt merged commit ffe0799 into veliovgroup:master Jan 24, 2019
@jankapunkt
Copy link
Collaborator

Thank you @pfmziota !

I think it would be a good idea to implement unit tests.

I already work on that an will provide a branch soon that will be merged tests are running.

dr-dimitru added a commit that referenced this pull request Jun 29, 2019
- 📦 Dependencies update
- 👷‍♂️ Merge #48, thanks to @pfmziota and @jankapunkt
- 👷‍♂️ Merge #53, introducing `accept` option/field, thanks to
@jankapunkt
- 👨‍💻 Minor codebase enhancements
- 📋 Documentation update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants