diff --git a/gen/mixins/ToolMixin.py b/gen/mixins/ToolMixin.py
index 0068f15..ffa7330 100644
--- a/gen/mixins/ToolMixin.py
+++ b/gen/mixins/ToolMixin.py
@@ -17,7 +17,8 @@ except ImportError:
_noroles = []
# Errors -----------------------------------------------------------------------
-jsMessages = ('no_elem_selected', 'delete_confirm', 'unlink_confirm')
+jsMessages = ('no_elem_selected', 'delete_confirm', 'unlink_confirm',
+ 'warn_leave_form')
# ------------------------------------------------------------------------------
class ToolMixin(BaseMixin):
diff --git a/gen/mixins/__init__.py b/gen/mixins/__init__.py
index 72e79d4..f45e274 100644
--- a/gen/mixins/__init__.py
+++ b/gen/mixins/__init__.py
@@ -202,7 +202,7 @@ class BaseMixin:
# page is already locked by the same user, we don't mind: he could have
# used back/forward buttons of its browser...
userId = user.getId()
- if (page in self.locks) and (userId != self.locks[page]):
+ if (page in self.locks) and (userId != self.locks[page][0]):
from AccessControl import Unauthorized
raise Unauthorized('This page is locked.')
# Set the lock
@@ -302,7 +302,8 @@ class BaseMixin:
# If this object is created from an initiator, get info about him.
initiator, initiatorPage, initiatorField = self.getInitiatorInfo()
# If the user clicked on 'Cancel', go back to the previous page.
- if rq.get('buttonCancel.x', None):
+ buttonClicked = rq.get('button')
+ if buttonClicked == 'cancel':
if initiator:
# Go back to the initiator page.
urlBack = initiator.getUrl(page=initiatorPage, nav='')
@@ -359,13 +360,13 @@ class BaseMixin:
# main site page.
if not obj.allows('View'):
return self.goto(tool.getSiteUrl(), msg)
- if rq.get('buttonOk.x', None) or saveConfirmed:
+ if (buttonClicked == 'save') or saveConfirmed:
obj.say(msg)
if isNew and initiator:
return self.goto(initiator.getUrl(page=initiatorPage, nav=''))
else:
return self.goto(obj.getUrl())
- if rq.get('buttonPrevious.x', None):
+ if buttonClicked == 'previous':
# Go to the previous page for this object.
# We recompute the list of phases and pages because things
# may have changed since the object has been updated (ie,
@@ -388,7 +389,7 @@ class BaseMixin:
else:
obj.say(msg)
return self.goto(obj.getUrl())
- if rq.get('buttonNext.x', None):
+ if buttonClicked == 'next':
# Go to the next page for this object.
# We remember page name, because the next method may set a new
# current page if the current one is not visible anymore.
@@ -398,7 +399,7 @@ class BaseMixin:
if pageName:
# Return to the edit or view page?
if pageInfo['showOnEdit']:
- # Same remark as above (buttonPrevious).
+ # Same remark as above (click on "previous").
return self.goto(obj.getUrl(mode='edit', page=pageName))
else:
return self.goto(obj.getUrl(page=pageName))
diff --git a/gen/po.py b/gen/po.py
index 04282bf..44ceb01 100644
--- a/gen/po.py
+++ b/gen/po.py
@@ -202,6 +202,9 @@ appyLabels = [
('changes_hide', 'Hide changes'),
('anonymous', 'an anonymous user'),
('page_locked', '${date} - This page is locked by ${user}.'),
+ ('warn_leave_form', 'In some situations, by leaving this page this way, you ' \
+ 'may lose encoded data or prevent other users from ' \
+ 'editing it afterwards. Please use buttons instead.'),
]
# Some default values for labels whose ids are not fixed (so they can't be
diff --git a/gen/ui/appy.js b/gen/ui/appy.js
index cbb4283..f0eb91b 100644
--- a/gen/ui/appy.js
+++ b/gen/ui/appy.js
@@ -333,6 +333,14 @@ function initSlaves() {
}
}
+// Function used to submit the appy form on edit.pt
+function submitAppyForm(button) {
+ var theForm = document.getElementById('appyForm');
+ // On which button has the user clicked?
+ theForm.button.value = button;
+ theForm.submit();
+}
+
// Function used for triggering a workflow transition
function triggerTransition(transitionId, msg) {
var theForm = document.getElementById('triggerTransitionForm');
@@ -517,8 +525,9 @@ function doAskPasswordReinit() {
// Function that finally posts the edit form after the user has confirmed that
// she really wants to post it.
function postConfirmedEditForm() {
- var theForm = document.getElementById('appyEditForm');
+ var theForm = document.getElementById('appyForm');
theForm.confirmed.value = "True";
+ theForm.button.value = 'save';
theForm.submit();
}
diff --git a/gen/ui/edit.pt b/gen/ui/edit.pt
index c99ee50..15f245d 100644
--- a/gen/ui/edit.pt
+++ b/gen/ui/edit.pt
@@ -14,16 +14,27 @@
tal:on-error="structure python: tool.manageError(error)">