admin_data 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +221 -0
- data/README.textile +21 -0
- data/Rakefile +46 -0
- data/app/controllers/admin_data/base_controller.rb +114 -0
- data/app/controllers/admin_data/diagnostic_controller.rb +28 -0
- data/app/controllers/admin_data/feed_controller.rb +17 -0
- data/app/controllers/admin_data/main_controller.rb +132 -0
- data/app/controllers/admin_data/migration_controller.rb +19 -0
- data/app/controllers/admin_data/search_controller.rb +125 -0
- data/app/controllers/admin_data/validate_model_controller.rb +106 -0
- data/app/views/admin_data/diagnostic/index.html.erb +17 -0
- data/app/views/admin_data/diagnostic/missing_index.html.erb +26 -0
- data/app/views/admin_data/feed/index.rss.builder +24 -0
- data/app/views/admin_data/main/all_models.html.erb +22 -0
- data/app/views/admin_data/main/association/_association_info.html.erb +10 -0
- data/app/views/admin_data/main/association/_belongs_to_info.html.erb +7 -0
- data/app/views/admin_data/main/association/_has_many_info.html.erb +7 -0
- data/app/views/admin_data/main/association/_has_one_info.html.erb +6 -0
- data/app/views/admin_data/main/edit.html.erb +38 -0
- data/app/views/admin_data/main/misc/_form.html.erb +25 -0
- data/app/views/admin_data/main/misc/_modify_record.html.erb +22 -0
- data/app/views/admin_data/main/new.html.erb +23 -0
- data/app/views/admin_data/main/show.html.erb +41 -0
- data/app/views/admin_data/main/table_structure.html.erb +55 -0
- data/app/views/admin_data/migration/index.html.erb +18 -0
- data/app/views/admin_data/migration/jstest.html.erb +51 -0
- data/app/views/admin_data/search/_search_base.html.erb +34 -0
- data/app/views/admin_data/search/advance_search.html.erb +3 -0
- data/app/views/admin_data/search/quick_search.html.erb +6 -0
- data/app/views/admin_data/search/search/_advance_search_form.html.erb +48 -0
- data/app/views/admin_data/search/search/_errors.html.erb +5 -0
- data/app/views/admin_data/search/search/_listing.html.erb +40 -0
- data/app/views/admin_data/search/search/_search_form.html.erb +28 -0
- data/app/views/admin_data/search/search/_sortby.html.erb +18 -0
- data/app/views/admin_data/search/search/_title.html.erb +34 -0
- data/app/views/admin_data/shared/_breadcrum.html.erb +10 -0
- data/app/views/admin_data/shared/_drop_down_klasses.html.erb +4 -0
- data/app/views/admin_data/shared/_flash_message.html.erb +13 -0
- data/app/views/admin_data/shared/_header.html.erb +23 -0
- data/app/views/admin_data/shared/_powered_by.html.erb +23 -0
- data/app/views/admin_data/shared/_secondary_navigation.html.erb +28 -0
- data/app/views/admin_data/validate_model/_bad.html.erb +1 -0
- data/app/views/admin_data/validate_model/tid.html.erb +2 -0
- data/app/views/admin_data/validate_model/validate.html.erb +67 -0
- data/app/views/layouts/admin_data.html.erb +60 -0
- data/config/routes.rb +34 -0
- data/init.rb +1 -0
- data/lib/admin_data.rb +34 -0
- data/lib/admin_data/chelper.rb +37 -0
- data/lib/admin_data/compatibility.rb +7 -0
- data/lib/admin_data/helpers.rb +222 -0
- data/lib/admin_data/railtie.rb +21 -0
- data/lib/admin_data/search.rb +186 -0
- data/lib/admin_data/settings.rb +72 -0
- data/lib/admin_data/util.rb +237 -0
- data/lib/admin_data/version.rb +3 -0
- data/lib/admin_data_date_validation.rb +79 -0
- data/lib/css/app.css +224 -0
- data/lib/css/base.css +1071 -0
- data/lib/css/header.css +65 -0
- data/lib/css/rounded.css +18 -0
- data/lib/css/themes/drastic-dark/style.css +374 -0
- data/lib/css/umbrella.css +34 -0
- data/lib/css/vendor/images/ui-bg_diagonals-thick_75_f3d8d8_40x40.png +0 -0
- data/lib/css/vendor/images/ui-bg_dots-small_65_a6a6a6_2x2.png +0 -0
- data/lib/css/vendor/images/ui-bg_flat_0_333333_40x100.png +0 -0
- data/lib/css/vendor/images/ui-bg_flat_65_ffffff_40x100.png +0 -0
- data/lib/css/vendor/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/lib/css/vendor/images/ui-bg_glass_55_fbf8ee_1x400.png +0 -0
- data/lib/css/vendor/images/ui-bg_highlight-hard_100_eeeeee_1x100.png +0 -0
- data/lib/css/vendor/images/ui-bg_highlight-hard_100_f6f6f6_1x100.png +0 -0
- data/lib/css/vendor/images/ui-bg_highlight-soft_15_cc0000_1x100.png +0 -0
- data/lib/css/vendor/images/ui-icons_004276_256x240.png +0 -0
- data/lib/css/vendor/images/ui-icons_cc0000_256x240.png +0 -0
- data/lib/css/vendor/images/ui-icons_ffffff_256x240.png +0 -0
- data/lib/css/vendor/jquery-ui-1.7.2.custom.css +406 -0
- data/lib/css/vendor/qunit.css +119 -0
- data/lib/js/advance_search/act_on_result.js +47 -0
- data/lib/js/advance_search/adv_search.js +46 -0
- data/lib/js/advance_search/advance_search.js +60 -0
- data/lib/js/advance_search/advance_search_structure.js +79 -0
- data/lib/js/advance_search/ajaxify_advance_search.js +28 -0
- data/lib/js/advance_search/build_first_row.js +12 -0
- data/lib/js/advance_search/event_bindings.js +87 -0
- data/lib/js/advance_search/global_ajax_setting.js +10 -0
- data/lib/js/advance_search/trigger_submit_on_domready.js +6 -0
- data/lib/js/misc/drop_down_change.js +8 -0
- data/lib/js/misc/js_util.js +42 -0
- data/lib/js/misc/quick_search_input_focus.js +6 -0
- data/lib/js/test/act_on_result.js +120 -0
- data/lib/js/test/advance_search.js +80 -0
- data/lib/js/test/ajaxify_advance_search.js +29 -0
- data/lib/js/test/build_first_row.js +10 -0
- data/lib/js/test/event_bindings.js +100 -0
- data/lib/js/validate_model/ajaxify_form.js +66 -0
- data/lib/js/validate_model/select_all.js +15 -0
- data/lib/js/vendor/jack.js +903 -0
- data/lib/js/vendor/jquery-1.4.1.js +6078 -0
- data/lib/js/vendor/jquery-ui-1.7.2.custom.min.js +298 -0
- data/lib/js/vendor/jquery.ba-isjquery.js +21 -0
- data/lib/js/vendor/jquery.form.js +814 -0
- data/lib/js/vendor/jquery.lint.js +604 -0
- data/lib/js/vendor/log.js +9 -0
- data/lib/js/vendor/qunit.js +1043 -0
- data/lib/tasks/admin_data_tasks.rake +7 -0
- data/lib/tasks/validate_models_bg.rake +23 -0
- data/test/factories/article.rb +9 -0
- data/test/factories/car.rb +4 -0
- data/test/factories/city.rb +4 -0
- data/test/factories/comment.rb +6 -0
- data/test/factories/door.rb +4 -0
- data/test/factories/engine.rb +4 -0
- data/test/functional/base_controller_test.rb +5 -0
- data/test/functional/feed_controller_test.rb +34 -0
- data/test/functional/main_controller_test.rb +421 -0
- data/test/functional/migration_controller_test.rb +30 -0
- data/test/functional/routes_test.rb +61 -0
- data/test/functional/search_controller_test.rb +814 -0
- data/test/helper/view_helper_test.rb +177 -0
- data/test/misc_tests/date_validation_test.rb +32 -0
- data/test/misc_tests/settings_test.rb +29 -0
- data/test/misc_tests/util_test.rb +83 -0
- data/test/rails_root/Gemfile +22 -0
- data/test/rails_root/Gemfile.lock +101 -0
- data/test/rails_root/Rakefile +7 -0
- data/test/rails_root/app/controllers/application_controller.rb +3 -0
- data/test/rails_root/app/helpers/application_helper.rb +2 -0
- data/test/rails_root/app/models/article.rb +25 -0
- data/test/rails_root/app/models/city.rb +15 -0
- data/test/rails_root/app/models/comment.rb +13 -0
- data/test/rails_root/app/models/tech_magazine.rb +2 -0
- data/test/rails_root/app/models/vehicle/car.rb +4 -0
- data/test/rails_root/app/models/vehicle/door.rb +3 -0
- data/test/rails_root/app/models/vehicle/engine.rb +3 -0
- data/test/rails_root/app/views/layouts/application.html.erb +14 -0
- data/test/rails_root/config.ru +4 -0
- data/test/rails_root/config/application.rb +42 -0
- data/test/rails_root/config/boot.rb +13 -0
- data/test/rails_root/config/database.yml +22 -0
- data/test/rails_root/config/environment.rb +5 -0
- data/test/rails_root/config/environments/development.rb +22 -0
- data/test/rails_root/config/environments/production.rb +49 -0
- data/test/rails_root/config/environments/test.rb +35 -0
- data/test/rails_root/config/initializers/backtrace_silencers.rb +7 -0
- data/test/rails_root/config/initializers/inflections.rb +10 -0
- data/test/rails_root/config/initializers/mime_types.rb +5 -0
- data/test/rails_root/config/initializers/secret_token.rb +7 -0
- data/test/rails_root/config/initializers/session_store.rb +8 -0
- data/test/rails_root/config/locales/en.yml +5 -0
- data/test/rails_root/config/routes.rb +58 -0
- data/test/rails_root/db/migrate/20090809061114_create_tables.rb +70 -0
- data/test/rails_root/db/schema.rb +74 -0
- data/test/rails_root/db/seeds.rb +7 -0
- data/test/rails_root/script/rails +6 -0
- data/test/rails_root/test/performance/browsing_test.rb +0 -0
- data/test/rails_root/test/test_helper.rb +13 -0
- data/test/support/assertions.rb +20 -0
- data/test/test_helper.rb +74 -0
- metadata +321 -0
@@ -0,0 +1,119 @@
|
|
1
|
+
|
2
|
+
ol#qunit-tests {
|
3
|
+
font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
|
4
|
+
margin:0;
|
5
|
+
padding:0;
|
6
|
+
list-style-position:inside;
|
7
|
+
|
8
|
+
font-size: smaller;
|
9
|
+
}
|
10
|
+
ol#qunit-tests li{
|
11
|
+
padding:0.4em 0.5em 0.4em 2.5em;
|
12
|
+
border-bottom:1px solid #fff;
|
13
|
+
font-size:small;
|
14
|
+
list-style-position:inside;
|
15
|
+
}
|
16
|
+
ol#qunit-tests li ol{
|
17
|
+
box-shadow: inset 0px 2px 13px #999;
|
18
|
+
-moz-box-shadow: inset 0px 2px 13px #999;
|
19
|
+
-webkit-box-shadow: inset 0px 2px 13px #999;
|
20
|
+
margin-top:0.5em;
|
21
|
+
margin-left:0;
|
22
|
+
padding:0.5em;
|
23
|
+
background-color:#fff;
|
24
|
+
border-radius:15px;
|
25
|
+
-moz-border-radius: 15px;
|
26
|
+
-webkit-border-radius: 15px;
|
27
|
+
}
|
28
|
+
ol#qunit-tests li li{
|
29
|
+
border-bottom:none;
|
30
|
+
margin:0.5em;
|
31
|
+
background-color:#fff;
|
32
|
+
list-style-position: inside;
|
33
|
+
padding:0.4em 0.5em 0.4em 0.5em;
|
34
|
+
}
|
35
|
+
|
36
|
+
ol#qunit-tests li li.pass{
|
37
|
+
border-left:26px solid #C6E746;
|
38
|
+
background-color:#fff;
|
39
|
+
color:#5E740B;
|
40
|
+
}
|
41
|
+
ol#qunit-tests li li.fail{
|
42
|
+
border-left:26px solid #EE5757;
|
43
|
+
background-color:#fff;
|
44
|
+
color:#710909;
|
45
|
+
}
|
46
|
+
ol#qunit-tests li.pass{
|
47
|
+
background-color:#D2E0E6;
|
48
|
+
color:#528CE0;
|
49
|
+
}
|
50
|
+
ol#qunit-tests li.fail{
|
51
|
+
background-color:#EE5757;
|
52
|
+
color:#000;
|
53
|
+
}
|
54
|
+
ol#qunit-tests li strong {
|
55
|
+
cursor:pointer;
|
56
|
+
}
|
57
|
+
h1#qunit-header{
|
58
|
+
background-color:#0d3349;
|
59
|
+
margin:0;
|
60
|
+
padding:0.5em 0 0.5em 1em;
|
61
|
+
color:#fff;
|
62
|
+
font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
|
63
|
+
border-top-right-radius:15px;
|
64
|
+
border-top-left-radius:15px;
|
65
|
+
-moz-border-radius-topright:15px;
|
66
|
+
-moz-border-radius-topleft:15px;
|
67
|
+
-webkit-border-top-right-radius:15px;
|
68
|
+
-webkit-border-top-left-radius:15px;
|
69
|
+
text-shadow: rgba(0, 0, 0, 0.5) 4px 4px 1px;
|
70
|
+
}
|
71
|
+
h2#qunit-banner{
|
72
|
+
font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
|
73
|
+
height:5px;
|
74
|
+
margin:0;
|
75
|
+
padding:0;
|
76
|
+
}
|
77
|
+
h2#qunit-banner.qunit-pass{
|
78
|
+
background-color:#C6E746;
|
79
|
+
}
|
80
|
+
h2#qunit-banner.qunit-fail, #qunit-testrunner-toolbar {
|
81
|
+
background-color:#EE5757;
|
82
|
+
}
|
83
|
+
#qunit-testrunner-toolbar {
|
84
|
+
font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
|
85
|
+
padding:0;
|
86
|
+
/*width:80%;*/
|
87
|
+
padding:0em 0 0.5em 2em;
|
88
|
+
font-size: small;
|
89
|
+
}
|
90
|
+
h2#qunit-userAgent {
|
91
|
+
font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
|
92
|
+
background-color:#2b81af;
|
93
|
+
margin:0;
|
94
|
+
padding:0;
|
95
|
+
color:#fff;
|
96
|
+
font-size: small;
|
97
|
+
padding:0.5em 0 0.5em 2.5em;
|
98
|
+
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
|
99
|
+
}
|
100
|
+
p#qunit-testresult{
|
101
|
+
font-family:"Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
|
102
|
+
margin:0;
|
103
|
+
font-size: small;
|
104
|
+
color:#2b81af;
|
105
|
+
border-bottom-right-radius:15px;
|
106
|
+
border-bottom-left-radius:15px;
|
107
|
+
-moz-border-radius-bottomright:15px;
|
108
|
+
-moz-border-radius-bottomleft:15px;
|
109
|
+
-webkit-border-bottom-right-radius:15px;
|
110
|
+
-webkit-border-bottom-left-radius:15px;
|
111
|
+
background-color:#D2E0E6;
|
112
|
+
padding:0.5em 0.5em 0.5em 2.5em;
|
113
|
+
}
|
114
|
+
strong b.fail{
|
115
|
+
color:#710909;
|
116
|
+
}
|
117
|
+
strong b.pass{
|
118
|
+
color:#5E740B;
|
119
|
+
}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
var AdminData = AdminData || {};
|
2
|
+
|
3
|
+
AdminData.actOnResult = {
|
4
|
+
|
5
|
+
action: function(action_type) {
|
6
|
+
log('has been invoked');
|
7
|
+
var formData = $('#advance_search_form').data('admin_data_form_array'),
|
8
|
+
parameterizedData;
|
9
|
+
|
10
|
+
formData.push({
|
11
|
+
'name': 'admin_data_advance_search_action_type',
|
12
|
+
'value': action_type
|
13
|
+
});
|
14
|
+
|
15
|
+
parameterizedData = $.param(formData);
|
16
|
+
|
17
|
+
$.ajax({
|
18
|
+
url: $('#advance_search_form').attr('action'),
|
19
|
+
type: 'post',
|
20
|
+
dataType: 'json',
|
21
|
+
data: parameterizedData,
|
22
|
+
success: function(json) {
|
23
|
+
AdminData.actOnResult.successCallback(json);
|
24
|
+
}
|
25
|
+
});
|
26
|
+
},
|
27
|
+
|
28
|
+
successCallback: function(json) {
|
29
|
+
$('#results').text(json.success);
|
30
|
+
}
|
31
|
+
|
32
|
+
};
|
33
|
+
|
34
|
+
$('#advance_search_delete_all').live('click', function() {
|
35
|
+
if (window.confirm('Are you sure?')) {
|
36
|
+
AdminData.actOnResult.action('delete');
|
37
|
+
}
|
38
|
+
return false;
|
39
|
+
});
|
40
|
+
|
41
|
+
$('#advance_search_destroy_all').live('click', function() {
|
42
|
+
if (AdminData.jsUtil.confirm('Are you sure?')) {
|
43
|
+
AdminData.actOnResult.action('destroy');
|
44
|
+
}
|
45
|
+
return false;
|
46
|
+
});
|
47
|
+
|
@@ -0,0 +1,46 @@
|
|
1
|
+
var AdminData = AdminData || {};
|
2
|
+
|
3
|
+
AdminData.advanceSearch = {
|
4
|
+
|
5
|
+
buildFirstRow: function(){
|
6
|
+
$('#advance_search_table').
|
7
|
+
append(this.buildRow()).find('tr td:last a').text('+').removeClass('remove_row').addClass('add_row_link');
|
8
|
+
},
|
9
|
+
|
10
|
+
buildCol1: function() {
|
11
|
+
var col = $('<select />', {className: 'col1' }).append($('<option />'));
|
12
|
+
var tableStructure = $('#advance_search_table').data('table_structure');
|
13
|
+
for (var i in tableStructure) {
|
14
|
+
$('<option />').text(i).attr('value', i).appendTo(col);
|
15
|
+
}
|
16
|
+
return $('<td />').append(col);
|
17
|
+
},
|
18
|
+
|
19
|
+
buildCol2: function() {
|
20
|
+
return $('<td />').
|
21
|
+
append('<select />').
|
22
|
+
find('select').
|
23
|
+
append('<option />').
|
24
|
+
addClass('col2 disabled').
|
25
|
+
attr({ disabled: true }).
|
26
|
+
end();
|
27
|
+
},
|
28
|
+
|
29
|
+
buildCol3: function() {
|
30
|
+
return $('<td />').append($('<input />',{disabled: true, className: 'col3'}));
|
31
|
+
},
|
32
|
+
|
33
|
+
buildCol4: function() {
|
34
|
+
return $('<td />').append($('<a />', {text: 'x', href: '#', className: 'remove_row'}));
|
35
|
+
},
|
36
|
+
|
37
|
+
buildRow: function() {
|
38
|
+
var $tr = $('<tr />').append(this.buildCol1(), this.buildCol2(), this.buildCol3(), this.buildCol4());
|
39
|
+
var randomNumber = AdminData.jsUtil.randomNumber();
|
40
|
+
$tr.find('select.col1').attr({ name: 'adv_search[' + randomNumber + '_row][col1]'});
|
41
|
+
$tr.find('select.col2').attr({ name: 'adv_search[' + randomNumber + '_row][col2]'});
|
42
|
+
$tr.find('input.col3').attr({ name: 'adv_search[' + randomNumber + '_row][col3]'});
|
43
|
+
return $tr;
|
44
|
+
}
|
45
|
+
|
46
|
+
};
|
@@ -0,0 +1,60 @@
|
|
1
|
+
var AdminData = AdminData || {};
|
2
|
+
|
3
|
+
AdminData.advanceSearch = {
|
4
|
+
|
5
|
+
buildFirstRow: function(){
|
6
|
+
$('#advance_search_table')
|
7
|
+
.append(this.buildRow())
|
8
|
+
.find('tr td:last a')
|
9
|
+
.text('+')
|
10
|
+
.removeClass('remove_row')
|
11
|
+
.addClass('add_row_link');
|
12
|
+
},
|
13
|
+
|
14
|
+
buildCol1: function() {
|
15
|
+
var i,
|
16
|
+
col = $('<select />', {className: 'col1' }).append($('<option />')),
|
17
|
+
tableStructure = $('#advance_search_table').data('table_structure');
|
18
|
+
|
19
|
+
for (i in tableStructure) {
|
20
|
+
$('<option />', {text: i, value: i}).appendTo(col);
|
21
|
+
}
|
22
|
+
return $('<td />').append(col);
|
23
|
+
},
|
24
|
+
|
25
|
+
buildCol2: function() {
|
26
|
+
return $('<td />')
|
27
|
+
.append('<select />')
|
28
|
+
.find('select')
|
29
|
+
.append('<option />')
|
30
|
+
.addClass('col2 disabled')
|
31
|
+
.attr({ disabled: true }).
|
32
|
+
end();
|
33
|
+
},
|
34
|
+
|
35
|
+
buildCol3: function() {
|
36
|
+
return $('<td />').append($('<input />',{disabled: true, className: 'col3'}));
|
37
|
+
},
|
38
|
+
|
39
|
+
buildCol4: function() {
|
40
|
+
return $('<td />').append($('<a />', {text: 'x', href: '#', className: 'remove_row'}));
|
41
|
+
},
|
42
|
+
|
43
|
+
buildRow: function() {
|
44
|
+
var $tr = $('<tr />'),
|
45
|
+
that = this,
|
46
|
+
randomNumber = AdminData.jsUtil.randomNumber(),
|
47
|
+
build_array = ['buildCol1', 'buildCol2', 'buildCol3', 'buildCol4'];
|
48
|
+
|
49
|
+
$.each(build_array, function(index, value) {
|
50
|
+
$tr.append(that[value]());
|
51
|
+
});
|
52
|
+
|
53
|
+
$tr.find('select.col1').attr({ name: 'adv_search[' + randomNumber + '_row][col1]'});
|
54
|
+
$tr.find('select.col2').attr({ name: 'adv_search[' + randomNumber + '_row][col2]'});
|
55
|
+
$tr.find('input.col3').attr({ name: 'adv_search[' + randomNumber + '_row][col3]'});
|
56
|
+
|
57
|
+
return $tr;
|
58
|
+
}
|
59
|
+
|
60
|
+
};
|
@@ -0,0 +1,79 @@
|
|
1
|
+
AdminData = AdminData || {};
|
2
|
+
|
3
|
+
AdminData.mappings = {
|
4
|
+
|
5
|
+
//JSLint complains if a hash has key named boolean. So I am changing the key to booleant
|
6
|
+
booleant: {
|
7
|
+
options: [
|
8
|
+
["is null", "is_null"],
|
9
|
+
["is not null", "is_not_null"],
|
10
|
+
["is true", "is_true"],
|
11
|
+
["is false", "is_false"]
|
12
|
+
]
|
13
|
+
},
|
14
|
+
|
15
|
+
string: {
|
16
|
+
options: [
|
17
|
+
["is null", "is_null"],
|
18
|
+
["is not null", "is_not_null"],
|
19
|
+
["contains", "contains"],
|
20
|
+
["is exactly", "is_exactly"],
|
21
|
+
["doesn't contain", "does_not_contain"]
|
22
|
+
]
|
23
|
+
},
|
24
|
+
|
25
|
+
text: {
|
26
|
+
options: [
|
27
|
+
["is null", "is_null"],
|
28
|
+
["is not null", "is_not_null"],
|
29
|
+
["Contains", "contains"],
|
30
|
+
["Doesn't Contain", "does_not_contain"]
|
31
|
+
]
|
32
|
+
},
|
33
|
+
|
34
|
+
datetime: {
|
35
|
+
options: [
|
36
|
+
["is null", "is_null"],
|
37
|
+
["is not null", "is_not_null"],
|
38
|
+
['on', "is_on"],
|
39
|
+
['on or before', "is_on_or_before_date"],
|
40
|
+
['on or after', "is_on_or_after_date"]
|
41
|
+
]
|
42
|
+
},
|
43
|
+
|
44
|
+
date: {
|
45
|
+
options: [
|
46
|
+
["is null", "is_null"],
|
47
|
+
["is not null", "is_not_null"],
|
48
|
+
['on', "is_on"],
|
49
|
+
['on or before', "is_on_or_before_date"],
|
50
|
+
['on or after', "is_on_or_after_date"]
|
51
|
+
]
|
52
|
+
},
|
53
|
+
|
54
|
+
time: {
|
55
|
+
options: [
|
56
|
+
["is null", "is_null"],
|
57
|
+
["is not null", "is_not_null"],
|
58
|
+
["is exactly", "is_exactly"]
|
59
|
+
]
|
60
|
+
},
|
61
|
+
|
62
|
+
decimal: {
|
63
|
+
options: [
|
64
|
+
['is equal to', "is_equal_to"],
|
65
|
+
['is less than', "less_than"],
|
66
|
+
['is greater than', "greater_than"]
|
67
|
+
]
|
68
|
+
},
|
69
|
+
|
70
|
+
integer: {
|
71
|
+
options: [
|
72
|
+
['is equal to', "is_equal_to"],
|
73
|
+
['is less than', "less_than"],
|
74
|
+
['is greater than', "greater_than"]
|
75
|
+
]
|
76
|
+
}
|
77
|
+
};
|
78
|
+
|
79
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
var AdminData = AdminData || {};
|
2
|
+
|
3
|
+
AdminData.ajaxifyAdvanceSearch = {
|
4
|
+
successCallback: function(responseText) {
|
5
|
+
$('#results').html(responseText);
|
6
|
+
},
|
7
|
+
|
8
|
+
beforeSubmitCallback: function(formArray, jqForm) {
|
9
|
+
$('#results').html('<span class="searching_message">searching...</span>');
|
10
|
+
$('#advance_search_form').data('admin_data_form_array', formArray);
|
11
|
+
}
|
12
|
+
};
|
13
|
+
|
14
|
+
$(function() {
|
15
|
+
|
16
|
+
var options = {
|
17
|
+
success: function(responseText) {
|
18
|
+
AdminData.ajaxifyAdvanceSearch.successCallback(responseText);
|
19
|
+
},
|
20
|
+
beforeSubmit: function(formArray, jqForm) {
|
21
|
+
AdminData.ajaxifyAdvanceSearch.beforeSubmitCallback(formArray, jqForm);
|
22
|
+
}
|
23
|
+
};
|
24
|
+
|
25
|
+
$('#advance_search_form').ajaxForm(options);
|
26
|
+
|
27
|
+
});
|
28
|
+
|
@@ -0,0 +1,12 @@
|
|
1
|
+
$(function() {
|
2
|
+
|
3
|
+
//TODO use $.parseJSON also use live method of jQuery 1.4.1
|
4
|
+
var table_structure_data_non_json = $('#admin_data_table_structure_data').html(),
|
5
|
+
table_structure_data_json = eval(table_structure_data_non_json);
|
6
|
+
|
7
|
+
$('#advance_search_table').data('table_structure', table_structure_data_json[0]);
|
8
|
+
|
9
|
+
AdminData.advanceSearch.buildFirstRow();
|
10
|
+
|
11
|
+
});
|
12
|
+
|
@@ -0,0 +1,87 @@
|
|
1
|
+
var AdminData = AdminData || {};
|
2
|
+
|
3
|
+
AdminData.bindings = {
|
4
|
+
col2_change: function(e) {
|
5
|
+
var arrayList = ['is_false', 'is_true', 'is_null', 'is_not_null'],
|
6
|
+
$col2 = $(e.target).closest('select'),
|
7
|
+
value = $col2.val(),
|
8
|
+
tableStructure = $('#advance_search_table').data('table_structure'),
|
9
|
+
columnType = tableStructure[$col2.val()],
|
10
|
+
col1ColumnType;
|
11
|
+
|
12
|
+
$col3 = $col2.parents('tr').find('td input.col3');
|
13
|
+
$col1 = $col2.parents('tr').find('td select.col1');
|
14
|
+
col1ColumnType = tableStructure[$col1.val()];
|
15
|
+
|
16
|
+
if (value.length === 0 || ($.inArray(value, arrayList) > - 1)) {
|
17
|
+
$col3.val('')
|
18
|
+
.attr('disabled', true)
|
19
|
+
.addClass('disabled');
|
20
|
+
|
21
|
+
} else {
|
22
|
+
$col3.attr('disabled', false)
|
23
|
+
.removeClass('disabled');
|
24
|
+
|
25
|
+
if (col1ColumnType === 'datetime' || col1ColumnType === 'date') {
|
26
|
+
$col3.val(AdminData.jsUtil.dateToString(new Date())).addClass('datepicker');
|
27
|
+
|
28
|
+
$('.datepicker').datepicker({
|
29
|
+
dateFormat: 'dd-MM-yy',
|
30
|
+
changeYear: true,
|
31
|
+
changeMonth: true
|
32
|
+
});
|
33
|
+
|
34
|
+
} else {
|
35
|
+
$('.datepicker').datepicker('destroy');
|
36
|
+
$col3.removeClass('datepicker').focus(); // do not create focus for date pickers
|
37
|
+
}
|
38
|
+
}
|
39
|
+
},
|
40
|
+
|
41
|
+
pagination_click: function(e) {
|
42
|
+
var href = $(e.target).closest('a').attr('href');
|
43
|
+
|
44
|
+
// usage of #results twice seems redundant
|
45
|
+
$('#results').load(href, function(responseText) {
|
46
|
+
$('#results').html(responseText);
|
47
|
+
});
|
48
|
+
|
49
|
+
AdminData.jsUtil.colorizeRows();
|
50
|
+
},
|
51
|
+
|
52
|
+
col1_change: function(e) {
|
53
|
+
var $col1 = $(e.target).closest('select'),
|
54
|
+
tableStructure = $('#advance_search_table').data('table_structure'),
|
55
|
+
columnType = tableStructure[$col1.val()],
|
56
|
+
options = AdminData.mappings[columnType]['options'];
|
57
|
+
|
58
|
+
$col2 = $col1.parents('tr').find('td select.col2');
|
59
|
+
$col2.html('');
|
60
|
+
AdminData.jsUtil.buildOptionsFromArray(options, $col2);
|
61
|
+
$col2.trigger('change');
|
62
|
+
}
|
63
|
+
};
|
64
|
+
|
65
|
+
$('.pagination a').live('click', function(e) {
|
66
|
+
AdminData.bindings.pagination_click(e);
|
67
|
+
return false;
|
68
|
+
});
|
69
|
+
|
70
|
+
$('#advance_search_table a.add_row_link').live('click', function() {
|
71
|
+
$('#advance_search_table').append(AdminData.advanceSearch.buildRow());
|
72
|
+
return false;
|
73
|
+
});
|
74
|
+
|
75
|
+
$('#advance_search_table a.remove_row').live('click', function(e) {
|
76
|
+
$(e.target).closest('tr').remove();
|
77
|
+
return false;
|
78
|
+
});
|
79
|
+
|
80
|
+
$('#advance_search_table select.col1').live('change', function(e) {
|
81
|
+
AdminData.bindings.col1_change(e);
|
82
|
+
});
|
83
|
+
|
84
|
+
$('#advance_search_table select.col2').live('change', function(e) {
|
85
|
+
AdminData.bindings.col2_change(e);
|
86
|
+
});
|
87
|
+
|