Skip to content

Commit

Permalink
Access Control: reveal user account topic (#415).
Browse files Browse the repository at this point in the history
Clicking the user name in the login status (upper/right) reveals the User Account topic.
This is useful when the logged in user want to change hers password.

Webclient public client-side API:
    dm4c.render.link() is new utility method.

Close ticket 415.
  • Loading branch information
jri committed Mar 9, 2013
1 parent 66cda55 commit f5234b7
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 13 deletions.
33 changes: 21 additions & 12 deletions modules/dm4-accesscontrol/src/main/resources/web/script/plugin.js
Expand Up @@ -73,22 +73,31 @@ dm4c.add_plugin("de.deepamehta.accesscontrol", function() {
}

function show_user(username) {
dom.append("Logged in as \"" + username + "\"<br>")
dom.append($("<a>").attr("href", "#").text("Logout").click(function() {
var response = dm4c.restc.logout()
if (response == "true") {
shutdown_gui()
} else {
update_gui_logout()
}
return false
}))
dom.append("Logged in as ").append(username_link()).append("<br>")
dom.append(logout_link())

function username_link() {
return dm4c.render.link(username, function() {
var user_account = dm4c.restc.get_topic_by_value("dm4.accesscontrol.user_account", username)
dm4c.show_topic(new Topic(user_account), "show")
}, "Reveal the User Account topic")
}

function logout_link() {
return dm4c.render.link("Logout", function() {
var response = dm4c.restc.logout()
if (response == "true") {
shutdown_gui()
} else {
update_gui_logout()
}
})
}
}

function show_login() {
dom.append($("<a>").attr("href", "#").text("Login").click(function() {
dom.append(dm4c.render.link("Login", function() {
login_dialog.open()
return false
}))
}
}
Expand Down
Expand Up @@ -5,6 +5,7 @@
top: 0.4em;
right: 1.2em;
font-size: 60%;
color: #555;
}

/* Login Dialog */
Expand Down
2 changes: 1 addition & 1 deletion modules/dm4-help/src/main/resources/web/script/plugin.js
Expand Up @@ -10,7 +10,7 @@ dm4c.add_plugin("de.deepamehta.help", function() {
'<div class="field-label">Version</div>' +
'<div>${project.version}</div>' +
'<div class="field-label">Release Date</div>' +
'<div>Mar 8, 2013</div>' +
'<div>Mar 9, 2013</div>' +
'<div class="field-label">Copyright</div>' +
'<div>2000-2013 Jörg Richter et al.</div>' +
'<div class="field-label">License</div>' +
Expand Down
Expand Up @@ -171,6 +171,22 @@ function RenderHelper() {

// ---

/**
* Renders a link.
*
* @param text The link text.
* @param handler The click handler.
* Must not care about its return value. This link's click handler always returns false.
* @param title Optional: the tooltip title.
* If not specified no tooltip is shown.
*/
this.link = function(text, handler, title) {
return $("<a>").attr({href: "#", title: title}).append(text).click(function() {
handler()
return false
})
}

/**
* @param page_model Optional: the initial value (a TopicRenderer.PageModel object or a non-object value).
* If not specified the text field will be empty.
Expand Down

0 comments on commit f5234b7

Please sign in to comment.