e9_crm 0.1.11 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -28,9 +28,10 @@
28
28
  = submit_tag t(:go), :name => nil
29
29
 
30
30
  = form_tag(resource_class, :method => :get, :class => 'scope-selects') do
31
- %select{:name => 'company'}
31
+ = label_tag 'contact_company_select', Company.model_name.human
32
+ %select{:name => 'company', :id => 'contact_company_select'}
32
33
  = company_select_options
33
34
 
34
35
  = render 'tag_table'
35
36
  .actions
36
- = submit_tag t(:clear), :name => nil, :id => 'contact_search_clear'
37
+ = submit_tag t(:clear_all_filters), :name => nil, :id => 'contact_search_clear'
@@ -1,15 +1,9 @@
1
1
  - tagged_params = Array.wrap(params[:tagged])
2
- %table.tag-table
3
- %thead
4
- %th{:colspan => 2}
5
- = t(:tags_name, :scope => :e9_tags)
6
- %tbody
7
- - contact_tags.sort.group_by {|tag| tag[0].upcase }.each do |letter, tags|
8
- %tr
9
- %td.tag-starts-with= letter
10
- %td.tags
11
- %ul.tags
12
- - tags.each do |tag|; tag_id = "tagged-#{tag.downcase.dasherize}"
13
- %li.tag
14
- = label_tag(tag_id, tag)
15
- = check_box_tag('tagged[]', tag, tagged_params.member?(tag), :id => tag_id)
2
+ %label= t(:tags_name, :scope => :e9_tags)
3
+ .tag-holder
4
+ - contact_tags.sort.group_by {|tag| tag[0].upcase }.each do |letter, tags|
5
+ %ul.tags
6
+ - tags.each do |tag|; tag_id = "tagged-#{tag.downcase.dasherize}"
7
+ %li.tag
8
+ = label_tag(tag_id, tag)
9
+ = check_box_tag('tagged[]', tag, tagged_params.member?(tag), :id => tag_id)
@@ -1,6 +1,7 @@
1
1
  en:
2
2
  actions: Actions
3
3
  clear: Clear
4
+ clear_all_filters: Clear All Filters
4
5
  edit_dated_costs: Edit Costs
5
6
  go: Go
6
7
  inline_help_link: '[?]'
@@ -1,3 +1,3 @@
1
1
  module E9Crm
2
- VERSION = '0.1.11'
2
+ VERSION = '0.1.12'
3
3
  end
