Skip to content

Commit

Permalink
Fix pr/hrm_AssignMethods to close popup after assigning inside popup
Browse files Browse the repository at this point in the history
  • Loading branch information
flavour committed Dec 1, 2017
1 parent 0d3d6b9 commit 226ba04
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 20 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7089b6f (2017-12-01 15:32:10)
0d3d6b9 (2017-12-01 15:45:40)
21 changes: 14 additions & 7 deletions modules/s3db/hrm.py
Original file line number Diff line number Diff line change
Expand Up @@ -5068,12 +5068,19 @@ def apply_method(self, r, **attr):
form = Storage(vars=link)
onaccept(form)
added += 1
current.session.confirmation = T("%(number)s assigned") % \
dict(number=added)
if added > 0:
redirect(URL(args=[r.id, self.next_tab], vars={}))

if r.representation == "popup":
# Don't redirect, so we retain popup extension & so close popup
response.confirmation = T("%(number)s assigned") % \
dict(number=added)
return {}
else:
redirect(URL(args=r.args, vars={}))
current.session.confirmation = T("%(number)s assigned") % \
dict(number=added)
if added > 0:
redirect(URL(args=[r.id, self.next_tab], vars={}))
else:
redirect(URL(args=r.args, vars={}))

elif r.http == "GET":

Expand Down Expand Up @@ -5141,7 +5148,7 @@ def apply_method(self, r, **attr):
# Bulk actions
dt_bulk_actions = [(T("Assign"), "assign")]

if r.representation == "html":
if r.representation in ("html", "popup"):
# Page load
resource.configure(deletable = False)

Expand Down Expand Up @@ -5215,9 +5222,9 @@ def apply_method(self, r, **attr):
)

STAFF = settings.get_hrm_staff_label()
output = dict()

response.view = "list_filter.html"

return {"items": items,
"title": T("Assign %(staff)s") % dict(staff=STAFF),
"list_filter_form": ff,
Expand Down
26 changes: 14 additions & 12 deletions modules/s3db/pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -6926,12 +6926,19 @@ def apply_method(self, r, **attr):
form = Storage(vars=link)
onaccept(form)
added += 1
current.session.confirmation = T("%(number)s assigned") % \
dict(number=added)
if added > 0:
redirect(URL(args=[r.id, self.next_tab], vars={}))

if r.representation == "popup":
# Don't redirect, so we retain popup extension & so close popup
response.confirmation = T("%(number)s assigned") % \
dict(number=added)
return {}
else:
redirect(URL(args=r.args, vars={}))
current.session.confirmation = T("%(number)s assigned") % \
dict(number=added)
if added > 0:
redirect(URL(args=[r.id, self.next_tab], vars={}))
else:
redirect(URL(args=r.args, vars={}))

elif r.http == "GET":

Expand Down Expand Up @@ -7018,8 +7025,7 @@ def apply_method(self, r, **attr):
# Bulk actions
dt_bulk_actions = [(T("Assign"), "assign")]

representation = r.representation
if representation in ("html", "popup"):
if r.representation in ("html", "popup"):
# Page load
resource.configure(deletable = False)

Expand Down Expand Up @@ -7094,16 +7100,12 @@ def apply_method(self, r, **attr):

response.view = "list_filter.html"

if r.representation == "popup":
# Don't redirect, so we retain popup extension & so close popup
self.next = None

return {"items": items,
"title": T("Assign People"),
"list_filter_form": ff,
}

elif representation == "aadata":
elif r.representation == "aadata":
# Ajax refresh
if "draw" in get_vars:
echo = int(get_vars.draw)
Expand Down

0 comments on commit 226ba04

Please sign in to comment.