eGovPDX / Council-Agenda-App

5 stars 0 forks source link

Smart Session Dates #6

Closed OscarGodson closed 13 years ago

OscarGodson commented 13 years ago

When creating a new session, the date and time should be guessed.

earenson commented 13 years ago

This should be working now. I added the the date/time insert as an inline script in new-session.html, but there may be a more elegant way to handle it.

OscarGodson commented 13 years ago

It's missing some things ;)

  1. Could you move that to in the main.js and the next Session code to a method of app() (example below)? The /templates directory is supposed to just be raw HTML. We'll want to reuse this, so we should move it. I.e. we change the front end presentation, make a mobile version, etc.
  2. Add a default to your switch in case (example below) a 3rd+ session comes up which does happen quite often (see: http://www.portlandonline.com/auditor/index.cfm?c=51775&a=296588 ) We want to make sure they cant break it (if they have to refresh we failed haha)
  3. This should support going to thursdays after N sessions (i think 3, see the example session link above and look for Thursday)
  4. We want to try to not use DOM elements for checking data, just to put data into it for presentation. So for var sessionCount you'll want to make an API call to get sessions for the current agenda. (i added an id param to the example code below that you'd use). In main.js you'd do something like (youll probably have to mod it a bit depending on the API response):
app().api({action:'get',type:'agenda','id':dataStore('active-agenda')},function(json){ 
  var sessionCount = json[x].sessions.length;
});

Here's an example method:

app = function(){ //...
//...the other methods here
  nextSession: function(id){
       // Set up the date and time for the first session
    var nextWednesday = nextSession();

    // Scour the HTML for any h3 tags, used to determine our session times
    var sessionCount = $('h3.session').length; //replace with API call

    switch(sessionCount){
        case 0: sessionTime = '09:30'; break;
        case 1: sessionTime = '14:00'; break;
        default: sessionTime = '9:30'; //Not sure what this should be yet
    }

    // Write it to the input as a default value
    return nextWednesday.getMonth()+1 + '-' + nextWednesday.getDate() + '-' + nextWednesday.getFullYear()+ ' ' + sessionTime;
  }
//...the other methods here
});

You'd use it like:

var theNextSession = app().nextSession(dataStore('active-agenda'));
$('input[name=date]').val(theNextSession);
earenson commented 13 years ago

Fixed in accordance with the anti 'codin' drrty' statute.

OscarGodson commented 13 years ago

We need to put that in our code style docs. Have a section called "Codin' Dirty"