[commits-cosmo] (travis) [4846] * Fix up the menu layout code to
get the anonymous ticketed collection page working correctly again.
Travis Vachon
travis at osafoundation.org
Tue Jun 26 16:08:23 PDT 2007
Whoops, got distracted during checkin, middle item should have been:
"I seem to have broken saving a subscription's display name. That's
fixed now"
-Travis
On Jun 26, 2007, at 4:06 PM, svncheckin at osafoundation.org wrote:
> Revision
> 4846
> Author
> travis
> Date
> 2007-06-26 16:06:43 -0700 (Tue, 26 Jun 2007)
> Log Message
>
> * Fix up the menu layout code to get the anonymous ticketed
> collection page working correctly again.
> * I seem to have broken
> * Also, delete apparently unused login.js.
> Modified Paths
>
> cosmo/trunk/cosmo/src/main/resources/PimMessageResources.properties
> cosmo/trunk/cosmo/src/main/webapp/WEB-INF/jsp/pim/pim.jsp
> cosmo/trunk/cosmo/src/main/webapp/js/cosmo/app/pim/layout.js
> cosmo/trunk/cosmo/src/main/webapp/js/cosmo/app/pim.js
> cosmo/trunk/cosmo/src/main/webapp/js/cosmo/app.js
> cosmo/trunk/cosmo/src/main/webapp/js/cosmo/ui/menu.js
> cosmo/trunk/cosmo/src/main/webapp/js/cosmo/ui/widget/
> CollectionDetailsDialog.js
> cosmo/trunk/cosmo/src/main/webapp/js/cosmo/ui/widget/
> CollectionSelector.js
> cosmo/trunk/cosmo/src/main/webapp/js/cosmo/ui/widget/LoginDialog.js
> cosmo/trunk/cosmo/src/main/webapp/js/cosmo/util/auth.js
> Removed Paths
>
> cosmo/trunk/cosmo/src/main/webapp/js/cosmo/ui/login.js
> Diff
>
> Modified: cosmo/trunk/cosmo/src/main/resources/
> PimMessageResources.properties (4845 => 4846)
>
> --- cosmo/trunk/cosmo/src/main/resources/
> PimMessageResources.properties 2007-06-26 22:57:03 UTC (rev 4845)
> +++ cosmo/trunk/cosmo/src/main/resources/
> PimMessageResources.properties 2007-06-26 23:06:43 UTC (rev 4846)
> @@ -196,6 +196,10 @@
> Main.Preferences=Preferences
> Main.Help=Help
> Main.LogOut=Log Out
> +Main.LogIn=Log In
> +Main.SignUp=Sign Up!
> +Main.AccountBrowser=Account Browser
> +Main.Settings=Settings
>
> Main.NavBar.QuickItemEntryHint=Create a new note
>
> Modified: cosmo/trunk/cosmo/src/main/webapp/WEB-INF/jsp/pim/pim.jsp
> (4845 => 4846)
>
> --- cosmo/trunk/cosmo/src/main/webapp/WEB-INF/jsp/pim/pim.jsp
> 2007-06-26 22:57:03 UTC (rev 4845)
> +++ cosmo/trunk/cosmo/src/main/webapp/WEB-INF/jsp/pim/pim.jsp
> 2007-06-26 23:06:43 UTC (rev 4846)
> @@ -80,9 +80,7 @@
> cosmo.app.initParams.ticketKey = params['ticket'];
> }
>
> -// If this is true, we are not in anonymous ticketed mode,
> -// and the user better have logged in
> -cosmo.app.initParams.authAccess = !cosmo.app.initParams.ticketKey;
> +cosmo.app.initParams.authAccess =
> cosmo.util.auth.currentlyAuthenticated();
>
> <authz:authorize ifAnyGranted="ROLE_USER">
> cosmo.app.initParams.roleUser = true;
> Modified: cosmo/trunk/cosmo/src/main/webapp/js/cosmo/app/pim/
> layout.js (4845 => 4846)
>
> --- cosmo/trunk/cosmo/src/main/webapp/js/cosmo/app/pim/layout.js
> 2007-06-26 22:57:03 UTC (rev 4845)
> +++ cosmo/trunk/cosmo/src/main/webapp/js/cosmo/app/pim/layout.js
> 2007-06-26 23:06:43 UTC (rev 4846)
> @@ -310,8 +310,8 @@
> this.baseLayout.menuBar.mainMenu = cB;
> cB.render(); // Go ahead and render the menubar -- no waiting
> for data
>
> - // Subscription selector thinger -- show only in anon view
> - if (!cosmo.app.initParams.authAccess) {
> + // Subscription selector thinger -- show only in ticketed view
> + if (cosmo.app.initParams.ticketKey) {
> var s = _createElem('span');
> s.id = 'subscribeSelector';
> var form = _createElem('form');
> Modified: cosmo/trunk/cosmo/src/main/webapp/js/cosmo/app/pim.js
> (4845 => 4846)
>
> --- cosmo/trunk/cosmo/src/main/webapp/js/cosmo/app/pim.js
> 2007-06-26 22:57:03 UTC (rev 4845)
> +++ cosmo/trunk/cosmo/src/main/webapp/js/cosmo/app/pim.js
> 2007-06-26 23:06:43 UTC (rev 4846)
> @@ -219,8 +219,8 @@
> // Uid of the first calendar to select.
> var selectUid = params.collectionUid;
>
> - //If we are not authenticated, use the collectionUrl in
> params to load a collection
> - if (!params.authAccess) {
> + //If we received a ticket key, use the collectionUrl in
> params to load a collection
> + if (params.ticketKey) {
> try {
> var collection = this.serv.getCollection
> (params.collectionUrl, {sync:true}).results[0];
> selectUid = collection.getUid();
> @@ -247,7 +247,6 @@
> }
> var subscriptions = this.serv.getSubscriptions
> ({sync:true}).results[0];
>
> - //XINT make sure this still works!
> var result = this.filterOutDeletedSubscriptions
> (subscriptions);
> subscriptions = result[0];
> deletedSubscriptions = result[1];
> Modified: cosmo/trunk/cosmo/src/main/webapp/js/cosmo/app.js (4845
> => 4846)
>
> --- cosmo/trunk/cosmo/src/main/webapp/js/cosmo/app.js 2007-06-26
> 22:57:03 UTC (rev 4845)
> +++ cosmo/trunk/cosmo/src/main/webapp/js/cosmo/app.js 2007-06-26
> 23:06:43 UTC (rev 4846)
> @@ -21,6 +21,7 @@
> dojo.require('cosmo.ui.widget.ModalDialog');
> dojo.require("cosmo.ui.button");
> dojo.require("cosmo.util.i18n");
> +dojo.require("cosmo.util.auth");
> dojo.require("cosmo.topics");
> dojo.require("cosmo.convenience");
> dojo.require("cosmo.util.popup");
> @@ -41,7 +42,7 @@
> // List of any queued-up error messages
> this.errorList = [];
> // Quick access to the currently logged-in user
> - this.currentUsername = dojo.io.cookie.getCookie('username');
> + this.currentUsername = cosmo.util.auth.getUsername();
> //select boxes to show/hide when displaying modal dialog box
> this._selectBoxIds = {};
>
> Deleted: cosmo/trunk/cosmo/src/main/webapp/js/cosmo/ui/login.js
> (4845 => 4846)
>
> --- cosmo/trunk/cosmo/src/main/webapp/js/cosmo/ui/login.js
> 2007-06-26 22:57:03 UTC (rev 4845)
> +++ cosmo/trunk/cosmo/src/main/webapp/js/cosmo/ui/login.js
> 2007-06-26 23:06:43 UTC (rev 4846)
> @@ -1,120 +0,0 @@
> -/*
> - * Copyright 2006 Open Source Applications Foundation
> - *
> - * Licensed under the Apache License, Version 2.0 (the "License");
> - * you may not use this file except in compliance with the License.
> - * You may obtain a copy of the License at
> - *
> - * http://www.apache.org/licenses/LICENSE-2.0
> - *
> - * Unless required by applicable law or agreed to in writing,
> software
> - * distributed under the License is distributed on an "AS IS" BASIS,
> - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> - * See the License for the specific language governing permissions
> and
> - * limitations under the License.
> -*/
> -
> -/**
> - * @fileoverview Login -- used for user auth
> - * @author Matthew Eernisse mailto:mde at osafoundation.org
> - * @license Apache License 2.0
> - */
> -
> -/**
> - * @object Login -- singleton for doing user auth
> - */
> -dojo.provide("cosmo.ui.login");
> -
> -dojo.require("dojo.io.*");
> -dojo.require("cosmo.env");
> -dojo.require("cosmo.util.i18n");
> -dojo.require("cosmo.util.cookie");
> -
> -var Login = new function () {
> -
> - var self = this;
> -
> - this.loginFocus = false;
> - this.loginReq = null;
> - this.loginForm = null;
> - this.authProc = '';
> -
> - this.init = function() {
> - var but = new Button('submitButton', 74, Login.doLogin,
> - _('App.Button.Submit'));
> - self.loginForm = document.getElementById('loginForm');
> - self.authProc = AUTH_PROC;
> - self.loginForm.j_username.focus();
> - // Add logo and button
> - //document.getElementById('logoDiv').innerHTML =
> - // '<img src="' + cosmo.env.getImagesUrl() +
> LOGO_GRAPHIC + '" alt="">';
> - document.getElementById('submitButtonDiv').appendChild
> (but.domNode);
> - }
> - this.handleLoginResp = function(str) {
> - if (str.indexOf('login.js') > -1) {
> - self.showErr(_('Login.Error.AuthFailed'));
> - self.loginForm.j_password.value = '';
> - }
> - else {
> - self.showPrompt('normal', 'Logging you on. Please
> wait ...');
> - var username = self.loginForm.j_username.value;
> - if (username == "root") {
> - location = cosmo.env.getBaseUrl() + "/console/
> account";
> - } else {
> - location = cosmo.env.getBaseUrl() + "/pim/pim.page";
> - }
> - }
> - }
> - this.doLogin = function() {
> - var un = self.loginForm.j_username.value;
> - var pw = self.loginForm.j_password.value;
> - var postData = {};
> - var err = '';
> -
> - if (!un || !pw) {
> - err = _('Login.Error.RequiredFields');
> - }
> - if (err) {
> - self.showErr(err);
> - }
> - else {
> - cosmo.util.cookie.set('username', un);
> - postData = { 'j_username': un, 'j_password': pw };
> - dojo.io.bind({
> - url: self.authProc,
> - method: 'POST',
> - content: postData,
> - load: function(type, data, evt)
> { Login.handleLoginResp(data); },
> - error: function(type, error) { alert
> (error.message); }
> - });
> - }
> - }
> -
> - this.showErr = function(str) {
> - this.showPrompt('error', str);
> - }
> -
> - this.showPrompt = function(promptType, str) {
> - var promptDiv = document.getElementById('promptDiv');
> - if (promptType.toLowerCase() == 'error') {
> - promptDiv.className = 'promptTextError';
> - }
> - else {
> - promptDiv.className = 'promptText';
> - }
> - promptDiv.innerHTML = str;
> - }
> - this.keyUpHandler = function(e) {
> - e = !e ? window.event : e;
> - if (e.keyCode == 13 && Login.loginFocus) {
> - Login.doLogin();
> - return false;
> - }
> - }
> -}
> -
> -Login.constructor = null;
> -
> -document.onkeyup = Login.keyUpHandler;
> -window.onload = Login.init;
> -
> Modified: cosmo/trunk/cosmo/src/main/webapp/js/cosmo/ui/menu.js
> (4845 => 4846)
>
> --- cosmo/trunk/cosmo/src/main/webapp/js/cosmo/ui/menu.js
> 2007-06-26 22:57:03 UTC (rev 4845)
> +++ cosmo/trunk/cosmo/src/main/webapp/js/cosmo/ui/menu.js
> 2007-06-26 23:06:43 UTC (rev 4846)
> @@ -43,28 +43,26 @@
> // Instantiate all the items as MenuItem obj
> for (var i = 0; i < items.length; i++) {
> var item = items[i];
> - if (this.isItemInCurrentDisplayMode(item) &&
> + if (this.itemShownInDisplayMode(item,
> this.calculateDisplayMode()) &&
> this.userHasRequiredRolesForItem(item) &&
> this.userHasRequiredPrefForItem(item, prefs)) {
> this.items.addItem(items[i].id, new _c(items[i]));
> }
> }
> };
> - this.isItemInCurrentDisplayMode = function (item) {
> +
> + this.calculateDisplayMode = function(){
> + var mode = 0;
> var modes = cosmo.ui.menu.displayModes;
> - switch (item.displayMode) {
> - case modes.ANY:
> - return true;
> - break;
> - case modes.AUTH:
> - return !!(cosmo.app.initParams.authAccess);
> - break;
> - case modes.ANON:
> - return !(cosmo.app.initParams.authAccess);
> - break;
> - }
> - return false;
> + if (cosmo.app.initParams.authAccess) mode |= modes.AUTH;
> + else mode |= modes.ANON;
> + if (cosmo.app.initParams.ticketKey) mode |= modes.TICKETED;
> + return mode;
> };
> +
> + this.itemShownInDisplayMode = function (item, displayMode) {
> + return displayMode & item.displayMode;
> + };
> this.userHasRequiredRolesForItem = function (item) {
> var roles = item.requiredRoles;
> for (var i = 0; i < roles.length; i++) {
> @@ -86,9 +84,10 @@
> };
>
> cosmo.ui.menu.displayModes = {
> - AUTH: 'authAccess',
> - ANON: 'anonAccess',
> - ANY: 'anyAccess'
> + ANON: 1,
> + AUTH: 2,
> + TICKETED: 4,
> + ANY: 7
> };
>
> cosmo.ui.menu.requiredRoles = {
> @@ -110,7 +109,7 @@
> // based on display mode, user permissions, and user prefs
> cosmo.ui.menu.allItems = [
> { id: 'welcomeMenuItem',
> - displayText: 'Welcome, ' + cosmo.app.currentUsername,
> + displayText: _('Main.Welcome', [cosmo.app.currentUsername]),
> displayMode: cosmo.ui.menu.displayModes.AUTH,
> requiredRoles: [cosmo.ui.menu.requiredRoles.USER]
> },
> @@ -121,13 +120,13 @@
> requiredRoles: [cosmo.ui.menu.requiredRoles.ROOT]
> },
> { id: 'settingsMenuItem',
> - displayText: 'Settings',
> + displayText: _('Main.Settings'),
> onclickFunc: function ()
> { cosmo.account.settings.showDialog(); },
> displayMode: cosmo.ui.menu.displayModes.AUTH,
> requiredRoles: [cosmo.ui.menu.requiredRoles.USER]
> },
> { id: 'accountBrowserMenuItem',
> - displayText: 'Account Browser',
> + displayText: _('Main.AccountBrowser'),
> onclickFunc: function (e) {
> window.open(cosmo.ui.menu.urls.ACCOUNT_BROWSER);
> e.preventDefault(); },
> urlString: cosmo.ui.menu.urls.ACCOUNT_BROWSER,
> @@ -136,13 +135,13 @@
> //requiredPref:
> cosmo.account.preferences.SHOW_ACCOUNT_BROWSER_LINK
> },
> { id: 'signupMenuItem',
> - displayText: 'Sign Up!',
> + displayText: _('Main.SignUp'),
> onclickFunc: function () { cosmo.account.create.showForm() },
> displayMode: cosmo.ui.menu.displayModes.ANON,
> requiredRoles: []
> },
> { id: 'helpMenuItem',
> - displayText: 'Help',
> + displayText: _('Main.Help'),
> onclickFunc: function (e) {
> window.open(cosmo.ui.menu.urls.HELP); e.preventDefault
> (); },
> urlString: cosmo.ui.menu.urls.HELP,
> @@ -150,8 +149,8 @@
> requiredRoles: []
> },
> { id: 'loginMenuItem',
> - displayText: 'Log In',
> - onclickFunc: cosmo.env.getLoginRedirect(),
> + displayText: _('Main.LogIn'),
> + onclickFunc: function(){location =
> cosmo.env.getLoginRedirect()},
> displayMode: cosmo.ui.menu.displayModes.ANON,
> requiredRoles: []
> },
> Modified: cosmo/trunk/cosmo/src/main/webapp/js/cosmo/ui/widget/
> CollectionDetailsDialog.js (4845 => 4846)
>
> --- cosmo/trunk/cosmo/src/main/webapp/js/cosmo/ui/widget/
> CollectionDetailsDialog.js 2007-06-26 22:57:03 UTC (rev 4845)
> +++ cosmo/trunk/cosmo/src/main/webapp/js/cosmo/ui/widget/
> CollectionDetailsDialog.js 2007-06-26 23:06:43 UTC (rev 4846)
> @@ -257,7 +257,7 @@
> btnsRight.push(closeButton);
> dummyNode.removeChild(closeButton.domNode);
>
> - if (this.saveable){
> + if (contentWidget.saveable){
> var saveButton = dojo.widget.createWidget(
> "cosmo:Button",
> { text: _("Main.CollectionDetails.Save"),
> Modified: cosmo/trunk/cosmo/src/main/webapp/js/cosmo/ui/widget/
> CollectionSelector.js (4845 => 4846)
>
> --- cosmo/trunk/cosmo/src/main/webapp/js/cosmo/ui/widget/
> CollectionSelector.js 2007-06-26 22:57:03 UTC (rev 4845)
> +++ cosmo/trunk/cosmo/src/main/webapp/js/cosmo/ui/widget/
> CollectionSelector.js 2007-06-26 23:06:43 UTC (rev 4846)
> @@ -98,13 +98,22 @@
> function renderButton() {
> var strings = self.strings;
> var imgPath = '';
> - var f = null;
> + var clickFunction = null;
> // If using a ticket, add the 'Add' button
> if (passedKey) {
> imgPath = 'subscribe';
> imgTitle = strings.imgTitleAdd;
> // Set up the authAction obj for the AuthBox
> -- this tells it
> // what to do if the user auths successfully
> +
> + var subscribeFunction = function (){
> + var subscription = new
> cosmo.model.Subscription({
> + displayName: curr.getDisplayName(),
> + uid: curr.getUid(),
> + ticketKey: passedKey
> + })
> + return
> cosmo.app.pim.serv.createSubscription(subscription);
> + }
> var authAction = {
> execInline: false,
> authInitPrompt: 'Please enter the login
> information for your Cosmo account.',
> @@ -112,13 +121,7 @@
> // Action to take after successful auth --
> try to add the
> // collection subscription
> attemptFunc: function () {
> -
> - var subscription = new
> cosmo.model.Subscription({
> - displayName: curr.getDisplayName(),
> - uid: curr.getUid(),
> - ticketKey: passedKey
> - })
> - var deferred =
> cosmo.app.pim.serv.createSubscription(subscription);
> + var deferred = subscribeFunction();
> deferred.addCallback(dojo.lang.hitch
> (this, function(x,y,z){
> dojo.debug(x)
> dojo.debug(y)
> @@ -140,17 +143,28 @@
> },
> attemptPrompt: strings.attemptPrompt,
> successPrompt: strings.successPrompt };
> - f = function () {
> - var authBoxProps =
> cosmo.ui.widget.AuthBox.getInitProperties(authAction);
> - cosmo.app.showDialog(authBoxProps);
> -
> cosmo.app.modalDialog.content.usernameInput.focus();
> +
> + clickFunction = function () {
> + if (!cosmo.util.auth.currentlyAuthenticated
> ()){
> + var authBoxProps =
> cosmo.ui.widget.AuthBox.getInitProperties(authAction);
> + cosmo.app.showDialog(authBoxProps);
> +
> cosmo.app.modalDialog.content.usernameInput.focus();
> + } else {
> + var deferred = subscribeFunction();
> + deferred.addCallback(function(){
> + location = cosmo.env.getBaseUrl()
> + '/pim/collection/' + curr.getUid();
> + });
> + deferred.addErrback(function(err){
> + cosmo.app.showErr
> (self.strings.collectionAddError, err);
> + });
> + }
> };
> }
> // Otherwise the user is logged in -- use the
> 'Info' button
> else {
> imgPath = 'details';
> imgTitle = self.strings.imgTitleInfo;
> - f = function () {
> + clickFunction = function () {
> var _pim = cosmo.app.pim;
> cosmo.app.showDialog(
>
> cosmo.ui.widget.CollectionDetailsDialog.getInitProperties(
> @@ -163,7 +177,7 @@
> collIcon.style.cursor = 'pointer';
> collIcon.alt = imgTitle;
> collIcon.title = imgTitle;
> - dojo.event.connect(collIcon, 'onclick', f);
> + dojo.event.connect(collIcon, 'onclick',
> clickFunction);
> // Img is an actual DOM element, so you set the
> vertical-align
> // prop on the image, not on the enclosing div
> collIcon.style.verticalAlign = 'middle';
> Modified: cosmo/trunk/cosmo/src/main/webapp/js/cosmo/ui/widget/
> LoginDialog.js (4845 => 4846)
>
> --- cosmo/trunk/cosmo/src/main/webapp/js/cosmo/ui/widget/
> LoginDialog.js 2007-06-26 22:57:03 UTC (rev 4845)
> +++ cosmo/trunk/cosmo/src/main/webapp/js/cosmo/ui/widget/
> LoginDialog.js 2007-06-26 23:06:43 UTC (rev 4846)
> @@ -65,7 +65,6 @@
> }
> else {
> self.showPrompt('normal', _
> ('Login.Prompt.Processing'));
> - dojo.io.cookie.set('username', un);
>
> postData = { 'j_username': un, 'j_password': pw };
>
> Modified: cosmo/trunk/cosmo/src/main/webapp/js/cosmo/util/auth.js
> (4845 => 4846)
>
> --- cosmo/trunk/cosmo/src/main/webapp/js/cosmo/util/auth.js
> 2007-06-26 22:57:03 UTC (rev 4845)
> +++ cosmo/trunk/cosmo/src/main/webapp/js/cosmo/util/auth.js
> 2007-06-26 23:06:43 UTC (rev 4846)
> @@ -67,6 +67,10 @@
> this.getCred = function(){
> return dojo.io.cookie.get(COSMO_AUTH_COOKIE);
> }
> +
> + this.currentlyAuthenticated = function(){
> + return !!this.getCred();
> + }
>
> this.getAuthorizedRequest = function(request, kwArgs){
> kwArgs = kwArgs || {};
>
> _______________________________________________
> Commits-Cosmo mailing list
> Commits-Cosmo at osafoundation.org
> http://lists.osafoundation.org/cgi-bin/mailman/listinfo/commits-cosmo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osafoundation.org/pipermail/commits-cosmo/attachments/20070626/5ef33858/attachment.html
More information about the Commits-Cosmo
mailing list