1. #1
    Sencha User
    Join Date
    Dec 2010
    Location
    SC - Brazil
    Posts
    27
    Answers
    3
    Vote Rating
    4
    Renan Cunha is on a distinguished road

      0  

    Default Unanswered: Send different actions to the backend

    Unanswered: Send different actions to the backend


    Hello,
    I have a doubt about which approach to use in this situation:

    In our system here we have an grid of orders. The data is handled by a store that uses an ajax or rest (this varies) proxy. For the basic operations (crud) everything is fine, the problem is that the orders have another "operations" that isn't an update. For example, I have a button to proces the order, basically it will update the status of the order. I cannot simply update the status and then sync the store, because we have a complex system of permissions. An user can update the data of a order but him cannot process.

    How I will differentiate these actions on the server side? My idea was to have two actions in my controller at backend (C# WebAPI)...

    Thanks,
    Renan.

  2. #2
    Touch Premium Member
    Join Date
    Jun 2011
    Posts
    1,099
    Answers
    113
    Vote Rating
    96
    Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light

      1  

    Default


    one idea could be to add an extra field to your store's model and use the value of this field to distinguish the two cases of update on the backend...

  3. #3
    Sencha User existdissolve's Avatar
    Join Date
    Jan 2010
    Location
    Kansas
    Posts
    522
    Answers
    31
    Vote Rating
    85
    existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice

      1  

    Default


    I typically have non-crud actions that are context-specific in the context menu. So when you right-click on a grid record, a list of available options will appear.

    For actions where I don't want to interact with the data record directly, I will often fire off ad-hoc AJAX requests (not using the store's proxy), and then use the response from the request to update any values needed within the store. For example, when changing statuses, I make a non-store based AJAX request, which in turn returns the new status of the record, which is then updated within the store. I do the data update manually in the response.

    Not necessarily the best fit for every scenario, but I found it was easier to manage than updating the full store record every time.

    Re: differentiating the actions, this is handled easily in my scenario, as the endpoint url of the ad-hoc AJAX request can be anything I want. So for status updates, I can point to status-specific endpoints, etc.

  4. #4
    Sencha User
    Join Date
    Dec 2010
    Location
    SC - Brazil
    Posts
    27
    Answers
    3
    Vote Rating
    4
    Renan Cunha is on a distinguished road

      0  

    Default


    Thanks for the answers!
    I implemented two ways for then analyze what is more "nice" to use.


    The first way is exactly how @existdissolve says. Making an ad-hoc AJAX call specific to this cases.


    The second that I implemented was add an "extraParam" before calling the store sync method and then the back-end route this param to his place. Like the answer of @Farish.


    The two ways has worked well for me!


    How I can mark this topic as answered?

Thread Participants: 2

Tags for this Thread