Fixed bunch of js bugs with comments. Also added development tips
This commit is contained in:
parent
92137b7beb
commit
4a6596af27
12 changed files with 269 additions and 200 deletions
|
@ -39,5 +39,6 @@ Email
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
|
[Development Tips](https://github.com/gitlabhq/gitlabhq/blob/master/doc/development.md)
|
||||||
Want to help - send a pull request.
|
Want to help - send a pull request.
|
||||||
We'll accept good pull requests.
|
We'll accept good pull requests.
|
||||||
|
|
|
@ -128,3 +128,23 @@ function showDiff(link) {
|
||||||
function ajaxGet(url) {
|
function ajaxGet(url) {
|
||||||
$.ajax({type: "GET", url: url, dataType: "script"});
|
$.ajax({type: "GET", url: url, dataType: "script"});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable button if text field is empty
|
||||||
|
*/
|
||||||
|
function disableButtonIfEmtpyField(field_selector, button_selector) {
|
||||||
|
field = $(field_selector);
|
||||||
|
if(field.val() == "") {
|
||||||
|
field.closest("form").find(button_selector).attr("disabled", "disabled").addClass("disabled");
|
||||||
|
}
|
||||||
|
|
||||||
|
field.on('keyup', function(){
|
||||||
|
var field = $(this);
|
||||||
|
var closest_submit = field.closest("form").find(button_selector);
|
||||||
|
if(field.val() == "") {
|
||||||
|
closest_submit.attr("disabled", "disabled").addClass("disabled");
|
||||||
|
} else {
|
||||||
|
closest_submit.removeAttr("disabled").removeClass("disabled");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -24,30 +24,19 @@ init:
|
||||||
$('.delete-note').live('ajax:success', function() {
|
$('.delete-note').live('ajax:success', function() {
|
||||||
$(this).closest('li').fadeOut(); });
|
$(this).closest('li').fadeOut(); });
|
||||||
|
|
||||||
$('#note_note').on('keyup', function(){
|
$(".note-form-holder").live("ajax:before", function(){
|
||||||
var field = $(this);
|
|
||||||
var closest_submit = field.closest("form").find(".submit_note");
|
|
||||||
if(field.val() == "") {
|
|
||||||
closest_submit.attr("disabled", "disabled").addClass("disabled");
|
|
||||||
} else {
|
|
||||||
closest_submit.removeAttr("disabled").removeClass("disabled");
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
$("#new_note").live("ajax:before", function(){
|
|
||||||
$(".submit_note").attr("disabled", "disabled");
|
$(".submit_note").attr("disabled", "disabled");
|
||||||
})
|
})
|
||||||
|
|
||||||
$("#new_note").live("ajax:complete", function(){
|
$(".note-form-holder").live("ajax:complete", function(){
|
||||||
$(".submit_note").removeAttr("disabled");
|
$(".submit_note").removeAttr("disabled");
|
||||||
})
|
})
|
||||||
|
|
||||||
$("#note_note").live("focus", function(){
|
disableButtonIfEmtpyField(".note-text", ".submit_note");
|
||||||
|
|
||||||
|
$(".note-text").live("focus", function(){
|
||||||
$(this).css("height", "80px");
|
$(this).css("height", "80px");
|
||||||
$('.note_advanced_opts').show();
|
$('.note_advanced_opts').show();
|
||||||
if($(this).val() == "") {
|
|
||||||
$(this).closest("form").find(".submit_note").attr("disabled", "disabled").addClass("disabled");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#note_attachment").change(function(e){
|
$("#note_attachment").change(function(e){
|
||||||
|
@ -140,8 +129,6 @@ setContent:
|
||||||
* 3. append old notes to bottom of list with 'append'
|
* 3. append old notes to bottom of list with 'append'
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
getOld:
|
getOld:
|
||||||
function() {
|
function() {
|
||||||
$('.loading').show();
|
$('.loading').show();
|
||||||
|
@ -164,7 +151,6 @@ append:
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
initLoadMore:
|
initLoadMore:
|
||||||
function() {
|
function() {
|
||||||
$(document).endlessScroll({
|
$(document).endlessScroll({
|
||||||
|
@ -179,4 +165,18 @@ initLoadMore:
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var PerLineNotes = {
|
||||||
|
init:
|
||||||
|
function() {
|
||||||
|
$(".line_note_link, .line_note_reply_link").live("click", function(e) {
|
||||||
|
var form = $(".per_line_form");
|
||||||
|
$(this).closest("tr").after(form);
|
||||||
|
form.find("#note_line_code").val($(this).attr("line_code"));
|
||||||
|
form.show();
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
disableButtonIfEmtpyField(".line-note-text", ".submit_inline_note");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
#new_note {
|
#new_note {
|
||||||
#note_note {
|
.note-text {
|
||||||
height:25px;
|
height:25px;
|
||||||
}
|
}
|
||||||
.attach_holder {
|
.attach_holder {
|
||||||
|
|
|
@ -5,12 +5,6 @@
|
||||||
|
|
||||||
|
|
||||||
:javascript
|
:javascript
|
||||||
$(document).ready(function(){
|
$(function(){
|
||||||
$(".line_note_link, .line_note_reply_link").live("click", function(e) {
|
PerLineNotes.init();
|
||||||
var form = $(".per_line_form");
|
|
||||||
$(this).parent().parent().after(form);
|
|
||||||
form.find("#note_line_code").val($(this).attr("line_code"));
|
|
||||||
form.show();
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
- if note.valid?
|
- if note.valid?
|
||||||
:plain
|
:plain
|
||||||
$("#new_note .error").remove();
|
$(".note-form-holder .error").remove();
|
||||||
$('#new_note textarea').val("");
|
$('.note-form-holder textarea').val("");
|
||||||
$('#preview-link').text('Preview');
|
$('.note-form-holder #preview-link').text('Preview');
|
||||||
$('#preview-note').hide(); $('#note_note').show();
|
$('.note-form-holder #preview-note').hide();
|
||||||
|
$('.note-form-holder').show();
|
||||||
NoteList.prepend(#{note.id}, "#{escape_javascript(render partial: "notes/show", locals: {note: note})}");
|
NoteList.prepend(#{note.id}, "#{escape_javascript(render partial: "notes/show", locals: {note: note})}");
|
||||||
- else
|
- else
|
||||||
:plain
|
:plain
|
||||||
$("#new_note").replaceWith("#{escape_javascript(render('form'))}");
|
$(".note-form-holder").replaceWith("#{escape_javascript(render('form'))}");
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
- if note.valid?
|
- if note.valid?
|
||||||
:plain
|
:plain
|
||||||
$(".per_line_form").hide();
|
$(".per_line_form").hide();
|
||||||
$('#new_note textarea').val("");
|
$('.line-note-form-holder textarea').val("");
|
||||||
$("a.line_note_reply_link[line_code='#{note.line_code}']").closest("tr").remove();
|
$("a.line_note_reply_link[line_code='#{note.line_code}']").closest("tr").remove();
|
||||||
var trEl = $(".#{note.line_code}").parent();
|
var trEl = $(".#{note.line_code}").parent();
|
||||||
trEl.after("#{escape_javascript(render partial: "notes/per_line_show", locals: {note: note})}");
|
trEl.after("#{escape_javascript(render partial: "notes/per_line_show", locals: {note: note})}");
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
.note-form-holder
|
||||||
= form_for [@project, @note], remote: "true", multipart: true do |f|
|
= form_for [@project, @note], remote: "true", multipart: true do |f|
|
||||||
%h3.page_title Leave a comment
|
%h3.page_title Leave a comment
|
||||||
-if @note.errors.any?
|
-if @note.errors.any?
|
||||||
|
@ -7,7 +8,7 @@
|
||||||
|
|
||||||
= f.hidden_field :noteable_id
|
= f.hidden_field :noteable_id
|
||||||
= f.hidden_field :noteable_type
|
= f.hidden_field :noteable_type
|
||||||
= f.text_area :note, size: 255
|
= f.text_area :note, size: 255, class: 'note-text'
|
||||||
#preview-note.preview_note.hide
|
#preview-note.preview_note.hide
|
||||||
.hint
|
.hint
|
||||||
.right Comments are parsed with #{link_to "Gitlab Flavored Markdown", help_markdown_path, target: '_blank'}.
|
.right Comments are parsed with #{link_to "Gitlab Flavored Markdown", help_markdown_path, target: '_blank'}.
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
%table{style: "display:none;"}
|
%table{style: "display:none;"}
|
||||||
%tr.per_line_form
|
%tr.per_line_form
|
||||||
%td{colspan: 3 }
|
%td{colspan: 3 }
|
||||||
|
.line-note-form-holder
|
||||||
= form_for [@project, @note], remote: "true", multipart: true do |f|
|
= form_for [@project, @note], remote: "true", multipart: true do |f|
|
||||||
%h3.page_title Leave a note
|
%h3.page_title Leave a note
|
||||||
%div.span10
|
%div.span10
|
||||||
|
@ -12,10 +13,10 @@
|
||||||
= f.hidden_field :noteable_id
|
= f.hidden_field :noteable_id
|
||||||
= f.hidden_field :noteable_type
|
= f.hidden_field :noteable_type
|
||||||
= f.hidden_field :line_code
|
= f.hidden_field :line_code
|
||||||
= f.text_area :note, size: 255
|
= f.text_area :note, size: 255, class: 'line-note-text'
|
||||||
.note_actions
|
.note_actions
|
||||||
.buttons
|
.buttons
|
||||||
= f.submit 'Add note', class: "btn primary submit_note", id: "submit_note"
|
= f.submit 'Add note', class: "btn primary submit_note submit_inline_note", id: "submit_note"
|
||||||
= link_to "Cancel", "#", class: "btn hide-button"
|
= link_to "Cancel", "#", class: "btn hide-button"
|
||||||
.options
|
.options
|
||||||
%h6.left Notify via email:
|
%h6.left Notify via email:
|
||||||
|
|
45
doc/development.md
Normal file
45
doc/development.md
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
## Development tips:
|
||||||
|
|
||||||
|
### Start application in development mode
|
||||||
|
|
||||||
|
#### 1. Via foreman
|
||||||
|
|
||||||
|
bundle exec foreman -p 3000
|
||||||
|
|
||||||
|
#### 2. Via gitlab cli
|
||||||
|
|
||||||
|
./gitlab start
|
||||||
|
|
||||||
|
#### 3. Manually
|
||||||
|
|
||||||
|
bundle exec rails s
|
||||||
|
bundle exec rake environment resque:work QUEUE=* VVERBOSE=1
|
||||||
|
|
||||||
|
|
||||||
|
### Run tests:
|
||||||
|
|
||||||
|
#### 1. Packages
|
||||||
|
|
||||||
|
# ubuntu
|
||||||
|
sudo apt-get install libqt4-dev libqtwebkit-dev
|
||||||
|
sudo apt-get install xvfb
|
||||||
|
|
||||||
|
# Mac
|
||||||
|
brew install qt
|
||||||
|
brew install xvfb
|
||||||
|
|
||||||
|
#### 2. DB & seeds
|
||||||
|
|
||||||
|
bundle exec rake db:setup RAILS_ENV=test
|
||||||
|
bundle exec rake db:seed_fu RAILS_ENV=test
|
||||||
|
|
||||||
|
### 3. Run Tests
|
||||||
|
|
||||||
|
# All in one
|
||||||
|
bundle exec gitlab:test
|
||||||
|
|
||||||
|
# Rspec
|
||||||
|
bundle exec rake spec
|
||||||
|
|
||||||
|
# Cucumber
|
||||||
|
bundle exec rake cucumber
|
7
gitlab
7
gitlab
|
@ -22,10 +22,11 @@ class GitlabCli
|
||||||
case @mode
|
case @mode
|
||||||
when 'production';
|
when 'production';
|
||||||
system(unicorn_start_cmd)
|
system(unicorn_start_cmd)
|
||||||
|
system(resque_start_cmd)
|
||||||
else
|
else
|
||||||
system(rails_start_cmd)
|
system(rails_start_cmd)
|
||||||
|
system(resque_dev_start_cmd)
|
||||||
end
|
end
|
||||||
system(resque_start_cmd)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def stop
|
def stop
|
||||||
|
@ -57,6 +58,10 @@ class GitlabCli
|
||||||
"kill -QUIT `cat #{pid}`"
|
"kill -QUIT `cat #{pid}`"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def resque_dev_start_cmd
|
||||||
|
"./resque_dev.sh > /dev/null 2>&1"
|
||||||
|
end
|
||||||
|
|
||||||
def resque_start_cmd
|
def resque_start_cmd
|
||||||
"./resque.sh > /dev/null 2>&1"
|
"./resque.sh > /dev/null 2>&1"
|
||||||
end
|
end
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
bundle exec rake environment resque:work QUEUE=post_receive,mailer,system_hook VVERBOSE=1
|
mkdir -p tmp/pids
|
||||||
|
bundle exec rake environment resque:work QUEUE=post_receive,mailer,system_hook VVERBOSE=1 PIDFILE=tmp/pids/resque_worker.pid RAILS_ENV=development BACKGROUND=yes
|
||||||
|
|
Loading…
Reference in a new issue