PageRenderTime 37ms CodeModel.GetById 33ms app.highlight 2ms RepoModel.GetById 0ms app.codeStats 1ms

/NewClientWindows.j

http://github.com/chollier/Edgar
Unknown | 143 lines | 114 code | 29 blank | 0 comment | 0 complexity | 9df3ee4b2dcbaa36cdd072e23d756fb7 MD5 | raw file
  1@import <Foundation/CPObject.j>
  2@import "DatePicker/DatePicker.j"
  3@import "ClientsController.j"
  4
  5var SharedClientWindow = nil;
  6
  7@implementation NewClientWindow : CPWindow
  8{
  9    @outlet CPTextField nom @accessors;
 10    @outlet CPTextField prenom @accessors;
 11    @outlet DatePicker datedenaissance @accessors;
 12    @outlet CPTextField telephone @accessors;
 13    @outlet CPTextField email @accessors;
 14    @outlet CPTextField adresse @accessors;
 15    @outlet CPTextField codepostal @accessors;
 16    @outlet CPTextField ville @accessors;
 17
 18
 19    @outlet ClientsController clientsController;
 20
 21    @outlet CPButton    addButton;
 22    @outlet CPButton    cancelButton;
 23
 24	//@outlet ClientController clientController;
 25}
 26
 27+ (id)sharedNewClientWindow
 28{
 29   return SharedClientWindow;
 30}
 31
 32- (void)awakeFromCib
 33{
 34	console.log("new client window woke up");
 35   	SharedClientWindow = self;
 36    [super awakeFromCib];
 37
 38	[datedenaissance displayPreset:1];
 39	[datedenaissance setDelegate:self];
 40//    [identifierField setValue:[CPColor grayColor] forThemeAttribute:"text-color" inState:CPTextFieldStatePlaceholder];
 41}
 42
 43- (id)initWithContentRect:(CGRect)aRect styleMask:(unsigned)aMask
 44{
 45	
 46    if (self = [super initWithContentRect:aRect styleMask:aMask])
 47    {
 48		//console.log("new client window init");
 49	
 50        [self center];
 51        //[self setMovableByWindowBackground:YES];
 52        [cancelButton setKeyEquivalent:CPEscapeFunctionKey];
 53    }
 54
 55    return self;
 56}
 57
 58- (@action)orderFront:(id)sender
 59{
 60    [super orderFront:sender];
 61    [nom setStringValue:""];
 62    //[addButton setEnabled:NO];
 63}
 64
 65-(@action)addButtonPressed:(id)sender 
 66{
 67	console.log("add pressed");
 68	
 69	if ([[nom stringValue] length] != 0 && [[prenom stringValue] length] != 0 && [datedenaissance date] != nil && [[telephone stringValue] length] != 0 && [[email stringValue] length] != 0 && [[adresse stringValue] length] != 0 && [[codepostal stringValue] length] != 0 && [[ville stringValue] length] != 0)
 70	{
 71		console.log([[datedenaissance date] toDateString]);
 72		//sale
 73		clientController = [[ClientsController alloc] init];
 74		
 75		client = [clientController addClient:{"nom":[nom stringValue], "prenom":[prenom stringValue], "anniversaire":[[datedenaissance date] toDateString], "telephone":[telephone stringValue], "email":[email stringValue], "adresse":[adresse stringValue], "codepostal":[codepostal intValue], "ville":[ville stringValue], "notes_memo":@"blah", "alias":[[nom stringValue] stringByAppendingString:[prenom stringValue]], "password":@"lol"}];
 76
 77		[[CPNotificationCenter defaultCenter] postNotificationName:@"ClientAdded" object:nil];
 78		
 79		
 80		[self orderOut:self]
 81	} else
 82	{
 83		console.log("we're not ok");
 84	}
 85}
 86
 87/*- (@action)addRepository:(id)sender
 88{
 89    var repoIdentifier = [identifierField stringValue];
 90    if (!repoIdentifier)
 91        return;
 92
 93    var existingRepo = [[GithubAPIController sharedController] repositoryForIdentifier:repoIdentifier];
 94    if (existingRepo)
 95    {
 96        [repoController addRepository:existingRepo];
 97        [self orderOut:self];
 98        return;
 99    }
100
101    [[GithubAPIController sharedController] loadRepositoryWithIdentifier:repoIdentifier callback:function(repo)
102    {
103        [progressIndicator setHidden:YES];
104        [errorMessageField setHidden:!!repo];
105        [defaultButton setEnabled:YES];
106        [cancelButton setEnabled:YES];
107
108        if (repo)
109        {
110            [repoController addRepository:repo];
111            [self orderOut:self];
112        }
113    }];    
114
115    [errorMessageField setHidden:YES];
116    [progressIndicator setHidden:NO];
117    [defaultButton setEnabled:NO];
118    [cancelButton setEnabled:NO];
119}*/
120
121- (void)sendEvent:(CPEvent)anEvent
122{
123/*    if ([anEvent type] === CPKeyUp && [anEvent keyCode] === CPTabKeyCode)
124      //  [self makeFirstResponder:nom];
125    else*/
126        [super sendEvent:anEvent];
127}
128
129-(void)datePickerValue:(id)sender
130{
131	//[theDatePicker setDate:[CPDate dateWithTimeIntervalSinceNow:9000000]];
132	//console.log([datedenaissance date]);
133}
134
135-(void)datePickerDidChange:(id)sender
136{
137	/*if([sender object] === theDatePicker){
138		[theDatePicker2 setMinDate: [theDatePicker date]];
139	}*/
140	//[self datePickerValue:sender];
141}
142
143@end