Skip to content

Commit

Permalink
FIX BUG: #1 add new items
Browse files Browse the repository at this point in the history
  • Loading branch information
christiansalazar committed Dec 17, 2016
1 parent dc3e2b2 commit 4ebe9f8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion CrmFindContactWidget.php
Expand Up @@ -69,6 +69,7 @@ class='btn btn-default cancel'>Cierra</button>
public $find_action_url = ['/crm/ajaxfind'];
public $get_action_url = ['/crm/ajaxget'];
public $save_action_url = ['/crm/ajaxsave'];
public $create_action_url = ['/crm/ajaxcreate'];

// THE SELECTED COLUMNS TO BE DISPLAYED ARE CONFIGURED IN CRM-CONFIG FILE
// VIA SETTING THE 'list' ATTRIBUTE TO A VALUE GREATHER THAN ZERO.
Expand All @@ -82,6 +83,7 @@ public function init() {
$this->find_action_url = Url::toRoute($this->find_action_url);
$this->get_action_url = Url::toRoute($this->get_action_url);
$this->save_action_url = Url::toRoute($this->save_action_url);
$this->create_action_url = Url::toRoute($this->create_action_url);
if($this->readonly)
$this->save_action_url = null;
}
Expand Down Expand Up @@ -164,6 +166,7 @@ class='form-control {$c}-input' maxlength=30 />
var find_action_url = '{$this->find_action_url}';
var get_action_url = '{$this->get_action_url}';
var save_action_url = '{$this->save_action_url}';
var create_action_url = '{$this->create_action_url}';
var find = widget.find('.{$c}-button');
var close = widget.find('.{$c}-close');
var add = widget.find('.{$c}-add');
Expand Down Expand Up @@ -224,10 +227,14 @@ class='form-control {$c}-input' maxlength=30 />
}); // find click
add.click(function(e){
console.log('crm add clicked');
$('.crmfield').val('');//cleared
_launch_form(null);
}); // add click
form_save.click(function(e){
var form = $('.{$c}-form');
var url = save_action_url;
if('' == form.find('[name=id]').val())
url = create_action_url;
var _data = [];
form.find('.crmfield').each(function(){
var value = $(this).val().trim();
Expand All @@ -237,7 +244,7 @@ class='form-control {$c}-input' maxlength=30 />
console.log('sending',_data);
$.ajax({ cache: false, type: 'post', async: true,
data: _data,
url: save_action_url, success: function(resp){
url: url, success: function(resp){
console.log('success save',resp);
form.hide();
}, error: function(e){
Expand Down

0 comments on commit 4ebe9f8

Please sign in to comment.