Skip to content

Commit

Permalink
Select job after add button
Browse files Browse the repository at this point in the history
Auto save on edit
show errors immediately
  • Loading branch information
Julien Guimont committed Nov 10, 2010
1 parent 8206779 commit ff18826
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 3 deletions.
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -17,6 +17,7 @@ gem 'mongo_session_store', :git => 'git://github.com/nmerouze/mongo_session_stor
gem "haml"
gem "json"
gem "formtastic"
gem "countries"
gem "jammit"
gem 'rails3-generators', :group => :development

Expand Down
4 changes: 4 additions & 0 deletions Gemfile.lock
Expand Up @@ -58,6 +58,9 @@ GEM
bson_ext (1.1.1)
builder (2.1.2)
closure-compiler (0.3.3)
countries (0.3.0)
currencies (>= 0.2.0)
currencies (0.2.1)
database_cleaner (0.6.0)
devise (1.1.3)
bcrypt-ruby (~> 2.1.2)
Expand Down Expand Up @@ -148,6 +151,7 @@ DEPENDENCIES
autotest-growl
autotest-rails
bson_ext
countries
database_cleaner
devise
forgery
Expand Down
2 changes: 1 addition & 1 deletion app/views/jobs/index.html.haml
Expand Up @@ -3,7 +3,7 @@

#connection-status{:style=>"display:none"}
.working Syncing with the server...
.error There was an error while syncing. Please correct it.
.error There were errors while syncing. Please correct them.
.ok Everything was synced successfully.
#job-app
#job-list
Expand Down
13 changes: 12 additions & 1 deletion public/javascripts/views.js
Expand Up @@ -24,6 +24,9 @@ $(function(){
item = this.items[job.cid] = new JobListItemView({model: job});
item.bind("edit:item", this.changeSelection);
item.bind("edit:item", JobEdit.changeSelection);
if(job.isNew()){
item.edit();
}
}else
item = this.items[job.cid];

Expand Down Expand Up @@ -105,9 +108,12 @@ $(function(){
"change input,textarea,select" : "formChanged"
},
initialize: function(){
_.bindAll(this, "formChanged", "error", "success");
_.bindAll(this, "save", "formChanged", "error", "success");
_.extend(this, Backbone.Events);
},
save: function(){
this.formChanged();
},
formChanged: function(){
var formArray = $("form", this.el).serializeArray();
var formMap = {};
Expand Down Expand Up @@ -159,14 +165,19 @@ $(function(){
me.el.html(html);
}
);
if(this.model.isNew()){
this.save();
}
}
},
closeEdit: function(){
this.model = undefined;
StatusView.close();
this.render();
},
changeSelection: function(item){
this.model = item.model;
StatusView.close();
this.render();
}
});
Expand Down
14 changes: 14 additions & 0 deletions public/stylesheets/formtastic_changes.css
Expand Up @@ -7,6 +7,20 @@ form.formtastic fieldset {
form.formtastic fieldset ol li {
display: block;
margin: 0 0 0.5em 1em; }
form.formtastic fieldset ol li.error {
border: none;
background-color: transparent; }
form.formtastic fieldset ol li.error input, form.formtastic fieldset ol li.error textarea, form.formtastic fieldset ol li.error select {
border: 1px solid red;
background-color: #fbe3e4; }
form.formtastic fieldset ol li.error p {
display: inline-block;
margin: 0px 0.5em; }
form.formtastic fieldset ol li textarea {
padding: 5px;
margin: 0.5em 0px;
border: 1px solid #bbbbbb;
font-size: 1.5em; }
form.formtastic fieldset ol li p.inline-hints {
margin: 0.5em 0px 0px 15%; }
form.formtastic fieldset ol li label {
Expand Down
3 changes: 2 additions & 1 deletion public/stylesheets/job.css
Expand Up @@ -86,4 +86,5 @@
border: 2px solid green;
padding: 0.8em; }
#connection-status .error {
margin: 0; }
margin: 0;
border: 2px solid red; }
14 changes: 14 additions & 0 deletions public/stylesheets/sass/formtastic_changes.sass
Expand Up @@ -9,6 +9,20 @@ form.formtastic
li
display: block
margin: 0 0 0.5em 1em
&.error
border: none
background-color: transparent
input, textarea, select
border: 1px solid red
background-color: #FBE3E4
p
display: inline-block
margin: 0px 0.5em
textarea
padding: 5px
margin: 0.5em 0px
border: 1px solid #bbb
font-size: 1.5em
p.inline-hints
margin: 0.5em 0px 0px 15%
label
Expand Down
1 change: 1 addition & 0 deletions public/stylesheets/sass/job.sass
Expand Up @@ -130,5 +130,6 @@
padding: 0.8em
.error
margin: 0
border: 2px solid red


1 change: 1 addition & 0 deletions public/views/job_edit.haml
Expand Up @@ -20,6 +20,7 @@
%input.title{name: 'state', value: job.state}
%li.string.required
%label Country:

%input.title{name: 'country', value: job.country}
%li.string
%label Short Desc.:
Expand Down

0 comments on commit ff18826

Please sign in to comment.