summaryrefslogtreecommitdiffstats
path: root/welco/static
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2016-01-05 10:27:46 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2016-01-05 10:27:46 (GMT)
commiteebdd89011f67172ce7af3d464e64cecec1ff4fb (patch)
treed7f27cb1d7d7449014ff1e731f5ce0d140607b21 /welco/static
parentfba65522327eaf81e4289e0b45fcd3aadf7dded5 (diff)
downloadwelco-eebdd89011f67172ce7af3d464e64cecec1ff4fb.zip
welco-eebdd89011f67172ce7af3d464e64cecec1ff4fb.tar.gz
welco-eebdd89011f67172ce7af3d464e64cecec1ff4fb.tar.bz2
contacts: automatically select the contact being displayed (#9499)
Diffstat (limited to 'welco/static')
-rw-r--r--welco/static/js/welco.js32
1 files changed, 25 insertions, 7 deletions
diff --git a/welco/static/js/welco.js b/welco/static/js/welco.js
index 0c3f82f..f498a81 100644
--- a/welco/static/js/welco.js
+++ b/welco/static/js/welco.js
@@ -61,7 +61,6 @@ $(function() {
dataType: 'html',
success: function(data) {
$('div.contacts h3').effect('highlight');
- $('div.contacts button.save').addClass('pinned');
},
error: function(error) { console.log(':/', error); }
});
@@ -122,12 +121,6 @@ $(function() {
var formdef_reference = $('#id_formdef_reference').val();
var source_type = $('div.source div[data-source-type]').data('source-type');
var source_pk = $('div.source .active[data-source-pk]').data('source-pk');
- if ($('div.contacts button.save').length &&
- $('div.contacts button.save.pinned').length == 0) {
- if (confirm("Transmettre alors que le contact n'est pas sélectionné ?") != true) {
- return false;
- }
- }
$.ajax({url: $(this).data('action-url'),
data: {formdef_reference: formdef_reference,
source_type: source_type,
@@ -217,6 +210,20 @@ $(function() {
new_zone.find('div.contact').empty();
$(zone).find('> div').replaceWith(new_zone);
+ if (new_zone.find('div.contact').length) {
+ /* unselect contact */
+ $.ajax({url: $('.cell.contacts').data('zone-url'),
+ data: {user_id: null,
+ source_type: source_type,
+ source_pk: source_pk},
+ method: 'POST',
+ dataType: 'html',
+ success: function(data) {
+ },
+ error: function(error) { console.log(':/', error); }
+ });
+ }
+
$(zone).find('select').select2();
$(zone).removeClass('has-contact-displayed');
$(zone).removeClass('has-page-displayed');
@@ -276,6 +283,17 @@ $(function() {
success: function(data) {
$('.contacts .contact').replaceWith(data);
$('.contacts').addClass('has-contact-displayed');
+ var selected_user_id = $('#current-selected-user').val();
+ $.ajax({url: $('.cell.contacts').data('zone-url'),
+ data: {user_id: selected_user_id,
+ source_type: source_type,
+ source_pk: source_pk},
+ method: 'POST',
+ dataType: 'html',
+ success: function(data) {
+ },
+ error: function(error) { console.log(':/', error); }
+ });
},
error: function(error) { console.log(':(', error); }
});