Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Remove in Article -> Add callback #1274

Closed
marianoqueirel opened this issue Mar 19, 2016 · 8 comments · Fixed by #1534
Closed

Remove in Article -> Add callback #1274

marianoqueirel opened this issue Mar 19, 2016 · 8 comments · Fixed by #1534

Comments

@marianoqueirel
Copy link

mean/modules/articles/client/controllers/articles.client.controller.js

function remove() {
  if ($window.confirm('Are you sure you want to delete?')) {
    vm.article.$remove($state.go('articles.list'));
}

I think it would be better to do as follow:

function remove() {
  if ($window.confirm('Are you sure you want to delete?')) {
    vm.article.$remove(function (){
      $state.go('articles.list'));
    });
}

In Order to do so with a callback, and so it en the next digest.

@ilanbiala
Copy link
Member

@marianoqueirel there should actually be error handling as well. Can you make a PR so we can fix this code a bit?

@jamviking
Copy link

There is a typo here: $state.go('articles.list'));
It should be: $state.go('articles.list');

This patch actually fixes a bug in 0.5 where the list sometimes still displays the deleted record after deletion.

I have not observed the bug in 0.4.2.

@lirantal lirantal added this to the 0.5.0 milestone Apr 1, 2016
@ilanbiala
Copy link
Member

@marianoqueirel can you make a PR with your code with @jamviking's typo fix?

@marianoqueirel
Copy link
Author

sure! @ilanbiala, I'm going to do, and Make my first PR.

@xiandalisay
Copy link

xiandalisay commented Jun 9, 2016

I'm also experiencing this issue. I deal with images associated with the article.

delete2

The 'news.list' was called even if the remove function has not finished executing (1 out 5 images has been deleted the moment 'news.list' was called). Thanks @marianoqueirel for the solution.

@lirantal
Copy link
Member

@xiandalisay , @marianoqueirel will you open a PR please to fix this?

@lirantal
Copy link
Member

@ilanbiala @xiandalisay @marianoqueirel one of you would like to open a PR for this fix?
@hyperreality or you? :)

@hyperreality
Copy link
Contributor

@lirantal Sure, I'll take a look at it sometime in the next few days.

mleanos pushed a commit that referenced this issue Sep 30, 2016
Add callback on remove article for state transition

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

Successfully merging a pull request may close this issue.

6 participants