@@ -1,44 +1,27 @@
1
- jQuery(function($) {
2
-
3
- $('.dated-costs > .actions a').bind('ajax:success', function(e, data, status, xhr) {
4
- $(data).insertBefore($(this).closest('.actions'));
5
- });
1
+ ;jQuery(function($) {
6
2
 
7
3
  /*
8
- * A function might exist for this already, but basically this stores the query variables
9
- * in a hash when the page loads for later re-use/modification.
4
+ * add offer class handler to quick_edit.
10
5
  */
11
- function query_to_hash(qs) {
12
- if (!qs) qs = document.location.search;
13
-
14
- if (!qs.length) return {};
15
-
16
- var params = {},
17
- regex = /[?&]?([^=]+)=([^&]*)/g,
18
- tokens, key, val;
19
-
20
- qs = qs.split('+').join(' ');
21
-
22
- while (tokens = regex.exec(qs)) {
23
- key = decodeURIComponent(tokens[1]);
24
- val = decodeURIComponent(tokens[2]);
25
-
26
- if(/\[\]$/.test(key)) {
27
- if (!params[key]) params[key] = [];
28
- params[key].push(val);
29
- } else {
30
- params[key] = val;
31
- }
6
+ $.quick_edit = $.quick_edit || {};
7
+ $.quick_edit.class_handlers = $.extend({
8
+ 'offer' : function(el) {
9
+ var path = el.attr('data-renderable-path'),
10
+ npath = el.attr('data-update-node-path'),
11
+ epath = path + '/edit';
12
+
13
+ //return '<a class="qe-qelink" href="'+ epath +'">Edit</a>' +
14
+ return '<a class="qe-ulink" href="'+ npath +'">Switch</a>' +
15
+ '<a class="qe-elink" href="'+ epath +'">Admin</a>';
32
16
  }
17
+ }, $.quick_edit.class_handlers);
33
18
 
34
- return params;
35
- }
36
-
37
- $.query = query_to_hash();
38
-
39
- $.fn.bindSelectChange = function(callback) {
40
- this.bind($.browser.msie ? 'propertychange' : 'change', callback);
41
- }
19
+ /*
20
+ *
21
+ */
22
+ $('.dated-costs > .actions a').bind('ajax:success', function(e, data, status, xhr) {
23
+ $(data).insertBefore($(this).closest('.actions'));
24
+ });
42
25
 
43
26
  $("#campaign_code_field input").keyup(function() {
44
27
  $.event.trigger('campaign_code_change', [$(this).val()]);
@@ -50,101 +33,37 @@ jQuery(function($) {
50
33
  });
51
34
  });
52
35
 
53
- $('.ordered-column a').live('click', function(e) {
54
- e.preventDefault();
55
-
56
- var $this = $(this),
57
- href = $this.attr('href'),
58
- qs = href.match(/\?.*$/)[0];
59
-
60
- var qh = qs && query_to_hash(qs) || {};
61
-
62
- $.extend($.query, {
63
- order : qh.order,
64
- sort : qh.sort
36
+ /*
37
+ * change the value of the new menu option type link when the scope select
38
+ * changes, e.g. when viewing "Email" menu options, clicking "Add Menu Option"
39
+ * defaults to creating a new email menu option.
40
+ */
41
+ $('body.admin a.new-menu-option').bind('scope-select:change:key', function(e, v) {
42
+ $(this).attr('href', function(i, val) {
43
+ return val.replace(/\[key\]=([^&]*)/, '[key]='+encodeURIComponent(v));
65
44
  });
66
-
67
- submit_with_query();
68
45
  });
69
46
 
70
- $("#campaign_search_form").each(function(i, el) {
71
- var
72
- $form = $(el),
73
- $st = $(el).find('select[name=type]'),
74
- $sg = $(el).find('select[name=group]'),
75
- $sa = $(el).find('select[name=active]'),
76
- $sf = $(el).find('select[name=from]'),
77
- $su = $(el).find('select[name=until]')
78
- ;
79
-
80
- $st.val($.query.type);
81
- $sg.val($.query.group);
82
- $sa.val($.query.active);
83
- $sf.val($.query.from);
84
- $su.val($.query.until);
85
-
86
- $('select', $form).bindSelectChange(function() {
87
- var opts = {}, v;
88
- if (v = $st.val()) {
89
- opts['type'] = v;
90
- } else {
91
- delete $.query['type'];
92
- }
93
- if (v = $sg.val()) {
94
- opts['group'] = v;
95
- } else {
96
- delete $.query['group'];
97
- }
98
- if (v = $sa.val()) {
99
- opts['active'] = v;
100
- } else {
101
- delete $.query['active'];
102
- }
103
- if (v = $sf.val()) {
104
- opts['from'] = v;
105
- } else {
106
- delete $.query['from'];
107
- }
108
- if (v = $su.val()) {
109
- opts['until'] = v;
110
- } else {
111
- delete $.query['until'];
112
- }
113
- $.extend($.query, opts);
114
- submit_with_query();
115
- });
116
- });
117
47
 
118
- $("#new_campaign_form").each(function(i, el) {
48
+ $("body.admin form#new_campaign_form, body.admin form#new_offer_form").each(function(i, el) {
119
49
  var $form = $(el);
120
50
 
121
51
  $('select', $form).bindSelectChange(function() {
122
52
  var $this = $(this);
123
-
124
53
  $form.attr("action", function(i, val) {
125
54
  return val.replace(/\/\w*\/new$/, '/'+$this.val()+'/new');
126
55
  });
127
56
  });
57
+
58
+ $form.submit(function(e) {
59
+ e.preventDefault();
60
+ window.location = $form.attr('action');
61
+ });
128
62
  });
129
63
 
130
64
  var selector_prefix = 'body.controller-e9-crm-contacts',
131
65
  $selector = $(selector_prefix);
132
66
 
133
- $.fn.exclusiveCheck = function() {
134
- var selector = $(this);
135
- return this.each(function(i) {
136
- $(this).click(function(e) {
137
- var clicked = this;
138
- if (this.checked) {
139
- selector.each(function() {
140
- if (this != clicked) this.checked = false;
141
- });
142
- }
143
- });
144
- });
145
- }
146
-
147
-
148
67
  /*
149
68
  * The status of "primary" for a User login is stored on the individual records, but must be exlcusive in
150
69
  * the scope of the Contact (only one User may be primary).
@@ -153,7 +72,11 @@ jQuery(function($) {
153
72
  */
154
73
  var exclusifyEmailRadios;
155
74
  (exclusifyEmailRadios = function() {
156
- $('.nested-association input[type=radio][name$="[primary]"]', $(selector_prefix)).exclusiveCheck();
75
+ var $radios = $('.nested-association input[type=radio][name$="[primary]"]', $(selector_prefix));
76
+
77
+ if (!$radios.is(':checked')) $radios.first().attr('checked', true);
78
+
79
+ $radios.exclusiveCheck();
157
80
  })();
158
81
 
159
82
  /*
@@ -205,13 +128,6 @@ jQuery(function($) {
205
128
  else { $parent.remove(); }
206
129
  });
207
130
 
208
- var submit_with_query = function(data) {
209
- $.ajax({
210
- dataType: 'script',
211
- url: window.location.pathname,
212
- data: data || $.param($.query)
213
- });
214
- }
215
131
 
216
132
  $('#contact_email_form', $selector).live('submit', function(e) {
217
133
  var $f = $(this);
@@ -223,44 +139,62 @@ jQuery(function($) {
223
139
  }
224
140
  });
225
141
 
226
- $.fn.undisable = function() {
227
- $('input[type=submit]', this).removeAttr('disabled').removeClass('ui-state-hover').blur();
228
- }
229
-
230
- $('#contact_newsletter_form', $selector).live('submit', function(e) {
231
- e.preventDefault();
232
-
233
- var $f = $(this);
234
-
235
- if (!$('select', this).children().length) {
236
- $f.undisable();
237
- return false;
238
- }
239
-
240
- if ($f.attr('data-count') == '0') {
241
- alert($f.attr('data-empty'));
242
- $f.undisable();
243
- return false;
244
- }
245
-
246
- if (!confirm($f.attr('data-confirm'))) {
247
- $f.undisable();
248
- return false;
249
- }
250
-
251
- $f.attr('action', function(i, val) {
252
- return val.replace(/__ID__/, $('#eid', $f).val());
253
- });
254
-
255
- $f.callRemote();
256
- });
142
+ //$('#contact_newsletter_form', $selector).live('submit', function(e) {
143
+ //e.preventDefault();
144
+
145
+ //var $f = $(this);
146
+
147
+ /*
148
+ * if no options, simply return (this shouldn't happen)
149
+ */
150
+ //if (!$('select', this).children().length) {
151
+ //$f.undisable();
152
+ //return false;
153
+ //}
154
+
155
+ /*
156
+ * warn if no selected contacts
157
+ */
158
+ //if ($f.attr('data-count') == '0') {
159
+ //alert($f.attr('data-empty'));
160
+ //$f.undisable();
161
+ //return false;
162
+ //}
163
+
164
+ /*
165
+ * run confirm
166
+ */
167
+ //if (!confirm($f.attr('data-confirm'))) {
168
+ //$f.undisable();
169
+ //return false;
170
+ //}
171
+
172
+ /*
173
+ * mod the form action to send to the correct email
174
+ */
175
+ //$f.attr('action', function(i, val) {
176
+ //return val.replace(/__ID__/, $('#eid', $f).val());
177
+ //});
178
+
179
+ /*
180
+ * we're going to remove the selected email from the options on completion, or
181
+ * the whole form if there are no more emails to send.
182
+ */
183
+ //var $sel = $('option:selected', $f);
184
+ //$to_remove = $sel.siblings().length ? $sel : $f;
185
+
186
+ //$f.bind('ajax:complete', function() { $to_remove.remove(); });
187
+
188
+
189
+ //$f.callRemote();
190
+ //});
257
191
 
258
- $('.tag-table', $selector).change(function(e) {
192
+ $('.tag-holder', $selector).change(function(e) {
259
193
  $.extend($.query, {
260
194
  'tagged[]': $.makeArray($(this).find('input[name="tagged[]"]').map(function(i, el) { return $(el).attr('checked') ? $(el).val() : null }))
261
195
  });
262
196
 
263
- submit_with_query();
197
+ $.submit_with_query();
264
198
  });
265
199
 
266
200
  $('form#contact_search_form', $(selector_prefix)).live('submit', function(e) {
@@ -270,7 +204,7 @@ jQuery(function($) {
270
204
  'search': $(this).find('input[name=search]').val()
271
205
  });
272
206
 
273
- submit_with_query();
207
+ $.submit_with_query();
274
208
  });
275
209
 
276
210
  $('input#contact_search_clear', $(selector_prefix)).live('click', function(e) {
@@ -282,10 +216,7 @@ jQuery(function($) {
282
216
 
283
217
  $.query = {};
284
218
 
285
- submit_with_query();
219
+ $.submit_with_query();
286
220
  });
287
221
 
288
- //$('#menu_option_key_select_form select').bindSelectChange(function(e) {
289
- //$(this).submit();
290
- //});
291
222
  });
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: e9_crm
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.11
5
+ version: 0.1.12
6
6
  platform: ruby
7
7
  authors:
8
8
  - Travis Cox