-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Neeraj Singh
committed
Oct 18, 2011
1 parent
4e3ce0d
commit fcd8e84
Showing
33 changed files
with
10,290 additions
and
1 deletion.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
var AdminData = AdminData || {}; | ||
|
||
AdminData.actOnResult = { | ||
|
||
action: function(action_type) { | ||
var formData = $('#advance_search_form').data('admin_data_form_array'), | ||
parameterizedData; | ||
|
||
formData.push({ | ||
'name': 'admin_data_advance_search_action_type', | ||
'value': action_type | ||
}); | ||
|
||
parameterizedData = $.param(formData); | ||
|
||
$.ajax({ | ||
url: $('#advance_search_form').attr('action'), | ||
type: 'post', | ||
dataType: 'json', | ||
data: parameterizedData, | ||
success: function(json) { | ||
AdminData.actOnResult.successCallback(json); | ||
} | ||
}); | ||
}, | ||
|
||
successCallback: function(json) { | ||
$('#results').text(json.success); | ||
} | ||
|
||
}; | ||
|
||
$('#advance_search_delete_all').live('click', function() { | ||
if (window.confirm('Are you sure?')) { | ||
AdminData.actOnResult.action('delete'); | ||
} | ||
return false; | ||
}); | ||
|
||
$('#advance_search_destroy_all').live('click', function() { | ||
if (window.confirm('Are you sure?')) { | ||
AdminData.actOnResult.action('destroy'); | ||
} | ||
return false; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
var AdminData = AdminData || {}; | ||
|
||
AdminData.advanceSearch = { | ||
|
||
buildFirstRow: function() { | ||
|
||
var img = $('<img />', { | ||
src: '/admin_data/public/images/add.png' | ||
}); | ||
|
||
$('#advance_search_table').append(this.buildRow()) | ||
.find('tr td:last a') | ||
.attr('id','add_row_link_1') | ||
.removeClass('remove_row') | ||
.addClass('add_row_link') | ||
.html('') | ||
.append(img); | ||
}, | ||
|
||
buildCol1: function() { | ||
var i, col = $('<select />', { className: 'col1' }).append($('<option />')), | ||
tableStructure = $('#advance_search_table').data('table_structure'); | ||
|
||
for (i in tableStructure) { | ||
$('<option />', { | ||
text: i, | ||
value: i | ||
}).appendTo(col); | ||
} | ||
return $('<td />').append(col); | ||
}, | ||
|
||
buildCol2: function() { | ||
var select = $('<select />', { className: 'col2', disabled: 'disabled' }); | ||
return $('<td />').append(select); | ||
}, | ||
|
||
buildCol3: function() { | ||
var select = $('<input />', { className: 'col3' }); | ||
return $('<td />').append($('<input />', { className: 'col3', disabled: 'disabled' })); | ||
}, | ||
|
||
buildCol4: function() { | ||
var img = $('<img />', { | ||
src: '/admin_data/public/images/no.png' | ||
}); | ||
|
||
return $('<td />').append($('<a />', { | ||
text: '', | ||
href: '#', | ||
className: 'remove_row' | ||
}).append(img)); | ||
}, | ||
|
||
buildRow: function() { | ||
|
||
var $tr = $('<tr />'), | ||
currentRowNumber = $(document).data('currentRowNumber'), | ||
that = this, | ||
build_array = ['buildCol1', 'buildCol2', 'buildCol3', 'buildCol4']; | ||
|
||
if (currentRowNumber === undefined) { | ||
currentRowNumber = 1; | ||
$(document).data('currentRowNumber', currentRowNumber); | ||
} else { | ||
currentRowNumber = parseInt(currentRowNumber, 10) + 1; | ||
$(document).data('currentRowNumber', currentRowNumber); | ||
} | ||
|
||
$.each(build_array, function(index, value) { | ||
$tr.append(that[value]()); | ||
}); | ||
|
||
$tr.find('select.col1').attr({ name: 'adv_search[' + currentRowNumber + '_row][col1]' }); | ||
$tr.find('select.col2').attr({ name: 'adv_search[' + currentRowNumber + '_row][col2]' }); | ||
$tr.find('input.col3').attr({ name: 'adv_search[' + currentRowNumber + '_row][col3]' }); | ||
|
||
$tr.find('.remove_row').attr('id', 'remove_row_'+currentRowNumber); | ||
|
||
return $tr; | ||
} | ||
|
||
}; |
79 changes: 79 additions & 0 deletions
79
app/assets/javascripts/advance_search/advance_search_structure.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
AdminData = AdminData || {}; | ||
|
||
AdminData.mappings = { | ||
|
||
//JSLint complains if a hash has key named boolean. So I am changing the key to booleant | ||
booleant: { | ||
options: [ | ||
["is null", "is_null"], | ||
["is not null", "is_not_null"], | ||
["is true", "is_true"], | ||
["is false", "is_false"] | ||
] | ||
}, | ||
|
||
string: { | ||
options: [ | ||
["is null", "is_null"], | ||
["is not null", "is_not_null"], | ||
["contains", "contains"], | ||
["is exactly", "is_exactly"], | ||
["doesn't contain", "does_not_contain"] | ||
] | ||
}, | ||
|
||
text: { | ||
options: [ | ||
["is null", "is_null"], | ||
["is not null", "is_not_null"], | ||
["Contains", "contains"], | ||
["Doesn't Contain", "does_not_contain"] | ||
] | ||
}, | ||
|
||
datetime: { | ||
options: [ | ||
["is null", "is_null"], | ||
["is not null", "is_not_null"], | ||
['on', "is_on"], | ||
['on or before', "is_on_or_before_date"], | ||
['on or after', "is_on_or_after_date"] | ||
] | ||
}, | ||
|
||
date: { | ||
options: [ | ||
["is null", "is_null"], | ||
["is not null", "is_not_null"], | ||
['on', "is_on"], | ||
['on or before', "is_on_or_before_date"], | ||
['on or after', "is_on_or_after_date"] | ||
] | ||
}, | ||
|
||
time: { | ||
options: [ | ||
["is null", "is_null"], | ||
["is not null", "is_not_null"], | ||
["is exactly", "is_exactly"] | ||
] | ||
}, | ||
|
||
decimal: { | ||
options: [ | ||
['is equal to', "is_equal_to"], | ||
['is less than', "less_than"], | ||
['is greater than', "greater_than"] | ||
] | ||
}, | ||
|
||
integer: { | ||
options: [ | ||
['is equal to', "is_equal_to"], | ||
['is less than', "less_than"], | ||
['is greater than', "greater_than"] | ||
] | ||
} | ||
}; | ||
|
||
|
28 changes: 28 additions & 0 deletions
28
app/assets/javascripts/advance_search/ajaxify_advance_search.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
var AdminData = AdminData || {}; | ||
|
||
AdminData.ajaxifyAdvanceSearch = { | ||
successCallback: function(responseText) { | ||
$('#results').html(responseText); | ||
}, | ||
|
||
beforeSubmitCallback: function(formArray, jqForm) { | ||
$('#results').html('<span class="searching_message">searching...</span>'); | ||
$('#advance_search_form').data('admin_data_form_array', formArray); | ||
} | ||
}; | ||
|
||
$(function() { | ||
|
||
var options = { | ||
success: function(responseText) { | ||
AdminData.ajaxifyAdvanceSearch.successCallback(responseText); | ||
}, | ||
beforeSubmit: function(formArray, jqForm) { | ||
AdminData.ajaxifyAdvanceSearch.beforeSubmitCallback(formArray, jqForm); | ||
} | ||
}; | ||
|
||
$('#advance_search_form').ajaxForm(options); | ||
|
||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
$(function() { | ||
|
||
var json = $.parseJSON( $('#primary_column_type_info').html()); | ||
$('#advance_search_table').data('table_structure', json); | ||
AdminData.advanceSearch.buildFirstRow(); | ||
|
||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
var AdminData = AdminData || {}; | ||
|
||
AdminData.bindings = { | ||
|
||
col2_change: function(e) { | ||
var arrayList = ['is_false', 'is_true', 'is_null', 'is_not_null'], | ||
$col2 = $(e.target).closest('select'), | ||
value = $col2.val(), | ||
tableStructure = $('#advance_search_table').data('table_structure'), | ||
$col3 = $col2.parents('tr').find('td input.col3'), | ||
$col1 = $col2.parents('tr').find('td select.col1'), | ||
col1ColumnType = tableStructure[$col1.val()]; | ||
|
||
|
||
if (value.length === 0 || ($.inArray(value, arrayList) > - 1)) { | ||
$col3.val('').attr('disabled','disabled'); | ||
|
||
} else { | ||
$col3.removeAttr('disabled'); | ||
if (col1ColumnType === 'datetime' || col1ColumnType === 'date') { | ||
$col3.val(AdminData.jsUtil.dateToString(new Date())).addClass('datepicker'); | ||
|
||
$('.datepicker').datepicker({ dateFormat: 'dd-MM-yy', changeYear: true, changeMonth: true }); | ||
|
||
} else { | ||
$('.datepicker').datepicker('destroy'); | ||
$col3.removeClass('datepicker').focus(); // do not create focus for date pickers | ||
} | ||
} | ||
}, | ||
|
||
pagination_click: function(e) { | ||
var href = $(e.target).closest('a').attr('href'); | ||
|
||
$.ajax({ url: href, dataType: "text", success: function(responseText){ | ||
$('#results').html(responseText); | ||
}}); | ||
|
||
AdminData.jsUtil.colorizeRows(); | ||
}, | ||
|
||
col1_change: function(e) { | ||
var col1 = $(e.target).closest('select'), | ||
tableStructure = $('#advance_search_table').data('table_structure'), | ||
columnType = tableStructure[col1.val()], | ||
options = AdminData.mappings[columnType]['options'], | ||
col2 = col1.parents('tr').find('td select.col2'); | ||
|
||
col2.html(''); | ||
AdminData.jsUtil.buildOptionsFromArray(options, col2); | ||
col2.trigger('change').removeAttr('disabled'); | ||
} | ||
}; | ||
|
||
$('.pagination a').live('click', function(e) { | ||
AdminData.bindings.pagination_click(e); | ||
return false; | ||
}); | ||
|
||
$('#advance_search_table a.add_row_link').live('click', function() { | ||
$('#advance_search_table').append(AdminData.advanceSearch.buildRow()); | ||
return false; | ||
}); | ||
|
||
$('#advance_search_table a.remove_row').live('click', function(e) { | ||
$(e.target).closest('tr').remove(); | ||
return false; | ||
}); | ||
|
||
$('#advance_search_table select.col1').live('change', function(e) { | ||
AdminData.bindings.col1_change(e); | ||
}); | ||
|
||
$('#advance_search_table select.col2').live('change', function(e) { | ||
AdminData.bindings.col2_change(e); | ||
}); |
10 changes: 10 additions & 0 deletions
10
app/assets/javascripts/advance_search/global_ajax_setting.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
$(function() { | ||
|
||
$.ajaxSetup({ | ||
'beforeSend': function(xhr) { | ||
xhr.setRequestHeader("Accept", "text/javascript"); | ||
} | ||
}); | ||
|
||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
$(function(){ | ||
|
||
var form = $('#advance_search_form'); | ||
|
||
if (form.length === 0) return; | ||
|
||
$('#view_table tr.thead').live('click', function(e){ | ||
var value = $(e.target).closest('.sortable').attr('data-sortby'); | ||
$('#advance_search_sortby').val(value); | ||
form.submit(); | ||
return false; | ||
}); | ||
|
||
}); |
6 changes: 6 additions & 0 deletions
6
app/assets/javascripts/advance_search/trigger_submit_on_domready.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
$(function() { | ||
|
||
$('#advance_search_form').trigger('submit'); | ||
|
||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
$(function(){ | ||
|
||
$('input[name=report_type]').change(function(){ | ||
window.location = $(this).val(); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
$(function() { | ||
|
||
$('.drop_down_value_klass').change(function() { | ||
window.location = $(this).val(); | ||
}); | ||
|
||
}); | ||
|
Oops, something went wrong.