Skip to content
Browse files

added event options

  • Loading branch information...
1 parent c77098c commit 91562c3955183f9c70705f2db2098b7ce8be819a @philellwood committed Jun 26, 2012
Showing with 67 additions and 31 deletions.
  1. +2 −2 Resources/eventHandler.js
  2. +42 −5 Resources/windows/event_options.js
  3. +5 −22 Resources/windows/events.js
  4. +18 −2 Resources/windows/new_event.js
View
4 Resources/eventHandler.js
@@ -22,8 +22,8 @@ Events.create = function(_data){
};
-Events.queryClub = function(_club,_callback){
- var whereString = JSON.stringify(Util.createSet([_club]));
+Events.queryClub = function(query,_callback){
+ var whereString = JSON.stringify(query);
var query = {
where: whereString
};
View
47 Resources/windows/event_options.js
@@ -1,7 +1,8 @@
Ti.include('/data.js');
+Ti.include('/util.js');
(function (window) {
- var cancel, save, options, ID;
+ var cancel, save, options, ID, queryObject, selectedIndex, myEvents;
ID = "EVENT_OPTIONS";
@@ -22,12 +23,48 @@ Ti.include('/data.js');
title: 'Save'
}));
save.addEventListener('click', function () {
- Data.save(ID, options);
- window.onchange && window.onchange();
- window.close();
+ options = Data.load(ID, Util.createSet(Data.getUserClubs()));
+ if(selectedIndex = 0){
+ options = Util.createSet(Data.getUserClubs());
+ }else{
+ options = Util.createSet([clubPicker.getSelectedRow(0)]);
+ }
+
+
+ if(myEvents){
+ Users.showCurrent(function(user){
+ options[id]=user.id;
+ Data.save(ID, options);
+ window.onchange && window.onchange();
+ window.close();
+ });
+ } else {
+
+ Data.save(ID, options);
+ window.onchange && window.onchange();
+ window.close();
+ }
+ });
+
+ clubPicker = Ti.UI.createPicker({ bottom: 0 });
+ window.add(clubPicker);
+ clubPicker.add(Util.foreach(Util.keys(Data.getUserClubs()), function (_, title) {
+ return Ti.UI.createPickerRow({ title: title });
+ }));
+
+ clubPicker.selectionIndicator = true;
+
+ clubPicker.addEventListener('change', function (event) {
+ selectedIndex = event.rowIndex;
+ })
+
+ myEvents = Ti.UI.createSwitch({
+ value: false
});
+ window.add(myEvents);
- options = Data.load(ID, {});
+
+
View
27 Resources/windows/events.js
@@ -12,29 +12,12 @@ Ti.include('/eventHandler.js');
requery = function () {
Ti.API.info("REQUERYING!");
- options = Data.load(ID, {});
- // table.data = [];
+ options = Data.load(ID, Util.createSet(Data.getUserClubs()));
- /*
-
- activityIndicator.on();
-
- CLOUD.QUERY(options, function onsuccess(events) {
- table.data = Util.foreach(events, function (event) {
- return Ti.UI.createTableViewRow({ title: event.title });
- });
- activityIndicator.off();
- }, function onerror() {
- alert("There was a problem loading the events.");
- activityIndicator.off();
- });
-
- */
-
- Events.queryClub(Util.keys(Data.getUserClubs()), function(events){
- for(var i =0;i<events.length;i++){
- table.appendRow(Ti.UI.createTableViewRow({title:events[i].name}));
- }
+ Events.queryClub(options, function(events){
+ table.data = Util.foreach(events, function (index, event) {
+ return Ti.UI.createTableViewRow({ title: event.name });
+ });
});
};
View
20 Resources/windows/new_event.js
@@ -3,7 +3,7 @@ Ti.include('/data.js');
Ti.include('/clubs_data.js');
Ti.include('/messageHandler.js');
(function (window) {
- var cancel, create, nameLabel, name, datePicker, clubPicker;
+ var cancel, create, nameLabel, name, datePicker, clubPicker, infoWin;
window.updateLayout({
title: "New Event",
@@ -31,14 +31,30 @@ Ti.include('/messageHandler.js');
borderWidth: 1, borderColor: '#bbb', borderRadius: 3
});
window.add(name);
+
+ dateLabel = Ti.UI.createLabel({
+ top:45, left:5, text:'Event Name:'
+ });
+ window.add(dateLabel);
+
+ date = Ti.UI.createTextField({
+ top:45, left:120, height: 30, width:150,
+ borderWidth: 1, borderColor: '#bbb', borderRadius: 3
+ });
+ window.add(date);
+
+ date.addEventListener('focus',function(){
+ infoWin.open();
+ })
+ infoWin = Ti.UI.createWindow({modal:true});
datePicker = Ti.UI.createPicker({
type:Titanium.UI.PICKER_TYPE_DATE_AND_TIME,
minDate: new Date(),
value: new Date(),
});
- window.add(datePicker);
+ infoWin.add(datePicker);
clubPicker = Ti.UI.createPicker({ bottom: 0 });
window.add(clubPicker);

0 comments on commit 91562c3

Please sign in to comment.
Something went wrong with that request. Please try again.