Commit 1b12fb82 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Update RowEditorUnlockStatusOk to polish the code.

parent a7e85ca8
......@@ -19,6 +19,15 @@ Ext.define("Limbra.grid.plugin.RowEditorUnlockStatusOk", {
*/
idStatusOk: 3,
/**
* @cfg {String}
* URL to the controller which will change the status.
* The joker APP will be replace by the name of the application
* The parameter id is the publications identifier in the database.
*
*/
controller: "/APP/publications/unlock_status?id=",
// shotcuts
rowEditor: null,
......@@ -79,8 +88,7 @@ Ext.define("Limbra.grid.plugin.RowEditorUnlockStatusOk", {
/**
* Handler to unlock the publication.
* A confirmation by te user is required to unlock the publication.
* Technically, the status field is reset to 1 (undefined)
* A confirmation is required to unlock the publication.
*
*/
onUnlock: function () {
......@@ -97,14 +105,14 @@ Ext.define("Limbra.grid.plugin.RowEditorUnlockStatusOk", {
idStatus = record.get("PublicationsId_status");
// inform the user that there is nothing to do
if (idStatus !== me.idStatusOk) {
Ext.Msg.alert(me.textInformation, me.textMsgInformation);
return;
}
// build the confirmation key. It is the family name of one authors
// of my institute signing the publications.
// the name is chosen randomly.
// build the confirmation key. It is the family name of my authors
// selected randoly
myAuthors = record.get("PublicationsAuthors_institute").split(",");
iAuth = Math.floor(Math.random() * (myAuthors.length - 1));
......@@ -114,9 +122,9 @@ Ext.define("Limbra.grid.plugin.RowEditorUnlockStatusOk", {
msg = me.textMsgConfirmation.replace("XYZ", ask);
// confirmation process
// modify the status when the value is equal to ask
// modify the status when the entered value is equal to ask
// the process is complex since the protection on the status
// have to be bypass. They are implemented at the database level
// have to be bypassed. They are implemented at the database level
// using callback.
Ext.Msg.prompt(me.textConfirmation, msg, function(buttonId, value) {
......@@ -132,8 +140,7 @@ Ext.define("Limbra.grid.plugin.RowEditorUnlockStatusOk", {
Ext.Ajax.request({
// go back to server to bypass protection on the status
url: "/" + Dbui.name +
"/publications/unlock_status?id=" +
url: me.controller.replace("APP", Dbui.name) +
record.get("PublicationsId"),
// something went wrong on the server side, inform the user
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment