Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edition view does not load entire entity after save changes #805

Closed
kinnrot opened this issue Nov 19, 2015 · 5 comments
Closed

Edition view does not load entire entity after save changes #805

kinnrot opened this issue Nov 19, 2015 · 5 comments

Comments

@kinnrot
Copy link

kinnrot commented Nov 19, 2015

Lets say I have a field x that his value is calculated on server side based on field y
if I update x value via admin ui, click save, than server side changes y returns it, but the change is not reflected on ui without refreshing the page

@fzaninotto
Copy link
Member

I guess it's related to #777

@kinnrot
Copy link
Author

kinnrot commented Nov 23, 2015

Yep, I think that for my issue there is a very simple solution...

// Form Controller
.updateOne(view, restEntry, this.originEntityId)
.then(() => {
this.progression.done();
this.notification.log('Changes successfully saved.', { addnCls: 'humane-flatty-success' });
}, this.handleError.bind(this));

just need to take the result from update one and update the $scope.entity attributes...

Should I create a pull req?

@fzaninotto
Copy link
Member

no, the default behaviour should be to keep the current entity.

@kinnrot
Copy link
Author

kinnrot commented Dec 9, 2015

@fzaninotto
Ok,
Found another way, just intercept the update one with a state reload after update, simple and do the work for me.


angular.module('crud')
  .config([
    '$provide', function ($provide) {
      $provide.decorator('WriteQueries', [
        '$delegate',
        '$state',
        function ($delegate, $state) {
          var originalUpdateOne = $delegate.updateOne;
          $delegate.updateOne = function () {
            return originalUpdateOne.apply($delegate, arguments).
              then(function () {
                $state.reload()
              });
          };
          return $delegate;
        }]);
    }
  ]);

@fzaninotto
Copy link
Member

Interesting approach, albeit a bit hacky. Thanks for sharing it!

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

No branches or pull requests

2 participants