Loris icon indicating copy to clipboard operation
Loris copied to clipboard

[new_profile] Use API for candidate creation and swal for success

Open driusan opened this issue 4 years ago • 4 comments

This updates the candidate creation on the new profile page to use the LORIS API instead of duplicating the logic in PHP. The form already collects the exact data that a POST request to the API requires, but submits it to a different endpoint in a form encoding instead of a json encoding.

At the same time, the logic for the response is simplified by using a swal instead of a (very empty looking) new page. swals are already used for errors in the module, just not success. This change simplifies both the code and the UX.

driusan avatar Oct 29 '21 14:10 driusan

Blocked by the release. Set it to "Draft" so that it doesn't accidentally get merged beforehand.

driusan avatar Oct 29 '21 14:10 driusan

Nice! Additionally, in modules/new_profile/php/new_profile.class.inc, private $_error; can be removed.

xlecours avatar Oct 29 '21 15:10 xlecours

looks like that's also true of _pscid and _candID and all the namespaces (which phan was complaining about).. should be fixed in the last commit.

driusan avatar Oct 29 '21 15:10 driusan

@xlecours now that the release is out I removed the blocked tag and rebased this, can you re-review it?

driusan avatar Mar 29 '22 18:03 driusan

@xlecours I've fixed the indentation, added a catch to the code paths that don't have a catch for the resp.json(), fixed an error in the API that was causing it to return non-JSON and, if the gods are good, fixed the failing test by checking the swal title instead of an element in the body. (Still needs to run on GitHub to be sure that it's working..)

driusan avatar Oct 25 '22 20:10 driusan

@driusan I haven't tested it because I am in the middle of other things.

xlecours avatar Oct 26 '22 13:10 xlecours

@driusan Tested now. it's working all right.

xlecours avatar Oct 27 '22 14:10 xlecours